Skip to content

Commit

Permalink
Add mentions-only parameter to notifications command
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwennerberg authored and ihabunek committed Jul 29, 2021
1 parent 8f0bf27 commit 0b6d4a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions toot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 6 additions & 1 deletion toot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions toot/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ def editor(value):
"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,
),
Expand Down

0 comments on commit 0b6d4a9

Please sign in to comment.