From 4d5ec883b7e7f54d92574a4cf0bdda781e7423e2 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 8 May 2018 21:52:21 -0400 Subject: [PATCH] Federate correct activity --- lib/pleroma/web/activity_pub/activity_pub.ex | 12 ++++++------ lib/pleroma/web/ostatus/activity_representer.ex | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 5f11b8410..334cfcc5b 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -151,13 +151,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do local \\ true, activity_id \\ nil ) do - with %Activity{} = activity <- get_existing_announce(actor.ap_id, object), - unannounce_data <- make_unannounce_data(actor, activity, activity_id), + with %Activity{} = announce_activity <- get_existing_announce(actor.ap_id, object), + unannounce_data <- make_unannounce_data(actor, announce_activity, activity_id), {:ok, unannounce_activity} <- insert(unannounce_data, local), - :ok <- maybe_federate(activity), - {:ok, _activity} <- Repo.delete(activity), - {:ok, object} <- remove_announce_from_object(activity, object) do - {:ok, unannounce_activity, activity, object} + :ok <- maybe_federate(unannounce_activity), + {:ok, _activity} <- Repo.delete(announce_activity), + {:ok, object} <- remove_announce_from_object(announce_activity, object) do + {:ok, unannounce_activity, announce_activity, object} else _e -> {:ok, object} end diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index 921a89bd0..1e9d4a7fb 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -240,7 +240,13 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do inserted_at = activity.data["published"] author = if with_author, do: [{:author, UserRepresenter.to_simple_form(user)}], else: [] - follow_activity = Activity.get_by_ap_id(activity.data["object"]) + + follow_activity = + if is_map(activity.data["object"]) do + Activity.get_by_ap_id(activity.data["object"]["id"]) + else + Activity.get_by_ap_id(activity.data["object"]) + end mentions = (activity.recipients || []) |> get_mentions