Remove functionality that is broken in the API

This commit is contained in:
Midgard 2021-08-07 19:23:14 +02:00
parent 2953c05292
commit c16a089c42
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -328,20 +328,13 @@ def status(mm_api: mattermost.MMApi, cmdline_args):
if not cmdline_args.status:
raise ValueError("No status selected")
until = None
if cmdline_args.until:
if cmdline_args.status != "dnd":
raise ValueError("--until works only with --dnd due to an API limitation")
until = parse_datetime_to_utc(cmdline_args.until)
# This API endpoint requires the user ID to be passed explicitly in the request body,
# duplicating the info in the URL. But "me" does not suffice here.
my_user_id = mm_api.get_user()["id"]
mm_api._put(f"/v4/users/me/status", data={
"user_id": my_user_id,
"status": cmdline_args.status,
"dnd_end_time": int(until.timestamp()) if until else None
"status": cmdline_args.status
})
@ -472,7 +465,6 @@ Hint: JSON output can be filtered on the command line with jq(1).
parser_status.add_argument("--away", dest="status", action="store_const", const="away", help="Set status to away")
parser_status.add_argument("--dnd", dest="status", action="store_const", const="dnd", help="Set status to 'do not disturb'")
parser_status.add_argument("--offline", dest="status", action="store_const", const="offline", help="Set status to offline")
parser_status.add_argument("--until", help="Datetime of when to clear the status (only for --dnd)")
parser_customstatus = subparsers.add_parser("customstatus",
help="update custom user status (emoji and message)")