forked from mirrors/akkoma
Allow to set both admin and moderator at the same time in mix task User
This commit is contained in:
parent
a40ba3ba57
commit
51dd294c48
1 changed files with 19 additions and 13 deletions
|
@ -218,18 +218,21 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
)
|
)
|
||||||
|
|
||||||
with %User{local: true} = user <- User.get_by_nickname(nickname) do
|
with %User{local: true} = user <- User.get_by_nickname(nickname) do
|
||||||
|
user =
|
||||||
case Keyword.get(options, :moderator) do
|
case Keyword.get(options, :moderator) do
|
||||||
nil -> nil
|
nil -> user
|
||||||
value -> set_moderator(user, value)
|
value -> set_moderator(user, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
user =
|
||||||
case Keyword.get(options, :locked) do
|
case Keyword.get(options, :locked) do
|
||||||
nil -> nil
|
nil -> user
|
||||||
value -> set_locked(user, value)
|
value -> set_locked(user, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
_user =
|
||||||
case Keyword.get(options, :admin) do
|
case Keyword.get(options, :admin) do
|
||||||
nil -> nil
|
nil -> user
|
||||||
value -> set_admin(user, value)
|
value -> set_admin(user, value)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -268,6 +271,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
{:ok, user} = User.update_and_set_cache(user_cng)
|
{:ok, user} = User.update_and_set_cache(user_cng)
|
||||||
|
|
||||||
Mix.shell().info("Moderator status of #{user.nickname}: #{user.info.is_moderator}")
|
Mix.shell().info("Moderator status of #{user.nickname}: #{user.info.is_moderator}")
|
||||||
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
defp set_admin(user, value) do
|
defp set_admin(user, value) do
|
||||||
|
@ -279,7 +283,8 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
|
|
||||||
{:ok, user} = User.update_and_set_cache(user_cng)
|
{:ok, user} = User.update_and_set_cache(user_cng)
|
||||||
|
|
||||||
Mix.shell().info("Admin status of #{user.nickname}: #{user.info.is_moderator}")
|
Mix.shell().info("Admin status of #{user.nickname}: #{user.info.is_admin}")
|
||||||
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
defp set_locked(user, value) do
|
defp set_locked(user, value) do
|
||||||
|
@ -292,5 +297,6 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
{:ok, user} = User.update_and_set_cache(user_cng)
|
{:ok, user} = User.update_and_set_cache(user_cng)
|
||||||
|
|
||||||
Mix.shell().info("Locked status of #{user.nickname}: #{user.info.locked}")
|
Mix.shell().info("Locked status of #{user.nickname}: #{user.info.locked}")
|
||||||
|
user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue