diff --git a/lib/graphql/api/search.ex b/lib/graphql/api/search.ex index 3b002b6f..f1a8600c 100644 --- a/lib/graphql/api/search.ex +++ b/lib/graphql/api/search.ex @@ -19,7 +19,7 @@ defmodule Mobilizon.GraphQL.API.Search do Searches actors. """ @spec search_actors(map(), integer | nil, integer | nil, ActorType.t()) :: - {:ok, Page.t()} | {:error, String.t()} + {:ok, Page.t(Actor.t())} | {:error, String.t()} def search_actors(%{term: term} = args, page \\ 1, limit \\ 10, result_type) do term = String.trim(term) @@ -64,7 +64,7 @@ defmodule Mobilizon.GraphQL.API.Search do Search events """ @spec search_events(map(), integer | nil, integer | nil) :: - {:ok, Page.t()} + {:ok, Page.t(Event.t())} def search_events(%{term: term} = args, page \\ 1, limit \\ 10) do term = String.trim(term) @@ -100,7 +100,7 @@ defmodule Mobilizon.GraphQL.API.Search do end # If the search string is an username - @spec process_from_username(String.t()) :: Page.t() + @spec process_from_username(String.t()) :: Page.t(Actor.t()) defp process_from_username(search) do case ActivityPubActor.find_or_make_actor_from_nickname(search) do {:ok, %Actor{type: :Group} = actor} -> @@ -118,7 +118,7 @@ defmodule Mobilizon.GraphQL.API.Search do end # If the search string is an URL - @spec process_from_url(String.t()) :: Page.t() + @spec process_from_url(String.t()) :: Page.t(struct()) defp process_from_url(search) do case ActivityPub.fetch_object_from_url(search) do {:ok, object} -> diff --git a/lib/graphql/resolvers/followers.ex b/lib/graphql/resolvers/followers.ex index e293fd75..0fe12700 100644 --- a/lib/graphql/resolvers/followers.ex +++ b/lib/graphql/resolvers/followers.ex @@ -10,7 +10,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Followers do alias Mobilizon.Storage.Page alias Mobilizon.Users.User - @spec find_followers_for_group(Actor.t(), map(), map()) :: {:ok, Page.t()} + @spec find_followers_for_group(Actor.t(), map(), map()) :: {:ok, Page.t(Follower.t())} def find_followers_for_group( %Actor{id: group_id} = group, args, diff --git a/lib/graphql/resolvers/person.ex b/lib/graphql/resolvers/person.ex index 060ae2d4..c37554a1 100644 --- a/lib/graphql/resolvers/person.ex +++ b/lib/graphql/resolvers/person.ex @@ -357,7 +357,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do @doc """ Returns this person's group memberships """ - @spec person_memberships(Actor.t(), map(), map()) :: {:ok, Page.t()} | {:error, String.t()} + @spec person_memberships(Actor.t(), map(), map()) :: + {:ok, Page.t(Member.t())} | {:error, String.t()} def person_memberships(%Actor{id: actor_id} = person, args, %{ context: %{current_user: %User{} = user} }) do @@ -399,7 +400,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Person do @doc """ Returns this person's group follows """ - @spec person_follows(Actor.t(), map(), map()) :: {:ok, Page.t()} | {:error, String.t()} + @spec person_follows(Actor.t(), map(), map()) :: + {:ok, Page.t(Follower.t())} | {:error, String.t()} def person_follows(%Actor{} = person, %{group: group}, %{ context: %{current_user: %User{} = user} }) do diff --git a/lib/mobilizon/activities/activities.ex b/lib/mobilizon/activities/activities.ex index 9d826bd7..52b7683e 100644 --- a/lib/mobilizon/activities/activities.ex +++ b/lib/mobilizon/activities/activities.ex @@ -81,7 +81,7 @@ defmodule Mobilizon.Activities do Keyword.t(), integer() | nil, integer() | nil - ) :: Page.t() + ) :: Page.t(Activity.t()) def list_group_activities_for_member( group_id, actor_asking_id, @@ -107,7 +107,7 @@ defmodule Mobilizon.Activities do Keyword.t(), integer() | nil, integer() | nil - ) :: Page.t() + ) :: Page.t(Activity.t()) def list_group_activities( group_id, filters \\ [], diff --git a/lib/mobilizon/actors/actors.ex b/lib/mobilizon/actors/actors.ex index cbf854ff..e8054b36 100644 --- a/lib/mobilizon/actors/actors.ex +++ b/lib/mobilizon/actors/actors.ex @@ -317,7 +317,7 @@ defmodule Mobilizon.Actors do boolean, integer | nil, integer | nil - ) :: Page.t() + ) :: Page.t(Actor.t()) def list_actors( type \\ :Person, preferred_username \\ "", @@ -452,7 +452,7 @@ defmodule Mobilizon.Actors do Keyword.t(), integer | nil, integer | nil - ) :: Page.t() + ) :: Page.t(Actor.t()) def search_actors( term, options \\ [], @@ -1103,7 +1103,7 @@ defmodule Mobilizon.Actors do Returns the paginated list of external followers for an actor. """ @spec list_external_followers_for_actor_paginated(Actor.t(), integer | nil, integer | nil) :: - Page.t() + Page.t(Actor.t()) def list_external_followers_for_actor_paginated(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do actor_id |> list_external_followers_for_actor_query() @@ -1113,7 +1113,7 @@ defmodule Mobilizon.Actors do @doc """ Build a page struct for followers of an actor. """ - @spec build_followers_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec build_followers_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t(Follower.t()) def build_followers_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do actor_id |> follower_actors_for_actor_query() @@ -1135,7 +1135,7 @@ defmodule Mobilizon.Actors do Returns a paginated list of followers for an actor. """ @spec list_paginated_followers_for_actor(Actor.t(), boolean | nil, integer | nil, integer | nil) :: - Page.t() + Page.t(Follower.t()) def list_paginated_followers_for_actor( %Actor{id: actor_id}, approved \\ nil, @@ -1165,7 +1165,7 @@ defmodule Mobilizon.Actors do Returns the list of external followings for an actor. """ @spec list_external_followings_for_actor_paginated(Actor.t(), integer | nil, integer | nil) :: - Page.t() + Page.t(Follower.t()) def list_external_followings_for_actor_paginated( %Actor{id: actor_id}, page \\ nil, @@ -1179,7 +1179,8 @@ defmodule Mobilizon.Actors do @doc """ Build a page struct for followings of an actor. """ - @spec build_followings_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec build_followings_for_actor(Actor.t(), integer | nil, integer | nil) :: + Page.t(Follower.t()) def build_followings_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do actor_id |> followings_actors_for_actor_query() diff --git a/lib/mobilizon/addresses/address.ex b/lib/mobilizon/addresses/address.ex index 89845102..66c7d4d3 100644 --- a/lib/mobilizon/addresses/address.ex +++ b/lib/mobilizon/addresses/address.ex @@ -16,7 +16,7 @@ defmodule Mobilizon.Addresses.Address do locality: String.t() | nil, region: String.t() | nil, description: String.t() | nil, - geom: Geo.PostGIS.Geometry.t() | nil, + geom: Geo.Point.t() | nil, postal_code: String.t() | nil, street: String.t() | nil, type: String.t() | nil, diff --git a/lib/mobilizon/admin/admin.ex b/lib/mobilizon/admin/admin.ex index de267042..c184bcba 100644 --- a/lib/mobilizon/admin/admin.ex +++ b/lib/mobilizon/admin/admin.ex @@ -36,7 +36,7 @@ defmodule Mobilizon.Admin do @doc """ Returns the list of action logs. """ - @spec list_action_logs(integer | nil, integer | nil) :: Page.t() + @spec list_action_logs(integer | nil, integer | nil) :: Page.t(ActionLog.t()) def list_action_logs(page \\ nil, limit \\ nil) do list_action_logs_query() |> Page.build_page(page, limit) diff --git a/lib/mobilizon/discussions/discussions.ex b/lib/mobilizon/discussions/discussions.ex index cfb080e2..78c06c91 100644 --- a/lib/mobilizon/discussions/discussions.ex +++ b/lib/mobilizon/discussions/discussions.ex @@ -225,7 +225,7 @@ defmodule Mobilizon.Discussions do @doc """ Returns a paginated list of local comments """ - @spec list_local_comments(integer | nil, integer | nil) :: Page.t() + @spec list_local_comments(integer | nil, integer | nil) :: Page.t(Comment.t()) def list_local_comments(page \\ nil, limit \\ nil) do Comment |> where([c], c.visibility == ^:public) @@ -238,7 +238,8 @@ defmodule Mobilizon.Discussions do @doc """ Returns the list of public comments for the actor. """ - @spec list_public_comments_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec list_public_comments_for_actor(Actor.t(), integer | nil, integer | nil) :: + Page.t(Comment.t()) def list_public_comments_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do actor_id |> public_comments_for_actor_query() @@ -263,7 +264,7 @@ defmodule Mobilizon.Discussions do @doc """ Get all the comments contained into a discussion """ - @spec get_comments_for_discussion(integer, integer | nil, integer | nil) :: Page.t() + @spec get_comments_for_discussion(integer, integer | nil, integer | nil) :: Page.t(Comment.t()) def get_comments_for_discussion(discussion_id, page \\ nil, limit \\ nil) do Comment |> where([c], c.discussion_id == ^discussion_id) @@ -326,7 +327,8 @@ defmodule Mobilizon.Discussions do @doc """ Get a paginated list of discussions for a group actor """ - @spec find_discussions_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec find_discussions_for_actor(Actor.t(), integer | nil, integer | nil) :: + Page.t(Discussion.t()) def find_discussions_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do Discussion |> where([c], c.actor_id == ^actor_id) diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 6f0887f9..17fd6eac 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -356,7 +356,7 @@ defmodule Mobilizon.Events do @doc """ Returns the list of events. """ - @spec list_events(integer | nil, integer | nil, atom, atom, boolean) :: Page.t() + @spec list_events(integer | nil, integer | nil, atom, atom, boolean) :: Page.t(Event.t()) def list_events( page \\ nil, limit \\ nil, @@ -410,7 +410,7 @@ defmodule Mobilizon.Events do @doc """ Lists public events for the actor, with all associations loaded. """ - @spec list_public_events_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec list_public_events_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t(Event.t()) def list_public_events_for_actor(actor, page \\ nil, limit \\ nil) def list_public_events_for_actor(%Actor{type: :Group} = group, page, limit), @@ -521,7 +521,7 @@ defmodule Mobilizon.Events do @doc """ Builds a page struct for events by their name. """ - @spec build_events_for_search(map(), integer | nil, integer | nil) :: Page.t() + @spec build_events_for_search(map(), integer | nil, integer | nil) :: Page.t(Event.t()) def build_events_for_search(%{term: term} = args, page \\ nil, limit \\ nil) do term |> normalize_search_string() @@ -812,7 +812,7 @@ defmodule Mobilizon.Events do Default behaviour is to not return :not_approved or :not_confirmed participants """ @spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) :: - Page.t() + Page.t(Participant.t()) def list_participants_for_event( id, roles \\ [], @@ -849,7 +849,7 @@ defmodule Mobilizon.Events do DateTime.t() | nil, integer | nil, integer | nil - ) :: Page.t() + ) :: Page.t(Participant.t()) def list_participations_for_user(user_id, after_datetime, before_datetime, page, limit) do user_id |> list_participations_for_user_query() @@ -891,7 +891,8 @@ defmodule Mobilizon.Events do @doc """ Returns the list of participations for an actor. """ - @spec list_event_participations_for_actor(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec list_event_participations_for_actor(Actor.t(), integer | nil, integer | nil) :: + Page.t(Participant.t()) def list_event_participations_for_actor(%Actor{id: actor_id}, page \\ nil, limit \\ nil) do actor_id |> event_participations_for_actor_query() diff --git a/lib/mobilizon/events/tag.ex b/lib/mobilizon/events/tag.ex index 128c2388..a0b1e34f 100644 --- a/lib/mobilizon/events/tag.ex +++ b/lib/mobilizon/events/tag.ex @@ -12,7 +12,7 @@ defmodule Mobilizon.Events.Tag do @type t :: %__MODULE__{ title: String.t(), - slug: TitleSlug.Type.t(), + slug: String.t(), related_tags: [t] } diff --git a/lib/mobilizon/instances/instance.ex b/lib/mobilizon/instances/instance.ex index a3acedde..82fef127 100644 --- a/lib/mobilizon/instances/instance.ex +++ b/lib/mobilizon/instances/instance.ex @@ -6,6 +6,16 @@ defmodule Mobilizon.Instances.Instance do """ use Ecto.Schema + @type t :: %__MODULE__{ + event_count: non_neg_integer(), + person_count: non_neg_integer(), + group_count: non_neg_integer(), + followers_count: non_neg_integer(), + followings_count: non_neg_integer(), + reports_count: non_neg_integer(), + media_size: non_neg_integer() + } + @primary_key {:domain, :string, []} schema "instances" do field(:event_count, :integer) diff --git a/lib/mobilizon/medias/medias.ex b/lib/mobilizon/medias/medias.ex index ef4d258f..fb946e4d 100644 --- a/lib/mobilizon/medias/medias.ex +++ b/lib/mobilizon/medias/medias.ex @@ -55,7 +55,7 @@ defmodule Mobilizon.Medias do @doc """ List the paginated media for user """ - @spec medias_for_user(integer | String.t(), integer | nil, integer | nil) :: Page.t() + @spec medias_for_user(integer | String.t(), integer | nil, integer | nil) :: Page.t(Media.t()) def medias_for_user(user_id, page, limit) do user_id |> medias_for_user_query() diff --git a/lib/mobilizon/posts/posts.ex b/lib/mobilizon/posts/posts.ex index 28271b1e..9bd54198 100644 --- a/lib/mobilizon/posts/posts.ex +++ b/lib/mobilizon/posts/posts.ex @@ -41,14 +41,14 @@ defmodule Mobilizon.Posts do @doc """ Returns the list of recent posts for a group """ - @spec get_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec get_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(Post.t()) def get_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do group_id |> do_get_posts_for_group() |> Page.build_page(page, limit) end - @spec get_public_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec get_public_posts_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(Post.t()) def get_public_posts_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do group_id |> do_get_posts_for_group() diff --git a/lib/mobilizon/resources/resources.ex b/lib/mobilizon/resources/resources.ex index c83522d9..a159a383 100644 --- a/lib/mobilizon/resources/resources.ex +++ b/lib/mobilizon/resources/resources.ex @@ -18,7 +18,7 @@ defmodule Mobilizon.Resources do @doc """ Returns the list of recent resources for a group """ - @spec get_resources_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec get_resources_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(Resource.t()) def get_resources_for_group(%Actor{id: group_id}, page \\ nil, limit \\ nil) do Resource |> where(actor_id: ^group_id) @@ -30,7 +30,8 @@ defmodule Mobilizon.Resources do @doc """ Returns the list of resources for a resource folder. """ - @spec get_resources_for_folder(Resource.t(), integer | nil, integer | nil) :: Page.t() + @spec get_resources_for_folder(Resource.t(), integer | nil, integer | nil) :: + Page.t(Resource.t()) def get_resources_for_folder(resource, page \\ nil, limit \\ nil) def get_resources_for_folder( diff --git a/lib/mobilizon/storage/repo.ex b/lib/mobilizon/storage/repo.ex index 545b9e6c..e57d8864 100644 --- a/lib/mobilizon/storage/repo.ex +++ b/lib/mobilizon/storage/repo.ex @@ -1,7 +1,5 @@ defmodule Mobilizon.Storage.Repo do - @moduledoc """ - Mobilizon Repo. - """ + @moduledoc false use Ecto.Repo, otp_app: :mobilizon, diff --git a/lib/mobilizon/todos/todos.ex b/lib/mobilizon/todos/todos.ex index 8910581b..22cf6f1b 100644 --- a/lib/mobilizon/todos/todos.ex +++ b/lib/mobilizon/todos/todos.ex @@ -22,7 +22,7 @@ defmodule Mobilizon.Todos do @doc """ Returns the list of todo lists for a group. """ - @spec get_todo_lists_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t() + @spec get_todo_lists_for_group(Actor.t(), integer | nil, integer | nil) :: Page.t(TodoList.t()) def get_todo_lists_for_group(%Actor{id: group_id, type: :Group}, page \\ nil, limit \\ nil) do TodoList |> where(actor_id: ^group_id) @@ -34,7 +34,7 @@ defmodule Mobilizon.Todos do @doc """ Returns the list of todos for a group. """ - @spec get_todos_for_todo_list(TodoList.t(), integer | nil, integer | nil) :: Page.t() + @spec get_todos_for_todo_list(TodoList.t(), integer | nil, integer | nil) :: Page.t(Todo.t()) def get_todos_for_todo_list(%TodoList{id: todo_list_id}, page \\ nil, limit \\ nil) do Todo |> where(todo_list_id: ^todo_list_id) diff --git a/lib/mobilizon/users/users.ex b/lib/mobilizon/users/users.ex index 2417f842..a1fa208b 100644 --- a/lib/mobilizon/users/users.ex +++ b/lib/mobilizon/users/users.ex @@ -358,7 +358,7 @@ defmodule Mobilizon.Users do Get a paginated list of all of a user's subscriptions """ @spec list_user_push_subscriptions(String.t() | integer(), integer() | nil, integer() | nil) :: - Page.t() + Page.t(PushSubscription.t()) def list_user_push_subscriptions(user_id, page \\ nil, limit \\ nil) do PushSubscription |> where([p], p.user_id == ^user_id) diff --git a/lib/service/export/common.ex b/lib/service/export/common.ex index 0a39b1ce..f0dba59b 100644 --- a/lib/service/export/common.ex +++ b/lib/service/export/common.ex @@ -106,7 +106,7 @@ defmodule Mobilizon.Service.Export.Common do actor |> fetch_identity_participations(limit) |> participations_to_events() end - @spec fetch_identity_participations(Actor.t(), integer()) :: Page.t() + @spec fetch_identity_participations(Actor.t(), integer()) :: Page.t(Participant.t()) defp fetch_identity_participations(%Actor{} = actor, limit) do with %Page{} = page <- Events.list_event_participations_for_actor(actor, 1, limit) do page diff --git a/lib/web/email/email.ex b/lib/web/email/email.ex index e7adaf85..433a0134 100644 --- a/lib/web/email/email.ex +++ b/lib/web/email/email.ex @@ -22,6 +22,7 @@ defmodule Mobilizon.Web.Email do |> put_layout({EmailView, :email}) end + @spec add_event_attachment(Swoosh.Email.t(), Event.t()) :: Swoosh.Email.t() def add_event_attachment(%Swoosh.Email{} = email, %Event{id: event_id}) do with {:ok, %Event{} = event} <- Events.get_event_with_preload(event_id), {:ok, event_ics_data} <- ICalendar.export_event(event) do diff --git a/lib/web/views/activity_pub/actor_view.ex b/lib/web/views/activity_pub/actor_view.ex index 7f3143a5..e67e5790 100644 --- a/lib/web/views/activity_pub/actor_view.ex +++ b/lib/web/views/activity_pub/actor_view.ex @@ -90,7 +90,7 @@ defmodule Mobilizon.Web.ActivityPub.ActorView do | :todos | :outbox - @spec fetch_collection(collection(), Actor.t(), integer()) :: Page.t() + @spec fetch_collection(collection(), Actor.t(), integer()) :: Page.t(Follower.t()) defp fetch_collection(:following, actor, page) do Actors.build_followings_for_actor(actor, page) end