Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_pubsub.py @ 3973:570254d5a798
cli (blog, pubsub): encryption argument for Pubsub Targeted Encryption:
add a new `--encrypt-for` argument to `blog/set` `blog/edit` `pubsub/set` and `pubsub/edit`
rel 382
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 31 Oct 2022 13:48:01 +0100 |
parents | 2695dafc5c4d |
children | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3972:5fbdf986670c | 3973:570254d5a798 |
---|---|
1228 "--encrypt", | 1228 "--encrypt", |
1229 action="store_true", | 1229 action="store_true", |
1230 help=_("end-to-end encrypt the blog item") | 1230 help=_("end-to-end encrypt the blog item") |
1231 ) | 1231 ) |
1232 self.parser.add_argument( | 1232 self.parser.add_argument( |
1233 "--encrypt-for", | |
1234 metavar="JID", | |
1235 action="append", | |
1236 help=_("encrypt a single item for") | |
1237 ) | |
1238 self.parser.add_argument( | |
1233 "-X", | 1239 "-X", |
1234 "--sign", | 1240 "--sign", |
1235 action="store_true", | 1241 action="store_true", |
1236 help=_("cryptographically sign the blog post") | 1242 help=_("cryptographically sign the blog post") |
1237 ) | 1243 ) |
1247 element = xml_tools.getPayload(self, element) | 1253 element = xml_tools.getPayload(self, element) |
1248 payload = etree.tostring(element, encoding="unicode") | 1254 payload = etree.tostring(element, encoding="unicode") |
1249 extra = {} | 1255 extra = {} |
1250 if self.args.encrypt: | 1256 if self.args.encrypt: |
1251 extra["encrypted"] = True | 1257 extra["encrypted"] = True |
1258 if self.args.encrypt_for: | |
1259 extra["encrypted_for"] = {"targets": self.args.encrypt_for} | |
1252 if self.args.sign: | 1260 if self.args.sign: |
1253 extra["signed"] = True | 1261 extra["signed"] = True |
1254 publish_options = NodeCreate.get_config_options(self.args) | 1262 publish_options = NodeCreate.get_config_options(self.args) |
1255 if publish_options: | 1263 if publish_options: |
1256 extra["publish_options"] = publish_options | 1264 extra["publish_options"] = publish_options |
1402 "--encrypt", | 1410 "--encrypt", |
1403 action="store_true", | 1411 action="store_true", |
1404 help=_("end-to-end encrypt the blog item") | 1412 help=_("end-to-end encrypt the blog item") |
1405 ) | 1413 ) |
1406 self.parser.add_argument( | 1414 self.parser.add_argument( |
1415 "--encrypt-for", | |
1416 metavar="JID", | |
1417 action="append", | |
1418 help=_("encrypt a single item for") | |
1419 ) | |
1420 self.parser.add_argument( | |
1407 "-X", | 1421 "-X", |
1408 "--sign", | 1422 "--sign", |
1409 action="store_true", | 1423 action="store_true", |
1410 help=_("cryptographically sign the blog post") | 1424 help=_("cryptographically sign the blog post") |
1411 ) | 1425 ) |
1412 | 1426 |
1413 async def publish(self, content): | 1427 async def publish(self, content): |
1414 extra = {} | 1428 extra = {} |
1415 if self.args.encrypt: | 1429 if self.args.encrypt: |
1416 extra["encrypted"] = True | 1430 extra["encrypted"] = True |
1431 if self.args.encrypt_for: | |
1432 extra["encrypted_for"] = {"targets": self.args.encrypt_for} | |
1417 if self.args.sign: | 1433 if self.args.sign: |
1418 extra["signed"] = True | 1434 extra["signed"] = True |
1419 published_id = await self.host.bridge.psItemSend( | 1435 published_id = await self.host.bridge.psItemSend( |
1420 self.pubsub_service, | 1436 self.pubsub_service, |
1421 self.pubsub_node, | 1437 self.pubsub_node, |