aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2019-05-25 05:19:47 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2019-05-25 05:19:47 +0000
commit4030837d91b7ff8525513589d5d810e9a1a6b959 (patch)
tree44c90e66fc383f73aa08de9627e3c20292a23681 /lib
parent9f44fa068648929aff639ecd5fd74e9c643803b5 (diff)
downloadpleroma-4030837d91b7ff8525513589d5d810e9a1a6b959.tar.gz
notification: add non_follows/non_followers notification control settings
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex32
-rw-r--r--lib/pleroma/user/info.ex11
2 files changed, 40 insertions, 3 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 844264307..4095e0474 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -166,7 +166,17 @@ defmodule Pleroma.Notification do
def get_notified_from_activity(_, _local_only), do: []
def skip?(activity, user) do
- [:self, :blocked, :local, :muted, :followers, :follows, :recently_followed]
+ [
+ :self,
+ :blocked,
+ :local,
+ :muted,
+ :followers,
+ :follows,
+ :non_followers,
+ :non_follows,
+ :recently_followed
+ ]
|> Enum.any?(&skip?(&1, activity, user))
end
@@ -201,12 +211,32 @@ defmodule Pleroma.Notification do
User.following?(follower, user)
end
+ def skip?(
+ :non_followers,
+ activity,
+ %{info: %{notification_settings: %{"non_followers" => false}}} = user
+ ) do
+ actor = activity.data["actor"]
+ follower = User.get_cached_by_ap_id(actor)
+ !User.following?(follower, user)
+ end
+
def skip?(:follows, activity, %{info: %{notification_settings: %{"follows" => false}}} = user) do
actor = activity.data["actor"]
followed = User.get_cached_by_ap_id(actor)
User.following?(user, followed)
end
+ def skip?(
+ :non_follows,
+ activity,
+ %{info: %{notification_settings: %{"non_follows" => false}}} = user
+ ) do
+ actor = activity.data["actor"]
+ followed = User.get_cached_by_ap_id(actor)
+ !User.following?(user, followed)
+ end
+
def skip?(:recently_followed, %{data: %{"type" => "Follow"}} = activity, user) do
actor = activity.data["actor"]
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index 6397e2737..fb4cf3cc3 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -47,7 +47,14 @@ defmodule Pleroma.User.Info do
field(:emoji, {:array, :map}, default: [])
field(:notification_settings, :map,
- default: %{"remote" => true, "local" => true, "followers" => true, "follows" => true}
+ default: %{
+ "remote" => true,
+ "local" => true,
+ "followers" => true,
+ "follows" => true,
+ "non_follows" => true,
+ "non_followers" => true
+ }
)
# Found in the wild
@@ -71,7 +78,7 @@ defmodule Pleroma.User.Info do
notification_settings =
info.notification_settings
|> Map.merge(settings)
- |> Map.take(["remote", "local", "followers", "follows"])
+ |> Map.take(["remote", "local", "followers", "follows", "non_follows", "non_followers"])
params = %{notification_settings: notification_settings}