Fix order of args for block/2

This commit is contained in:
Mark Felder 2024-07-22 18:39:20 -04:00
parent 1cccc0fc21
commit cbc5e48417
8 changed files with 13 additions and 13 deletions

View file

@ -31,7 +31,7 @@ defmodule Pleroma.User.Import do
identifiers, identifiers,
fn identifier -> fn identifier ->
with {:ok, %User{} = blocked} <- User.get_or_fetch(identifier), with {:ok, %User{} = blocked} <- User.get_or_fetch(identifier),
{:ok, _block} <- CommonAPI.block(blocker, blocked) do {:ok, _block} <- CommonAPI.block(blocked, blocker) do
blocked blocked
else else
error -> handle_error(:blocks_import, identifier, error) error -> handle_error(:blocks_import, identifier, error)

View file

@ -27,7 +27,7 @@ defmodule Pleroma.Web.CommonAPI do
require Logger require Logger
@spec block(User.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()} @spec block(User.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()}
def block(blocker, blocked) do def block(blocked, blocker) do
with {:ok, block_data, _} <- Builder.block(blocker, blocked), with {:ok, block_data, _} <- Builder.block(blocker, blocked),
{:ok, block, _} <- Pipeline.common_pipeline(block_data, local: true) do {:ok, block, _} <- Pipeline.common_pipeline(block_data, local: true) do
{:ok, block} {:ok, block}

View file

@ -495,7 +495,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
@doc "POST /api/v1/accounts/:id/block" @doc "POST /api/v1/accounts/:id/block"
def block(%{assigns: %{user: blocker, account: blocked}} = conn, _params) do def block(%{assigns: %{user: blocker, account: blocked}} = conn, _params) do
with {:ok, _activity} <- CommonAPI.block(blocker, blocked) do with {:ok, _activity} <- CommonAPI.block(blocked, blocker) do
render(conn, "relationship.json", user: blocker, target: blocked) render(conn, "relationship.json", user: blocker, target: blocked)
else else
{:error, message} -> json_response(conn, :forbidden, %{error: message}) {:error, message} -> json_response(conn, :forbidden, %{error: message})

View file

@ -519,7 +519,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
{:ok, like} = CommonAPI.favorite(post.id, user) {:ok, like} = CommonAPI.favorite(post.id, user)
{:ok, reaction} = CommonAPI.react_with_emoji(post.id, user, "👍") {:ok, reaction} = CommonAPI.react_with_emoji(post.id, user, "👍")
{:ok, announce} = CommonAPI.repeat(post.id, user) {:ok, announce} = CommonAPI.repeat(post.id, user)
{:ok, block} = CommonAPI.block(user, poster) {:ok, block} = CommonAPI.block(poster, user)
{:ok, undo_data, _meta} = Builder.undo(user, like) {:ok, undo_data, _meta} = Builder.undo(user, like)
{:ok, like_undo, _meta} = ActivityPub.persist(undo_data, local: true) {:ok, like_undo, _meta} = ActivityPub.persist(undo_data, local: true)
@ -965,7 +965,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
group: group, group: group,
poster: poster poster: poster
} do } do
{:ok, _} = CommonAPI.block(group, poster) {:ok, _} = CommonAPI.block(poster, group)
create_activity_data = make_create.([group]) create_activity_data = make_create.([group])
{:ok, create_activity, _meta} = ActivityPub.persist(create_activity_data, local: false) {:ok, create_activity, _meta} = ActivityPub.persist(create_activity_data, local: false)

View file

@ -382,9 +382,9 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
user1 = insert(:user) user1 = insert(:user)
user2 = insert(:user) user2 = insert(:user)
assert {:ok, %Activity{} = _} = CommonAPI.block(user1, user2) assert {:ok, %Activity{} = _} = CommonAPI.block(user2, user1)
assert {:ok, %Activity{} = _} = CommonAPI.block(user1, user2) assert {:ok, %Activity{} = _} = CommonAPI.block(user2, user1)
assert {:ok, %Activity{} = activity} = CommonAPI.block(user1, user2) assert {:ok, %Activity{} = activity} = CommonAPI.block(user2, user1)
assert Utils.fetch_latest_block(user1, user2) == activity assert Utils.fetch_latest_block(user1, user2) == activity
end end

View file

@ -95,7 +95,7 @@ defmodule Pleroma.Web.CommonAPITest do
assert User.get_follow_state(blocker, blocked) == :follow_accept assert User.get_follow_state(blocker, blocked) == :follow_accept
refute is_nil(Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(blocker, blocked)) refute is_nil(Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(blocker, blocked))
assert {:ok, block} = CommonAPI.block(blocker, blocked) assert {:ok, block} = CommonAPI.block(blocked, blocker)
assert block.local assert block.local
assert User.blocks?(blocker, blocked) assert User.blocks?(blocker, blocked)
@ -120,7 +120,7 @@ defmodule Pleroma.Web.CommonAPITest do
with_mock Pleroma.Web.Federator, with_mock Pleroma.Web.Federator,
publish: fn _ -> nil end do publish: fn _ -> nil end do
assert {:ok, block} = CommonAPI.block(blocker, blocked) assert {:ok, block} = CommonAPI.block(blocked, blocker)
assert block.local assert block.local
assert User.blocks?(blocker, blocked) assert User.blocks?(blocker, blocked)
@ -1914,7 +1914,7 @@ defmodule Pleroma.Web.CommonAPITest do
end end
test "it does not boost if group is blocking poster", %{poster: poster, group: group} do test "it does not boost if group is blocking poster", %{poster: poster, group: group} do
{:ok, _} = CommonAPI.block(group, poster) {:ok, _} = CommonAPI.block(poster, group)
{:ok, post} = CommonAPI.post(poster, %{status: "hey @#{group.nickname}"}) {:ok, post} = CommonAPI.post(poster, %{status: "hey @#{group.nickname}"})
announces = get_announces_of_object(post.object) announces = get_announces_of_object(post.object)

View file

@ -148,7 +148,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
%{user: user, conn: conn} = oauth_access(["read:notifications"]) %{user: user, conn: conn} = oauth_access(["read:notifications"])
blocker = insert(:user) blocker = insert(:user)
{:ok, _} = CommonAPI.block(blocker, user) {:ok, _} = CommonAPI.block(user, blocker)
{:ok, activity} = CommonAPI.post(blocker, %{status: "hi @#{user.nickname}"}) {:ok, activity} = CommonAPI.post(blocker, %{status: "hi @#{user.nickname}"})
{:ok, [_notification]} = Notification.create_notifications(activity) {:ok, [_notification]} = Notification.create_notifications(activity)

View file

@ -47,7 +47,7 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
test "returns v2 suggestions excluding blocked accounts", %{conn: conn, user: blocker} do test "returns v2 suggestions excluding blocked accounts", %{conn: conn, user: blocker} do
blocked = insert(:user, is_suggested: true) blocked = insert(:user, is_suggested: true)
{:ok, _} = CommonAPI.block(blocker, blocked) {:ok, _} = CommonAPI.block(blocked, blocker)
res = res =
conn conn