cli (pubsub): new reference subcommand to send references/mentions to pubsub items:
rel 369
This commit is contained in:
parent
e84436adfd
commit
eb4c766489
1 changed files with 48 additions and 0 deletions
|
|
@ -1610,6 +1610,53 @@ class Affiliations(base.CommandBase):
|
|||
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 @@ class Pubsub(base.CommandBase):
|
|||
Unsubscribe,
|
||||
Subscriptions,
|
||||
Affiliations,
|
||||
Reference,
|
||||
Search,
|
||||
Transform,
|
||||
Hook,
|
||||
|
|
|
|||
Loading…
Reference in a new issue