X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Factivity_pub.ex;h=03e72be58443f9f7e3822cc23a1d84499ac7d7d4;hb=5796d81d9877de51b2669da7d8f6fcc903c0ebda;hp=8ab87bfee8742e9030573af86fc2bd1277dcd23a;hpb=9df732c42b5469ddfcf2990c8cc3433865df5871;p=akkoma diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 8ab87bfee..03e72be58 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -327,7 +327,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end end - defp do_unfollow(follower, followed, activity_id, local) do + defp do_unfollow(follower, followed, activity_id, local) + + defp do_unfollow(follower, followed, activity_id, local) when local == true do with %Activity{} = follow_activity <- fetch_latest_follow(follower, followed), {:ok, follow_activity} <- update_follow_state(follow_activity, "cancelled"), unfollow_data <- make_unfollow_data(follower, followed, follow_activity, activity_id), @@ -341,6 +343,32 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end end + defp do_unfollow(follower, followed, activity_id, false) do + # On a remote unfollow, _remove_ their activity from the database, since some software (MISSKEEEEY) + # uses deterministic ids for follows. + with %Activity{} = follow_activity <- fetch_latest_follow(follower, followed), + {:ok, _activity} <- Repo.delete(follow_activity), + unfollow_data <- make_unfollow_data(follower, followed, follow_activity, activity_id), + unfollow_activity <- remote_unfollow_data(unfollow_data), + _ <- notify_and_stream(unfollow_activity) do + {:ok, unfollow_activity} + else + nil -> nil + {:error, error} -> Repo.rollback(error) + end + end + + defp remote_unfollow_data(data) do + {recipients, _, _} = get_recipients(data) + + %Activity{ + data: data, + local: false, + actor: data["actor"], + recipients: recipients + } + end + @spec flag(map()) :: {:ok, Activity.t()} | {:error, any()} def flag(params) do with {:ok, result} <- Repo.transaction(fn -> do_flag(params) end) do