2018-12-23 21:05:55 +01:00
|
|
|
# Pleroma: A lightweight social networking server
|
2019-09-18 23:20:54 +02:00
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 21:05:55 +01:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-06-29 02:24:51 +02:00
|
|
|
defmodule Mix.Tasks.Pleroma.User do
|
|
|
|
use Mix.Task
|
2019-06-20 01:05:19 +02:00
|
|
|
import Mix.Pleroma
|
2019-10-20 12:42:42 +02:00
|
|
|
alias Ecto.Changeset
|
2019-02-09 16:16:26 +01:00
|
|
|
alias Pleroma.User
|
2019-04-06 11:58:22 +02:00
|
|
|
alias Pleroma.UserInviteToken
|
2018-06-29 02:24:51 +02:00
|
|
|
|
|
|
|
@shortdoc "Manages Pleroma users"
|
2019-10-03 12:59:49 +02:00
|
|
|
@moduledoc File.read!("docs/administration/CLI_tasks/user.md")
|
2018-06-29 02:24:51 +02:00
|
|
|
|
|
|
|
def run(["new", nickname, email | rest]) do
|
|
|
|
{options, [], []} =
|
|
|
|
OptionParser.parse(
|
|
|
|
rest,
|
|
|
|
strict: [
|
|
|
|
name: :string,
|
|
|
|
bio: :string,
|
|
|
|
password: :string,
|
2018-12-02 09:36:31 +01:00
|
|
|
moderator: :boolean,
|
2019-01-04 22:11:46 +01:00
|
|
|
admin: :boolean,
|
|
|
|
assume_yes: :boolean
|
|
|
|
],
|
|
|
|
aliases: [
|
|
|
|
y: :assume_yes
|
2018-06-29 02:24:51 +02:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
name = Keyword.get(options, :name, nickname)
|
|
|
|
bio = Keyword.get(options, :bio, "")
|
|
|
|
|
|
|
|
{password, generated_password?} =
|
|
|
|
case Keyword.get(options, :password) do
|
|
|
|
nil ->
|
|
|
|
{:crypto.strong_rand_bytes(16) |> Base.encode64(), true}
|
|
|
|
|
|
|
|
password ->
|
|
|
|
{password, false}
|
|
|
|
end
|
|
|
|
|
|
|
|
moderator? = Keyword.get(options, :moderator, false)
|
2018-12-02 09:36:31 +01:00
|
|
|
admin? = Keyword.get(options, :admin, false)
|
2019-01-04 22:11:46 +01:00
|
|
|
assume_yes? = Keyword.get(options, :assume_yes, false)
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("""
|
2018-06-29 02:24:51 +02:00
|
|
|
A user will be created with the following information:
|
|
|
|
- nickname: #{nickname}
|
|
|
|
- email: #{email}
|
|
|
|
- password: #{
|
|
|
|
if(generated_password?, do: "[generated; a reset link will be created]", else: password)
|
|
|
|
}
|
|
|
|
- name: #{name}
|
|
|
|
- bio: #{bio}
|
|
|
|
- moderator: #{if(moderator?, do: "true", else: "false")}
|
2018-12-02 09:36:31 +01:00
|
|
|
- admin: #{if(admin?, do: "true", else: "false")}
|
2018-06-29 02:24:51 +02:00
|
|
|
""")
|
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
proceed? = assume_yes? or shell_yes?("Continue?")
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-05-01 11:09:53 +02:00
|
|
|
if proceed? do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2018-12-16 17:25:31 +01:00
|
|
|
params = %{
|
|
|
|
nickname: nickname,
|
|
|
|
email: email,
|
|
|
|
password: password,
|
|
|
|
password_confirmation: password,
|
|
|
|
name: name,
|
|
|
|
bio: bio
|
|
|
|
}
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-05-13 20:35:45 +02:00
|
|
|
changeset = User.register_changeset(%User{}, params, need_confirmation: false)
|
2018-12-18 15:13:52 +01:00
|
|
|
{:ok, _user} = User.register(changeset)
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("User #{nickname} created")
|
2018-06-29 02:24:51 +02:00
|
|
|
|
|
|
|
if moderator? do
|
|
|
|
run(["set", nickname, "--moderator"])
|
|
|
|
end
|
|
|
|
|
2018-12-02 09:36:31 +01:00
|
|
|
if admin? do
|
|
|
|
run(["set", nickname, "--admin"])
|
|
|
|
end
|
|
|
|
|
2018-06-29 02:24:51 +02:00
|
|
|
if generated_password? do
|
|
|
|
run(["reset_password", nickname])
|
|
|
|
end
|
|
|
|
else
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("User will not be created.")
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(["rm", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
|
2019-05-06 18:45:22 +02:00
|
|
|
User.perform(:delete, user)
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("User #{nickname} deleted.")
|
2018-12-02 09:36:31 +01:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No local user #{nickname}")
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(["toggle_activated", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
2019-10-16 20:59:21 +02:00
|
|
|
{:ok, user} = User.deactivate(user, !user.deactivated)
|
2018-12-12 21:30:16 +01:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info(
|
2019-10-16 20:59:21 +02:00
|
|
|
"Activation status of #{nickname}: #{if(user.deactivated, do: "de", else: "")}activated"
|
2018-12-12 21:30:16 +01:00
|
|
|
)
|
2018-12-02 09:36:31 +01:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No user #{nickname}")
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(["reset_password", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-06-29 02:24:51 +02:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{local: true} = user <- User.get_cached_by_nickname(nickname),
|
2018-06-29 02:24:51 +02:00
|
|
|
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Generated password reset token for #{user.nickname}")
|
2018-06-29 02:24:51 +02:00
|
|
|
|
|
|
|
IO.puts(
|
|
|
|
"URL: #{
|
2019-06-24 21:01:56 +02:00
|
|
|
Pleroma.Web.Router.Helpers.reset_password_url(
|
2018-06-29 02:24:51 +02:00
|
|
|
Pleroma.Web.Endpoint,
|
2019-06-24 21:01:56 +02:00
|
|
|
:reset,
|
2018-06-29 02:24:51 +02:00
|
|
|
token.token
|
|
|
|
)
|
|
|
|
}"
|
|
|
|
)
|
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No local user #{nickname}")
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|
2018-12-02 18:05:59 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def run(["unsubscribe", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-12-02 18:05:59 +01:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Deactivating #{user.nickname}")
|
2018-12-02 18:05:59 +01:00
|
|
|
User.deactivate(user)
|
|
|
|
|
2019-09-24 09:16:52 +02:00
|
|
|
user
|
|
|
|
|> User.get_friends()
|
|
|
|
|> Enum.each(fn friend ->
|
2019-04-22 09:20:43 +02:00
|
|
|
user = User.get_cached_by_id(user.id)
|
2018-12-02 18:05:59 +01:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Unsubscribing #{friend.nickname} from #{user.nickname}")
|
2018-12-02 18:05:59 +01:00
|
|
|
User.unfollow(user, friend)
|
|
|
|
end)
|
|
|
|
|
|
|
|
:timer.sleep(500)
|
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
user = User.get_cached_by_id(user.id)
|
2018-12-02 18:05:59 +01:00
|
|
|
|
2019-10-10 21:35:32 +02:00
|
|
|
if Enum.empty?(User.get_friends(user)) do
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Successfully unsubscribed all followers from #{user.nickname}")
|
2018-12-02 18:05:59 +01:00
|
|
|
end
|
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No user #{nickname}")
|
2018-12-02 18:05:59 +01:00
|
|
|
end
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|
|
|
|
|
2019-07-19 21:11:04 +02:00
|
|
|
def run(["unsubscribe_all_from_instance", instance]) do
|
|
|
|
start_pleroma()
|
|
|
|
|
|
|
|
Pleroma.User.Query.build(%{nickname: "@#{instance}"})
|
|
|
|
|> Pleroma.RepoStreamer.chunk_stream(500)
|
|
|
|
|> Stream.each(fn users ->
|
|
|
|
users
|
|
|
|
|> Enum.each(fn user ->
|
|
|
|
run(["unsubscribe", user.nickname])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|> Stream.run()
|
|
|
|
end
|
|
|
|
|
2018-06-29 02:24:51 +02:00
|
|
|
def run(["set", nickname | rest]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-12-04 19:00:45 +01:00
|
|
|
|
2018-06-29 02:24:51 +02:00
|
|
|
{options, [], []} =
|
|
|
|
OptionParser.parse(
|
|
|
|
rest,
|
|
|
|
strict: [
|
|
|
|
moderator: :boolean,
|
2018-12-01 16:55:52 +01:00
|
|
|
admin: :boolean,
|
2018-06-29 02:24:51 +02:00
|
|
|
locked: :boolean
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
|
2018-12-12 21:32:32 +01:00
|
|
|
user =
|
|
|
|
case Keyword.get(options, :moderator) do
|
|
|
|
nil -> user
|
|
|
|
value -> set_moderator(user, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
user =
|
|
|
|
case Keyword.get(options, :locked) do
|
|
|
|
nil -> user
|
|
|
|
value -> set_locked(user, value)
|
|
|
|
end
|
|
|
|
|
|
|
|
_user =
|
|
|
|
case Keyword.get(options, :admin) do
|
|
|
|
nil -> user
|
|
|
|
value -> set_admin(user, value)
|
|
|
|
end
|
2018-06-29 02:24:51 +02:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No local user #{nickname}")
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-04 03:33:11 +01:00
|
|
|
def run(["tag", nickname | tags]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-02-04 03:33:11 +01:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
2019-02-04 03:33:11 +01:00
|
|
|
user = user |> User.tag(tags)
|
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Tags of #{user.nickname}: #{inspect(tags)}")
|
2019-02-04 03:33:11 +01:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("Could not change user tags for #{nickname}")
|
2019-02-04 03:33:11 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run(["untag", nickname | tags]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-02-04 03:33:11 +01:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
2019-02-04 03:33:11 +01:00
|
|
|
user = user |> User.untag(tags)
|
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Tags of #{user.nickname}: #{inspect(tags)}")
|
2019-02-04 03:33:11 +01:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("Could not change user tags for #{nickname}")
|
2019-02-04 03:33:11 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-06 11:58:22 +02:00
|
|
|
def run(["invite" | rest]) do
|
|
|
|
{options, [], []} =
|
|
|
|
OptionParser.parse(rest,
|
|
|
|
strict: [
|
2019-04-08 11:01:28 +02:00
|
|
|
expires_at: :string,
|
2019-04-06 11:58:22 +02:00
|
|
|
max_use: :integer
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2019-04-06 17:38:35 +02:00
|
|
|
options =
|
|
|
|
options
|
2019-04-08 11:01:28 +02:00
|
|
|
|> Keyword.update(:expires_at, {:ok, nil}, fn
|
2019-04-06 17:38:35 +02:00
|
|
|
nil -> {:ok, nil}
|
|
|
|
val -> Date.from_iso8601(val)
|
|
|
|
end)
|
|
|
|
|> Enum.into(%{})
|
2019-04-06 11:58:22 +02:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2018-12-09 10:12:48 +01:00
|
|
|
|
2019-04-08 11:01:28 +02:00
|
|
|
with {:ok, val} <- options[:expires_at],
|
|
|
|
options = Map.put(options, :expires_at, val),
|
2019-04-06 17:38:35 +02:00
|
|
|
{:ok, invite} <- UserInviteToken.create_invite(options) do
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Generated user invite token " <> String.replace(invite.invite_type, "_", " "))
|
2018-12-09 10:12:48 +01:00
|
|
|
|
|
|
|
url =
|
|
|
|
Pleroma.Web.Router.Helpers.redirect_url(
|
|
|
|
Pleroma.Web.Endpoint,
|
|
|
|
:registration_page,
|
2019-04-06 15:24:22 +02:00
|
|
|
invite.token
|
2018-12-09 10:12:48 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
IO.puts(url)
|
|
|
|
else
|
2019-04-06 17:38:35 +02:00
|
|
|
error ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("Could not create invite token: #{inspect(error)}")
|
2018-12-09 10:12:48 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-06 17:38:35 +02:00
|
|
|
def run(["invites"]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-04-06 11:58:22 +02:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Invites list:")
|
2019-04-06 11:58:22 +02:00
|
|
|
|
|
|
|
UserInviteToken.list_invites()
|
|
|
|
|> Enum.each(fn invite ->
|
2019-04-06 17:38:35 +02:00
|
|
|
expire_info =
|
2019-04-08 11:01:28 +02:00
|
|
|
with expires_at when not is_nil(expires_at) <- invite.expires_at do
|
|
|
|
" | Expires at: #{Date.to_string(expires_at)}"
|
2019-04-06 11:58:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
using_info =
|
2019-04-06 17:38:35 +02:00
|
|
|
with max_use when not is_nil(max_use) <- invite.max_use do
|
|
|
|
" | Max use: #{max_use} Left use: #{max_use - invite.uses}"
|
2019-04-06 11:58:22 +02:00
|
|
|
end
|
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info(
|
2019-04-06 17:38:35 +02:00
|
|
|
"ID: #{invite.id} | Token: #{invite.token} | Token type: #{invite.invite_type} | Used: #{
|
2019-04-06 11:58:22 +02:00
|
|
|
invite.used
|
2019-04-06 17:38:35 +02:00
|
|
|
}#{expire_info}#{using_info}"
|
2019-04-06 11:58:22 +02:00
|
|
|
)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2019-04-06 17:38:35 +02:00
|
|
|
def run(["revoke_invite", token]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-04-06 11:58:22 +02:00
|
|
|
|
2019-04-06 17:38:35 +02:00
|
|
|
with {:ok, invite} <- UserInviteToken.find_by_token(token),
|
|
|
|
{:ok, _} <- UserInviteToken.update_invite(invite, %{used: true}) do
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("Invite for token #{token} was revoked.")
|
2019-04-06 11:58:22 +02:00
|
|
|
else
|
2019-06-20 01:05:19 +02:00
|
|
|
_ -> shell_error("No invite found with token #{token}")
|
2019-04-06 11:58:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-12 16:04:08 +01:00
|
|
|
def run(["delete_activities", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-03-12 16:04:08 +01:00
|
|
|
|
2019-04-22 09:20:43 +02:00
|
|
|
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
|
2019-09-24 09:16:52 +02:00
|
|
|
User.delete_user_activities(user)
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("User #{nickname} statuses deleted.")
|
2019-03-12 16:04:08 +01:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No local user #{nickname}")
|
2019-03-12 16:04:08 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-16 15:23:41 +02:00
|
|
|
def run(["toggle_confirmed", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-05-16 15:23:41 +02:00
|
|
|
|
|
|
|
with %User{} = user <- User.get_cached_by_nickname(nickname) do
|
|
|
|
{:ok, user} = User.toggle_confirmation(user)
|
|
|
|
|
2019-10-16 20:59:21 +02:00
|
|
|
message = if user.confirmation_pending, do: "needs", else: "doesn't need"
|
2019-05-16 15:23:41 +02:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("#{nickname} #{message} confirmation.")
|
2019-05-16 15:23:41 +02:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No local user #{nickname}")
|
2019-05-16 15:23:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-19 21:29:36 +02:00
|
|
|
def run(["sign_out", nickname]) do
|
2019-06-20 01:05:19 +02:00
|
|
|
start_pleroma()
|
2019-06-19 21:29:36 +02:00
|
|
|
|
2019-06-19 21:39:53 +02:00
|
|
|
with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
|
2019-12-05 22:25:44 +01:00
|
|
|
User.global_sign_out(user)
|
2019-06-19 21:29:36 +02:00
|
|
|
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_info("#{nickname} signed out from all apps.")
|
2019-06-19 21:29:36 +02:00
|
|
|
else
|
|
|
|
_ ->
|
2019-06-20 01:05:19 +02:00
|
|
|
shell_error("No local user #{nickname}")
|
2019-06-19 21:29:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-17 21:58:30 +01:00
|
|
|
def run(["list"]) do
|
|
|
|
start_pleroma()
|
|
|
|
|
|
|
|
Pleroma.User.Query.build(%{local: true})
|
|
|
|
|> Pleroma.RepoStreamer.chunk_stream(500)
|
|
|
|
|> Stream.each(fn users ->
|
|
|
|
users
|
|
|
|
|> Enum.each(fn user ->
|
|
|
|
shell_info(
|
2019-12-02 12:11:45 +01:00
|
|
|
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
|
|
|
user.locked
|
|
|
|
}, deactivated: #{user.deactivated}"
|
2019-11-17 21:58:30 +01:00
|
|
|
)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|> Stream.run()
|
|
|
|
end
|
|
|
|
|
2018-12-04 19:00:45 +01:00
|
|
|
defp set_moderator(user, value) do
|
2019-10-20 12:42:42 +02:00
|
|
|
{:ok, user} =
|
|
|
|
user
|
|
|
|
|> Changeset.change(%{is_moderator: value})
|
|
|
|
|> User.update_and_set_cache()
|
2018-12-05 17:58:26 +01:00
|
|
|
|
2019-10-16 20:59:21 +02:00
|
|
|
shell_info("Moderator status of #{user.nickname}: #{user.is_moderator}")
|
2018-12-12 21:32:32 +01:00
|
|
|
user
|
2018-12-04 19:00:45 +01:00
|
|
|
end
|
2018-12-01 16:55:52 +01:00
|
|
|
|
2018-12-04 19:00:45 +01:00
|
|
|
defp set_admin(user, value) do
|
2019-12-05 22:25:44 +01:00
|
|
|
{:ok, user} = User.admin_api_update(user, %{is_admin: value})
|
2018-12-04 19:00:45 +01:00
|
|
|
|
2019-10-16 20:59:21 +02:00
|
|
|
shell_info("Admin status of #{user.nickname}: #{user.is_admin}")
|
2018-12-12 21:32:32 +01:00
|
|
|
user
|
2018-12-04 19:00:45 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
defp set_locked(user, value) do
|
2019-10-20 12:42:42 +02:00
|
|
|
{:ok, user} =
|
|
|
|
user
|
|
|
|
|> Changeset.change(%{locked: value})
|
|
|
|
|> User.update_and_set_cache()
|
2018-12-04 19:00:45 +01:00
|
|
|
|
2019-10-16 20:59:21 +02:00
|
|
|
shell_info("Locked status of #{user.nickname}: #{user.locked}")
|
2018-12-12 21:32:32 +01:00
|
|
|
user
|
2018-12-01 16:55:52 +01:00
|
|
|
end
|
2018-06-29 02:24:51 +02:00
|
|
|
end
|