Fix order of args for add_mute/2
This commit is contained in:
parent
d27ad36ce4
commit
4601473aaf
@ -552,8 +552,8 @@ defmodule Pleroma.Web.CommonAPI do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec add_mute(User.t(), Activity.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
|
@spec add_mute(Activity.t(), User.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
|
||||||
def add_mute(user, activity, params \\ %{}) do
|
def add_mute(activity, user, params \\ %{}) do
|
||||||
expires_in = Map.get(params, :expires_in, 0)
|
expires_in = Map.get(params, :expires_in, 0)
|
||||||
|
|
||||||
with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]),
|
with {:ok, _} <- ThreadMute.add_mute(user.id, activity.data["context"]),
|
||||||
|
@ -453,7 +453,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.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)
|
try_render(conn, "show.json", activity: activity, for: user, as: :activity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -693,7 +693,7 @@ defmodule Pleroma.NotificationTest do
|
|||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey @#{other_user.nickname}!"})
|
{: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} =
|
{:ok, same_context_activity} =
|
||||||
CommonAPI.post(user, %{
|
CommonAPI.post(user, %{
|
||||||
|
@ -1171,7 +1171,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
note_two = insert(:note, data: %{"context" => "suya.."})
|
note_two = insert(:note, data: %{"context" => "suya.."})
|
||||||
activity_two = insert(:note_activity, note: note_two)
|
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})
|
assert [_activity_one] = ActivityPub.fetch_activities([], %{muting_user: user})
|
||||||
end
|
end
|
||||||
@ -1182,7 +1182,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||||||
note_two = insert(:note, data: %{"context" => "suya.."})
|
note_two = insert(:note, data: %{"context" => "suya.."})
|
||||||
activity_two = insert(:note_activity, note: note_two)
|
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] =
|
assert [_activity_two, _activity_one] =
|
||||||
ActivityPub.fetch_activities([], %{muting_user: user, with_muted: true})
|
ActivityPub.fetch_activities([], %{muting_user: user, with_muted: true})
|
||||||
|
@ -1172,7 +1172,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
n.type == "mention" && n.activity_id == reply_activity.id
|
n.type == "mention" && n.activity_id == reply_activity.id
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{:ok, _} = CommonAPI.add_mute(author, activity)
|
{:ok, _} = CommonAPI.add_mute(activity, author)
|
||||||
assert CommonAPI.thread_muted?(author, activity)
|
assert CommonAPI.thread_muted?(author, activity)
|
||||||
|
|
||||||
assert Repo.aggregate(
|
assert Repo.aggregate(
|
||||||
@ -1197,12 +1197,12 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "add mute", %{user: user, activity: activity} do
|
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)
|
assert CommonAPI.thread_muted?(user, activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "add expiring mute", %{user: user, activity: activity} do
|
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)
|
assert CommonAPI.thread_muted?(user, activity)
|
||||||
|
|
||||||
worker = Pleroma.Workers.MuteExpireWorker
|
worker = Pleroma.Workers.MuteExpireWorker
|
||||||
@ -1218,20 +1218,20 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "remove mute", %{user: user, activity: activity} do
|
test "remove mute", %{user: user, activity: activity} do
|
||||||
CommonAPI.add_mute(user, activity)
|
CommonAPI.add_mute(activity, user)
|
||||||
{:ok, _} = CommonAPI.remove_mute(activity, user)
|
{: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(activity, user)
|
||||||
{:ok, _} = CommonAPI.remove_mute(activity.id, user.id)
|
{:ok, _} = CommonAPI.remove_mute(activity.id, user.id)
|
||||||
refute CommonAPI.thread_muted?(user, activity)
|
refute CommonAPI.thread_muted?(user, activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "check that mutes can't be duplicate", %{user: user, activity: activity} do
|
test "check that mutes can't be duplicate", %{user: user, activity: activity} do
|
||||||
CommonAPI.add_mute(user, activity)
|
CommonAPI.add_mute(activity, user)
|
||||||
{:error, _} = CommonAPI.add_mute(user, activity)
|
{:error, _} = CommonAPI.add_mute(activity, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1771,7 +1771,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "cannot mute already muted conversation", %{conn: conn, user: user, activity: activity} do
|
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 =
|
||||||
conn
|
conn
|
||||||
@ -1784,7 +1784,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "unmute conversation", %{conn: conn, user: user, activity: activity} do
|
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)
|
id_str = to_string(activity.id)
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||||||
|
|
||||||
assert status.pleroma.thread_muted == false
|
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})
|
status = StatusView.render("show.json", %{activity: activity, for: user})
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||||||
user2 = insert(:user)
|
user2 = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
{: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)
|
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, user2, user, _activity} = CommonAPI.follow(user2, user)
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "super hot take"})
|
{: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_receive {:render_with_user, _, _, ^activity, _}
|
||||||
assert Streamer.filtered_by_user?(user2, activity)
|
assert Streamer.filtered_by_user?(user2, activity)
|
||||||
|
Loading…
Reference in New Issue
Block a user