1 defmodule Mix.Tasks.Pleroma.NotificationSettings do
2 @shortdoc "Enable&Disable privacy option for push notifications"
6 > mix pleroma.notification_settings --privacy-option=false --nickname-users="parallel588" # set false only for parallel588 user
7 > mix pleroma.notification_settings --privacy-option=true # set true for all users
22 privacy_option: :boolean,
24 nickname_users: :string
28 privacy_option = Keyword.get(options, :privacy_option)
30 if not is_nil(privacy_option) do
32 |> build_query(options)
33 |> Pleroma.Repo.update_all([])
39 defp build_query(privacy_option, options) do
41 from(u in Pleroma.User,
44 notification_settings:
46 "jsonb_set(notification_settings, '{privacy_option}', ?)",
55 |> Keyword.get(:email_users, "")
57 |> Enum.map(&String.trim(&1))
58 |> Enum.reject(&(&1 == ""))
61 if length(user_emails) > 0 do
62 where(query, [u], u.email in ^user_emails)
69 |> Keyword.get(:nickname_users, "")
71 |> Enum.map(&String.trim(&1))
72 |> Enum.reject(&(&1 == ""))
75 if length(user_nicknames) > 0 do
76 where(query, [u], u.nickname in ^user_nicknames)