From 0b6d4a9e871d630ed9e29fad694605634a735c3d Mon Sep 17 00:00:00 2001 From: alex wennerberg Date: Tue, 27 Jul 2021 19:26:51 -0700 Subject: [PATCH] Add mentions-only parameter to notifications command --- toot/api.py | 5 +++-- toot/commands.py | 7 ++++++- toot/console.py | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/toot/api.py b/toot/api.py index 0a528cb..f268de2 100644 --- a/toot/api.py +++ b/toot/api.py @@ -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): diff --git a/toot/commands.py b/toot/commands.py index 1daee12..e4f2020 100644 --- a/toot/commands.py +++ b/toot/commands.py @@ -316,7 +316,12 @@ def notifications(app, user, args): print_out("Cleared notifications") 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("No notification") return diff --git a/toot/console.py b/toot/console.py index 9cf6b06..3e95baa 100644 --- a/toot/console.py +++ b/toot/console.py @@ -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, ),