forked from AkkomaGang/akkoma
Hook up block/unblock to TwitterAPI
This commit is contained in:
parent
55f9aefd08
commit
72b93d13f8
3 changed files with 7 additions and 5 deletions
|
@ -45,7 +45,8 @@ def unfollow(%User{} = follower, params) 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 @@ def block(%User{} = blocker, params) 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
|
||||
|
|
|
@ -443,7 +443,7 @@ test "without valid credentials", %{conn: conn} 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 =
|
||||
|
|
|
@ -166,7 +166,7 @@ test "Block another user using screen_name" 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 @@ test "Unblock another user using user_id" 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"] == []
|
||||
|
|
Loading…
Reference in a new issue