Fixes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
246555a768
commit
eaf424e79f
@ -592,7 +592,12 @@ defmodule Mobilizon.Events do
|
|||||||
"""
|
"""
|
||||||
@spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) ::
|
@spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) ::
|
||||||
[Participant.t()]
|
[Participant.t()]
|
||||||
def list_participants_for_event(uuid, roles \\ @default_participant_roles, page, limit) do
|
def list_participants_for_event(
|
||||||
|
uuid,
|
||||||
|
roles \\ @default_participant_roles,
|
||||||
|
page \\ nil,
|
||||||
|
limit \\ nil
|
||||||
|
) do
|
||||||
uuid
|
uuid
|
||||||
|> list_participants_for_event_query()
|
|> list_participants_for_event_query()
|
||||||
|> filter_role(roles)
|
|> filter_role(roles)
|
||||||
|
@ -201,7 +201,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
}
|
}
|
||||||
) do
|
) do
|
||||||
# Check that moderator provided is rightly authenticated
|
# Check that moderator provided is rightly authenticated
|
||||||
with {:is_owned, true, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
with {:is_owned, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
||||||
# Check that participation already exists
|
# Check that participation already exists
|
||||||
{:has_participation, %Participant{role: :not_approved} = participation} <-
|
{:has_participation, %Participant{role: :not_approved} = participation} <-
|
||||||
{:has_participation, Mobilizon.Events.get_participant(participation_id)},
|
{:has_participation, Mobilizon.Events.get_participant(participation_id)},
|
||||||
@ -213,7 +213,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
MobilizonWeb.API.Participations.accept(participation, moderator_actor) do
|
MobilizonWeb.API.Participations.accept(participation, moderator_actor) do
|
||||||
{:ok, participation}
|
{:ok, participation}
|
||||||
else
|
else
|
||||||
{:is_owned, false} ->
|
{:is_owned, nil} ->
|
||||||
{:error, "Moderator Actor ID is not owned by authenticated user"}
|
{:error, "Moderator Actor ID is not owned by authenticated user"}
|
||||||
|
|
||||||
{:has_participation, %Participant{role: role, id: id}} ->
|
{:has_participation, %Participant{role: role, id: id}} ->
|
||||||
@ -238,7 +238,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
}
|
}
|
||||||
) do
|
) do
|
||||||
# Check that moderator provided is rightly authenticated
|
# Check that moderator provided is rightly authenticated
|
||||||
with {:is_owned, true, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
with {:is_owned, moderator_actor} <- User.owns_actor(user, moderator_actor_id),
|
||||||
# Check that participation really exists
|
# Check that participation really exists
|
||||||
{:has_participation, %Participant{} = participation} <-
|
{:has_participation, %Participant{} = participation} <-
|
||||||
{:has_participation, Mobilizon.Events.get_participant(participation_id)},
|
{:has_participation, Mobilizon.Events.get_participant(participation_id)},
|
||||||
@ -261,7 +261,7 @@ defmodule MobilizonWeb.Resolvers.Event do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{:is_owned, false} ->
|
{:is_owned, nil} ->
|
||||||
{:error, "Moderator Actor ID is not owned by authenticated user"}
|
{:error, "Moderator Actor ID is not owned by authenticated user"}
|
||||||
|
|
||||||
{:actor_approve_permission, _} ->
|
{:actor_approve_permission, _} ->
|
||||||
|
@ -225,7 +225,7 @@ defmodule MobilizonWeb.Schema.EventType do
|
|||||||
arg(:begins_on, non_null(:datetime))
|
arg(:begins_on, non_null(:datetime))
|
||||||
arg(:ends_on, :datetime)
|
arg(:ends_on, :datetime)
|
||||||
arg(:status, :event_status)
|
arg(:status, :event_status)
|
||||||
arg(:visibility, :event_visibility, default_value: :private)
|
arg(:visibility, :event_visibility, default_value: :public)
|
||||||
arg(:join_options, :event_join_options, default_value: :free)
|
arg(:join_options, :event_join_options, default_value: :free)
|
||||||
|
|
||||||
arg(:tags, list_of(:string),
|
arg(:tags, list_of(:string),
|
||||||
@ -258,8 +258,8 @@ defmodule MobilizonWeb.Schema.EventType do
|
|||||||
arg(:begins_on, :datetime)
|
arg(:begins_on, :datetime)
|
||||||
arg(:ends_on, :datetime)
|
arg(:ends_on, :datetime)
|
||||||
arg(:status, :event_status)
|
arg(:status, :event_status)
|
||||||
arg(:visibility, :event_visibility)
|
arg(:visibility, :event_visibility, default_value: :public)
|
||||||
arg(:join_options, :event_join_options)
|
arg(:join_options, :event_join_options, default_value: :free)
|
||||||
|
|
||||||
arg(:tags, list_of(:string), description: "The list of tags associated to the event")
|
arg(:tags, list_of(:string), description: "The list of tags associated to the event")
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ defmodule Mobilizon.Service.ActivityPub do
|
|||||||
alias Mobilizon.Service.ActivityPub.{Activity, Convertible}
|
alias Mobilizon.Service.ActivityPub.{Activity, Convertible}
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
import Mobilizon.Service.ActivityPub.{Utils, Visibility}
|
import Mobilizon.Service.ActivityPub.Utils
|
||||||
|
import Mobilizon.Service.ActivityPub.Visibility
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Get recipients for an activity or object
|
Get recipients for an activity or object
|
||||||
|
@ -186,6 +186,7 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do
|
|||||||
"mediaType" => "text/html",
|
"mediaType" => "text/html",
|
||||||
"startTime" => event.begins_on |> date_to_string(),
|
"startTime" => event.begins_on |> date_to_string(),
|
||||||
"endTime" => event.ends_on |> date_to_string(),
|
"endTime" => event.ends_on |> date_to_string(),
|
||||||
|
"joinOptions" => to_string(event.join_options),
|
||||||
"tag" => event.tags |> build_tags(),
|
"tag" => event.tags |> build_tags(),
|
||||||
"id" => event.url,
|
"id" => event.url,
|
||||||
"url" => event.url
|
"url" => event.url
|
||||||
|
@ -315,8 +315,9 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do
|
|||||||
%{"type" => "Update", "object" => %{"type" => "Event"} = object, "actor" => actor} =
|
%{"type" => "Update", "object" => %{"type" => "Event"} = object, "actor" => actor} =
|
||||||
_update
|
_update
|
||||||
) do
|
) do
|
||||||
with {:ok, %{"actor" => existing_organizer_actor_url} = _existing_event_data} <-
|
with {:ok, %{"actor" => existing_organizer_actor_url} = existing_event_data} <-
|
||||||
fetch_obj_helper_as_activity_streams(object),
|
fetch_obj_helper_as_activity_streams(object),
|
||||||
|
object <- Map.merge(existing_event_data, object),
|
||||||
{:ok, %Actor{url: actor_url}} <- actor |> Utils.get_url() |> Actors.get_actor_by_url(),
|
{:ok, %Actor{url: actor_url}} <- actor |> Utils.get_url() |> Actors.get_actor_by_url(),
|
||||||
true <- Utils.get_url(existing_organizer_actor_url) == actor_url do
|
true <- Utils.get_url(existing_organizer_actor_url) == actor_url do
|
||||||
ActivityPub.update(%{
|
ActivityPub.update(%{
|
||||||
|
Loading…
Reference in New Issue
Block a user