Philipp Hörist pushed to branch mainwindow at gajim / gajim
Commits:
3d2cc2e6 by lovetox at 2021-02-28T17:55:38+01:00
Fix MUC rejoins
- - - - -
2 changed files:
- gajim/common/modules/contacts.py
- gajim/common/modules/muc.py
Changes:
=====================================
gajim/common/modules/contacts.py
=====================================
@@ -328,7 +328,7 @@ def update_avatar(self, *args):
app.interface.avatar_storage.invalidate_cache(self._jid)
self.notify('avatar-update')
- def set_destroyed(self):
+ def set_not_joined(self):
for contact in self._resources.values():
contact.update_presence(UNKNOWN_MUC_PRESENCE)
=====================================
gajim/common/modules/muc.py
=====================================
@@ -251,7 +251,6 @@ def leave(self, room_jid, reason=None):
self._remove_join_timeout(room_jid)
self._remove_rejoin_timeout(room_jid)
- self._manager.set_state(room_jid, MUCJoinedState.NOT_JOINED)
self._con.get_module('Presence').send_presence(
muc_data.occupant_jid,
@@ -259,6 +258,10 @@ def leave(self, room_jid, reason=None):
status=reason,
caps=False)
+ self._manager.set_state(room_jid, MUCJoinedState.NOT_JOINED)
+ room = self._get_contact(room_jid)
+ room.set_not_joined()
+
def configure_room(self, room_jid):
self._nbxmpp('MUC').request_config(room_jid,
callback=self._on_room_config)
@@ -356,12 +359,17 @@ def change_nick(self, room_jid, new_nick):
show=status,
status=message)
- def _on_error_presence(self, _con, _stanza, properties):
+ def _on_error_presence(self, _con, stanza, properties):
room_jid = properties.jid.bare
muc_data = self._manager.get(room_jid)
if muc_data is None:
return
+ if properties.jid.resource != muc_data.nick:
+ self._log.warning('Unknown error presence')
+ self._log.warning(stanza)
+ return
+
room = self._get_contact(room_jid)
if muc_data.state == MUCJoinedState.JOINING:
@@ -387,9 +395,9 @@ def _on_error_presence(self, _con, _stanza, properties):
room.notify('room-creation-failed', properties)
elif muc_data.state == MUCJoinedState.CAPTCHA_REQUEST:
- room.notify('room-captcha-error', properties.error)
self._manager.set_state(room_jid, MUCJoinedState.CAPTCHA_FAILED)
self._manager.set_state(room_jid, MUCJoinedState.NOT_JOINED)
+ room.notify('room-captcha-error', properties.error)
elif muc_data.state == MUCJoinedState.CAPTCHA_FAILED:
self._manager.set_state(room_jid, MUCJoinedState.NOT_JOINED)
@@ -415,6 +423,7 @@ def _on_muc_user_presence(self, _con, stanza, properties):
self._log.info('MUC destroyed: %s', room_jid)
self._remove_join_timeout(room_jid)
self._manager.set_state(room_jid, MUCJoinedState.NOT_JOINED)
+ room.set_not_joined()
room.notify('destroyed', properties)
return
@@ -466,6 +475,7 @@ def _on_muc_user_presence(self, _con, stanza, properties):
if properties.is_muc_self_presence and properties.is_kicked:
self._manager.set_state(room_jid, MUCJoinedState.NOT_JOINED)
+ room.set_not_joined()
room.notify('kicked', properties)
status_codes = properties.muc_status_codes or []
if StatusCode.REMOVED_SERVICE_SHUTDOWN in status_codes:
@@ -786,6 +796,7 @@ def add(self, muc):
def remove(self, muc):
self._mucs.pop(muc.jid, None)
+ self._joined_users.pop(muc.jid, None)
def get(self, room_jid):
return self._mucs.get(room_jid)
@@ -796,6 +807,7 @@ def set_state(self, room_jid, state):
if muc.state == state:
return
self._log.info('Set MUC state: %s %s', room_jid, state)
+
muc.state = state
self.notify('state-changed',
state,
@@ -809,8 +821,12 @@ def get_mucs_with_state(self, states):
return [muc for muc in self._mucs.values() if muc.state in states]
def reset_state(self):
+ client = app.get_client(self._account)
for muc in self._mucs.values():
self.set_state(muc.jid, MUCJoinedState.NOT_JOINED)
+ self._joined_users.pop(muc.jid, None)
+ contact = client.get_module('Contacts').get_contact(muc.jid)
+ contact.set_not_joined()
def __contains__(self, room_jid):
return room_jid in self._mucs
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3d2cc2e65ef8e4a6d4932f0e0032c9a8f7468635
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3d2cc2e65ef8e4a6d4932f0e0032c9a8f7468635
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits