Fix credo style reports following it's update
Mainly transform `with` into `case` Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -176,11 +176,12 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
# and that it's the actor requesting leaving the event we return true
|
||||
@spec check_that_participant_is_not_only_organizer(integer(), integer()) :: boolean()
|
||||
defp check_that_participant_is_not_only_organizer(event_id, actor_id) do
|
||||
with [%Participant{actor: %Actor{id: participant_actor_id}}] <-
|
||||
Mobilizon.Events.list_organizers_participants_for_event(event_id) do
|
||||
participant_actor_id == actor_id
|
||||
else
|
||||
_ -> false
|
||||
case Mobilizon.Events.list_organizers_participants_for_event(event_id) do
|
||||
[%Participant{actor: %Actor{id: participant_actor_id}}] ->
|
||||
participant_actor_id == actor_id
|
||||
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -218,17 +218,18 @@ defmodule MobilizonWeb.Resolvers.Group do
|
||||
# and that it's the actor requesting leaving the group we return true
|
||||
@spec check_that_member_is_not_only_administrator(integer(), integer()) :: boolean()
|
||||
defp check_that_member_is_not_only_administrator(group_id, actor_id) do
|
||||
with [
|
||||
%Member{
|
||||
actor: %Actor{
|
||||
id: member_actor_id
|
||||
}
|
||||
}
|
||||
] <-
|
||||
Member.list_administrator_members_for_group(group_id) do
|
||||
actor_id == member_actor_id
|
||||
else
|
||||
_ -> false
|
||||
case Member.list_administrator_members_for_group(group_id) do
|
||||
[
|
||||
%Member{
|
||||
actor: %Actor{
|
||||
id: member_actor_id
|
||||
}
|
||||
}
|
||||
] ->
|
||||
actor_id == member_actor_id
|
||||
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,10 +35,17 @@ defmodule MobilizonWeb.Resolvers.Picture do
|
||||
|
||||
@spec do_fetch_picture(String.t()) :: {:ok, Picture.t()} | {:error, :not_found}
|
||||
defp do_fetch_picture(picture_id) do
|
||||
with %Picture{id: id, file: file} = _pic <- Media.get_picture(picture_id) do
|
||||
{:ok,
|
||||
%{name: file.name, url: file.url, id: id, content_type: file.content_type, size: file.size}}
|
||||
else
|
||||
case Media.get_picture(picture_id) do
|
||||
%Picture{id: id, file: file} = _pic ->
|
||||
{:ok,
|
||||
%{
|
||||
name: file.name,
|
||||
url: file.url,
|
||||
id: id,
|
||||
content_type: file.content_type,
|
||||
size: file.size
|
||||
}}
|
||||
|
||||
_err ->
|
||||
{:error, "Picture with ID #{picture_id} was not found"}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user