Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0384.py @ 2757:1f612547fb2e
plugin XEP-0384: give feedback to user when trust must be handled before sending a message
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 05 Jan 2019 14:15:11 +0100 |
parents | 3bea6b5ae972 |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2756:1048d8dc8a9d | 2757:1f612547fb2e |
---|---|
821 | 821 |
822 | 822 |
823 ## triggers | 823 ## triggers |
824 | 824 |
825 @defer.inlineCallbacks | 825 @defer.inlineCallbacks |
826 def handleProblems(self, client, bundles, problems): | 826 def handleProblems(self, client, entity, bundles, problems): |
827 """Try to solve problem found by EncryptMessage | 827 """Try to solve problem found by EncryptMessage |
828 | 828 |
829 @param entity(jid.JID): bare jid of the destinee | |
829 @param bundles(dict): bundles data as used in EncryptMessage | 830 @param bundles(dict): bundles data as used in EncryptMessage |
830 already filled with known bundles, missing bundles | 831 already filled with known bundles, missing bundles |
831 need to be added to it | 832 need to be added to it |
832 @param problems(list): exceptions raised by EncryptMessage | 833 @param problems(list): exceptions raised by EncryptMessage |
833 @return (dict): expect_problems arguments, used in EncryptMessage | 834 @return (dict): expect_problems arguments, used in EncryptMessage |
849 trust_data[trust_id] = { | 850 trust_data[trust_id] = { |
850 'jid': jid.JID(data.bare_jid), | 851 'jid': jid.JID(data.bare_jid), |
851 'device': data.device, | 852 'device': data.device, |
852 'ik': data.ik} | 853 'ik': data.ik} |
853 | 854 |
855 user_msg = D_(u"Not all destination devices are trusted, we can't encrypt " | |
856 u"message in such a situation. Please indicate if you trust " | |
857 u"those devices or not in the trust manager before we can " | |
858 "send this message") | |
859 client.feedback(entity, user_msg) | |
854 xmlui = yield self.getTrustUI(client, trust_data=trust_data, submit_id=u"") | 860 xmlui = yield self.getTrustUI(client, trust_data=trust_data, submit_id=u"") |
855 | 861 |
856 answer = yield xml_tools.deferXMLUI( | 862 answer = yield xml_tools.deferXMLUI( |
857 self.host, | 863 self.host, |
858 xmlui, | 864 xmlui, |
896 entity_bare_jid, | 902 entity_bare_jid, |
897 message, | 903 message, |
898 bundles) | 904 bundles) |
899 except omemo_excpt.EncryptionProblemsException as e: | 905 except omemo_excpt.EncryptionProblemsException as e: |
900 # we know the problem to solve, we can try to fix them | 906 # we know the problem to solve, we can try to fix them |
901 expect_problems = yield self.handleProblems(client, bundles, e.problems) | 907 expect_problems = yield self.handleProblems(client, entity_bare_jid, bundles, e.problems) |
902 # and try an encryption again. | 908 # and try an encryption again. |
903 try: | 909 try: |
904 encrypted = yield omemo_session.encryptMessage( | 910 encrypted = yield omemo_session.encryptMessage( |
905 entity_bare_jid, | 911 entity_bare_jid, |
906 message, | 912 message, |