Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_pubsub.py @ 3758:b7cef1b24f83
plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
- update psSubscriptionsGet to use serialised return value
- implement XEP-0376 Pubsub Account Management
- implement XEP-0465 Public Pubsub Subscriptions
- CLI `pubsub` commands updated accordingly, and added `--public` flags to `subscribe`,
`Subscriptions` and `node Subscriptions get`
⚠ `XEP-0465` is speculative, the XEP has been accepted by council but not published yet.
As is should be the next one, and current latest one is `XEP-0464`, `XEP-0465` has been
anticipated.
rel 365
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 13 May 2022 18:38:05 +0200 |
parents | 5bda9d2e8b35 |
children | f599e0e36444 |
comparison
equal
deleted
inserted
replaced
3757:5bda9d2e8b35 | 3758:b7cef1b24f83 |
---|---|
495 pubsub_flags={C.NODE}, | 495 pubsub_flags={C.NODE}, |
496 help=_("retrieve node subscriptions (for node owner)"), | 496 help=_("retrieve node subscriptions (for node owner)"), |
497 ) | 497 ) |
498 | 498 |
499 def add_parser_options(self): | 499 def add_parser_options(self): |
500 pass | 500 self.parser.add_argument( |
501 | 501 "--public", |
502 async def start(self): | 502 action="store_true", |
503 try: | 503 help=_("get public subscriptions"), |
504 subscriptions = await self.host.bridge.psNodeSubscriptionsGet( | 504 ) |
505 | |
506 async def start(self): | |
507 if self.args.public: | |
508 method = self.host.bridge.psPublicNodeSubscriptionsGet | |
509 else: | |
510 method = self.host.bridge.psNodeSubscriptionsGet | |
511 try: | |
512 subscriptions = await method( | |
505 self.args.service, | 513 self.args.service, |
506 self.args.node, | 514 self.args.node, |
507 self.profile, | 515 self.profile, |
508 ) | 516 ) |
509 except Exception as e: | 517 except Exception as e: |
1462 use_verbose=True, | 1470 use_verbose=True, |
1463 help=_("subscribe to a node"), | 1471 help=_("subscribe to a node"), |
1464 ) | 1472 ) |
1465 | 1473 |
1466 def add_parser_options(self): | 1474 def add_parser_options(self): |
1467 pass | 1475 self.parser.add_argument( |
1468 | 1476 "--public", |
1469 async def start(self): | 1477 action="store_true", |
1478 help=_("make the registration visible for everybody"), | |
1479 ) | |
1480 | |
1481 async def start(self): | |
1482 options = {} | |
1483 if self.args.public: | |
1484 namespaces = await self.host.bridge.namespacesGet() | |
1485 try: | |
1486 ns_pps = namespaces["pps"] | |
1487 except KeyError: | |
1488 self.disp( | |
1489 "Pubsub Public Subscription plugin is not loaded, can't use --public " | |
1490 "option, subscription stopped", error=True | |
1491 ) | |
1492 self.host.quit(C.EXIT_MISSING_FEATURE) | |
1493 else: | |
1494 options[f"{{{ns_pps}}}public"] = True | |
1470 try: | 1495 try: |
1471 sub_id = await self.host.bridge.psSubscribe( | 1496 sub_id = await self.host.bridge.psSubscribe( |
1472 self.args.service, | 1497 self.args.service, |
1473 self.args.node, | 1498 self.args.node, |
1474 data_format.serialise(options), | 1499 data_format.serialise(options), |
1526 use_pubsub=True, | 1551 use_pubsub=True, |
1527 help=_("retrieve all subscriptions on a service"), | 1552 help=_("retrieve all subscriptions on a service"), |
1528 ) | 1553 ) |
1529 | 1554 |
1530 def add_parser_options(self): | 1555 def add_parser_options(self): |
1531 pass | 1556 self.parser.add_argument( |
1532 | 1557 "--public", |
1533 async def start(self): | 1558 action="store_true", |
1534 try: | 1559 help=_("get public subscriptions"), |
1535 subscriptions = await self.host.bridge.psSubscriptionsGet( | 1560 ) |
1536 self.args.service, | 1561 |
1537 self.args.node, | 1562 async def start(self): |
1538 self.profile, | 1563 if self.args.public: |
1564 method = self.host.bridge.psPublicSubscriptionsGet | |
1565 else: | |
1566 method = self.host.bridge.psSubscriptionsGet | |
1567 try: | |
1568 subscriptions = data_format.deserialise( | |
1569 await method( | |
1570 self.args.service, | |
1571 self.args.node, | |
1572 self.profile, | |
1573 ), | |
1574 type_check=list | |
1539 ) | 1575 ) |
1540 except Exception as e: | 1576 except Exception as e: |
1541 self.disp(_("can't retrieve subscriptions: {e}").format(e=e), error=True) | 1577 self.disp(_("can't retrieve subscriptions: {e}").format(e=e), error=True) |
1542 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 1578 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
1543 else: | 1579 else: |