Merge branch 'refresh-in-ap' into 'master'

Refresh after invite accept only if remote group

See merge request framasoft/mobilizon!909
This commit is contained in:
Thomas Citharel 2021-04-26 09:11:29 +00:00
commit 4486a85565
2 changed files with 10 additions and 6 deletions

View File

@ -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} <-

View File

@ -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} ->