comparison sat/plugins/plugin_xep_0045.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 813595f88612
children 32d714a8ea51
comparison
equal deleted inserted replaced
3910:199598223f82 3911:8289ac1b34f4
24 from twisted.words.protocols.jabber import jid 24 from twisted.words.protocols.jabber import jid
25 from twisted.words.protocols.jabber import error as xmpp_error 25 from twisted.words.protocols.jabber import error as xmpp_error
26 from twisted.python import failure 26 from twisted.python import failure
27 27
28 from sat.core import exceptions 28 from sat.core import exceptions
29 from sat.core.xmpp import SatXMPPClient
29 from sat.memory import memory 30 from sat.memory import memory
30 31
31 import time 32 import time
32 import uuid 33 import uuid
33 34
202 log.warning("Received groupchat message for a room which has not been " 203 log.warning("Received groupchat message for a room which has not been "
203 "joined, ignoring it: {}".format(message_elt.toXml())) 204 "joined, ignoring it: {}".format(message_elt.toXml()))
204 return False 205 return False
205 return True 206 return True
206 207
207 def getRoom(self, client, room_jid): 208 def getRoom(self, client: SatXMPPClient, room_jid: jid.JID) -> muc.Room:
208 """Retrieve Room instance from its jid 209 """Retrieve Room instance from its jid
209 210
210 @param room_jid(jid.JID): jid of the room 211 @param room_jid: jid of the room
211 @raise exceptions.NotFound: the room has not been joined 212 @raise exceptions.NotFound: the room has not been joined
212 """ 213 """
213 try: 214 try:
214 return client._muc_client.joined_rooms[room_jid] 215 return client._muc_client.joined_rooms[room_jid]
215 except KeyError: 216 except KeyError:
221 @param room_jid (JID): room JID 222 @param room_jid (JID): room JID
222 """ 223 """
223 if room_jid not in client._muc_client.joined_rooms: 224 if room_jid not in client._muc_client.joined_rooms:
224 raise exceptions.NotFound(_("This room has not been joined")) 225 raise exceptions.NotFound(_("This room has not been joined"))
225 226
226 def isJoinedRoom(self, client, room_jid): 227 def isJoinedRoom(self, client: SatXMPPClient, room_jid: jid.JID) -> bool:
227 """Tell if a jid is a known and joined room 228 """Tell if a jid is a known and joined room
228 229
229 @room_jid(jid.JID): jid of the room 230 @room_jid: jid of the room
230 """ 231 """
231 try: 232 try:
232 self.checkRoomJoined(client, room_jid) 233 self.checkRoomJoined(client, room_jid)
233 except exceptions.NotFound: 234 except exceptions.NotFound:
234 return False 235 return False