projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Switch to Jason over Poison
[akkoma]
/
lib
/
mix
/
tasks
/
pleroma
/
user.ex
diff --git
a/lib/mix/tasks/pleroma/user.ex
b/lib/mix/tasks/pleroma/user.ex
index 80b07d1ac52e26e174c2b119c0caefb27d5beaaf..d130ff8c960e3ba919514490ffb2f22a2b7f35a2 100644
(file)
--- a/
lib/mix/tasks/pleroma/user.ex
+++ b/
lib/mix/tasks/pleroma/user.ex
@@
-30,7
+30,7
@@
defmodule Mix.Tasks.Pleroma.User do
mix pleroma.user invite [OPTION...]
Options:
mix pleroma.user invite [OPTION...]
Options:
- - `--expire_at DATE` - last day on which token is active (e.g. "2019-04-05")
+ - `--expire
s
_at DATE` - last day on which token is active (e.g. "2019-04-05")
- `--max_use NUMBER` - maximum numbers of token uses
## List generated invites
- `--max_use NUMBER` - maximum numbers of token uses
## List generated invites
@@
-126,7
+126,7
@@
defmodule Mix.Tasks.Pleroma.User do
proceed? = assume_yes? or Mix.shell().yes?("Continue?")
proceed? = assume_yes? or Mix.shell().yes?("Continue?")
-
unless not
proceed? do
+
if
proceed? do
Common.start_pleroma()
params = %{
Common.start_pleroma()
params = %{
@@
-138,7
+138,7
@@
defmodule Mix.Tasks.Pleroma.User do
bio: bio
}
bio: bio
}
- changeset = User.register_changeset(%User{}, params,
confirmed: tru
e)
+ changeset = User.register_changeset(%User{}, params,
need_confirmation: fals
e)
{:ok, _user} = User.register(changeset)
Mix.shell().info("User #{nickname} created")
{:ok, _user} = User.register(changeset)
Mix.shell().info("User #{nickname} created")
@@
-162,8
+162,8
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["rm", nickname]) do
Common.start_pleroma()
def run(["rm", nickname]) do
Common.start_pleroma()
- with %User{local: true} = user <- User.get_by_nickname(nickname) do
- User.
delete(
user)
+ with %User{local: true} = user <- User.get_
cached_
by_nickname(nickname) do
+ User.
perform(:delete,
user)
Mix.shell().info("User #{nickname} deleted.")
else
_ ->
Mix.shell().info("User #{nickname} deleted.")
else
_ ->
@@
-174,7
+174,7
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["toggle_activated", nickname]) do
Common.start_pleroma()
def run(["toggle_activated", nickname]) do
Common.start_pleroma()
- with %User{} = user <- User.get_by_nickname(nickname) do
+ with %User{} = user <- User.get_
cached_
by_nickname(nickname) do
{:ok, user} = User.deactivate(user, !user.info.deactivated)
Mix.shell().info(
{:ok, user} = User.deactivate(user, !user.info.deactivated)
Mix.shell().info(
@@
-189,7
+189,7
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["reset_password", nickname]) do
Common.start_pleroma()
def run(["reset_password", nickname]) do
Common.start_pleroma()
- with %User{local: true} = user <- User.get_by_nickname(nickname),
+ with %User{local: true} = user <- User.get_
cached_
by_nickname(nickname),
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
Mix.shell().info("Generated password reset token for #{user.nickname}")
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
Mix.shell().info("Generated password reset token for #{user.nickname}")
@@
-211,14
+211,14
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["unsubscribe", nickname]) do
Common.start_pleroma()
def run(["unsubscribe", nickname]) do
Common.start_pleroma()
- with %User{} = user <- User.get_by_nickname(nickname) do
+ with %User{} = user <- User.get_
cached_
by_nickname(nickname) do
Mix.shell().info("Deactivating #{user.nickname}")
User.deactivate(user)
{:ok, friends} = User.get_friends(user)
Enum.each(friends, fn friend ->
Mix.shell().info("Deactivating #{user.nickname}")
User.deactivate(user)
{:ok, friends} = User.get_friends(user)
Enum.each(friends, fn friend ->
- user = User.get_by_id(user.id)
+ user = User.get_
cached_
by_id(user.id)
Mix.shell().info("Unsubscribing #{friend.nickname} from #{user.nickname}")
User.unfollow(user, friend)
Mix.shell().info("Unsubscribing #{friend.nickname} from #{user.nickname}")
User.unfollow(user, friend)
@@
-226,7
+226,7
@@
defmodule Mix.Tasks.Pleroma.User do
:timer.sleep(500)
:timer.sleep(500)
- user = User.get_by_id(user.id)
+ user = User.get_
cached_
by_id(user.id)
if Enum.empty?(user.following) do
Mix.shell().info("Successfully unsubscribed all followers from #{user.nickname}")
if Enum.empty?(user.following) do
Mix.shell().info("Successfully unsubscribed all followers from #{user.nickname}")
@@
-250,7
+250,7
@@
defmodule Mix.Tasks.Pleroma.User do
]
)
]
)
- with %User{local: true} = user <- User.get_by_nickname(nickname) do
+ with %User{local: true} = user <- User.get_
cached_
by_nickname(nickname) do
user =
case Keyword.get(options, :moderator) do
nil -> user
user =
case Keyword.get(options, :moderator) do
nil -> user
@@
-277,7
+277,7
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["tag", nickname | tags]) do
Common.start_pleroma()
def run(["tag", nickname | tags]) do
Common.start_pleroma()
- with %User{} = user <- User.get_by_nickname(nickname) do
+ with %User{} = user <- User.get_
cached_
by_nickname(nickname) do
user = user |> User.tag(tags)
Mix.shell().info("Tags of #{user.nickname}: #{inspect(tags)}")
user = user |> User.tag(tags)
Mix.shell().info("Tags of #{user.nickname}: #{inspect(tags)}")
@@
-290,7
+290,7
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["untag", nickname | tags]) do
Common.start_pleroma()
def run(["untag", nickname | tags]) do
Common.start_pleroma()
- with %User{} = user <- User.get_by_nickname(nickname) do
+ with %User{} = user <- User.get_
cached_
by_nickname(nickname) do
user = user |> User.untag(tags)
Mix.shell().info("Tags of #{user.nickname}: #{inspect(tags)}")
user = user |> User.untag(tags)
Mix.shell().info("Tags of #{user.nickname}: #{inspect(tags)}")
@@
-304,14
+304,14
@@
defmodule Mix.Tasks.Pleroma.User do
{options, [], []} =
OptionParser.parse(rest,
strict: [
{options, [], []} =
OptionParser.parse(rest,
strict: [
- expire_at: :string,
+ expire
s
_at: :string,
max_use: :integer
]
)
options =
options
max_use: :integer
]
)
options =
options
- |> Keyword.update(:expire_at, {:ok, nil}, fn
+ |> Keyword.update(:expire
s
_at, {:ok, nil}, fn
nil -> {:ok, nil}
val -> Date.from_iso8601(val)
end)
nil -> {:ok, nil}
val -> Date.from_iso8601(val)
end)
@@
-319,8
+319,8
@@
defmodule Mix.Tasks.Pleroma.User do
Common.start_pleroma()
Common.start_pleroma()
- with {:ok, val} <- options[:expire_at],
- options = Map.put(options, :expire_at, val),
+ with {:ok, val} <- options[:expire
s
_at],
+ options = Map.put(options, :expire
s
_at, val),
{:ok, invite} <- UserInviteToken.create_invite(options) do
Mix.shell().info(
"Generated user invite token " <> String.replace(invite.invite_type, "_", " ")
{:ok, invite} <- UserInviteToken.create_invite(options) do
Mix.shell().info(
"Generated user invite token " <> String.replace(invite.invite_type, "_", " ")
@@
-348,8
+348,8
@@
defmodule Mix.Tasks.Pleroma.User do
UserInviteToken.list_invites()
|> Enum.each(fn invite ->
expire_info =
UserInviteToken.list_invites()
|> Enum.each(fn invite ->
expire_info =
- with expire
_at when not is_nil(expire_at) <- invite.expire
_at do
- " | Expire
at: #{Date.to_string(expire
_at)}"
+ with expire
s_at when not is_nil(expires_at) <- invite.expires
_at do
+ " | Expire
s at: #{Date.to_string(expires
_at)}"
end
using_info =
end
using_info =
@@
-379,8
+379,8
@@
defmodule Mix.Tasks.Pleroma.User do
def run(["delete_activities", nickname]) do
Common.start_pleroma()
def run(["delete_activities", nickname]) do
Common.start_pleroma()
- with %User{local: true} = user <- User.get_by_nickname(nickname) do
- User.delete_user_activities(user)
+ with %User{local: true} = user <- User.get_
cached_
by_nickname(nickname) do
+
{:ok, _} =
User.delete_user_activities(user)
Mix.shell().info("User #{nickname} statuses deleted.")
else
_ ->
Mix.shell().info("User #{nickname} statuses deleted.")
else
_ ->