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
This commit is contained in:
Goffi 2022-08-31 17:07:03 +02:00
commit 68fb304032

View file

@ -2473,7 +2473,6 @@ class AttachmentSet(base.CommandBase):
def add_parser_options(self):
self.parser.add_argument(
"-R",
"--replace",
action="store_true",
help=_(
@ -2492,9 +2491,16 @@ class AttachmentSet(base.CommandBase):
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 @@ class AttachmentSet(base.CommandBase):
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."))