Fix order of args for thread_muted?/2
This commit is contained in:
parent
4601473aaf
commit
8127e0d8cc
@ -734,7 +734,7 @@ defmodule Pleroma.Notification do
|
|||||||
|
|
||||||
def mark_as_read?(activity, target_user) do
|
def mark_as_read?(activity, target_user) do
|
||||||
user = Activity.user_actor(activity)
|
user = Activity.user_actor(activity)
|
||||||
User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(target_user, activity)
|
User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(activity, target_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_user_and_activity(user, activity) do
|
def for_user_and_activity(user, activity) do
|
||||||
|
@ -593,8 +593,8 @@ defmodule Pleroma.Web.CommonAPI do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec thread_muted?(User.t(), Activity.t()) :: boolean()
|
@spec thread_muted?(Activity.t(), User.t()) :: boolean()
|
||||||
def thread_muted?(%User{id: user_id}, %{data: %{"context" => context}})
|
def thread_muted?(%{data: %{"context" => context}}, %User{id: user_id})
|
||||||
when is_binary(context) do
|
when is_binary(context) do
|
||||||
ThreadMute.exists?(user_id, context)
|
ThreadMute.exists?(user_id, context)
|
||||||
end
|
end
|
||||||
|
@ -293,7 +293,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||||||
cond do
|
cond do
|
||||||
is_nil(opts[:for]) -> false
|
is_nil(opts[:for]) -> false
|
||||||
is_boolean(activity.thread_muted?) -> activity.thread_muted?
|
is_boolean(activity.thread_muted?) -> activity.thread_muted?
|
||||||
true -> CommonAPI.thread_muted?(opts[:for], activity)
|
true -> CommonAPI.thread_muted?(activity, opts[:for])
|
||||||
end
|
end
|
||||||
|
|
||||||
attachment_data = object.data["attachment"] || []
|
attachment_data = object.data["attachment"] || []
|
||||||
|
@ -206,7 +206,7 @@ defmodule Pleroma.Web.Streamer do
|
|||||||
false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, item_host),
|
false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, item_host),
|
||||||
false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, parent_host),
|
false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, parent_host),
|
||||||
true <- thread_containment(item, user),
|
true <- thread_containment(item, user),
|
||||||
false <- CommonAPI.thread_muted?(user, parent) do
|
false <- CommonAPI.thread_muted?(parent, user) do
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
_ -> true
|
_ -> true
|
||||||
|
@ -1526,7 +1526,7 @@ defmodule Pleroma.UserTest do
|
|||||||
|
|
||||||
assert [activity] == ActivityPub.fetch_public_activities(%{}) |> Repo.preload(:bookmark)
|
assert [activity] == ActivityPub.fetch_public_activities(%{}) |> Repo.preload(:bookmark)
|
||||||
|
|
||||||
assert [%{activity | thread_muted?: CommonAPI.thread_muted?(user2, activity)}] ==
|
assert [%{activity | thread_muted?: CommonAPI.thread_muted?(activity, user2)}] ==
|
||||||
ActivityPub.fetch_activities([user2.ap_id | User.following(user2)], %{
|
ActivityPub.fetch_activities([user2.ap_id | User.following(user2)], %{
|
||||||
user: user2
|
user: user2
|
||||||
})
|
})
|
||||||
|
@ -1173,7 +1173,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
{:ok, _} = CommonAPI.add_mute(activity, author)
|
{:ok, _} = CommonAPI.add_mute(activity, author)
|
||||||
assert CommonAPI.thread_muted?(author, activity)
|
assert CommonAPI.thread_muted?(activity, author)
|
||||||
|
|
||||||
assert Repo.aggregate(
|
assert Repo.aggregate(
|
||||||
from(n in Notification, where: n.seen == false and n.user_id == ^friend1.id),
|
from(n in Notification, where: n.seen == false and n.user_id == ^friend1.id),
|
||||||
@ -1198,12 +1198,12 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
|
|
||||||
test "add mute", %{user: user, activity: activity} do
|
test "add mute", %{user: user, activity: activity} do
|
||||||
{:ok, _} = CommonAPI.add_mute(activity, user)
|
{:ok, _} = CommonAPI.add_mute(activity, user)
|
||||||
assert CommonAPI.thread_muted?(user, activity)
|
assert CommonAPI.thread_muted?(activity, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "add expiring mute", %{user: user, activity: activity} do
|
test "add expiring mute", %{user: user, activity: activity} do
|
||||||
{:ok, _} = CommonAPI.add_mute(activity, user, %{expires_in: 60})
|
{:ok, _} = CommonAPI.add_mute(activity, user, %{expires_in: 60})
|
||||||
assert CommonAPI.thread_muted?(user, activity)
|
assert CommonAPI.thread_muted?(activity, user)
|
||||||
|
|
||||||
worker = Pleroma.Workers.MuteExpireWorker
|
worker = Pleroma.Workers.MuteExpireWorker
|
||||||
args = %{"op" => "unmute_conversation", "user_id" => user.id, "activity_id" => activity.id}
|
args = %{"op" => "unmute_conversation", "user_id" => user.id, "activity_id" => activity.id}
|
||||||
@ -1214,19 +1214,19 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert :ok = perform_job(worker, args)
|
assert :ok = perform_job(worker, args)
|
||||||
refute CommonAPI.thread_muted?(user, activity)
|
refute CommonAPI.thread_muted?(activity, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "remove mute", %{user: user, activity: activity} do
|
test "remove mute", %{user: user, activity: activity} do
|
||||||
CommonAPI.add_mute(activity, user)
|
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?(activity, user)
|
||||||
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(activity, user)
|
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?(activity, user)
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user