aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2020-06-26 11:24:28 -0500
committerMark Felder <feld@FreeBSD.org>2020-06-26 11:24:28 -0500
commitfd5e797379155e5a85deb88dc79f8fbca483948e (patch)
treebf7790ebc43a79cdb87815b0de271126fb9fe606 /lib
parentb950fb01db51f14a9fd3a827b90573418a5b95da (diff)
downloadpleroma-fd5e797379155e5a85deb88dc79f8fbca483948e.tar.gz
Simplify notification filtering settings further
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/notification.ex28
-rw-r--r--lib/pleroma/user/notification_setting.ex8
-rw-r--r--lib/pleroma/web/api_spec/schemas/account.ex8
3 files changed, 7 insertions, 37 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 9d09cf082..8a28a1821 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -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"]
diff --git a/lib/pleroma/user/notification_setting.ex b/lib/pleroma/user/notification_setting.ex
index e47ac4cab..ffe9860de 100644
--- a/lib/pleroma/user/notification_setting.ex
+++ b/lib/pleroma/user/notification_setting.ex
@@ -10,18 +10,14 @@ defmodule Pleroma.User.NotificationSetting do
@primary_key false
embedded_schema do
- field(:from_followers, :boolean, default: true)
- field(:from_following, :boolean, default: true)
- field(:from_strangers, :boolean, default: true)
+ field(:block_from_strangers, :boolean, default: false)
field(:privacy_option, :boolean, default: false)
end
def changeset(schema, params) do
schema
|> cast(prepare_attrs(params), [
- :from_followers,
- :from_following,
- :from_strangers,
+ :block_from_strangers,
:privacy_option
])
end
diff --git a/lib/pleroma/web/api_spec/schemas/account.ex b/lib/pleroma/web/api_spec/schemas/account.ex
index ed90ef3db..91bb1ba88 100644
--- a/lib/pleroma/web/api_spec/schemas/account.ex
+++ b/lib/pleroma/web/api_spec/schemas/account.ex
@@ -57,9 +57,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
notification_settings: %Schema{
type: :object,
properties: %{
- from_followers: %Schema{type: :boolean},
- from_following: %Schema{type: :boolean},
- from_strangers: %Schema{type: :boolean},
+ block_from_strangers: %Schema{type: :boolean},
privacy_option: %Schema{type: :boolean}
}
},
@@ -122,9 +120,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
"unread_conversation_count" => 0,
"tags" => [],
"notification_settings" => %{
- "from_followers" => true,
- "from_following" => true,
- "from_strangers" => true,
+ "block_from_strangers" => false,
"privacy_option" => false
},
"relationship" => %{