# HG changeset patch # User Goffi # Date 1657462509 -7200 # Node ID f599e0e364448508b0da8bea111005cce67a14e3 # Parent 3260401fdb987318e96b0a05883cd7912c2cb00d cli (pubsub): new `reference` subcommand to send references/mentions to pubsub items: rel 369 diff -r 3260401fdb98 -r f599e0e36444 sat_frontends/jp/cmd_pubsub.py --- a/sat_frontends/jp/cmd_pubsub.py Sun Jul 10 16:15:09 2022 +0200 +++ b/sat_frontends/jp/cmd_pubsub.py Sun Jul 10 16:15:09 2022 +0200 @@ -1610,6 +1610,53 @@ self.host.quit() +class Reference(base.CommandBase): + def __init__(self, host): + super().__init__( + host, + "reference", + use_pubsub=True, + pubsub_flags={C.NODE, C.SINGLE_ITEM}, + help=_("send a reference/mention to pubsub item"), + ) + + def add_parser_options(self): + self.parser.add_argument( + "-t", + "--type", + default="mention", + choices=("data", "mention"), + help=_("type of reference to send (DEFAULT: mention)"), + ) + self.parser.add_argument( + "recipient", + help=_("recipient of the reference") + ) + + async def start(self): + service = self.args.service or await self.host.get_profile_jid() + if self.args.item: + anchor = uri.buildXMPPUri( + "pubsub", path=service, node=self.args.node, item=self.args.item + ) + else: + anchor = uri.buildXMPPUri("pubsub", path=service, node=self.args.node) + + try: + await self.host.bridge.referenceSend( + self.args.recipient, + anchor, + self.args.type, + "", + self.profile, + ) + except Exception as e: + self.disp(f"can't send reference: {e}", error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + else: + self.host.quit() + + class Search(base.CommandBase): """This command do a search without using MAM @@ -2530,6 +2577,7 @@ Unsubscribe, Subscriptions, Affiliations, + Reference, Search, Transform, Hook,