forked from AkkomaGang/akkoma
Merge branch 'refactor/notification_settings' into 'develop'
Refactor notification settings See merge request pleroma/pleroma!2602
This commit is contained in:
commit
00f9b53f07
134 changed files with 69 additions and 130 deletions
|
@ -25,6 +25,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Added `pleroma.metadata.fields_limits` to /api/v1/instance
|
- Mastodon API: Added `pleroma.metadata.fields_limits` to /api/v1/instance
|
||||||
- Mastodon API: On deletion, returns the original post text.
|
- Mastodon API: On deletion, returns the original post text.
|
||||||
- Mastodon API: Add `pleroma.unread_count` to the Marker entity.
|
- Mastodon API: Add `pleroma.unread_count` to the Marker entity.
|
||||||
|
- **Breaking:** Notification Settings API for suppressing notifications
|
||||||
|
has been simplified down to `block_from_strangers`.
|
||||||
|
- **Breaking:** Notification Settings API option for hiding push notification
|
||||||
|
contents has been renamed to `hide_notification_contents`
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
|
@ -287,11 +287,8 @@ See [Admin-API](admin_api.md)
|
||||||
* Method `PUT`
|
* Method `PUT`
|
||||||
* Authentication: required
|
* Authentication: required
|
||||||
* Params:
|
* Params:
|
||||||
* `followers`: BOOLEAN field, receives notifications from followers
|
* `block_from_strangers`: BOOLEAN field, blocks notifications from accounts you do not follow
|
||||||
* `follows`: BOOLEAN field, receives notifications from people the user follows
|
* `hide_notification_contents`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification.
|
||||||
* `remote`: BOOLEAN field, receives notifications from people on remote instances
|
|
||||||
* `local`: BOOLEAN field, receives notifications from people on the local instance
|
|
||||||
* `privacy_option`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification.
|
|
||||||
* Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}`
|
* Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}`
|
||||||
|
|
||||||
## `/api/pleroma/healthcheck`
|
## `/api/pleroma/healthcheck`
|
||||||
|
|
|
@ -3,8 +3,8 @@ defmodule Mix.Tasks.Pleroma.NotificationSettings do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
> mix pleroma.notification_settings --privacy-option=false --nickname-users="parallel588" # set false only for parallel588 user
|
> mix pleroma.notification_settings --hide-notification-contents=false --nickname-users="parallel588" # set false only for parallel588 user
|
||||||
> mix pleroma.notification_settings --privacy-option=true # set true for all users
|
> mix pleroma.notification_settings --hide-notification-contents=true # set true for all users
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -19,16 +19,16 @@ def run(args) do
|
||||||
OptionParser.parse(
|
OptionParser.parse(
|
||||||
args,
|
args,
|
||||||
strict: [
|
strict: [
|
||||||
privacy_option: :boolean,
|
hide_notification_contents: :boolean,
|
||||||
email_users: :string,
|
email_users: :string,
|
||||||
nickname_users: :string
|
nickname_users: :string
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
privacy_option = Keyword.get(options, :privacy_option)
|
hide_notification_contents = Keyword.get(options, :hide_notification_contents)
|
||||||
|
|
||||||
if not is_nil(privacy_option) do
|
if not is_nil(hide_notification_contents) do
|
||||||
privacy_option
|
hide_notification_contents
|
||||||
|> build_query(options)
|
|> build_query(options)
|
||||||
|> Pleroma.Repo.update_all([])
|
|> Pleroma.Repo.update_all([])
|
||||||
end
|
end
|
||||||
|
@ -36,15 +36,15 @@ def run(args) do
|
||||||
shell_info("Done")
|
shell_info("Done")
|
||||||
end
|
end
|
||||||
|
|
||||||
defp build_query(privacy_option, options) do
|
defp build_query(hide_notification_contents, options) do
|
||||||
query =
|
query =
|
||||||
from(u in Pleroma.User,
|
from(u in Pleroma.User,
|
||||||
update: [
|
update: [
|
||||||
set: [
|
set: [
|
||||||
notification_settings:
|
notification_settings:
|
||||||
fragment(
|
fragment(
|
||||||
"jsonb_set(notification_settings, '{privacy_option}', ?)",
|
"jsonb_set(notification_settings, '{hide_notification_contents}', ?)",
|
||||||
^privacy_option
|
^hide_notification_contents
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
|
@ -571,10 +571,7 @@ def skip?(%Activity{} = activity, %User{} = user) do
|
||||||
[
|
[
|
||||||
:self,
|
:self,
|
||||||
:invisible,
|
:invisible,
|
||||||
:followers,
|
:block_from_strangers,
|
||||||
:follows,
|
|
||||||
:non_followers,
|
|
||||||
:non_follows,
|
|
||||||
:recently_followed,
|
:recently_followed,
|
||||||
:filtered
|
:filtered
|
||||||
]
|
]
|
||||||
|
@ -595,45 +592,15 @@ def skip?(:invisible, %Activity{} = activity, _) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(
|
def skip?(
|
||||||
:followers,
|
:block_from_strangers,
|
||||||
%Activity{} = activity,
|
%Activity{} = activity,
|
||||||
%User{notification_settings: %{followers: 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?(
|
|
||||||
:non_followers,
|
|
||||||
%Activity{} = activity,
|
|
||||||
%User{notification_settings: %{non_followers: false}} = user
|
|
||||||
) do
|
) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
follower = User.get_cached_by_ap_id(actor)
|
follower = User.get_cached_by_ap_id(actor)
|
||||||
!User.following?(follower, user)
|
!User.following?(follower, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip?(
|
|
||||||
:follows,
|
|
||||||
%Activity{} = activity,
|
|
||||||
%User{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{} = activity,
|
|
||||||
%User{notification_settings: %{non_follows: 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
|
# 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
|
def skip?(:recently_followed, %Activity{data: %{"type" => "Follow"}} = activity, %User{} = user) do
|
||||||
actor = activity.data["actor"]
|
actor = activity.data["actor"]
|
||||||
|
|
|
@ -10,21 +10,15 @@ defmodule Pleroma.User.NotificationSetting do
|
||||||
@primary_key false
|
@primary_key false
|
||||||
|
|
||||||
embedded_schema do
|
embedded_schema do
|
||||||
field(:followers, :boolean, default: true)
|
field(:block_from_strangers, :boolean, default: false)
|
||||||
field(:follows, :boolean, default: true)
|
field(:hide_notification_contents, :boolean, default: false)
|
||||||
field(:non_follows, :boolean, default: true)
|
|
||||||
field(:non_followers, :boolean, default: true)
|
|
||||||
field(:privacy_option, :boolean, default: false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def changeset(schema, params) do
|
def changeset(schema, params) do
|
||||||
schema
|
schema
|
||||||
|> cast(prepare_attrs(params), [
|
|> cast(prepare_attrs(params), [
|
||||||
:followers,
|
:block_from_strangers,
|
||||||
:follows,
|
:hide_notification_contents
|
||||||
:non_follows,
|
|
||||||
:non_followers,
|
|
||||||
:privacy_option
|
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
||||||
notification_settings: %Schema{
|
notification_settings: %Schema{
|
||||||
type: :object,
|
type: :object,
|
||||||
properties: %{
|
properties: %{
|
||||||
followers: %Schema{type: :boolean},
|
block_from_strangers: %Schema{type: :boolean},
|
||||||
follows: %Schema{type: :boolean},
|
hide_notification_contents: %Schema{type: :boolean}
|
||||||
non_followers: %Schema{type: :boolean},
|
|
||||||
non_follows: %Schema{type: :boolean},
|
|
||||||
privacy_option: %Schema{type: :boolean}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
relationship: AccountRelationship,
|
relationship: AccountRelationship,
|
||||||
|
@ -182,11 +179,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
||||||
"unread_conversation_count" => 0,
|
"unread_conversation_count" => 0,
|
||||||
"tags" => [],
|
"tags" => [],
|
||||||
"notification_settings" => %{
|
"notification_settings" => %{
|
||||||
"followers" => true,
|
"block_from_strangers" => false,
|
||||||
"follows" => true,
|
"hide_notification_contents" => false
|
||||||
"non_followers" => true,
|
|
||||||
"non_follows" => true,
|
|
||||||
"privacy_option" => false
|
|
||||||
},
|
},
|
||||||
"relationship" => %{
|
"relationship" => %{
|
||||||
"blocked_by" => false,
|
"blocked_by" => false,
|
||||||
|
|
|
@ -104,7 +104,7 @@ def build_content(notification, actor, object, mastodon_type \\ nil)
|
||||||
|
|
||||||
def build_content(
|
def build_content(
|
||||||
%{
|
%{
|
||||||
user: %{notification_settings: %{privacy_option: true}}
|
user: %{notification_settings: %{hide_notification_contents: true}}
|
||||||
} = notification,
|
} = notification,
|
||||||
_actor,
|
_actor,
|
||||||
_object,
|
_object,
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.RenameNotificationPrivacyOption do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
execute(
|
||||||
|
"UPDATE users SET notification_settings = notification_settings - 'privacy_option' || jsonb_build_object('hide_notification_contents', notification_settings->'privacy_option')
|
||||||
|
where notification_settings ? 'privacy_option'
|
||||||
|
and local"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
execute(
|
||||||
|
"UPDATE users SET notification_settings = notification_settings - 'hide_notification_contents' || jsonb_build_object('privacy_option', notification_settings->'hide_notification_contents')
|
||||||
|
where notification_settings ? 'hide_notification_contents'
|
||||||
|
and local"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1 +1 @@
|
||||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,user-scalable=no"><title>Pleroma</title><!--server-generated-meta--><link rel=icon type=image/png href=/favicon.png><link href=/static/css/app.77b1644622e3bae24b6b.css rel=stylesheet><link href=/static/fontello.1594374054351.css rel=stylesheet></head><body class=hidden><noscript>To use Pleroma, please enable JavaScript.</noscript><div id=app></div><script type=text/javascript src=/static/js/vendors~app.247dc52c7abe6a0dab87.js></script><script type=text/javascript src=/static/js/app.1e68e208590653dab5aa.js></script></body></html>
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,user-scalable=no"><title>Pleroma</title><!--server-generated-meta--><link rel=icon type=image/png href=/favicon.png><link href=/static/css/app.6dbc7dea4fc148c85860.css rel=stylesheet><link href=/static/fontello.1594823398494.css rel=stylesheet></head><body class=hidden><noscript>To use Pleroma, please enable JavaScript.</noscript><div id=app></div><script type=text/javascript src=/static/js/vendors~app.9e24ed238da5a8538f50.js></script><script type=text/javascript src=/static/js/app.31bba9f1e242ff273dcb.js></script></body></html>
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/font/fontello.1594823398494.woff2
Normal file
BIN
priv/static/static/font/fontello.1594823398494.woff2
Normal file
Binary file not shown.
BIN
priv/static/static/fontello.1589385935077.css
vendored
BIN
priv/static/static/fontello.1589385935077.css
vendored
Binary file not shown.
BIN
priv/static/static/fontello.1594030805019.css
vendored
BIN
priv/static/static/fontello.1594030805019.css
vendored
Binary file not shown.
BIN
priv/static/static/fontello.1594134783339.css
vendored
BIN
priv/static/static/fontello.1594134783339.css
vendored
Binary file not shown.
Binary file not shown.
0
priv/static/static/fontello.json
Executable file → Normal file
0
priv/static/static/fontello.json
Executable file → Normal file
Binary file not shown.
BIN
priv/static/static/js/10.5ef4671883649cf93524.js
Normal file
BIN
priv/static/static/js/10.5ef4671883649cf93524.js
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/11.c5b938b4349f87567338.js
Normal file
BIN
priv/static/static/js/11.c5b938b4349f87567338.js
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/12.ab82f9512fa85e78c114.js
Normal file
BIN
priv/static/static/js/12.ab82f9512fa85e78c114.js
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/13.40e59c5015d3307b94ad.js
Normal file
BIN
priv/static/static/js/13.40e59c5015d3307b94ad.js
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/14.de791a47ee5249a526b1.js
Normal file
BIN
priv/static/static/js/14.de791a47ee5249a526b1.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/14.de791a47ee5249a526b1.js.map
Normal file
BIN
priv/static/static/js/14.de791a47ee5249a526b1.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/15.e24854297ad682aec45a.js
Normal file
BIN
priv/static/static/js/15.e24854297ad682aec45a.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/15.e24854297ad682aec45a.js.map
Normal file
BIN
priv/static/static/js/15.e24854297ad682aec45a.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/16.b7b0e4b8227a50fcb9bb.js
Normal file
BIN
priv/static/static/js/16.b7b0e4b8227a50fcb9bb.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/16.b7b0e4b8227a50fcb9bb.js.map
Normal file
BIN
priv/static/static/js/16.b7b0e4b8227a50fcb9bb.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/17.c98118b6bb84ee3b5b08.js
Normal file
BIN
priv/static/static/js/17.c98118b6bb84ee3b5b08.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/17.c98118b6bb84ee3b5b08.js.map
Normal file
BIN
priv/static/static/js/17.c98118b6bb84ee3b5b08.js.map
Normal file
Binary file not shown.
BIN
priv/static/static/js/18.89c20aa67a4dd067ea37.js
Normal file
BIN
priv/static/static/js/18.89c20aa67a4dd067ea37.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/18.89c20aa67a4dd067ea37.js.map
Normal file
BIN
priv/static/static/js/18.89c20aa67a4dd067ea37.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/19.6e13bad8131c4501c1c5.js
Normal file
BIN
priv/static/static/js/19.6e13bad8131c4501c1c5.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/19.6e13bad8131c4501c1c5.js.map
Normal file
BIN
priv/static/static/js/19.6e13bad8131c4501c1c5.js.map
Normal file
Binary file not shown.
BIN
priv/static/static/js/2.78a48aa26599b00c3b8d.js
Normal file
BIN
priv/static/static/js/2.78a48aa26599b00c3b8d.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/2.78a48aa26599b00c3b8d.js.map
Normal file
BIN
priv/static/static/js/2.78a48aa26599b00c3b8d.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/20.3615c3cea2e1c2707a4f.js
Normal file
BIN
priv/static/static/js/20.3615c3cea2e1c2707a4f.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/20.3615c3cea2e1c2707a4f.js.map
Normal file
BIN
priv/static/static/js/20.3615c3cea2e1c2707a4f.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/21.64dedfc646e13e6f7915.js
Normal file
BIN
priv/static/static/js/21.64dedfc646e13e6f7915.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/21.64dedfc646e13e6f7915.js.map
Normal file
BIN
priv/static/static/js/21.64dedfc646e13e6f7915.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/22.6fa63bc6a054b7638e9e.js
Normal file
BIN
priv/static/static/js/22.6fa63bc6a054b7638e9e.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/22.6fa63bc6a054b7638e9e.js.map
Normal file
BIN
priv/static/static/js/22.6fa63bc6a054b7638e9e.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/23.e0ddea2b6e049d221ee7.js
Normal file
BIN
priv/static/static/js/23.e0ddea2b6e049d221ee7.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/23.e0ddea2b6e049d221ee7.js.map
Normal file
BIN
priv/static/static/js/23.e0ddea2b6e049d221ee7.js.map
Normal file
Binary file not shown.
BIN
priv/static/static/js/24.38e3b9d44e9ee703ebf6.js
Normal file
BIN
priv/static/static/js/24.38e3b9d44e9ee703ebf6.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/24.38e3b9d44e9ee703ebf6.js.map
Normal file
BIN
priv/static/static/js/24.38e3b9d44e9ee703ebf6.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/25.696b41c0a8660e1f85af.js
Normal file
BIN
priv/static/static/js/25.696b41c0a8660e1f85af.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/25.696b41c0a8660e1f85af.js.map
Normal file
BIN
priv/static/static/js/25.696b41c0a8660e1f85af.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/26.1168f22384be75dc5492.js
Normal file
BIN
priv/static/static/js/26.1168f22384be75dc5492.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/26.1168f22384be75dc5492.js.map
Normal file
BIN
priv/static/static/js/26.1168f22384be75dc5492.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/27.3c0cfbb2a898b35486dd.js
Normal file
BIN
priv/static/static/js/27.3c0cfbb2a898b35486dd.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/27.3c0cfbb2a898b35486dd.js.map
Normal file
BIN
priv/static/static/js/27.3c0cfbb2a898b35486dd.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
priv/static/static/js/28.926c71d6f1813e177271.js
Normal file
BIN
priv/static/static/js/28.926c71d6f1813e177271.js
Normal file
Binary file not shown.
BIN
priv/static/static/js/28.926c71d6f1813e177271.js.map
Normal file
BIN
priv/static/static/js/28.926c71d6f1813e177271.js.map
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue