From a44acbc1bbd014b223626f798ceb871834a1fe45 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 17 Jun 2022 14:15:23 +0200 Subject: [PATCH] cli (message/retract): message retractation command: rel 367 --- sat_frontends/jp/cmd_message.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sat_frontends/jp/cmd_message.py b/sat_frontends/jp/cmd_message.py index 3276b238..75c57964 100644 --- a/sat_frontends/jp/cmd_message.py +++ b/sat_frontends/jp/cmd_message.py @@ -187,6 +187,33 @@ class Send(base.CommandBase): await self.sendStdin(jid_) +class Retract(base.CommandBase): + + def __init__(self, host): + super().__init__(host, "retract", help=_("retract a message")) + + def add_parser_options(self): + self.parser.add_argument( + "message_id", + help=_("ID of the message (internal ID)") + ) + + async def start(self): + try: + await self.host.bridge.messRetract( + self.args.message_id, + self.profile + ) + except Exception as e: + self.disp(f"can't retract message: {e}", error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + else: + self.disp( + "message retraction has been requested, please note that this is a " + "request which can't be enforced (see documentation for details).") + self.host.quit(C.EXIT_OK) + + class MAM(base.CommandBase): def __init__(self, host): @@ -269,7 +296,7 @@ class MAM(base.CommandBase): class Message(base.CommandBase): - subcommands = (Send, MAM) + subcommands = (Send, Retract, MAM) def __init__(self, host): super(Message, self).__init__(