1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.NotificationSettings do
6 @shortdoc "Enable&Disable privacy option for push notifications"
10 > mix pleroma.notification_settings --hide-notification-contents=false --nickname-users="parallel588" # set false only for parallel588 user
11 > mix pleroma.notification_settings --hide-notification-contents=true # set true for all users
26 hide_notification_contents: :boolean,
28 nickname_users: :string
32 hide_notification_contents = Keyword.get(options, :hide_notification_contents)
34 if not is_nil(hide_notification_contents) do
35 hide_notification_contents
36 |> build_query(options)
37 |> Pleroma.Repo.update_all([])
43 defp build_query(hide_notification_contents, options) do
45 from(u in Pleroma.User,
48 notification_settings:
50 "jsonb_set(notification_settings, '{hide_notification_contents}', ?)",
51 ^hide_notification_contents
59 |> Keyword.get(:email_users, "")
61 |> Enum.map(&String.trim(&1))
62 |> Enum.reject(&(&1 == ""))
65 if length(user_emails) > 0 do
66 where(query, [u], u.email in ^user_emails)
73 |> Keyword.get(:nickname_users, "")
75 |> Enum.map(&String.trim(&1))
76 |> Enum.reject(&(&1 == ""))
79 if length(user_nicknames) > 0 do
80 where(query, [u], u.nickname in ^user_nicknames)