Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_pubsub.py @ 3947:08c1d5485411
cli (pubsub/set, edit): add `--encrypt` flag:
rel 380
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 15 Oct 2022 20:38:33 +0200 |
parents | 8ae3e870be94 |
children | da0e772881c3 |
comparison
equal
deleted
inserted
replaced
3946:f2a5936f2496 | 3947:08c1d5485411 |
---|---|
1222 ) | 1222 ) |
1223 | 1223 |
1224 def add_parser_options(self): | 1224 def add_parser_options(self): |
1225 NodeCreate.add_node_config_options(self.parser) | 1225 NodeCreate.add_node_config_options(self.parser) |
1226 self.parser.add_argument( | 1226 self.parser.add_argument( |
1227 "-e", | |
1228 "--encrypt", | |
1229 action="store_true", | |
1230 help=_("end-to-end encrypt the blog item") | |
1231 ) | |
1232 self.parser.add_argument( | |
1227 "item", | 1233 "item", |
1228 nargs="?", | 1234 nargs="?", |
1229 default="", | 1235 default="", |
1230 help=_("id, URL of the item to update, keyword, or nothing for new item"), | 1236 help=_("id, URL of the item to update, keyword, or nothing for new item"), |
1231 ) | 1237 ) |
1233 async def start(self): | 1239 async def start(self): |
1234 element, etree = xml_tools.etreeParse(self, sys.stdin) | 1240 element, etree = xml_tools.etreeParse(self, sys.stdin) |
1235 element = xml_tools.getPayload(self, element) | 1241 element = xml_tools.getPayload(self, element) |
1236 payload = etree.tostring(element, encoding="unicode") | 1242 payload = etree.tostring(element, encoding="unicode") |
1237 extra = {} | 1243 extra = {} |
1244 if self.args.encrypt: | |
1245 extra["encrypted"] = True | |
1238 publish_options = NodeCreate.get_config_options(self.args) | 1246 publish_options = NodeCreate.get_config_options(self.args) |
1239 if publish_options: | 1247 if publish_options: |
1240 extra["publish_options"] = publish_options | 1248 extra["publish_options"] = publish_options |
1241 | 1249 |
1242 try: | 1250 try: |
1379 help=_("edit an existing or new pubsub item"), | 1387 help=_("edit an existing or new pubsub item"), |
1380 ) | 1388 ) |
1381 common.BaseEdit.__init__(self, self.host, PUBSUB_TMP_DIR) | 1389 common.BaseEdit.__init__(self, self.host, PUBSUB_TMP_DIR) |
1382 | 1390 |
1383 def add_parser_options(self): | 1391 def add_parser_options(self): |
1384 pass | 1392 self.parser.add_argument( |
1393 "-e", | |
1394 "--encrypt", | |
1395 action="store_true", | |
1396 help=_("end-to-end encrypt the blog item") | |
1397 ) | |
1385 | 1398 |
1386 async def publish(self, content): | 1399 async def publish(self, content): |
1400 extra = {} | |
1401 if self.args.encrypt: | |
1402 extra["encrypted"] = True | |
1387 published_id = await self.host.bridge.psItemSend( | 1403 published_id = await self.host.bridge.psItemSend( |
1388 self.pubsub_service, | 1404 self.pubsub_service, |
1389 self.pubsub_node, | 1405 self.pubsub_node, |
1390 content, | 1406 content, |
1391 self.pubsub_item or "", | 1407 self.pubsub_item or "", |
1392 "", | 1408 data_format.serialise(extra), |
1393 self.profile, | 1409 self.profile, |
1394 ) | 1410 ) |
1395 if published_id: | 1411 if published_id: |
1396 self.disp("Item published at {pub_id}".format(pub_id=published_id)) | 1412 self.disp("Item published at {pub_id}".format(pub_id=published_id)) |
1397 else: | 1413 else: |