Mercurial > libervia-backend
changeset 3889:1ab5fb468a41
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 31 Aug 2022 17:07:03 +0200 |
parents | aa7197b67c26 |
children | c129234a5d0b |
files | sat_frontends/jp/cmd_pubsub.py |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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."))