diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex index cfb36bc1c..751260a46 100644 --- 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 index f75efd00d..ab5a104dd 100644 --- 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 index 8ad287a7f..a7ab5883a 100644 --- 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 index 433278d39..0ad296e42 100644 --- 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