Hook up block/unblock to TwitterAPI
authorFrancis Dinh <normandy@firemail.cc>
Tue, 22 May 2018 09:41:17 +0000 (05:41 -0400)
committerFrancis Dinh <normandy@firemail.cc>
Tue, 22 May 2018 09:41:17 +0000 (05:41 -0400)
lib/pleroma/web/twitter_api/twitter_api.ex
test/web/twitter_api/twitter_api_controller_test.exs
test/web/twitter_api/twitter_api_test.exs

index 5eeebe1615330c21374690351300a552c1553396..3ccdaed6ff38e7f462e6ce03970b401e781497c0 100644 (file)
@@ -45,7 +45,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
   def block(%User{} = blocker, params) do
     with {:ok, %User{} = blocked} <- get_user(params),
-         {:ok, blocker} <- User.block(blocker, blocked) do
+         {:ok, blocker} <- User.block(blocker, blocked),
+         {:ok, _activity} <- ActivityPub.block(blocker, blocked) do
       {:ok, blocker, blocked}
     else
       err -> err
@@ -54,7 +55,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
   def unblock(%User{} = blocker, params) do
     with {:ok, %User{} = blocked} <- get_user(params),
-         {:ok, blocker} <- User.unblock(blocker, blocked) do
+         {:ok, blocker} <- User.unblock(blocker, blocked),
+         {:ok, _activity} <- ActivityPub.unblock(blocker, blocked) do
       {:ok, blocker, blocked}
     else
       err -> err
index 02aba0bc8859ba105ce73d919275667f6b69955a..625303b84f18d33842a8e70bccec7d8684b765f9 100644 (file)
@@ -443,7 +443,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
     test "with credentials", %{conn: conn, user: current_user} do
       blocked = insert(:user)
 
-      {:ok, current_user} = User.block(current_user, blocked)
+      {:ok, current_user, blocked} = TwitterAPI.block(current_user, %{"user_id" => blocked.id})
       assert User.blocks?(current_user, blocked)
 
       conn =
index af565c0e558340dee22b0adc46a1da321c9bb65d..4716abb84e38824bab8d0d97f3f0ad6b655010c1 100644 (file)
@@ -166,7 +166,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
   test "Unblock another user using user_id" do
     unblocked = insert(:user)
     user = insert(:user)
-    User.block(user, unblocked)
+    {:ok, user, _unblocked} = TwitterAPI.block(user, %{"user_id" => unblocked.id})
 
     {:ok, user, _unblocked} = TwitterAPI.unblock(user, %{"user_id" => unblocked.id})
     assert user.info["blocks"] == []
@@ -175,7 +175,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
   test "Unblock another user using screen_name" do
     unblocked = insert(:user)
     user = insert(:user)
-    User.block(user, unblocked)
+    {:ok, user, _unblocked} = TwitterAPI.block(user, %{"screen_name" => unblocked.nickname})
 
     {:ok, user, _unblocked} = TwitterAPI.unblock(user, %{"screen_name" => unblocked.nickname})
     assert user.info["blocks"] == []