mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Make notifications about new statuses from muted threads read
This commit is contained in:
parent
0865f36965
commit
25c69e271a
4 changed files with 10 additions and 3 deletions
|
@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
contents has been renamed to `hide_notification_contents`
|
contents has been renamed to `hide_notification_contents`
|
||||||
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
||||||
- Mastodon API (legacy): Allow query parameters for `/api/v1/domain_blocks`, e.g. `/api/v1/domain_blocks?domain=badposters.zone`
|
- Mastodon API (legacy): Allow query parameters for `/api/v1/domain_blocks`, e.g. `/api/v1/domain_blocks?domain=badposters.zone`
|
||||||
|
- Mastodon API: Make notifications about statuses from muted users and threads read automatically
|
||||||
- Pleroma API: `/api/pleroma/captcha` responses now include `seconds_valid` with an integer value.
|
- Pleroma API: `/api/pleroma/captcha` responses now include `seconds_valid` with an integer value.
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ defmodule Pleroma.Notification do
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.ThreadMute
|
alias Pleroma.ThreadMute
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.CommonAPI.Utils
|
alias Pleroma.Web.CommonAPI.Utils
|
||||||
alias Pleroma.Web.Push
|
alias Pleroma.Web.Push
|
||||||
alias Pleroma.Web.Streamer
|
alias Pleroma.Web.Streamer
|
||||||
|
@ -637,7 +638,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)
|
User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(target_user, activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_user_and_activity(user, activity) do
|
def for_user_and_activity(user, activity) do
|
||||||
|
|
|
@ -465,7 +465,7 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
end
|
end
|
||||||
|
|
||||||
def thread_muted?(%User{id: user_id}, %{data: %{"context" => context}})
|
def thread_muted?(%User{id: user_id}, %{data: %{"context" => context}})
|
||||||
when is_binary("context") do
|
when is_binary(context) do
|
||||||
ThreadMute.exists?(user_id, context)
|
ThreadMute.exists?(user_id, context)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,10 @@ defmodule Pleroma.NotificationTest do
|
||||||
in_reply_to_status_id: activity.id
|
in_reply_to_status_id: activity.id
|
||||||
})
|
})
|
||||||
|
|
||||||
assert Notification.create_notification(activity, muter)
|
notification = Notification.create_notification(activity, muter)
|
||||||
|
|
||||||
|
assert notification.id
|
||||||
|
assert notification.seen
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it disables notifications from strangers" do
|
test "it disables notifications from strangers" do
|
||||||
|
@ -320,6 +323,7 @@ defmodule Pleroma.NotificationTest do
|
||||||
{:ok, [notification]} = Notification.create_notifications(status)
|
{:ok, [notification]} = Notification.create_notifications(status)
|
||||||
|
|
||||||
assert notification
|
assert notification
|
||||||
|
refute notification.seen
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it creates notifications when someone likes user's status with a filtered word" do
|
test "it creates notifications when someone likes user's status with a filtered word" do
|
||||||
|
@ -333,6 +337,7 @@ defmodule Pleroma.NotificationTest do
|
||||||
{:ok, [notification]} = Notification.create_notifications(activity_two)
|
{:ok, [notification]} = Notification.create_notifications(activity_two)
|
||||||
|
|
||||||
assert notification
|
assert notification
|
||||||
|
refute notification.seen
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue