Fix order of args for add_mute/2

This commit is contained in:
Mark Felder 2024-07-22 18:18:30 -04:00
parent d27ad36ce4
commit 4601473aaf
8 changed files with 18 additions and 18 deletions

View File

@ -552,8 +552,8 @@ defmodule Pleroma.Web.CommonAPI do
end
end
@spec add_mute(User.t(), Activity.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
def add_mute(user, activity, params \\ %{}) do
@spec add_mute(Activity.t(), User.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
def add_mute(activity, user, params \\ %{}) do
expires_in = Map.get(params, :expires_in, 0)
with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]),

View File

@ -453,7 +453,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
_
) do
with %Activity{} = activity <- Activity.get_by_id(id),
{:ok, activity} <- CommonAPI.add_mute(user, activity, params) do
{:ok, activity} <- CommonAPI.add_mute(activity, user, params) do
try_render(conn, "show.json", activity: activity, for: user, as: :activity)
end
end

View File

@ -693,7 +693,7 @@ defmodule Pleroma.NotificationTest do
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
{:ok, _} = CommonAPI.add_mute(other_user, activity)
{:ok, _} = CommonAPI.add_mute(activity, other_user)
{:ok, same_context_activity} =
CommonAPI.post(user, %{

View File

@ -1171,7 +1171,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
note_two = insert(:note, data: %{"context" => "suya.."})
activity_two = insert(:note_activity, note: note_two)
{:ok, _activity_two} = CommonAPI.add_mute(user, activity_two)
{:ok, _activity_two} = CommonAPI.add_mute(activity_two, user)
assert [_activity_one] = ActivityPub.fetch_activities([], %{muting_user: user})
end
@ -1182,7 +1182,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
note_two = insert(:note, data: %{"context" => "suya.."})
activity_two = insert(:note_activity, note: note_two)
{:ok, _activity_two} = CommonAPI.add_mute(user, activity_two)
{:ok, _activity_two} = CommonAPI.add_mute(activity_two, user)
assert [_activity_two, _activity_one] =
ActivityPub.fetch_activities([], %{muting_user: user, with_muted: true})

View File

@ -1172,7 +1172,7 @@ defmodule Pleroma.Web.CommonAPITest do
n.type == "mention" && n.activity_id == reply_activity.id
end)
{:ok, _} = CommonAPI.add_mute(author, activity)
{:ok, _} = CommonAPI.add_mute(activity, author)
assert CommonAPI.thread_muted?(author, activity)
assert Repo.aggregate(
@ -1197,12 +1197,12 @@ defmodule Pleroma.Web.CommonAPITest do
end
test "add mute", %{user: user, activity: activity} do
{:ok, _} = CommonAPI.add_mute(user, activity)
{:ok, _} = CommonAPI.add_mute(activity, user)
assert CommonAPI.thread_muted?(user, activity)
end
test "add expiring mute", %{user: user, activity: activity} do
{:ok, _} = CommonAPI.add_mute(user, activity, %{expires_in: 60})
{:ok, _} = CommonAPI.add_mute(activity, user, %{expires_in: 60})
assert CommonAPI.thread_muted?(user, activity)
worker = Pleroma.Workers.MuteExpireWorker
@ -1218,20 +1218,20 @@ defmodule Pleroma.Web.CommonAPITest do
end
test "remove mute", %{user: user, activity: activity} do
CommonAPI.add_mute(user, activity)
CommonAPI.add_mute(activity, user)
{:ok, _} = CommonAPI.remove_mute(activity, user)
refute CommonAPI.thread_muted?(user, activity)
end
test "remove mute by ids", %{user: user, activity: activity} do
CommonAPI.add_mute(user, activity)
CommonAPI.add_mute(activity, user)
{:ok, _} = CommonAPI.remove_mute(activity.id, user.id)
refute CommonAPI.thread_muted?(user, activity)
end
test "check that mutes can't be duplicate", %{user: user, activity: activity} do
CommonAPI.add_mute(user, activity)
{:error, _} = CommonAPI.add_mute(user, activity)
CommonAPI.add_mute(activity, user)
{:error, _} = CommonAPI.add_mute(activity, user)
end
end

View File

@ -1771,7 +1771,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
end
test "cannot mute already muted conversation", %{conn: conn, user: user, activity: activity} do
{:ok, _} = CommonAPI.add_mute(user, activity)
{:ok, _} = CommonAPI.add_mute(activity, user)
conn =
conn
@ -1784,7 +1784,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
end
test "unmute conversation", %{conn: conn, user: user, activity: activity} do
{:ok, _} = CommonAPI.add_mute(user, activity)
{:ok, _} = CommonAPI.add_mute(activity, user)
id_str = to_string(activity.id)

View File

@ -388,7 +388,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
assert status.pleroma.thread_muted == false
{:ok, activity} = CommonAPI.add_mute(user, activity)
{:ok, activity} = CommonAPI.add_mute(activity, user)
status = StatusView.render("show.json", %{activity: activity, for: user})

View File

@ -430,7 +430,7 @@ defmodule Pleroma.Web.StreamerTest do
user2 = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
{:ok, _} = CommonAPI.add_mute(user, activity)
{:ok, _} = CommonAPI.add_mute(activity, user)
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
@ -878,7 +878,7 @@ defmodule Pleroma.Web.StreamerTest do
{:ok, user2, user, _activity} = CommonAPI.follow(user2, user)
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
{:ok, _} = CommonAPI.add_mute(user2, activity)
{:ok, _} = CommonAPI.add_mute(activity, user2)
assert_receive {:render_with_user, _, _, ^activity, _}
assert Streamer.filtered_by_user?(user2, activity)