Use correct activity for undo
authorFrancis Dinh <normandy@firemail.cc>
Sat, 21 Apr 2018 03:22:16 +0000 (23:22 -0400)
committerFrancis Dinh <normandy@firemail.cc>
Sat, 21 Apr 2018 03:22:16 +0000 (23:22 -0400)
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/utils.ex
test/web/activity_pub/activity_pub_test.exs

index 215ddc57a6ed17835e0f952f9828dd1ab150841a..ace230804fb6a0e16071be2a36a34d1851a69752 100644 (file)
@@ -142,7 +142,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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, object),
+         unannounce_data <- make_unannounce_data(actor, activity),
          {:ok, unannounce_activity} <- insert(unannounce_data, local),
          :ok <- maybe_federate(activity),
          {:ok, _activity} <- Repo.delete(activity),
index 1f740eda551ee4f518c0fddb068c5e625463be33..9e2fa1fb22967875b0e8050b11e8f15854122462 100644 (file)
@@ -283,13 +283,13 @@ defmodule Pleroma.Web.ActivityPub.Utils do
   """
   def make_unannounce_data(
         %User{ap_id: ap_id} = user,
-        %Object{data: %{"id" => id, "context" => context}} = 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" => context
     }
index 6a07da775242c545488b58134233da9456e9c48b..e3258ed4edecd5a9f2379598393333dde10641ce 100644 (file)
@@ -291,12 +291,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
 
       assert unannounce_activity.data["to"] == [
                User.ap_followers(user),
-               note_activity.data["actor"]
+               announce_activity.data["actor"]
       ]
       assert unannounce_activity.data["type"] == "Undo"
-      assert unannounce_activity.data["object"] == object.data["id"]
+      assert unannounce_activity.data["object"] == announce_activity.data["id"]
       assert unannounce_activity.data["actor"] == user.ap_id
-      assert unannounce_activity.data["context"] == object.data["context"]
+      assert unannounce_activity.data["context"] == announce_activity.data["context"]
 
       assert Repo.get(Activity, announce_activity.id) == nil
     end