Simplify notification filtering settings further
This commit is contained in:
parent
b950fb01db
commit
fd5e797379
9 changed files with 15 additions and 123 deletions
|
|
@ -550,9 +550,7 @@ defmodule Pleroma.Notification do
|
|||
[
|
||||
:self,
|
||||
:invisible,
|
||||
:from_followers,
|
||||
:from_following,
|
||||
:from_strangers,
|
||||
:block_from_strangers,
|
||||
:recently_followed
|
||||
]
|
||||
|> Enum.find(&skip?(&1, activity, user))
|
||||
|
|
@ -572,35 +570,15 @@ defmodule Pleroma.Notification do
|
|||
end
|
||||
|
||||
def skip?(
|
||||
:from_followers,
|
||||
:block_from_strangers,
|
||||
%Activity{} = activity,
|
||||
%User{notification_settings: %{from_followers: false}} = user
|
||||
) do
|
||||
actor = activity.data["actor"]
|
||||
follower = User.get_cached_by_ap_id(actor)
|
||||
User.following?(follower, user)
|
||||
end
|
||||
|
||||
def skip?(
|
||||
:from_strangers,
|
||||
%Activity{} = activity,
|
||||
%User{notification_settings: %{from_strangers: false}} = user
|
||||
%User{notification_settings: %{block_from_strangers: true}} = user
|
||||
) do
|
||||
actor = activity.data["actor"]
|
||||
follower = User.get_cached_by_ap_id(actor)
|
||||
!User.following?(follower, user)
|
||||
end
|
||||
|
||||
def skip?(
|
||||
:from_following,
|
||||
%Activity{} = activity,
|
||||
%User{notification_settings: %{from_following: false}} = user
|
||||
) do
|
||||
actor = activity.data["actor"]
|
||||
followed = User.get_cached_by_ap_id(actor)
|
||||
User.following?(user, followed)
|
||||
end
|
||||
|
||||
# To do: consider defining recency in hours and checking FollowingRelationship with a single SQL
|
||||
def skip?(:recently_followed, %Activity{data: %{"type" => "Follow"}} = activity, %User{} = user) do
|
||||
actor = activity.data["actor"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue