Commit 01c92b9f authored by Philipp Hörist's avatar Philipp Hörist
Browse files

[omemo] Show correctly fingerprints in MUC

parent c90275c4
......@@ -329,14 +329,19 @@ class LiteAxolotlStore(AxolotlStore):
self._con.commit()
def getSessionsFromJid(self, recipientId):
query = '''SELECT _id, recipient_id as "recipient_id [jid]",
device_id, record, active
from sessions WHERE recipient_id = ?'''
query = '''SELECT recipient_id as "recipient_id [jid]",
device_id,
record as "record [session_record]",
active
FROM sessions WHERE recipient_id = ?'''
return self._con.execute(query, (recipientId,)).fetchall()
def getSessionsFromJids(self, recipientIds):
query = '''SELECT _id, recipient_id as "recipient_id [jid]",
device_id, record, active from sessions
query = '''SELECT recipient_id as "recipient_id [jid]",
device_id,
record as "record [session_record]",
active
FROM sessions
WHERE recipient_id IN ({})'''.format(
', '.join(['?'] * len(recipientIds)))
return self._con.execute(query, recipientIds).fetchall()
......@@ -478,6 +483,15 @@ class LiteAxolotlStore(AxolotlStore):
WHERE recipient_id = ? ORDER BY trust ASC'''
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):
query = '''SELECT public_key as "public_key [pk]" FROM identities
WHERE recipient_id = ? AND trust = ?'''
......
......@@ -117,8 +117,6 @@ class KeyDialog(Gtk.Dialog):
self._load_fingerprints(self._contact.jid, self._groupchat is True)
def _load_fingerprints(self, contact_jid, groupchat=False):
from axolotl.state.sessionrecord import SessionRecord
if groupchat:
members = list(self._omemo.backend.get_muc_members(contact_jid))
sessions = self._omemo.backend.storage.getSessionsFromJids(members)
......@@ -126,17 +124,19 @@ class KeyDialog(Gtk.Dialog):
sessions = self._omemo.backend.storage.getSessionsFromJid(contact_jid)
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:
rows[result.public_key] = KeyRow(result.recipient_id,
result.public_key,
result.trust)
for item in sessions:
session_record = SessionRecord(serialized=item.record)
identity_key = session_record.getSessionState().getRemoteIdentityKey()
if identity_key is None:
continue
if item.record.isFresh():
return
identity_key = item.record.getSessionState().getRemoteIdentityKey()
identity_key = IdentityKeyExtended(identity_key.getPublicKey())
try:
key_row = rows[identity_key]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment