Fix some typespecs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-04-18 14:38:57 +02:00
parent 714e9216c1
commit 83f2880dd9
33 changed files with 76 additions and 60 deletions

View File

@@ -21,13 +21,13 @@ defmodule Mobilizon.Activities.Activity do
@attrs @required_attrs ++ @optional_attrs
@type t :: %__MODULE__{
priority: Priority.t(),
type: Type.t(),
subject: Subject.t(),
priority: pos_integer(),
type: String.t(),
subject: String.t(),
subject_params: map(),
message: String.t(),
message_params: map(),
object_type: ObjectType.t(),
object_type: String.t(),
object_id: String.t(),
object: map(),
author: Actor.t(),

View File

@@ -33,15 +33,15 @@ defmodule Mobilizon.Actors.Actor do
resources_url: String.t(),
posts_url: String.t(),
events_url: String.t(),
type: ActorType.t(),
type: atom(),
name: String.t() | nil,
domain: String.t() | nil,
summary: String.t(),
preferred_username: String.t(),
keys: String.t(),
manually_approves_followers: boolean,
openness: ActorOpenness.t(),
visibility: ActorVisibility.t(),
openness: atom(),
visibility: atom(),
suspended: boolean,
avatar: File.t() | nil,
banner: File.t() | nil,
@@ -358,7 +358,7 @@ defmodule Mobilizon.Actors.Actor do
# When we don't even have any preferred_username, don't even try validating preferred_username
defp unique_username_validator(changeset), do: changeset
@spec build_urls(Ecto.Changeset.t(), ActorType.t()) :: Ecto.Changeset.t()
@spec build_urls(Ecto.Changeset.t(), atom()) :: Ecto.Changeset.t()
defp build_urls(changeset, type \\ :Person)
defp build_urls(%Ecto.Changeset{changes: %{preferred_username: username}} = changeset, type) do

View File

@@ -145,7 +145,7 @@ defmodule Mobilizon.Actors do
@doc """
Gets an actor by name.
"""
@spec get_actor_by_name(String.t(), ActorType.t() | nil) :: Actor.t() | nil
@spec get_actor_by_name(String.t(), atom() | nil) :: Actor.t() | nil
def get_actor_by_name(name, type \\ nil) do
Actor
|> filter_by_type(type)
@@ -1635,7 +1635,7 @@ defmodule Mobilizon.Actors do
|> preload([f, a], [:target_actor, :actor])
end
@spec filter_by_type(Ecto.Queryable.t(), ActorType.t() | nil) :: Ecto.Queryable.t()
@spec filter_by_type(Ecto.Queryable.t(), atom() | nil) :: Ecto.Queryable.t()
defp filter_by_type(query, type)
when type in [:Person, :Group, :Application, :Service, :Organisation] do
from(a in query, where: a.type == ^type)

View File

@@ -14,7 +14,7 @@ defmodule Mobilizon.Actors.Member do
@type t :: %__MODULE__{
id: String.t(),
url: String.t(),
role: MemberRole.t(),
role: atom(),
parent: Actor.t(),
actor: Actor.t(),
metadata: Metadata.t()

View File

@@ -22,7 +22,7 @@ defmodule Mobilizon.Discussions.Comment do
url: String.t(),
id: integer(),
local: boolean,
visibility: CommentVisibility.t(),
visibility: atom(),
uuid: Ecto.UUID.t(),
actor: Actor.t(),
attributed_to: Actor.t(),

View File

@@ -43,10 +43,10 @@ defmodule Mobilizon.Events.Event do
description: String.t(),
ends_on: DateTime.t(),
title: String.t(),
status: EventStatus.t(),
status: atom(),
draft: boolean,
visibility: EventVisibility.t(),
join_options: JoinOptions.t(),
visibility: atom(),
join_options: atom(),
publish_at: DateTime.t() | nil,
uuid: Ecto.UUID.t(),
online_address: String.t() | nil,

View File

@@ -442,7 +442,7 @@ defmodule Mobilizon.Events do
@spec list_organized_events_for_group(
Actor.t(),
EventVisibility.t() | :all,
atom(),
DateTime.t() | nil,
DateTime.t() | nil,
integer | nil,

View File

@@ -16,7 +16,7 @@ defmodule Mobilizon.Events.Participant do
@type t :: %__MODULE__{
id: String.t(),
role: ParticipantRole.t(),
role: atom(),
code: String.t(),
url: String.t(),
event: Event.t(),

View File

@@ -39,7 +39,7 @@ defmodule Mobilizon.Posts.Post do
body: String.t(),
title: String.t(),
draft: boolean,
visibility: PostVisibility.t(),
visibility: atom(),
publish_at: DateTime.t(),
author: Actor.t(),
attributed_to: Actor.t(),

View File

@@ -17,7 +17,7 @@ defmodule Mobilizon.Reports.Report do
@type t :: %__MODULE__{
id: integer(),
content: String.t(),
status: ReportStatus.t(),
status: atom(),
url: String.t(),
reported: Actor.t(),
reporter: Actor.t(),

View File

@@ -99,7 +99,7 @@ defmodule Mobilizon.Reports do
@spec delete_note(Note.t()) :: {:ok, Note.t()} | {:error, Ecto.Changeset.t()}
def delete_note(%Note{} = note), do: Repo.delete(note)
@spec list_reports_query(ReportStatus.t()) :: Ecto.Query.t()
@spec list_reports_query(atom()) :: Ecto.Query.t()
defp list_reports_query(status) do
Report
|> preload([:reported, :reporter, :manager, :event, :comments, :notes])

View File

@@ -13,9 +13,9 @@ defmodule Mobilizon.Users.Setting do
notification_on_day: boolean,
notification_each_week: boolean,
notification_before_event: boolean,
notification_pending_participation: NotificationPendingNotificationDelay.t(),
notification_pending_membership: NotificationPendingNotificationDelay.t(),
group_notifications: NotificationPendingNotificationDelay.t(),
notification_pending_participation: non_neg_integer(),
notification_pending_membership: non_neg_integer(),
group_notifications: non_neg_integer(),
last_notification_sent: DateTime.t(),
user: User.t()
}

View File

@@ -18,7 +18,7 @@ defmodule Mobilizon.Users.User do
email: String.t(),
password_hash: String.t(),
password: String.t(),
role: UserRole.t(),
role: atom(),
confirmed_at: DateTime.t() | nil,
confirmation_sent_at: DateTime.t(),
confirmation_token: String.t(),