comparison sat/plugins/plugin_xep_0359.py @ 3911:8289ac1b34f4

plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo: - support for both (modern) OMEMO under the `urn:xmpp:omemo:2` namespace and (legacy) OMEMO under the `eu.siacs.conversations.axolotl` namespace - maintains one identity across both versions of OMEMO - migrates data from the old plugin - includes more features for protocol stability - uses SCE for modern OMEMO - fully type-checked, linted and format-checked - added type hints to various pieces of backend code used by the plugin - added stubs for some Twisted APIs used by the plugin under stubs/ (use `export MYPYPATH=stubs/` before running mypy) - core (xmpp): enabled `send` trigger and made it an asyncPoint fix 375
author Syndace <me@syndace.dev>
date Tue, 23 Aug 2022 21:06:24 +0200
parents cc653b2685f0
children 524856bd7b19
comparison
equal deleted inserted replaced
3910:199598223f82 3911:8289ac1b34f4
16 # GNU Affero General Public License for more details. 16 # GNU Affero General Public License for more details.
17 17
18 # You should have received a copy of the GNU Affero General Public License 18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21 from typing import Optional
21 import uuid 22 import uuid
22 from zope.interface import implementer 23 from zope.interface import implementer
23 from twisted.words.protocols.jabber import xmlstream 24 from twisted.words.protocols.jabber import xmlstream
24 from wokkel import disco 25 from wokkel import disco
25 from sat.core.constants import Const as C 26 from sat.core.constants import Const as C
26 from sat.core import exceptions 27 from sat.core import exceptions
27 from sat.core.i18n import _ 28 from sat.core.i18n import _
28 from sat.core.log import getLogger 29 from sat.core.log import getLogger
30 from twisted.words.xish import domish
29 31
30 log = getLogger(__name__) 32 log = getLogger(__name__)
31 33
32 34
33 PLUGIN_INFO = { 35 PLUGIN_INFO = {
99 """ 101 """
100 sid_elt = element.addElement((NS_SID, "stanza-id")) 102 sid_elt = element.addElement((NS_SID, "stanza-id"))
101 sid_elt["by"] = client.jid.userhost() if by is None else by.userhost() 103 sid_elt["by"] = client.jid.userhost() if by is None else by.userhost()
102 sid_elt["id"] = stanza_id 104 sid_elt["id"] = stanza_id
103 105
104 def getOriginId(self, element): 106 def getOriginId(self, element: domish.Element) -> Optional[str]:
105 """Return origin-id if found in element 107 """Return origin-id if found in element
106 108
107 @param element(domish.Element): element to parse 109 @param element: element to parse
108 @return (unicode, None): origin-id if found 110 @return: origin-id if found
109 """ 111 """
110 try: 112 try:
111 origin_elt = next(element.elements(NS_SID, "origin-id")) 113 origin_elt = next(element.elements(NS_SID, "origin-id"))
112 except StopIteration: 114 except StopIteration:
113 return None 115 return None