[omemo] Show correctly fingerprints in MUC
This commit is contained in:
@@ -329,14 +329,19 @@ class LiteAxolotlStore(AxolotlStore):
|
|||||||
self._con.commit()
|
self._con.commit()
|
||||||
|
|
||||||
def getSessionsFromJid(self, recipientId):
|
def getSessionsFromJid(self, recipientId):
|
||||||
query = '''SELECT _id, recipient_id as "recipient_id [jid]",
|
query = '''SELECT recipient_id as "recipient_id [jid]",
|
||||||
device_id, record, active
|
device_id,
|
||||||
from sessions WHERE recipient_id = ?'''
|
record as "record [session_record]",
|
||||||
|
active
|
||||||
|
FROM sessions WHERE recipient_id = ?'''
|
||||||
return self._con.execute(query, (recipientId,)).fetchall()
|
return self._con.execute(query, (recipientId,)).fetchall()
|
||||||
|
|
||||||
def getSessionsFromJids(self, recipientIds):
|
def getSessionsFromJids(self, recipientIds):
|
||||||
query = '''SELECT _id, recipient_id as "recipient_id [jid]",
|
query = '''SELECT recipient_id as "recipient_id [jid]",
|
||||||
device_id, record, active from sessions
|
device_id,
|
||||||
|
record as "record [session_record]",
|
||||||
|
active
|
||||||
|
FROM sessions
|
||||||
WHERE recipient_id IN ({})'''.format(
|
WHERE recipient_id IN ({})'''.format(
|
||||||
', '.join(['?'] * len(recipientIds)))
|
', '.join(['?'] * len(recipientIds)))
|
||||||
return self._con.execute(query, recipientIds).fetchall()
|
return self._con.execute(query, recipientIds).fetchall()
|
||||||
@@ -478,6 +483,15 @@ class LiteAxolotlStore(AxolotlStore):
|
|||||||
WHERE recipient_id = ? ORDER BY trust ASC'''
|
WHERE recipient_id = ? ORDER BY trust ASC'''
|
||||||
return self._con.execute(query, (jid,)).fetchall()
|
return self._con.execute(query, (jid,)).fetchall()
|
||||||
|
|
||||||
|
def getMucFingerprints(self, jids):
|
||||||
|
query = '''
|
||||||
|
SELECT recipient_id as "recipient_id [jid]",
|
||||||
|
public_key as "public_key [pk]", trust FROM identities
|
||||||
|
WHERE recipient_id IN ({}) ORDER BY trust ASC
|
||||||
|
'''.format(', '.join(['?'] * len(jids)))
|
||||||
|
|
||||||
|
return self._con.execute(query, jids).fetchall()
|
||||||
|
|
||||||
def getTrustedFingerprints(self, jid):
|
def getTrustedFingerprints(self, jid):
|
||||||
query = '''SELECT public_key as "public_key [pk]" FROM identities
|
query = '''SELECT public_key as "public_key [pk]" FROM identities
|
||||||
WHERE recipient_id = ? AND trust = ?'''
|
WHERE recipient_id = ? AND trust = ?'''
|
||||||
|
|||||||
@@ -117,8 +117,6 @@ class KeyDialog(Gtk.Dialog):
|
|||||||
self._load_fingerprints(self._contact.jid, self._groupchat is True)
|
self._load_fingerprints(self._contact.jid, self._groupchat is True)
|
||||||
|
|
||||||
def _load_fingerprints(self, contact_jid, groupchat=False):
|
def _load_fingerprints(self, contact_jid, groupchat=False):
|
||||||
from axolotl.state.sessionrecord import SessionRecord
|
|
||||||
|
|
||||||
if groupchat:
|
if groupchat:
|
||||||
members = list(self._omemo.backend.get_muc_members(contact_jid))
|
members = list(self._omemo.backend.get_muc_members(contact_jid))
|
||||||
sessions = self._omemo.backend.storage.getSessionsFromJids(members)
|
sessions = self._omemo.backend.storage.getSessionsFromJids(members)
|
||||||
@@ -126,17 +124,19 @@ class KeyDialog(Gtk.Dialog):
|
|||||||
sessions = self._omemo.backend.storage.getSessionsFromJid(contact_jid)
|
sessions = self._omemo.backend.storage.getSessionsFromJid(contact_jid)
|
||||||
|
|
||||||
rows = {}
|
rows = {}
|
||||||
results = self._omemo.backend.storage.getFingerprints(contact_jid)
|
if groupchat:
|
||||||
|
results = self._omemo.backend.storage.getMucFingerprints(members)
|
||||||
|
else:
|
||||||
|
results = self._omemo.backend.storage.getFingerprints(contact_jid)
|
||||||
for result in results:
|
for result in results:
|
||||||
rows[result.public_key] = KeyRow(result.recipient_id,
|
rows[result.public_key] = KeyRow(result.recipient_id,
|
||||||
result.public_key,
|
result.public_key,
|
||||||
result.trust)
|
result.trust)
|
||||||
|
|
||||||
for item in sessions:
|
for item in sessions:
|
||||||
session_record = SessionRecord(serialized=item.record)
|
if item.record.isFresh():
|
||||||
identity_key = session_record.getSessionState().getRemoteIdentityKey()
|
return
|
||||||
if identity_key is None:
|
identity_key = item.record.getSessionState().getRemoteIdentityKey()
|
||||||
continue
|
|
||||||
identity_key = IdentityKeyExtended(identity_key.getPublicKey())
|
identity_key = IdentityKeyExtended(identity_key.getPublicKey())
|
||||||
try:
|
try:
|
||||||
key_row = rows[identity_key]
|
key_row = rows[identity_key]
|
||||||
|
|||||||
Reference in New Issue
Block a user