mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-18 02:49:18 +00:00
Add user muted status info to MastodonAPI.
This commit is contained in:
parent
c4235f96bd
commit
c1ae495878
|
@ -960,6 +960,7 @@ def unblock(blocker, %{ap_id: ap_id}) do
|
|||
update_and_set_cache(cng)
|
||||
end
|
||||
|
||||
def mutes?(nil, _), do: false
|
||||
def mutes?(user, %{ap_id: ap_id}), do: Enum.member?(user.info.mutes, ap_id)
|
||||
|
||||
def blocks?(user, %{ap_id: ap_id}) do
|
||||
|
|
|
@ -168,7 +168,7 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
|
|||
reblogged: present?(repeated),
|
||||
favourited: present?(favorited),
|
||||
bookmarked: present?(bookmarked),
|
||||
muted: CommonAPI.thread_muted?(user, activity),
|
||||
muted: CommonAPI.thread_muted?(user, activity) || User.mutes?(opts[:for], user),
|
||||
pinned: pinned?(activity, user),
|
||||
sensitive: sensitive,
|
||||
spoiler_text: object["summary"] || "",
|
||||
|
|
|
@ -126,6 +126,22 @@ test "a note activity" do
|
|||
assert status == expected
|
||||
end
|
||||
|
||||
test "tells if the message is muted for some reason" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, user} = User.mute(user, other_user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "test"})
|
||||
status = StatusView.render("status.json", %{activity: activity})
|
||||
|
||||
assert status.muted == false
|
||||
|
||||
status = StatusView.render("status.json", %{activity: activity, for: user})
|
||||
|
||||
assert status.muted == true
|
||||
end
|
||||
|
||||
test "a reply" do
|
||||
note = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
|
Loading…
Reference in a new issue