comparison sat/plugins/plugin_xep_0334.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 68a11b95a7d3
children 13a2403774d4
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 Iterable
21 from sat.core.i18n import _, D_ 22 from sat.core.i18n import _, D_
22 from sat.core.log import getLogger 23 from sat.core.log import getLogger
23 24
24 log = getLogger(__name__) 25 log = getLogger(__name__)
25 from sat.core.constants import Const as C 26 from sat.core.constants import Const as C
27 from sat.tools.common import data_format 28 from sat.tools.common import data_format
28 29
29 from wokkel import disco, iwokkel 30 from wokkel import disco, iwokkel
30 31
31 from twisted.words.protocols.jabber import xmlstream 32 from twisted.words.protocols.jabber import xmlstream
33 from twisted.words.xish import domish
32 from zope.interface import implementer 34 from zope.interface import implementer
33 from textwrap import dedent 35 from textwrap import dedent
34 36
35 37
36 PLUGIN_INFO = { 38 PLUGIN_INFO = {
81 if hint in self.HINTS: 83 if hint in self.HINTS:
82 hints.add(hint) 84 hints.add(hint)
83 else: 85 else:
84 log.error("Unknown hint: {}".format(hint)) 86 log.error("Unknown hint: {}".format(hint))
85 87
86 def addHintElements(self, message_elt, hints): 88 def addHintElements(self, message_elt: domish.Element, hints: Iterable[str]) -> None:
87 """Add hints elements to message stanza 89 """Add hints elements to message stanza
88 90
89 @param message_elt(domish.Element): stanza where hints must be added 91 @param message_elt: stanza where hints must be added
90 @param hints(iterable(unicode)): hints to add 92 @param hints: hints to add
91 """ 93 """
92 for hint in hints: 94 for hint in hints:
93 message_elt.addElement((NS_HINTS, hint)) 95 message_elt.addElement((NS_HINTS, hint))
94 96
95 def _sendPostXmlTreatment(self, mess_data): 97 def _sendPostXmlTreatment(self, mess_data):