From dc9ef9c1b57c38fa007f4c2eb89e5f5bf81b6866 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 2 Sep 2019 17:23:00 +0200 Subject: [PATCH 1/3] Improve create event and prepare update event --- lib/mobilizon_web/api/events.ex | 133 +++++++++++++++--- lib/mobilizon_web/resolvers/event.ex | 115 +++++++++++++-- lib/mobilizon_web/schema/event.ex | 29 ++++ .../resolvers/event_resolver_test.exs | 128 +++++++++++++++++ 4 files changed, 371 insertions(+), 34 deletions(-) diff --git a/lib/mobilizon_web/api/events.ex b/lib/mobilizon_web/api/events.ex index 5e138eef8..45e107022 100644 --- a/lib/mobilizon_web/api/events.ex +++ b/lib/mobilizon_web/api/events.ex @@ -12,28 +12,69 @@ defmodule MobilizonWeb.API.Events do Create an event """ @spec create_event(map()) :: {:ok, Activity.t(), Event.t()} | any() - def create_event( - %{ - begins_on: begins_on, - description: description, - options: options, - organizer_actor_id: organizer_actor_id, - tags: tags, - title: title - } = args - ) - when is_map(options) do - with %Actor{url: url} = actor <- - Actors.get_local_actor_with_everything(organizer_actor_id), - physical_address <- Map.get(args, :physical_address, nil), - title <- String.trim(title), - visibility <- Map.get(args, :visibility, :public), - picture <- Map.get(args, :picture, nil), - {content_html, tags, to, cc} <- - Utils.prepare_content(actor, description, visibility, tags, nil), + def create_event(%{organizer_actor: organizer_actor} = args) do + with %{ + title: title, + physical_address: physical_address, + visibility: visibility, + picture: picture, + content_html: content_html, + tags: tags, + to: to, + cc: cc, + begins_on: begins_on, + category: category, + options: options + } <- prepare_args(args), event <- ActivityPubUtils.make_event_data( - url, + organizer_actor.url, + %{to: to, cc: cc}, + title, + content_html, + picture, + tags, + %{begins_on: begins_on, physical_address: physical_address, category: category, options: options} + ) do + ActivityPub.create(%{ + to: ["https://www.w3.org/ns/activitystreams#Public"], + actor: organizer_actor, + object: event, + local: true + }) + end + end + + @doc """ + Update an event + """ + @spec update_event(map()) :: {:ok, Activity.t(), Event.t()} | any() + def update_event( + %{ + organizer_actor: organizer_actor, + event: event + } = args + ) do + with %{ + title: title, + physical_address: physical_address, + visibility: visibility, + picture: picture, + content_html: content_html, + tags: tags, + to: to, + cc: cc, + begins_on: begins_on, + category: category, + options: options + } <- + prepare_args( + args + |> update_args(event) + ), + event <- + ActivityPubUtils.make_event_data( + organizer_actor.url, %{to: to, cc: cc}, title, content_html, @@ -46,12 +87,60 @@ defmodule MobilizonWeb.API.Events do options: options } ) do - ActivityPub.create(%{ + ActivityPub.update(%{ to: ["https://www.w3.org/ns/activitystreams#Public"], - actor: actor, + actor: organizer_actor, object: event, local: true }) end end + + defp update_args(args, event) do + %{ + title: Map.get(args, :title, event.title), + description: Map.get(args, :description, event.description), + tags: Map.get(args, :tags, event.tags), + physical_address: Map.get(args, :physical_address, event.physical_address), + visibility: Map.get(args, :visibility, event.visibility), + physical_address: Map.get(args, :physical_address, event.physical_address), + begins_on: Map.get(args, :begins_on, event.begins_on), + category: Map.get(args, :category, event.category), + options: Map.get(args, :options, event.options) + } + end + + defp prepare_args( + %{ + organizer_actor: organizer_actor, + title: title, + description: description, + options: options, + tags: tags, + begins_on: begins_on, + category: category, + options: options + } = args + ) do + with physical_address <- Map.get(args, :physical_address, nil), + title <- String.trim(title), + visibility <- Map.get(args, :visibility, :public), + picture <- Map.get(args, :picture, nil), + {content_html, tags, to, cc} <- + Utils.prepare_content(organizer_actor, description, visibility, tags, nil) do + %{ + title: title, + physical_address: physical_address, + visibility: visibility, + picture: picture, + content_html: content_html, + tags: tags, + to: to, + cc: cc, + begins_on: begins_on, + category: category, + options: options + } + end + end end diff --git a/lib/mobilizon_web/resolvers/event.ex b/lib/mobilizon_web/resolvers/event.ex index 8a01b2cf0..d34402f0f 100644 --- a/lib/mobilizon_web/resolvers/event.ex +++ b/lib/mobilizon_web/resolvers/event.ex @@ -58,7 +58,8 @@ defmodule MobilizonWeb.Resolvers.Event do ) do # We get the organizer's next public event events = - [Events.get_actor_upcoming_public_event(organizer_actor, uuid)] |> Enum.filter(&is_map/1) + [Events.get_actor_upcoming_public_event(organizer_actor, uuid)] + |> Enum.filter(&is_map/1) # We find similar events with the same tags # uniq_by : It's possible event_from_same_actor is inside events_from_tags @@ -150,7 +151,17 @@ defmodule MobilizonWeb.Resolvers.Event do {:has_event, {:ok, %Event{} = event}} <- {:has_event, Mobilizon.Events.get_event_full(event_id)}, {:ok, _activity, _participant} <- MobilizonWeb.API.Participations.leave(event, actor) do - {:ok, %{event: %{id: event_id}, actor: %{id: actor_id}}} + { + :ok, + %{ + event: %{ + id: event_id + }, + actor: %{ + id: actor_id + } + } + } else {:has_event, _} -> {:error, "Event with this ID #{inspect(event_id)} doesn't exist"} @@ -173,12 +184,33 @@ defmodule MobilizonWeb.Resolvers.Event do @doc """ Create an event """ - def create_event(_parent, args, %{context: %{current_user: _user}} = _resolution) do - with {:ok, args} <- save_attached_picture(args), + def create_event( + _parent, + %{organizer_actor_id: organizer_actor_id} = args, + %{ + context: %{ + current_user: user + } + } = _resolution + ) do + with {:is_owned, true, organizer_actor} <- User.owns_actor(user, organizer_actor_id), + {:ok, args} <- save_attached_picture(args), {:ok, args} <- save_physical_address(args), - {:ok, %Activity{data: %{"object" => %{"type" => "Event"} = _object}}, %Event{} = event} <- - MobilizonWeb.API.Events.create_event(args) do + args_with_organizer <- Map.put(args, :organizer_actor, organizer_actor), + { + :ok, + %Activity{ + data: %{ + "object" => %{"type" => "Event"} = _object + } + }, + %Event{} = event + } <- + MobilizonWeb.API.Events.create_event(args_with_organizer) do {:ok, event} + else + {:is_owned, false} -> + {:error, "Organizer actor id is not owned by the user"} end end @@ -186,19 +218,66 @@ defmodule MobilizonWeb.Resolvers.Event do {:error, "You need to be logged-in to create events"} end + @doc """ + Update an event + """ + def update_event( + _parent, + %{event_id: event_id} = args, + %{ + context: %{ + current_user: user + } + } = _resolution + ) do + with {:ok, %Event{} = event} <- Mobilizon.Events.get_event(event_id), + {:is_owned, true, organizer_actor} <- User.owns_actor(user, event.organizer_actor_id), + {:ok, args} <- save_attached_picture(args), + {:ok, args} <- save_physical_address(args), + { + :ok, + %Activity{ + data: %{ + "object" => %{"type" => "Event"} = _object + } + }, + %Event{} = event + } <- + MobilizonWeb.API.Events.update_event(args) do + {:ok, event} + else + {:error, :event_not_found} -> + {:error, "Event not found"} + end + end + + def update_event(_parent, _args, _resolution) do + {:error, "You need to be logged-in to update an event"} + end + # If we have an attached picture, just transmit it. It will be handled by # Mobilizon.Service.ActivityPub.Utils.make_picture_data/1 # However, we need to pass it's actor ID @spec save_attached_picture(map()) :: {:ok, map()} defp save_attached_picture( - %{picture: %{picture: %{file: %Plug.Upload{} = _picture} = all_pic}} = args + %{ + picture: %{ + picture: %{file: %Plug.Upload{} = _picture} = all_pic + } + } = args ) do {:ok, Map.put(args, :picture, Map.put(all_pic, :actor_id, args.organizer_actor_id))} end # Otherwise if we use a previously uploaded picture we need to fetch it from database @spec save_attached_picture(map()) :: {:ok, map()} - defp save_attached_picture(%{picture: %{picture_id: picture_id}} = args) do + defp save_attached_picture( + %{ + picture: %{ + picture_id: picture_id + } + } = args + ) do with %Picture{} = picture <- Mobilizon.Media.get_picture(picture_id) do {:ok, Map.put(args, :picture, picture)} end @@ -208,7 +287,13 @@ defmodule MobilizonWeb.Resolvers.Event do defp save_attached_picture(args), do: {:ok, args} @spec save_physical_address(map()) :: {:ok, map()} - defp save_physical_address(%{physical_address: %{url: physical_address_url}} = args) + defp save_physical_address( + %{ + physical_address: %{ + url: physical_address_url + } + } = args + ) when not is_nil(physical_address_url) do with %Address{} = address <- Addresses.get_address_by_url(physical_address_url), args <- Map.put(args, :physical_address, address.url) do @@ -230,9 +315,15 @@ defmodule MobilizonWeb.Resolvers.Event do @doc """ Delete an event """ - def delete_event(_parent, %{event_id: event_id, actor_id: actor_id}, %{ - context: %{current_user: user} - }) do + def delete_event( + _parent, + %{event_id: event_id, actor_id: actor_id}, + %{ + context: %{ + current_user: user + } + } + ) do with {:ok, %Event{} = event} <- Mobilizon.Events.get_event(event_id), {:is_owned, true, _} <- User.owns_actor(user, actor_id), {:event_can_be_managed, true} <- Event.can_event_be_managed_by(event, actor_id), diff --git a/lib/mobilizon_web/schema/event.ex b/lib/mobilizon_web/schema/event.ex index 8cbed015e..5c9956a6a 100644 --- a/lib/mobilizon_web/schema/event.ex +++ b/lib/mobilizon_web/schema/event.ex @@ -234,6 +234,35 @@ defmodule MobilizonWeb.Schema.EventType do resolve(&Event.create_event/3) end + @desc "Update an event" + field :update_event, type: :event do + arg(:event_id, non_null(:integer)) + + arg(:title, :string) + arg(:description, :string) + arg(:begins_on, :datetime) + arg(:ends_on, :datetime) + arg(:state, :integer) + arg(:status, :integer) + arg(:public, :boolean) + arg(:visibility, :event_visibility) + + arg(:tags, list_of(:string), description: "The list of tags associated to the event") + + arg(:picture, :picture_input, + description: + "The picture for the event, either as an object or directly the ID of an existing Picture" + ) + + arg(:publish_at, :datetime) + arg(:online_address, :string) + arg(:phone_address, :string) + arg(:category, :string) + arg(:physical_address, :address_input) + + resolve(&Event.update_event/3) + end + @desc "Delete an event" field :delete_event, :deleted_object do arg(:event_id, non_null(:integer)) diff --git a/test/mobilizon_web/resolvers/event_resolver_test.exs b/test/mobilizon_web/resolvers/event_resolver_test.exs index 077f2ec05..7aa69929e 100644 --- a/test/mobilizon_web/resolvers/event_resolver_test.exs +++ b/test/mobilizon_web/resolvers/event_resolver_test.exs @@ -58,6 +58,40 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do json_response(res, 200)["errors"] end + test "create_event/3 should check the organizer_actor_id is owned by the user", %{ + conn: conn, + user: user + } do + another_actor = insert(:actor) + + begins_on = DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601() + + mutation = """ + mutation { + createEvent( + title: "come to my event", + description: "it will be fine", + begins_on: "#{begins_on}", + organizer_actor_id: "#{another_actor.id}", + category: "birthday" + ) { + title, + uuid + } + } + """ + + res = + conn + |> auth_conn(user) + |> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) + + assert json_response(res, 200)["data"]["createEvent"] == nil + + assert hd(json_response(res, 200)["errors"])["message"] == + "Organizer actor id is not owned by the user" + end + test "create_event/3 creates an event", %{conn: conn, actor: actor, user: user} do mutation = """ mutation { @@ -384,6 +418,100 @@ defmodule MobilizonWeb.Resolvers.EventResolverTest do assert json_response(res, 200)["data"]["createEvent"]["picture"]["url"] end + test "update_event/3 should check the event exists", %{conn: conn, actor: actor, user: user} do + mutation = """ + mutation { + updateEvent( + event_id: 45, + title: "my event updated", + ) { + title, + uuid, + tags { + title, + slug + } + } + } + """ + + res = + conn + |> auth_conn(user) + |> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) + + assert hd(json_response(res, 200)["errors"])["message"] == "Event not found" + end + + test "update_event/3 should check the user is an administrator", %{ + conn: conn, + actor: actor, + user: user + } do + event = insert(:event) + + mutation = """ + mutation { + updateEvent( + title: "my event updated", + ) { + title, + uuid, + tags { + title, + slug + } + } + } + """ + + res = + conn + |> auth_conn(user) + |> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) + + assert json_response(res, 200)["errors"] == nil + end + + test "update_event/3 updates an event", %{conn: conn, actor: actor, user: user} do + event = insert(:event) + + begins_on = DateTime.utc_now() |> DateTime.truncate(:second) |> DateTime.to_iso8601() + + mutation = """ + mutation { + updateEvent( + title: "my event updated", + description: "description updated", + begins_on: "#{begins_on}", + organizer_actor_id: "#{actor.id}", + category: "birthday", + tags: ["tag1_updated", "tag2_updated"] + ) { + title, + uuid, + tags { + title, + slug + } + } + } + """ + + res = + conn + |> auth_conn(user) + |> post("/api", AbsintheHelpers.mutation_skeleton(mutation)) + + assert json_response(res, 200)["errors"] == nil + assert json_response(res, 200)["data"]["updateEvent"]["title"] == "my event updated" + + assert json_response(res, 200)["data"]["createEvent"]["tags"] == [ + %{"slug" => "tag1_updated", "title" => "tag1_updated"}, + %{"slug" => "tag2_updated", "title" => "tag2_updated"} + ] + end + test "list_events/3 returns events", context do event = insert(:event) From 6845825db2fed155815df7e279ffcda6a1c976bf Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 3 Sep 2019 08:38:04 +0200 Subject: [PATCH 2/3] Split ActivityPub.insert to create activity & insert object So that when we're not inserting anything no need to call method Signed-off-by: Thomas Citharel --- lib/service/activity_pub/activity_pub.ex | 64 +++++++++++++++--------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/service/activity_pub/activity_pub.ex b/lib/service/activity_pub/activity_pub.ex index 3823d7c33..b4bc6cb3d 100644 --- a/lib/service/activity_pub/activity_pub.ex +++ b/lib/service/activity_pub/activity_pub.ex @@ -39,11 +39,9 @@ defmodule Mobilizon.Service.ActivityPub do @doc """ Wraps an object into an activity """ - # TODO: Rename me - @spec insert(map(), boolean()) :: {:ok, %Activity{}} | {:error, any()} - def insert(map, local \\ true) when is_map(map) do - with map <- lazy_put_activity_defaults(map), - {:ok, object} <- insert_full_object(map) do + @spec create_activity(map(), boolean()) :: {:ok, %Activity{}} | {:error, any()} + def create_activity(map, local \\ true) when is_map(map) do + with map <- lazy_put_activity_defaults(map) do activity = %Activity{ data: map, local: local, @@ -53,9 +51,8 @@ defmodule Mobilizon.Service.ActivityPub do # Notification.create_notifications(activity) # stream_out(activity) - {:ok, activity, object} + {:ok, activity} else - %Activity{} = activity -> {:ok, activity} error -> {:error, error} end end @@ -137,7 +134,8 @@ defmodule Mobilizon.Service.ActivityPub do %{to: to, actor: actor, published: published, object: object}, additional ), - {:ok, activity, object} <- insert(create_data, local), + {:ok, activity} <- create_activity(create_data, local), + {:ok, object} <- insert_full_object(create_data), :ok <- maybe_federate(activity) do # {:ok, actor} <- Actors.increase_event_count(actor) do {:ok, activity, object} @@ -160,7 +158,8 @@ defmodule Mobilizon.Service.ActivityPub do "object" => object, "id" => activity_wrapper_id || get_url(object) <> "/activity" }, - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} end @@ -177,7 +176,8 @@ defmodule Mobilizon.Service.ActivityPub do "object" => object, "id" => activity_wrapper_id || get_url(object) <> "/activity" }, - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} end @@ -195,7 +195,8 @@ defmodule Mobilizon.Service.ActivityPub do "actor" => actor, "object" => object }, - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} end @@ -210,7 +211,8 @@ defmodule Mobilizon.Service.ActivityPub do # ) do # with nil <- get_existing_like(url, object), # like_data <- make_like_data(user, object, activity_id), - # {:ok, activity, object} <- insert(like_data, local), + # {:ok, activity} <- create_activity(like_data, local), + # {:ok, object} <- insert_full_object(data), # {:ok, object} <- add_like_to_object(activity, object), # :ok <- maybe_federate(activity) do # {:ok, activity, object} @@ -228,7 +230,8 @@ defmodule Mobilizon.Service.ActivityPub do # ) do # with %Activity{} = like_activity <- get_existing_like(actor.ap_id, object), # unlike_data <- make_unlike_data(actor, like_activity, activity_id), - # {:ok, unlike_activity, _object} <- insert(unlike_data, local), + # {:ok, unlike_activity} <- create_activity(unlike_data, local), + # {:ok, _object} <- insert_full_object(data), # {:ok, _activity} <- Repo.delete(like_activity), # {:ok, object} <- remove_like_from_object(like_activity, object), # :ok <- maybe_federate(unlike_activity) do @@ -247,7 +250,8 @@ defmodule Mobilizon.Service.ActivityPub do ) do with true <- is_public?(object), announce_data <- make_announce_data(actor, object, activity_id, public), - {:ok, activity, object} <- insert(announce_data, local), + {:ok, activity} <- create_activity(announce_data, local), + {:ok, object} <- insert_full_object(announce_data), :ok <- maybe_federate(activity) do {:ok, activity, object} else @@ -265,7 +269,8 @@ defmodule Mobilizon.Service.ActivityPub do ) do with announce_activity <- make_announce_data(actor, object, cancelled_activity_id), unannounce_data <- make_unannounce_data(actor, announce_activity, activity_id), - {:ok, unannounce_activity, _object} <- insert(unannounce_data, local), + {:ok, unannounce_activity} <- create_activity(unannounce_data, local), + {:ok, object} <- insert_full_object(unannounce_data), :ok <- maybe_federate(unannounce_activity) do {:ok, unannounce_activity, object} else @@ -282,7 +287,8 @@ defmodule Mobilizon.Service.ActivityPub do activity_follow_id <- activity_id || follow_url, data <- make_follow_data(followed, follower, activity_follow_id), - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} else @@ -304,12 +310,14 @@ defmodule Mobilizon.Service.ActivityPub do follower, "#{MobilizonWeb.Endpoint.url()}/follow/#{follow_id}/activity" ), - {:ok, follow_activity, _object} <- insert(data, local), + {:ok, follow_activity} <- create_activity(data, local), + {:ok, _object} <- insert_full_object(data), activity_unfollow_id <- activity_id || "#{MobilizonWeb.Endpoint.url()}/unfollow/#{follow_id}/activity", unfollow_data <- make_unfollow_data(follower, followed, follow_activity, activity_unfollow_id), - {:ok, activity, object} <- insert(unfollow_data, local), + {:ok, activity} <- create_activity(unfollow_data, local), + {:ok, object} <- insert_full_object(unfollow_data), :ok <- maybe_federate(activity) do {:ok, activity, object} else @@ -331,7 +339,8 @@ defmodule Mobilizon.Service.ActivityPub do } with {:ok, _} <- Events.delete_event(event), - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} end @@ -347,7 +356,8 @@ defmodule Mobilizon.Service.ActivityPub do } with {:ok, _} <- Events.delete_comment(comment), - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} end @@ -363,7 +373,8 @@ defmodule Mobilizon.Service.ActivityPub do } with {:ok, _} <- Actors.delete_actor(actor), - {:ok, activity, object} <- insert(data, local), + {:ok, activity} <- create_activity(data, local), + {:ok, object} <- insert_full_object(data), :ok <- maybe_federate(activity) do {:ok, activity, object} end @@ -384,9 +395,10 @@ defmodule Mobilizon.Service.ActivityPub do end with flag_data <- make_flag_data(params, additional), - {:ok, activity, report} <- insert(flag_data, local), + {:ok, activity} <- create_activity(flag_data, local), + {:ok, object} <- insert_full_object(flag_data), :ok <- maybe_federate(activity) do - {:ok, activity, report} + {:ok, activity, object} end end @@ -403,7 +415,8 @@ defmodule Mobilizon.Service.ActivityPub do join_data <- Convertible.model_to_as(participant), join_data <- Map.put(join_data, "to", [event.organizer_actor.url]), join_data <- Map.put(join_data, "cc", []), - {:ok, activity, _} <- insert(join_data, local), + {:ok, activity} <- create_activity(join_data, local), + {:ok, _object} <- insert_full_object(join_data), :ok <- maybe_federate(activity) do if role === :participant do accept( @@ -443,7 +456,8 @@ defmodule Mobilizon.Service.ActivityPub do "to" => [event.organizer_actor.url], "cc" => [] }, - {:ok, activity, _} <- insert(leave_data, local), + {:ok, activity} <- create_activity(leave_data, local), + {:ok, _object} <- insert_full_object(leave_data), :ok <- maybe_federate(activity) do {:ok, activity, participant} end From f5c3dbf128bb9b05b71a2de6ac3c97ae1c1ffb5d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 4 Sep 2019 18:24:31 +0200 Subject: [PATCH 3/3] Correctly handle event update Signed-off-by: Thomas Citharel --- .../components/Event/AddressAutoComplete.vue | 3 +- js/src/components/Event/TagInput.vue | 50 ++++++----- js/src/graphql/event.ts | 50 ++++++++++- js/src/types/event.model.ts | 12 +-- js/src/views/Event/Edit.vue | 13 +-- js/src/views/Event/Event.vue | 2 +- lib/mobilizon/actors/actor.ex | 18 ++++ lib/mobilizon/actors/actors.ex | 2 +- lib/mobilizon/events/event.ex | 36 +++++++- lib/mobilizon/events/events.ex | 10 ++- lib/mobilizon_web/api/events.ex | 60 ++++++-------- lib/mobilizon_web/api/groups.ex | 6 +- lib/mobilizon_web/resolvers/event.ex | 14 +++- lib/mobilizon_web/schema/event.ex | 6 +- lib/service/activity_pub/activity_pub.ex | 23 ++---- lib/service/activity_pub/converters/actor.ex | 22 ++++- lib/service/activity_pub/converters/event.ex | 4 +- lib/service/activity_pub/transmogrifier.ex | 32 ++++++-- lib/service/activity_pub/utils.ex | 55 +++++++++++-- schema.graphql | 46 ++++++++--- test/fixtures/mastodon-update.json | 26 +++--- test/mobilizon/actors/actors_test.exs | 4 - .../activity_pub/activity_pub_test.exs | 42 +++++++++- .../activity_pub/converters/actor_test.exs | 2 +- .../activity_pub/transmogrifier_test.exs | 30 ++++++- .../resolvers/event_resolver_test.exs | 82 +++++++++++++++++-- test/support/factory.ex | 4 +- 27 files changed, 493 insertions(+), 161 deletions(-) diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue index 5dc47ea5b..76197a2d0 100644 --- a/js/src/components/Event/AddressAutoComplete.vue +++ b/js/src/components/Event/AddressAutoComplete.vue @@ -81,11 +81,12 @@ import { Modal } from 'buefy/dist/components/dialog'; export default class AddressAutoComplete extends Vue { @Prop({ required: false, default: () => [] }) initialData!: IAddress[]; + @Prop({ required: false }) value!: IAddress; data: IAddress[] = this.initialData; selected: IAddress|null = new Address(); isFetching: boolean = false; - queryText: string = ''; + queryText: string = this.value && this.value.description || ''; addressModalActive: boolean = false; async getAsyncData(query) { diff --git a/js/src/components/Event/TagInput.vue b/js/src/components/Event/TagInput.vue index 0a5f556df..385f4d38f 100644 --- a/js/src/components/Event/TagInput.vue +++ b/js/src/components/Event/TagInput.vue @@ -1,33 +1,51 @@