Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "muted" & "blocked" commands #390

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions toot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ def unmute(app, user, account):
return _account_action(app, user, account, 'unmute')


def muted(app, user):
return _get_response_list(app, user, "/api/v1/mutes")


def block(app, user, account):
return _account_action(app, user, account, 'block')

Expand All @@ -529,6 +533,10 @@ def unblock(app, user, account):
return _account_action(app, user, account, 'unblock')


def blocked(app, user):
return _get_response_list(app, user, "/api/v1/blocks")


def verify_credentials(app, user):
return http.get(app, user, '/api/v1/accounts/verify_credentials').json()

Expand Down
10 changes: 10 additions & 0 deletions toot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,11 @@ def unmute(app, user, args):
print_out("<green>✓ {} is no longer muted</green>".format(args.account))


def muted(app, user, args):
response = api.muted(app, user)
print_acct_list(response)


def block(app, user, args):
account = api.find_account(app, user, args.account)
api.block(app, user, account['id'])
Expand All @@ -505,6 +510,11 @@ def unblock(app, user, args):
print_out("<green>✓ {} is no longer blocked</green>".format(args.account))


def blocked(app, user, args):
response = api.blocked(app, user)
print_acct_list(response)


def whoami(app, user, args):
account = api.verify_credentials(app, user)
print_account(account)
Expand Down
12 changes: 12 additions & 0 deletions toot/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,12 @@ def editor(value):
],
require_auth=True,
),
Command(
name="muted",
description="List accounts the given account muted",
arguments=[],
require_auth=True,
),
Command(
name="block",
description="Block an account",
Expand All @@ -720,6 +726,12 @@ def editor(value):
],
require_auth=True,
),
Command(
name="blocked",
description="List accounts the given account muted",
arguments=[],
require_auth=True,
),
]

TAG_COMMANDS = [
Expand Down