logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 4601473aaf65cfc5696e17069014a92750f1560d
parent d27ad36ce4b2f00d89ca96bd4d7c6f688ec67262
Author: Mark Felder <feld@feld.me>
Date:   Mon, 22 Jul 2024 18:18:30 -0400

Fix order of args for add_mute/2

Diffstat:

Mlib/pleroma/web/common_api.ex4++--
Mlib/pleroma/web/mastodon_api/controllers/status_controller.ex2+-
Mtest/pleroma/notification_test.exs2+-
Mtest/pleroma/web/activity_pub/activity_pub_test.exs4++--
Mtest/pleroma/web/common_api_test.exs14+++++++-------
Mtest/pleroma/web/mastodon_api/controllers/status_controller_test.exs4++--
Mtest/pleroma/web/mastodon_api/views/status_view_test.exs2+-
Mtest/pleroma/web/streamer_test.exs4++--
8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex @@ -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"]), diff --git a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex @@ -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 diff --git a/test/pleroma/notification_test.exs b/test/pleroma/notification_test.exs @@ -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, %{ diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -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}) diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs @@ -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 diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -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) diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -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}) diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs @@ -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)