Fix new credo warnings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-26 14:30:46 +01:00
parent 52e624bb88
commit 51afec1856
20 changed files with 77 additions and 72 deletions

View File

@@ -155,7 +155,7 @@ defmodule Mobilizon.Federation.ActivityPub do
end
# Create an activity from an event
@spec event_to_activity(%Event{}, boolean()) :: Activity.t()
@spec event_to_activity(Event.t(), boolean()) :: Activity.t()
defp event_to_activity(%Event{} = event, local \\ true) do
%Activity{
recipients: [@public_ap_adress],
@@ -166,7 +166,7 @@ defmodule Mobilizon.Federation.ActivityPub do
end
# Create an activity from a comment
@spec comment_to_activity(%Comment{}, boolean()) :: Activity.t()
@spec comment_to_activity(Comment.t(), boolean()) :: Activity.t()
defp comment_to_activity(%Comment{} = comment, local \\ true) do
%Activity{
recipients: [@public_ap_adress],

View File

@@ -77,7 +77,7 @@ defmodule Mobilizon.Federation.ActivityPub.Permission do
@spec can_manage_group_object?(
existing_object_permissions(),
%Actor{url: String.t()},
Actor.t(),
object()
) :: boolean()
defp can_manage_group_object?(permission, %Actor{url: actor_url} = actor, object) do

View File

@@ -967,10 +967,8 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier do
defp do_handle_incoming_reject_invite(invite_object, %Actor{} = actor_rejecting) do
with {:invite, {:ok, %Member{role: :invited, actor_id: actor_id} = member}} <-
{:invite, get_member(invite_object)},
{:same_actor, true} <- {:same_actor, actor_rejecting.id == actor_id},
{:ok, activity, member} <-
Actions.Reject.reject(:invite, member, false) do
{:ok, activity, member}
{:same_actor, true} <- {:same_actor, actor_rejecting.id == actor_id} do
Actions.Reject.reject(:invite, member, false)
end
end

View File

@@ -149,25 +149,23 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Comments do
),
tags <- ConverterUtils.fetch_tags(tags),
mentions <- Map.get(args, :mentions, []) ++ ConverterUtils.fetch_mentions(mentions),
lang <- Map.get(args, :language, "und"),
args <-
Map.merge(args, %{
actor_id: Map.get(args, :actor_id),
text: text,
mentions: mentions,
tags: tags,
event: event,
in_reply_to_comment: in_reply_to_comment,
in_reply_to_comment_id:
if(is_nil(in_reply_to_comment), do: nil, else: Map.get(in_reply_to_comment, :id)),
origin_comment_id:
if(is_nil(in_reply_to_comment),
do: nil,
else: Comment.get_thread_id(in_reply_to_comment)
),
language: if(lang == "und", do: LanguageDetection.detect(:comment, args), else: lang)
}) do
args
lang <- Map.get(args, :language, "und") do
Map.merge(args, %{
actor_id: Map.get(args, :actor_id),
text: text,
mentions: mentions,
tags: tags,
event: event,
in_reply_to_comment: in_reply_to_comment,
in_reply_to_comment_id:
if(is_nil(in_reply_to_comment), do: nil, else: Map.get(in_reply_to_comment, :id)),
origin_comment_id:
if(is_nil(in_reply_to_comment),
do: nil,
else: Comment.get_thread_id(in_reply_to_comment)
),
language: if(lang == "und", do: LanguageDetection.detect(:comment, args), else: lang)
})
end
end