comparison sat/plugins/plugin_sec_oxps.py @ 3952:9badc46c5481

plugin OXPS: fix triggers return values: rel 381
author Goffi <goffi@goffi.org>
date Fri, 28 Oct 2022 18:47:17 +0200
parents cd4d95b3fed3
children 524856bd7b19
comparison
equal deleted inserted replaced
3951:4b8776eb6826 3952:9badc46c5481
692 service: Optional[jid.JID], 692 service: Optional[jid.JID],
693 node: str, 693 node: str,
694 items: List[domish.Element], 694 items: List[domish.Element],
695 rsm_response: rsm.RSMResponse, 695 rsm_response: rsm.RSMResponse,
696 extra: Dict[str, Any], 696 extra: Dict[str, Any],
697 ) -> None: 697 ) -> bool:
698 if not extra.get(C.KEY_DECRYPT, True): 698 if not extra.get(C.KEY_DECRYPT, True):
699 return 699 return True
700 if service is None: 700 if service is None:
701 service = client.jid.userhostJID() 701 service = client.jid.userhostJID()
702 shared_secrets = None 702 shared_secrets = None
703 for item in items: 703 for item in items:
704 payload = item.firstChildElement() 704 payload = item.firstChildElement()
717 shared_secrets = await self.load_secrets(client, node_uri) 717 shared_secrets = await self.load_secrets(client, node_uri)
718 if shared_secrets is None: 718 if shared_secrets is None:
719 log.warning( 719 log.warning(
720 f"No known shared secret for {node_uri}, can't decrypt" 720 f"No known shared secret for {node_uri}, can't decrypt"
721 ) 721 )
722 return 722 return True
723 try: 723 try:
724 shared_secret = shared_secrets[secret_id] 724 shared_secret = shared_secrets[secret_id]
725 except KeyError: 725 except KeyError:
726 log.warning( 726 log.warning(
727 f"No key known for encrypted item {item['id']!r} (shared secret " 727 f"No key known for encrypted item {item['id']!r} (shared secret "
735 ) 735 )
736 decrypted_elt = xml_tools.parse(decrypted) 736 decrypted_elt = xml_tools.parse(decrypted)
737 item.children.clear() 737 item.children.clear()
738 item.addChild(decrypted_elt) 738 item.addChild(decrypted_elt)
739 extra.setdefault("encrypted", {})[item["id"]] = {"type": NS_OXPS} 739 extra.setdefault("encrypted", {})[item["id"]] = {"type": NS_OXPS}
740 return True
740 741
741 async def _message_received_trigger( 742 async def _message_received_trigger(
742 self, 743 self,
743 client: SatXMPPEntity, 744 client: SatXMPPEntity,
744 message_elt: domish.Element, 745 message_elt: domish.Element,