Fix order of args for remove_mute/2
This commit is contained in:
parent
f602813d31
commit
d27ad36ce4
@ -572,16 +572,17 @@ defmodule Pleroma.Web.CommonAPI do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec remove_mute(User.t(), Activity.t()) :: {:ok, Activity.t()} | {:error, any()}
|
@spec remove_mute(Activity.t(), User.t()) :: {:ok, Activity.t()} | {:error, any()}
|
||||||
def remove_mute(%User{} = user, %Activity{} = activity) do
|
def remove_mute(%Activity{} = activity, %User{} = user) do
|
||||||
ThreadMute.remove_mute(user.id, activity.data["context"])
|
ThreadMute.remove_mute(user.id, activity.data["context"])
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
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)},
|
with {:user, %User{} = user} <- {:user, User.get_by_id(user_id)},
|
||||||
{:activity, %Activity{} = activity} <- {:activity, Activity.get_by_id(activity_id)} do
|
{:activity, %Activity{} = activity} <- {:activity, Activity.get_by_id(activity_id)} do
|
||||||
remove_mute(user, activity)
|
remove_mute(activity, user)
|
||||||
else
|
else
|
||||||
{what, result} = error ->
|
{what, result} = error ->
|
||||||
Logger.warning(
|
Logger.warning(
|
||||||
|
@ -467,7 +467,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||||||
_
|
_
|
||||||
) do
|
) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id(id),
|
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)
|
try_render(conn, "show.json", activity: activity, for: user, as: :activity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,7 +14,7 @@ defmodule Pleroma.Workers.MuteExpireWorker do
|
|||||||
def perform(%Job{
|
def perform(%Job{
|
||||||
args: %{"op" => "unmute_conversation", "user_id" => user_id, "activity_id" => activity_id}
|
args: %{"op" => "unmute_conversation", "user_id" => user_id, "activity_id" => activity_id}
|
||||||
}) do
|
}) do
|
||||||
Pleroma.Web.CommonAPI.remove_mute(user_id, activity_id)
|
Pleroma.Web.CommonAPI.remove_mute(activity_id, user_id)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1219,13 +1219,13 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
|
|
||||||
test "remove mute", %{user: user, activity: activity} do
|
test "remove mute", %{user: user, activity: activity} do
|
||||||
CommonAPI.add_mute(user, activity)
|
CommonAPI.add_mute(user, activity)
|
||||||
{:ok, _} = CommonAPI.remove_mute(user, activity)
|
{:ok, _} = CommonAPI.remove_mute(activity, user)
|
||||||
refute CommonAPI.thread_muted?(user, activity)
|
refute CommonAPI.thread_muted?(user, activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "remove mute by ids", %{user: user, activity: activity} do
|
test "remove mute by ids", %{user: user, activity: activity} do
|
||||||
CommonAPI.add_mute(user, activity)
|
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)
|
refute CommonAPI.thread_muted?(user, activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user