mirror of
https://github.com/ihabunek/toot
synced 2025-02-03 12:47:32 +01:00
Add --type and --exclude-type options to notification
This commit is contained in:
parent
4b88b86b6f
commit
20eec3ba63
@ -23,6 +23,18 @@ T = t.TypeVar("T")
|
||||
PRIVACY_CHOICES = ["public", "unlisted", "private"]
|
||||
VISIBILITY_CHOICES = ["public", "unlisted", "private", "direct"]
|
||||
IMAGE_FORMAT_CHOICES = ["block", "iterm", "kitty"]
|
||||
NOTIFICATION_TYPE_CHOICES = [
|
||||
"mention",
|
||||
"status",
|
||||
"reblog",
|
||||
"follow",
|
||||
"follow_request",
|
||||
"favourite",
|
||||
"poll",
|
||||
"update",
|
||||
"admin.sign_up",
|
||||
"admin.report",
|
||||
]
|
||||
TUI_COLORS = {
|
||||
"1": 1,
|
||||
"16": 16,
|
||||
|
@ -2,8 +2,8 @@ import sys
|
||||
import click
|
||||
|
||||
from toot import api
|
||||
from toot.cli import InstanceParamType, cli, get_context, pass_context, Context, json_option
|
||||
from typing import Optional
|
||||
from toot.cli import NOTIFICATION_TYPE_CHOICES, InstanceParamType, cli, get_context, pass_context, Context, json_option
|
||||
from typing import Optional, Tuple
|
||||
from toot.cli.validators import validate_instance
|
||||
|
||||
from toot.entities import Notification, Status, from_dict
|
||||
@ -119,9 +119,21 @@ def bookmarks(
|
||||
"--reverse", "-r", is_flag=True,
|
||||
help="Reverse the order of the shown notifications (newest on top)"
|
||||
)
|
||||
@click.option(
|
||||
"--type", "-t", "types",
|
||||
type=click.Choice(NOTIFICATION_TYPE_CHOICES),
|
||||
multiple=True,
|
||||
help="Types to include in the result, can be specified multiple times"
|
||||
)
|
||||
@click.option(
|
||||
"--exclude-type", "-e", "exclude_types",
|
||||
type=click.Choice(NOTIFICATION_TYPE_CHOICES),
|
||||
multiple=True,
|
||||
help="Types to exclude in the result, can be specified multiple times"
|
||||
)
|
||||
@click.option(
|
||||
"--mentions", "-m", is_flag=True,
|
||||
help="Show only mentions"
|
||||
help="Show only mentions (same as --type mention, overrides --type, DEPRECATED)"
|
||||
)
|
||||
@json_option
|
||||
@pass_context
|
||||
@ -130,6 +142,8 @@ def notifications(
|
||||
clear: bool,
|
||||
reverse: bool,
|
||||
mentions: bool,
|
||||
types: Tuple[str],
|
||||
exclude_types: Tuple[str],
|
||||
json: bool,
|
||||
):
|
||||
"""Show notifications"""
|
||||
@ -138,13 +152,11 @@ def notifications(
|
||||
click.secho("✓ Notifications cleared", fg="green")
|
||||
return
|
||||
|
||||
exclude = []
|
||||
if mentions:
|
||||
# Filter everything except mentions
|
||||
# https://docs.joinmastodon.org/methods/notifications/
|
||||
exclude = ["follow", "favourite", "reblog", "poll", "follow_request"]
|
||||
print_warning("`--mentions` option is deprecated in favour of `--type mentions`")
|
||||
types = ("mention",)
|
||||
|
||||
response = api.get_notifications(ctx.app, ctx.user, exclude_types=exclude)
|
||||
response = api.get_notifications(ctx.app, ctx.user, types=types, exclude_types=exclude_types)
|
||||
|
||||
if json:
|
||||
if reverse:
|
||||
|
Loading…
x
Reference in New Issue
Block a user