Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
f239d31f
Unverified
Commit
f239d31f
authored
2 years ago
by
Claire
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add --email and --dry-run options to `tootctl accounts delete` (#22328)
parent
5917b46c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mastodon/accounts_cli.rb
+32
-9
32 additions, 9 deletions
lib/mastodon/accounts_cli.rb
with
32 additions
and
9 deletions
lib/mastodon/accounts_cli.rb
+
32
−
9
View file @
f239d31f
...
...
@@ -200,21 +200,44 @@ module Mastodon
end
end
desc
'delete USERNAME'
,
'Delete a user'
option
:email
option
:dry_run
,
type: :boolean
desc
'delete [USERNAME]'
,
'Delete a user'
long_desc
<<-
LONG_DESC
Remove a user account with a given USERNAME.
LONG_DESC
def
delete
(
username
)
account
=
Account
.
find_local
(
username
)
if
account
.
nil?
say
(
'No user with such username'
,
:red
)
With the --email option, the user is selected based on email
rather than username.
LONG_DESC
def
delete
(
username
=
nil
)
if
username
.
present?
&&
options
[
:email
].
present?
say
(
'Use username or --email, not both'
,
:red
)
exit
(
1
)
elsif
username
.
blank?
&&
options
[
:email
].
blank?
say
(
'No username provided'
,
:red
)
exit
(
1
)
end
say
(
"Deleting user with
#{
account
.
statuses_count
}
statuses, this might take a while..."
)
DeleteAccountService
.
new
.
call
(
account
,
reserve_email:
false
)
say
(
'OK'
,
:green
)
dry_run
=
options
[
:dry_run
]
?
' (DRY RUN)'
:
''
account
=
nil
if
username
.
present?
account
=
Account
.
find_local
(
username
)
if
account
.
nil?
say
(
'No user with such username'
,
:red
)
exit
(
1
)
end
else
account
=
Account
.
left_joins
(
:user
).
find_by
(
user:
{
email:
options
[
:email
]
})
if
account
.
nil?
say
(
'No user with such email'
,
:red
)
exit
(
1
)
end
end
say
(
"Deleting user with
#{
account
.
statuses_count
}
statuses, this might take a while...
#{
dry_run
}
"
)
DeleteAccountService
.
new
.
call
(
account
,
reserve_email:
false
)
unless
options
[
:dry_run
]
say
(
"OK
#{
dry_run
}
"
,
:green
)
end
option
:force
,
type: :boolean
,
aliases:
[
:f
],
description:
'Override public key check'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment