Spec improvements

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-09-27 09:41:36 +02:00
parent cc3106e425
commit 41f086e2c9
21 changed files with 299 additions and 90 deletions

View File

@@ -17,6 +17,7 @@ defmodule Mobilizon.Web.ActivityPub.ActorView do
@json_ld_header Utils.make_json_ld_header()
@selected_member_roles ~w(creator administrator moderator member)a
@spec render(String.t(), map()) :: map()
def render("actor.json", %{actor: actor}) do
actor
|> Convertible.model_to_as()

View File

@@ -3,6 +3,7 @@ defmodule Mobilizon.Web.ActivityPub.ObjectView do
alias Mobilizon.Federation.ActivityPub.{Activity, Utils}
@spec render(String.t(), map()) :: map()
def render("activity.json", %{activity: %Activity{local: local, data: data} = activity}) do
%{
"id" => data["id"],

View File

@@ -8,6 +8,7 @@ defmodule Mobilizon.Web.AuthView do
alias Phoenix.HTML.Tag
import Mobilizon.Web.Views.Utils
@spec render(String.t(), map()) :: String.t() | Plug.Conn.t()
def render("callback.html", %{
conn: conn,
access_token: access_token,

View File

@@ -8,6 +8,7 @@ defmodule Mobilizon.Web.ErrorHelpers do
@doc """
Translates an error message using gettext.
"""
@spec translate_error({msg :: String.t(), opts :: map()}) :: String.t()
def translate_error({msg, opts}) do
# Because error messages were defined within Ecto, we must
# call the Gettext module passing our Gettext backend. We

View File

@@ -6,6 +6,7 @@ defmodule Mobilizon.Web.ErrorView do
alias Mobilizon.Service.Metadata.Instance
import Mobilizon.Web.Views.Utils
@spec render(String.t(), map()) :: map() | String.t() | Plug.Conn.t()
def render("404.html", %{conn: conn}) do
with tags <- Instance.build_tags(),
{:ok, html} <- inject_tags(tags, get_locale(conn)) do

View File

@@ -8,6 +8,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
alias Mobilizon.Web.Endpoint
alias Mobilizon.Web.JsonLD.ObjectView
@spec render(String.t(), map()) :: map()
def render("group.json", %{group: %Actor{} = group}) do
%{
"@context" => "http://schema.org",
@@ -93,6 +94,7 @@ defmodule Mobilizon.Web.JsonLD.ObjectView do
}
end
@spec render_location(map()) :: map() | nil
defp render_location(%{physical_address: %Address{} = address}),
do: render_one(address, ObjectView, "place.json", as: :address)

View File

@@ -19,6 +19,8 @@ defmodule Mobilizon.Web.PageView do
alias Mobilizon.Federation.ActivityStream.Convertible
import Mobilizon.Web.Views.Utils
@doc false
@spec render(String.t(), %{conn: Plug.Conn.t()}) :: map() | String.t() | Plug.Conn.t()
def render("actor.activity-json", %{conn: %{assigns: %{object: %Actor{} = actor}}}) do
actor
|> Convertible.model_to_as()