Rename notification "privacy_option" setting
This commit is contained in:
parent
fd5e797379
commit
69848d5c97
10 changed files with 45 additions and 26 deletions
|
|
@ -3,8 +3,8 @@ defmodule Mix.Tasks.Pleroma.NotificationSettings do
|
|||
@moduledoc """
|
||||
Example:
|
||||
|
||||
> mix pleroma.notification_settings --privacy-option=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=false --nickname-users="parallel588" # set false only for parallel588 user
|
||||
> mix pleroma.notification_settings --hide-notification-contents=true # set true for all users
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -19,16 +19,16 @@ defmodule Mix.Tasks.Pleroma.NotificationSettings do
|
|||
OptionParser.parse(
|
||||
args,
|
||||
strict: [
|
||||
privacy_option: :boolean,
|
||||
hide_notification_contents: :boolean,
|
||||
email_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
|
||||
privacy_option
|
||||
if not is_nil(hide_notification_contents) do
|
||||
hide_notification_contents
|
||||
|> build_query(options)
|
||||
|> Pleroma.Repo.update_all([])
|
||||
end
|
||||
|
|
@ -36,15 +36,15 @@ defmodule Mix.Tasks.Pleroma.NotificationSettings do
|
|||
shell_info("Done")
|
||||
end
|
||||
|
||||
defp build_query(privacy_option, options) do
|
||||
defp build_query(hide_notification_contents, options) do
|
||||
query =
|
||||
from(u in Pleroma.User,
|
||||
update: [
|
||||
set: [
|
||||
notification_settings:
|
||||
fragment(
|
||||
"jsonb_set(notification_settings, '{privacy_option}', ?)",
|
||||
^privacy_option
|
||||
"jsonb_set(notification_settings, '{hide_notification_contents}', ?)",
|
||||
^hide_notification_contents
|
||||
)
|
||||
]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ defmodule Pleroma.User.NotificationSetting do
|
|||
|
||||
embedded_schema do
|
||||
field(:block_from_strangers, :boolean, default: false)
|
||||
field(:privacy_option, :boolean, default: false)
|
||||
field(:hide_notification_contents, :boolean, default: false)
|
||||
end
|
||||
|
||||
def changeset(schema, params) do
|
||||
schema
|
||||
|> cast(prepare_attrs(params), [
|
||||
:block_from_strangers,
|
||||
:privacy_option
|
||||
:hide_notification_contents
|
||||
])
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||
type: :object,
|
||||
properties: %{
|
||||
block_from_strangers: %Schema{type: :boolean},
|
||||
privacy_option: %Schema{type: :boolean}
|
||||
hide_notification_contents: %Schema{type: :boolean}
|
||||
}
|
||||
},
|
||||
relationship: AccountRelationship,
|
||||
|
|
@ -121,7 +121,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||
"tags" => [],
|
||||
"notification_settings" => %{
|
||||
"block_from_strangers" => false,
|
||||
"privacy_option" => false
|
||||
"hide_notification_contents" => false
|
||||
},
|
||||
"relationship" => %{
|
||||
"blocked_by" => false,
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ defmodule Pleroma.Web.Push.Impl do
|
|||
|
||||
def build_content(
|
||||
%{
|
||||
user: %{notification_settings: %{privacy_option: true}}
|
||||
user: %{notification_settings: %{hide_notification_contents: true}}
|
||||
} = notification,
|
||||
_actor,
|
||||
_object,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue