Add federation for unrepeats
authorFrancis Dinh <normandy@firemail.cc>
Wed, 18 Apr 2018 00:35:07 +0000 (20:35 -0400)
committerFrancis Dinh <normandy@firemail.cc>
Wed, 18 Apr 2018 00:35:07 +0000 (20:35 -0400)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/utils.ex

index b3154ea99b5ad65edc57e710b09fcd9963883019..2239da472a3fc27d79fe665fb84f88789e95259b 100644 (file)
@@ -140,8 +140,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     end
   end
 
-  def unannounce(%User{} = actor, %Object{} = object) do
+  def unannounce(%User{} = actor, %Object{} = object, local \\ true) do
     with %Activity{} = activity <- get_existing_announce(actor.ap_id, object),
+         unannounce_data <- make_unannounce_data(actor, activity),
+         {:ok, _unannounce_activity} <- insert(unannounce_data, local),
          {:ok, _activity} <- Repo.delete(activity),
          {:ok, object} <- remove_announce_from_object(activity, object) do
       {:ok, object}
index a124bb8b6a07edc811ea389c45e9ad92c28e0b20..9e2fa1fb22967875b0e8050b11e8f15854122462 100644 (file)
@@ -283,15 +283,15 @@ defmodule Pleroma.Web.ActivityPub.Utils do
   """
   def make_unannounce_data(
         %User{ap_id: ap_id} = user,
-        %Object{data: %{"id" => id}} = object
+        %Activity{data: %{"id" => id, "context" => context}} = activity
       ) do
     %{
       "type" => "Undo",
       "actor" => ap_id,
       "object" => id,
-      "to" => [user.follower_address, object.data["actor"]],
+      "to" => [user.follower_address, activity.data["actor"]],
       "cc" => ["https://www.w3.org/ns/activitystreams#Public"],
-      "context" => object.data["context"]
+      "context" => context
     }
   end