From 8185fcd0bde21f0e8cdfd45e2bcbe80b7e2daa11 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 26 Apr 2021 10:13:29 +0200 Subject: [PATCH] Refresh after invite accept only if remote group Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/activity_pub.ex | 14 ++++++++++---- lib/graphql/resolvers/member.ex | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/federation/activity_pub/activity_pub.ex b/lib/federation/activity_pub/activity_pub.ex index 67be0962..a46a02cb 100644 --- a/lib/federation/activity_pub/activity_pub.ex +++ b/lib/federation/activity_pub/activity_pub.ex @@ -824,10 +824,7 @@ defmodule Mobilizon.Federation.ActivityPub do Mobilizon.Service.Activity.Member.insert_activity(member, subject: "member_approved" ), - _ <- - unless(is_nil(member.parent.domain), - do: Refresher.fetch_group(member.parent.url, member.actor) - ), + _ <- maybe_refresh_group(member), Absinthe.Subscription.publish(Endpoint, member.actor, group_membership_changed: [ Actor.preferred_username_and_domain(member.parent), @@ -866,6 +863,7 @@ defmodule Mobilizon.Federation.ActivityPub do Mobilizon.Service.Activity.Member.insert_activity(member, subject: "member_accepted_invitation" ), + _ <- maybe_refresh_group(member), accept_data <- %{ "type" => "Accept", "attributedTo" => member.parent.url, @@ -879,6 +877,14 @@ defmodule Mobilizon.Federation.ActivityPub do end end + defp maybe_refresh_group(%Member{ + parent: %Actor{domain: parent_domain, url: parent_url}, + actor: %Actor{} = actor + }) do + unless is_nil(parent_domain), + do: Refresher.fetch_group(parent_url, actor) + end + @spec reject_join(Participant.t(), map()) :: {:ok, Participant.t(), Activity.t()} | any() defp reject_join(%Participant{} = participant, additional) do with {:ok, %Participant{} = participant} <- diff --git a/lib/graphql/resolvers/member.ex b/lib/graphql/resolvers/member.ex index 8af57bba..7db30908 100644 --- a/lib/graphql/resolvers/member.ex +++ b/lib/graphql/resolvers/member.ex @@ -109,8 +109,6 @@ defmodule Mobilizon.GraphQL.Resolvers.Member do member, true ) do - # Launch an async task to refresh the group profile, fetch resources, discussions, members - Refresher.fetch_group(member.parent.url, actor) {:ok, member} else {:is_same_actor, false} ->