From eaf424e79fe5183014bad3f067c22cefd5c74870 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 22 Sep 2019 11:22:16 +0200 Subject: [PATCH] Fixes Signed-off-by: Thomas Citharel --- lib/mobilizon/events/events.ex | 7 ++++++- lib/mobilizon_web/resolvers/event.ex | 8 ++++---- lib/mobilizon_web/schema/event.ex | 6 +++--- lib/service/activity_pub/activity_pub.ex | 3 ++- lib/service/activity_pub/converters/event.ex | 1 + lib/service/activity_pub/transmogrifier.ex | 3 ++- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 7eb44363f..c6c47b72a 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -592,7 +592,12 @@ defmodule Mobilizon.Events do """ @spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) :: [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 |> list_participants_for_event_query() |> filter_role(roles) diff --git a/lib/mobilizon_web/resolvers/event.ex b/lib/mobilizon_web/resolvers/event.ex index b1b14341b..96783f3c2 100644 --- a/lib/mobilizon_web/resolvers/event.ex +++ b/lib/mobilizon_web/resolvers/event.ex @@ -201,7 +201,7 @@ defmodule MobilizonWeb.Resolvers.Event do } ) do # 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 {:has_participation, %Participant{role: :not_approved} = participation} <- {: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 {:ok, participation} else - {:is_owned, false} -> + {:is_owned, nil} -> {:error, "Moderator Actor ID is not owned by authenticated user"} {:has_participation, %Participant{role: role, id: id}} -> @@ -238,7 +238,7 @@ defmodule MobilizonWeb.Resolvers.Event do } ) do # 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 {:has_participation, %Participant{} = participation} <- {:has_participation, Mobilizon.Events.get_participant(participation_id)}, @@ -261,7 +261,7 @@ defmodule MobilizonWeb.Resolvers.Event do } } else - {:is_owned, false} -> + {:is_owned, nil} -> {:error, "Moderator Actor ID is not owned by authenticated user"} {:actor_approve_permission, _} -> diff --git a/lib/mobilizon_web/schema/event.ex b/lib/mobilizon_web/schema/event.ex index 2ccd44405..5584a9d35 100644 --- a/lib/mobilizon_web/schema/event.ex +++ b/lib/mobilizon_web/schema/event.ex @@ -225,7 +225,7 @@ defmodule MobilizonWeb.Schema.EventType do arg(:begins_on, non_null(:datetime)) arg(:ends_on, :datetime) 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(:tags, list_of(:string), @@ -258,8 +258,8 @@ defmodule MobilizonWeb.Schema.EventType do arg(:begins_on, :datetime) arg(:ends_on, :datetime) arg(:status, :event_status) - arg(:visibility, :event_visibility) - arg(:join_options, :event_join_options) + arg(:visibility, :event_visibility, default_value: :public) + arg(:join_options, :event_join_options, default_value: :free) arg(:tags, list_of(:string), description: "The list of tags associated to the event") diff --git a/lib/service/activity_pub/activity_pub.ex b/lib/service/activity_pub/activity_pub.ex index 5dab5b12e..604a60165 100644 --- a/lib/service/activity_pub/activity_pub.ex +++ b/lib/service/activity_pub/activity_pub.ex @@ -25,7 +25,8 @@ defmodule Mobilizon.Service.ActivityPub do alias Mobilizon.Service.ActivityPub.{Activity, Convertible} require Logger - import Mobilizon.Service.ActivityPub.{Utils, Visibility} + import Mobilizon.Service.ActivityPub.Utils + import Mobilizon.Service.ActivityPub.Visibility @doc """ Get recipients for an activity or object diff --git a/lib/service/activity_pub/converters/event.ex b/lib/service/activity_pub/converters/event.ex index ae19c2831..bba57d009 100644 --- a/lib/service/activity_pub/converters/event.ex +++ b/lib/service/activity_pub/converters/event.ex @@ -186,6 +186,7 @@ defmodule Mobilizon.Service.ActivityPub.Converters.Event do "mediaType" => "text/html", "startTime" => event.begins_on |> date_to_string(), "endTime" => event.ends_on |> date_to_string(), + "joinOptions" => to_string(event.join_options), "tag" => event.tags |> build_tags(), "id" => event.url, "url" => event.url diff --git a/lib/service/activity_pub/transmogrifier.ex b/lib/service/activity_pub/transmogrifier.ex index ef34e1477..fedd980ee 100644 --- a/lib/service/activity_pub/transmogrifier.ex +++ b/lib/service/activity_pub/transmogrifier.ex @@ -315,8 +315,9 @@ defmodule Mobilizon.Service.ActivityPub.Transmogrifier do %{"type" => "Update", "object" => %{"type" => "Event"} = object, "actor" => actor} = _update ) 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), + object <- Map.merge(existing_event_data, object), {: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 ActivityPub.update(%{