commit: d27ad36ce4b2f00d89ca96bd4d7c6f688ec67262
parent f602813d314533a50ab7cadf64f1f0fbbb863cc6
Author: Mark Felder <feld@feld.me>
Date: Mon, 22 Jul 2024 17:59:33 -0400
Fix order of args for remove_mute/2
Diffstat:
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex
@@ -572,16 +572,17 @@ defmodule Pleroma.Web.CommonAPI do
end
end
- @spec remove_mute(User.t(), Activity.t()) :: {:ok, Activity.t()} | {:error, any()}
- def remove_mute(%User{} = user, %Activity{} = activity) do
+ @spec remove_mute(Activity.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()}
+ def remove_mute(%Activity{} = activity, %User{} = user) do
ThreadMute.remove_mute(user.id, activity.data["context"])
{:ok, activity}
end
- def remove_mute(user_id, activity_id) do
+ @spec remove_mute(String.t(), String.t()) :: {:ok, Activity.t()} | {:error, any()}
+ def remove_mute(activity_id, user_id) do
with {:user, %User{} = user} <- {:user, User.get_by_id(user_id)},
{:activity, %Activity{} = activity} <- {:activity, Activity.get_by_id(activity_id)} do
- remove_mute(user, activity)
+ remove_mute(activity, user)
else
{what, result} = error ->
Logger.warning(
diff --git a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex
@@ -467,7 +467,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
_
) do
with %Activity{} = activity <- Activity.get_by_id(id),
- {:ok, activity} <- CommonAPI.remove_mute(user, activity) do
+ {:ok, activity} <- CommonAPI.remove_mute(activity, user) do
try_render(conn, "show.json", activity: activity, for: user, as: :activity)
end
end
diff --git a/lib/pleroma/workers/mute_expire_worker.ex b/lib/pleroma/workers/mute_expire_worker.ex
@@ -14,7 +14,7 @@ defmodule Pleroma.Workers.MuteExpireWorker do
def perform(%Job{
args: %{"op" => "unmute_conversation", "user_id" => user_id, "activity_id" => activity_id}
}) do
- Pleroma.Web.CommonAPI.remove_mute(user_id, activity_id)
+ Pleroma.Web.CommonAPI.remove_mute(activity_id, user_id)
:ok
end
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs
@@ -1219,13 +1219,13 @@ defmodule Pleroma.Web.CommonAPITest do
test "remove mute", %{user: user, activity: activity} do
CommonAPI.add_mute(user, activity)
- {:ok, _} = CommonAPI.remove_mute(user, activity)
+ {: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)
- {:ok, _} = CommonAPI.remove_mute(user.id, activity.id)
+ {:ok, _} = CommonAPI.remove_mute(activity.id, user.id)
refute CommonAPI.thread_muted?(user, activity)
end