From 530539c631fc05337b0f90553b52ffbdf6142fa5 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 26 Sep 2022 10:20:51 +0200 Subject: [PATCH 1/5] Make sure instance list is refreshed before notifying admin from new instance follow Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/types/actors.ex | 9 +++++++-- lib/graphql/resolvers/admin.ex | 7 ++++++- lib/mobilizon/instances/instances.ex | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/federation/activity_pub/types/actors.ex b/lib/federation/activity_pub/types/actors.ex index 48aa34fd..e612000c 100644 --- a/lib/federation/activity_pub/types/actors.ex +++ b/lib/federation/activity_pub/types/actors.ex @@ -1,6 +1,6 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Actors do @moduledoc false - alias Mobilizon.Actors + alias Mobilizon.{Actors, Instances} alias Mobilizon.Actors.{Actor, Follower, Member} alias Mobilizon.Federation.ActivityPub.{Actions, Audience, Permission, Relay} alias Mobilizon.Federation.ActivityPub.Types.Entity @@ -204,7 +204,12 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Actors do def follow(%Actor{} = follower_actor, %Actor{type: type} = followed, _local, additional) when type != :Person do case Mobilizon.Actors.follow(followed, follower_actor, additional["activity_id"], false) do - {:ok, %Follower{} = follower} -> + {:ok, %Follower{actor: %Actor{type: actor_type}} = follower} -> + # We refresh the instance materialized view to make sure the instance page will be available + # when the admin clicks on the email link and access it + if actor_type == :Application do + Instances.refresh() + end FollowMailer.send_notification_to_admins(follower) follower_as_data = Convertible.model_to_as(follower) approve_if_manually_approves_followers(follower, follower_as_data) diff --git a/lib/graphql/resolvers/admin.ex b/lib/graphql/resolvers/admin.ex index 0bbe46c8..8246675c 100644 --- a/lib/graphql/resolvers/admin.ex +++ b/lib/graphql/resolvers/admin.ex @@ -464,6 +464,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do {:error, :unauthenticated} end + @spec get_instance(any, map(), Absinthe.Resolution.t()) :: + {:error, :unauthenticated | :unauthorized | :not_found} | {:ok, Mobilizon.Instances.Instance.t()} def get_instance(_parent, %{domain: domain}, %{ context: %{current_user: %User{role: role}} }) @@ -482,7 +484,10 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do followed_status: follow_status(local_relay, remote_relay) } - {:ok, Map.merge(Instances.instance(domain), result)} + case Instances.instance(domain) do + nil -> {:error, :not_found} + instance -> {:ok, Map.merge(instance, result)} + end end def get_instance(_parent, _args, %{context: %{current_user: %User{}}}) do diff --git a/lib/mobilizon/instances/instances.ex b/lib/mobilizon/instances/instances.ex index 470e06c1..94a293e7 100644 --- a/lib/mobilizon/instances/instances.ex +++ b/lib/mobilizon/instances/instances.ex @@ -67,7 +67,7 @@ defmodule Mobilizon.Instances do } end - @spec instance(String.t()) :: Instance.t() + @spec instance(String.t()) :: Instance.t() | nil def instance(domain) do Instance |> where(domain: ^domain) From a37bab3b844244cb22ed9e6b90bbfe880a72c521 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 26 Sep 2022 10:29:37 +0200 Subject: [PATCH 2/5] Fix some Dializer issue Signed-off-by: Thomas Citharel --- lib/graphql/resolvers/admin.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/graphql/resolvers/admin.ex b/lib/graphql/resolvers/admin.ex index 8246675c..e89fc132 100644 --- a/lib/graphql/resolvers/admin.ex +++ b/lib/graphql/resolvers/admin.ex @@ -62,7 +62,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do Map.merge(map, %{actor: actor, id: id, inserted_at: inserted_at}) end - @spec transform_action_log(module(), atom(), ActionLog.t()) :: map() + @spec transform_action_log(module(), atom(), ActionLog.t()) :: map() | nil defp transform_action_log( Report, :update, @@ -132,6 +132,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do } end + defp transform_action_log(_, _, _), do: nil + # Changes are stored as %{"key" => "value"} so we need to convert them back as struct @spec convert_changes_to_struct(module(), map()) :: struct() defp convert_changes_to_struct(struct, %{"report_id" => _report_id} = changes) do From 6f7d5f649b9f904ca72f0be8269474fddf796411 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 26 Sep 2022 10:29:20 +0200 Subject: [PATCH 3/5] Add participant info in event search results Signed-off-by: Thomas Citharel --- js/src/components/Event/EventCard.vue | 31 ++++++++--- js/src/components/TagElement.vue | 2 +- js/src/graphql/search.ts | 10 ++++ js/src/views/SearchView.vue | 53 ++++++++++++++++--- lib/graphql/resolvers/event.ex | 2 +- lib/graphql/schema/search.ex | 27 ++++++++++ lib/mobilizon/events/events.ex | 20 ++++--- lib/service/global_search/event_result.ex | 2 +- lib/service/global_search/search_mobilizon.ex | 27 ++++++++-- 9 files changed, 145 insertions(+), 29 deletions(-) diff --git a/js/src/components/Event/EventCard.vue b/js/src/components/Event/EventCard.vue index bcf92c9b..8b14a2a8 100644 --- a/js/src/components/Event/EventCard.vue +++ b/js/src/components/Event/EventCard.vue @@ -26,13 +26,13 @@ variant="info" v-if="event.status === EventStatus.TENTATIVE" > - {{ $t("Tentative") }} + {{ t("Tentative") }} - {{ $t("Cancelled") }} + {{ t("Cancelled") }}