forked from AkkomaGang/akkoma
Merge branch 'fix/mix-tasks-set-user-info' into 'develop'
Fix mix task User See merge request pleroma/pleroma!539
This commit is contained in:
commit
a5a10988e8
1 changed files with 24 additions and 15 deletions
|
@ -142,8 +142,11 @@ def run(["toggle_activated", nickname]) do
|
||||||
Common.start_pleroma()
|
Common.start_pleroma()
|
||||||
|
|
||||||
with %User{} = user <- User.get_by_nickname(nickname) do
|
with %User{} = user <- User.get_by_nickname(nickname) do
|
||||||
User.deactivate(user, !user.info["deactivated"])
|
{:ok, user} = User.deactivate(user, !user.info.deactivated)
|
||||||
Mix.shell().info("Activation status of #{nickname}: #{user.info["deactivated"]}")
|
|
||||||
|
Mix.shell().info(
|
||||||
|
"Activation status of #{nickname}: #{if(user.info.deactivated, do: "de", else: "")}activated"
|
||||||
|
)
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
Mix.shell().error("No user #{nickname}")
|
Mix.shell().error("No user #{nickname}")
|
||||||
|
@ -215,20 +218,23 @@ def run(["set", nickname | rest]) do
|
||||||
)
|
)
|
||||||
|
|
||||||
with %User{local: true} = user <- User.get_by_nickname(nickname) do
|
with %User{local: true} = user <- User.get_by_nickname(nickname) do
|
||||||
case Keyword.get(options, :moderator) do
|
user =
|
||||||
nil -> nil
|
case Keyword.get(options, :moderator) do
|
||||||
value -> set_moderator(user, value)
|
nil -> user
|
||||||
end
|
value -> set_moderator(user, value)
|
||||||
|
end
|
||||||
|
|
||||||
case Keyword.get(options, :locked) do
|
user =
|
||||||
nil -> nil
|
case Keyword.get(options, :locked) do
|
||||||
value -> set_locked(user, value)
|
nil -> user
|
||||||
end
|
value -> set_locked(user, value)
|
||||||
|
end
|
||||||
|
|
||||||
case Keyword.get(options, :admin) do
|
_user =
|
||||||
nil -> nil
|
case Keyword.get(options, :admin) do
|
||||||
value -> set_admin(user, value)
|
nil -> user
|
||||||
end
|
value -> set_admin(user, value)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
Mix.shell().error("No local user #{nickname}")
|
Mix.shell().error("No local user #{nickname}")
|
||||||
|
@ -265,6 +271,7 @@ defp set_moderator(user, value) 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
|
||||||
|
@ -276,7 +283,8 @@ defp set_admin(user, value) 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
|
||||||
|
@ -289,5 +297,6 @@ defp set_locked(user, value) 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