mirror of
https://github.com/ihabunek/toot
synced 2024-12-23 15:37:47 +01:00
Added toot list_add_account command
This commit is contained in:
parent
bfdd84870f
commit
80f05e8147
12
toot/api.py
12
toot/api.py
@ -549,3 +549,15 @@ def create_list(app, user, title, replies_policy):
|
||||
|
||||
def delete_list(app, user, id):
|
||||
return http.delete(app, user, f"/api/v1/lists/{id}")
|
||||
|
||||
|
||||
def add_accounts_to_list(app, user, list_id, account_ids):
|
||||
url = f"/api/v1/lists/{list_id}/accounts"
|
||||
json = {'account_ids': account_ids}
|
||||
return http.post(app, user, url, json=json).json()
|
||||
|
||||
|
||||
def remove_accounts_from_list(app, user, list_id, account_ids):
|
||||
url = f"/api/v1/lists/{list_id}/accounts"
|
||||
json = {'account_ids[]': account_ids}
|
||||
return http.delete(app, user, url, json=json)
|
||||
|
@ -446,6 +446,22 @@ def list_delete(app, user, args):
|
||||
print_out(f"<green>✓ List \"{args.title}\"</green> <red>deleted.</red>")
|
||||
|
||||
|
||||
def list_add_account(app, user, args):
|
||||
list_id = args.id if args.id else api.find_list_id(app, user, args.title)
|
||||
if not list_id:
|
||||
print_out("<red>List not found</red>")
|
||||
return
|
||||
account = find_account(app, user, args.account)
|
||||
if not account:
|
||||
print_out("<red>Account not found</red>")
|
||||
return
|
||||
try:
|
||||
api.add_accounts_to_list(app, user, list_id, [account['id']])
|
||||
print_out(f"<green>✓ Added account \"{account['acct']}\"</green>")
|
||||
except Exception as ex:
|
||||
print_out(f"<red>{ex}</red>")
|
||||
|
||||
|
||||
def mute(app, user, args):
|
||||
account = find_account(app, user, args.account)
|
||||
api.mute(app, user, account['id'])
|
||||
|
@ -779,6 +779,25 @@ LIST_COMMANDS = [
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="list_add_account",
|
||||
description="Add account to list",
|
||||
arguments=[
|
||||
(["--id"], {
|
||||
"type": str,
|
||||
"help": "ID of the list"
|
||||
}),
|
||||
(["--title"], {
|
||||
"type": str,
|
||||
"help": "title of the list"
|
||||
}),
|
||||
(["--account"], {
|
||||
"type": str,
|
||||
"help": "Account to add"
|
||||
}),
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
COMMAND_GROUPS = [
|
||||
("Authentication", AUTH_COMMANDS),
|
||||
|
Loading…
Reference in New Issue
Block a user