diff options
Diffstat (limited to 'lib/mix/tasks')
-rw-r--r-- | lib/mix/tasks/pleroma/app.ex | 2 | ||||
-rw-r--r-- | lib/mix/tasks/pleroma/user.ex | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/mix/tasks/pleroma/app.ex b/lib/mix/tasks/pleroma/app.ex index 0bf7ffabc..aa5c9cd54 100644 --- a/lib/mix/tasks/pleroma/app.ex +++ b/lib/mix/tasks/pleroma/app.ex @@ -21,7 +21,7 @@ defmodule Mix.Tasks.Pleroma.App do scopes = if opts[:scopes] do - String.split(opts[:scopes], ",") + String.split(opts[:scopes], ",", trim: true) else ["read", "write", "follow", "push"] end diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 53d5fc6d9..d2a545e91 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -433,6 +433,35 @@ defmodule Mix.Tasks.Pleroma.User do |> Stream.run() end + def run(["email_notifications", nickname | options]) do + start_pleroma() + + {opts, _} = + OptionParser.parse!(options, + strict: [digest: :boolean, notifications: :string], + aliases: [n: :notifications] + ) + + params = + Map.new(opts, fn + {:digest, v} -> + {"digest", v} + + {:notifications, v} -> + types = if v == "off", do: [], else: String.split(v, ",", trim: true) + {"notifications", types} + end) + + with keys when keys != [] <- Map.keys(params), + %User{local: true} = user <- User.get_cached_by_nickname(nickname) do + {:ok, user} = User.update_email_notifications(user, params) + shell_info("Email notifications for user #{user.nickname} were successfully updated.") + else + [] -> shell_error("No changes passed") + _ -> shell_error("No local user #{nickname}") + end + end + defp set_moderator(user, value) do {:ok, user} = user |