[omemo] Fix detecting room members on join

This commit is contained in:
lovetox
2022-05-20 19:14:32 +02:00
parent 83d0ad2883
commit 5d6ee537ad
2 changed files with 18 additions and 9 deletions

View File

@@ -346,10 +346,11 @@ class OMEMO(BaseModule):
def on_muc_disco_update(self, event): def on_muc_disco_update(self, event):
self._check_if_omemo_capable(event.jid) self._check_if_omemo_capable(event.jid)
def on_muc_joined(self, event): def on_room_joined(self, contact):
self._check_if_omemo_capable(event.room_jid) jid = str(contact.jid)
if self.is_omemo_groupchat(event.room_jid): self._check_if_omemo_capable(jid)
self.get_affiliation_list(event.room_jid) if self.is_omemo_groupchat(jid):
self.get_affiliation_list(jid)
def _check_if_omemo_capable(self, jid): def _check_if_omemo_capable(self, jid):
disco_info = app.storage.cache.get_last_disco_info(jid) disco_info = app.storage.cache.get_last_disco_info(jid)

View File

@@ -93,7 +93,6 @@ class OmemoPlugin(GajimPlugin):
'omemo-new-fingerprint': (ged.PRECORE, self._on_new_fingerprints), 'omemo-new-fingerprint': (ged.PRECORE, self._on_new_fingerprints),
'signed-in': (ged.PRECORE, self._on_signed_in), 'signed-in': (ged.PRECORE, self._on_signed_in),
'muc-disco-update': (ged.GUI1, self._on_muc_disco_update), 'muc-disco-update': (ged.GUI1, self._on_muc_disco_update),
'room-joined': (ged.GUI1, self._on_muc_joined),
} }
self.modules = [omemo] self.modules = [omemo]
@@ -108,7 +107,10 @@ class OmemoPlugin(GajimPlugin):
self._on_encryption_button_clicked, None), self._on_encryption_button_clicked, None),
'encryption_state' + self.encryption_name: ( 'encryption_state' + self.encryption_name: (
self._encryption_state, None), self._encryption_state, None),
'update_caps': (self._update_caps, None)} 'update_caps': (self._update_caps, None),
'groupchat_control': (self._gc_control_connect,
self._gc_control_disconnect)
}
self.disabled_accounts = [] self.disabled_accounts = []
self._windows = {} self._windows = {}
@@ -182,10 +184,10 @@ class OmemoPlugin(GajimPlugin):
return return
self.get_omemo(event.account).on_muc_disco_update(event) self.get_omemo(event.account).on_muc_disco_update(event)
def _on_muc_joined(self, event): def _on_room_joined(self, contact, _signal_name: str):
if not self._is_enabled_account(event.account): if not self._is_enabled_account(contact.account):
return return
self.get_omemo(event.account).on_muc_joined(event) self.get_omemo(contact.account).on_room_joined(contact)
def _update_caps(self, account, features): def _update_caps(self, account, features):
if not self._is_enabled_account(account): if not self._is_enabled_account(account):
@@ -328,3 +330,9 @@ class OmemoPlugin(GajimPlugin):
if msg is None: if msg is None:
return return
chat_control.add_info_message(msg) chat_control.add_info_message(msg)
def _gc_control_connect(self, groupchat_control):
groupchat_control.contact.connect('room-joined', self._on_room_joined)
def _gc_control_disconnect(self, groupchat_control):
groupchat_control.contact.disconnect(self)