Fix unblock handling
authorFrancis Dinh <normandy@firemail.cc>
Mon, 21 May 2018 09:00:58 +0000 (05:00 -0400)
committerFrancis Dinh <normandy@firemail.cc>
Mon, 21 May 2018 09:00:58 +0000 (05:00 -0400)
lib/pleroma/web/activity_pub/transmogrifier.ex
test/fixtures/mastodon-unblock-activity.json
test/web/activity_pub/transmogrifier_test.exs

index 24e876efb39d09c7e79ea1ba8d92bd060d71c4d4..b941fdf162f925fe43da3fd15a4708f362914bf2 100644 (file)
@@ -270,6 +270,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     with %User{local: true} = blocked <- User.get_cached_by_ap_id(blocked),
          %User{} = blocker <- User.get_or_fetch_by_ap_id(blocker),
          {:ok, activity} <- ActivityPub.unblock(blocker, blocked, id, false) do
+      User.unblock(blocker, blocked)
       {:ok, activity}
     else
       e -> :error
index 53b2f42a8bb1ce2361d39c670d031f58d6e71dac..f4a2d30dd100882d688d569acf41d1ca690c9a72 100644 (file)
@@ -26,8 +26,9 @@
       "type": "Block", 
       "object": "http://localtesting.pleroma.lol/users/lain",
       "nickname": "lain",
-      "id": "http://mastodon.example.org/users/admin#follows/2",
+      "id": "http://mastodon.example.org/users/admin#blocks/2",
       "actor": "http://mastodon.example.org/users/admin" 
     },
-    "actor": "http://mastodon.example.org/users/admin"
+    "actor": "http://mastodon.example.org/users/admin",
+    "id": "http://mastodon.example.org/users/admin#blocks/2/undo"
 }
index da55909bc897c590c972a043cdebffaac8427709..cf6b1d0b59b642ecf64187c0ce9cedd8b56281a3 100644 (file)
@@ -316,7 +316,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
                "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity"
     end
 
-    test "it works for incomming unfollows" do
+    test "it works for incomming unfollows with an existing follow" do
       user = insert(:user)
 
       follow_data =
@@ -360,7 +360,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert User.blocks?(blocker, user)
     end
 
-    test "it works for incoming unblocks" do
+    test "it works for incoming unblocks with an existing block" do
       user = insert(:user)
 
       block_data =
@@ -379,11 +379,11 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert data["type"] == "Undo"
       assert data["object"]["type"] == "Block"
       assert data["object"]["object"] == user.ap_id
-      assert data["actor"] == "https://mastodon.example.org/users/admin"
+      assert data["actor"] == "http://mastodon.example.org/users/admin"
 
       blocker = User.get_by_ap_id(data["actor"])
 
-      refute User.blocks?(blocker, user.ap_id)
+      refute User.blocks?(blocker, user)
     end
   end