comparison sat/plugins/plugin_xep_0249.py @ 4001:32d714a8ea51

plugin XEP-0045: dot not wait for MAM retrieval to be completed: in `_join_MAM`, `room.fully_joined` is called before retrieving the MAM archive, as the process can be very long, and is not necessary to have the room working (message can be received after being in the room, and added out of order). This avoid blocking the `join` workflow for an extended time. Some renaming and coroutine integrations.
author Goffi <goffi@goffi.org>
date Fri, 10 Mar 2023 17:22:41 +0100
parents be6d91572633
children 524856bd7b19
comparison
equal deleted inserted replaced
4000:2d59974a8e3e 4001:32d714a8ea51
15 # GNU Affero General Public License for more details. 15 # GNU Affero General Public License for more details.
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _, D_ 20 from twisted.internet import defer
21 from twisted.words.protocols.jabber import jid
22 from twisted.words.xish import domish
23 from wokkel import disco, iwokkel
24 from zope.interface import implementer
25
26 from sat.core import exceptions
21 from sat.core.constants import Const as C 27 from sat.core.constants import Const as C
22 from sat.core import exceptions 28 from sat.core.i18n import D_, _
23 from sat.core.log import getLogger 29 from sat.core.log import getLogger
30 from sat.tools import xml_tools
24 31
25 log = getLogger(__name__) 32 log = getLogger(__name__)
26 from sat.tools import xml_tools 33
27 from twisted.words.xish import domish
28 from twisted.words.protocols.jabber import jid
29
30 from zope.interface import implementer
31
32 from wokkel import disco, iwokkel
33 34
34 35
35 try: 36 try:
36 from twisted.words.protocols.xmlstream import XMPPHandler 37 from twisted.words.protocols.xmlstream import XMPPHandler
37 except ImportError: 38 except ImportError:
138 client = self.host.getClient(profile_key) 139 client = self.host.getClient(profile_key)
139 log.info( 140 log.info(
140 _("Invitation accepted for room %(room)s [%(profile)s]") 141 _("Invitation accepted for room %(room)s [%(profile)s]")
141 % {"room": room_jid.userhost(), "profile": client.profile} 142 % {"room": room_jid.userhost(), "profile": client.profile}
142 ) 143 )
143 d = self.host.plugins["XEP-0045"].join(client, room_jid, client.jid.user, {}) 144 d = defer.ensureDeferred(
145 self.host.plugins["XEP-0045"].join(client, room_jid, client.jid.user, {})
146 )
144 return d 147 return d
145 148
146 def _messageReceivedTrigger(self, client, message_elt, post_treat): 149 def _messageReceivedTrigger(self, client, message_elt, post_treat):
147 """Check if a direct invitation is in the message, and handle it""" 150 """Check if a direct invitation is in the message, and handle it"""
148 x_elt = next(message_elt.elements(NS_X_CONFERENCE, 'x'), None) 151 x_elt = next(message_elt.elements(NS_X_CONFERENCE, 'x'), None)