diff options
author | lain <lain@soykaf.club> | 2018-02-21 18:34:19 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-02-21 18:34:19 +0100 |
commit | 94db9ac4dba6ba02fcae1b9055b532818cf787c7 (patch) | |
tree | 0b6189c60adbca5e0ea6b9aded01dccfbbc35755 /lib/mix/tasks/make_moderator.ex | |
parent | a06b9a3e0b5639dfc3a975c7a5f3ea11a05a286f (diff) | |
parent | e98aeabbdebee8f6c9a10d0c9e3f48c1031172cb (diff) | |
download | pleroma-94db9ac4dba6ba02fcae1b9055b532818cf787c7.tar.gz pleroma-94db9ac4dba6ba02fcae1b9055b532818cf787c7.zip |
Merge branch 'develop' into feature/activitypub
Diffstat (limited to 'lib/mix/tasks/make_moderator.ex')
-rw-r--r-- | lib/mix/tasks/make_moderator.ex | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/mix/tasks/make_moderator.ex b/lib/mix/tasks/make_moderator.ex new file mode 100644 index 000000000..a76b54f40 --- /dev/null +++ b/lib/mix/tasks/make_moderator.ex @@ -0,0 +1,27 @@ +defmodule Mix.Tasks.SetModerator do + use Mix.Task + import Mix.Ecto + alias Pleroma.{Repo, User} + + @shortdoc "Set moderator status" + def run([nickname | rest]) do + ensure_started(Repo, []) + + moderator = case rest do + [moderator] -> moderator == "true" + _ -> true + end + + with %User{local: true} = user <- User.get_by_nickname(nickname) do + info = user.info + |> Map.put("is_moderator", !!moderator) + cng = User.info_changeset(user, %{info: info}) + user = Repo.update!(cng) + + IO.puts "Moderator status of #{nickname}: #{user.info["is_moderator"]}" + else + _ -> + IO.puts "No local user #{nickname}" + end + end +end |