Various refactoring and typespec improvements

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-09-24 16:46:42 +02:00
parent d235653876
commit 1893d9f55b
142 changed files with 1854 additions and 1297 deletions

View File

@@ -51,11 +51,11 @@ defmodule Mobilizon.Service.Activity.Comment do
"object_type" => :comment
}
@spec handle_notification(Keyword.t(), notification_type, Comment.t(), Event.t(), Keyword.t()) ::
Keyword.t()
defp handle_notification(global_res, function, comment, event, options) do
case notify(function, comment, event, options) do
{:ok, res} -> Keyword.put(global_res, function, res)
_ -> Keyword.put(global_res, function, :error)
end
{:ok, res} = notify(function, comment, event, options)
Keyword.put(global_res, function, res)
end
@spec legacy_notifier_enqueue(map()) :: :ok
@@ -66,11 +66,11 @@ defmodule Mobilizon.Service.Activity.Comment do
)
end
@type notification_type :: atom()
@type notification_type :: :mentionned | :announcement | :organizer
# An actor is mentionned
@spec notify(notification_type(), Comment.t(), Event.t(), Keyword.t()) ::
{:ok, Oban.Job.t()} | {:ok, :skipped}
{:ok, :enqueued} | {:ok, :skipped}
defp notify(
:mentionned,
%Comment{actor_id: actor_id, id: comment_id, mentions: mentions},