# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1661958423 -7200
# Node ID 1ab5fb468a4163f09113401de6b8353be8edd88d
# Parent  aa7197b67c26f551b17ac50d8966653ec3715581
cli (pubsub/attachment/set): update reactions handling:

- reactions data has been updated following changes in XEP-0470 plugin
- it is now possible to remove a reaction using uppercase `-R`
- short option from `--replace` has been removed, as it is more handy to use `-R` to
  remove reactions

rel 371

diff -r aa7197b67c26 -r 1ab5fb468a41 sat_frontends/jp/cmd_pubsub.py
--- a/sat_frontends/jp/cmd_pubsub.py	Wed Aug 31 17:07:03 2022 +0200
+++ b/sat_frontends/jp/cmd_pubsub.py	Wed Aug 31 17:07:03 2022 +0200
@@ -2473,7 +2473,6 @@
 
     def add_parser_options(self):
         self.parser.add_argument(
-            "-R",
             "--replace",
             action="store_true",
             help=_(
@@ -2492,9 +2491,16 @@
         self.parser.add_argument(
             "-r",
             "--reactions",
-            # FIXME: to be replace by "extend" when we stop supporting python 3.7
+            # FIXME: to be replaced by "extend" when we stop supporting python 3.7
             action="append",
-            help=_("add emojis to react to an item")
+            help=_("emojis to add to react to an item")
+        )
+        self.parser.add_argument(
+            "-R",
+            "--reactions-remove",
+            # FIXME: to be replaced by "extend" when we stop supporting python 3.7
+            action="append",
+            help=_("emojis to remove from reactions to an item")
         )
 
     async def start(self):
@@ -2510,11 +2516,16 @@
                 self.args.noticed = C.BOOL_TRUE
             mb_data["extra"]["noticed"] = C.bool(self.args.noticed)
 
-        if self.args.reactions is not None:
-            mb_data["extra"]["reaction"] = {
-                "operation": operation,
-                "reactions": [r for emojis in self.args.reactions for r in emojis]
+        if self.args.reactions or self.args.reactions_remove:
+            reactions = mb_data["extra"]["reactions"] = {
+                "operation": operation
             }
+            if self.args.replace:
+                reactions["reactions"] = self.args.reactions
+            else:
+                reactions["add"] = self.args.reactions
+                reactions["remove"] = self.args.reactions_remove
+
 
         if not mb_data["extra"]:
             self.parser.error(_("At leat one attachment must be specified."))