Skip to content

Commit

Permalink
Merge pull request #390 from fobser/muted_blocked_commands
Browse files Browse the repository at this point in the history
Add "muted" & "blocked" commands
  • Loading branch information
ihabunek committed Jul 24, 2023
2 parents 4f62f41 + acc80f6 commit 09aa4e8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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

0 comments on commit 09aa4e8

Please sign in to comment.