From c140133141c528be3c49f9505b5b4876cc75ac26 Mon Sep 17 00:00:00 2001 From: fmodf Date: Sat, 31 Aug 2024 15:00:16 +0200 Subject: [PATCH] wip --- .../AppData/Client/Client+MartinOMEMO.swift | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift b/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift index d975206..1fb4a34 100644 --- a/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift +++ b/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift @@ -171,16 +171,21 @@ extension ClientMartinOMEMO: SignalIdentityKeyStoreProtocol { return nil } - // guard - // let data = try! Database.main.reader({ database in - // try database.select(query: .omemoKeyPairForAccount, params: ["account": account, "name": account.stringValue, "deviceId": deviceId]).mapFirst { $0.data(for: "key") } - // }) - // else { - // return nil - // } - // - // return SignalIdentityKeyPair(fromKeyPairData: data) - return nil + do { + let record = try Database.shared.dbQueue.read { db in + try OMEMOIdentity + .filter(Column("account") == credentials.bareJid) + .filter(Column("name") == credentials.bareJid) + .filter(Column("deviceId") == deviceId) + .fetchOne(db) + } + guard let key = record?.key else { + return nil + } + return SignalIdentityKeyPair(fromKeyPairData: key) + } catch { + return nil + } } func localRegistrationId() -> UInt32 {