Add mentions-only parameter to notifications command

This commit is contained in:
alex wennerberg 2021-07-27 19:26:51 -07:00 committed by Ivan Habunek
parent 8f0bf27e5e
commit 0b6d4a9e87
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
3 changed files with 14 additions and 3 deletions

View File

@ -268,8 +268,9 @@ def single_status(app, user, status_id):
return http.get(app, user, url).json()
def get_notifications(app, user):
return http.get(app, user, '/api/v1/notifications').json()
def get_notifications(app, user, exclude_types=[], limit=20):
params={"exclude_types[]": exclude_types, "limit": limit}
return http.get(app, user, '/api/v1/notifications', params).json()
def clear_notifications(app, user):

View File

@ -316,7 +316,12 @@ def notifications(app, user, args):
print_out("<green>Cleared notifications</green>")
return
notifications = api.get_notifications(app, user)
exclude = []
if args.mentions:
# Filter everything except mentions
# https://docs.joinmastodon.org/methods/notifications/
exclude = ["follow", "favourite", "reblog", "poll", "follow_request"]
notifications = api.get_notifications(app, user, exclude_types=exclude)
if not notifications:
print_out("<yellow>No notification</yellow>")
return

View File

@ -229,6 +229,11 @@ READ_COMMANDS = [
"default": False,
"help": "Reverse the order of the shown notifications (newest on top)",
}),
(["-m", "--mentions"], {
"action": "store_true",
"default": False,
"help": "Only print mentions",
})
],
require_auth=True,
),