From fa0381e2381dee47f0e6e24cc66cc28fdcd86d71 Mon Sep 17 00:00:00 2001 From: fmodf Date: Mon, 2 Sep 2024 17:01:20 +0200 Subject: [PATCH] fix --- .../AppData/Client/Client+MartinMessages.swift | 2 ++ .../AppData/Client/Client+MartinOMEMO.swift | 9 ++++++--- .../AppData/Services/Database+Migrations.swift | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ConversationsClassic/AppData/Client/Client+MartinMessages.swift b/ConversationsClassic/AppData/Client/Client+MartinMessages.swift index db08b99..0eeb57a 100644 --- a/ConversationsClassic/AppData/Client/Client+MartinMessages.swift +++ b/ConversationsClassic/AppData/Client/Client+MartinMessages.swift @@ -24,6 +24,8 @@ final class ClientMartinMessagesManager { print("---") #endif + // Try to recognize if message is omemo-encoded and decode it + if let msg = Message.map(message) { Task { do { diff --git a/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift b/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift index 1a26bec..422d6d4 100644 --- a/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift +++ b/ConversationsClassic/AppData/Client/Client+MartinOMEMO.swift @@ -43,9 +43,12 @@ final class ClientMartinOMEMO { let regId = context.generateRegistrationId() let address = SignalAddress(name: credentials.bareJid, deviceId: Int32(regId)) - var settings = Settings.getFor(credentials.bareJid) - settings?.omemoRegId = Int(regId) - settings?.save() + if var settings = Settings.getFor(credentials.bareJid) { + settings.omemoRegId = Int(regId) + settings.save() + } else { + Settings(bareJid: credentials.bareJid, omemoRegId: Int(regId)).save() + } guard let keyPair = SignalIdentityKeyPair.generateKeyPair(context: context), let publicKey = keyPair.publicKey else { return false diff --git a/ConversationsClassic/AppData/Services/Database+Migrations.swift b/ConversationsClassic/AppData/Services/Database+Migrations.swift index 455e9b1..ad23119 100644 --- a/ConversationsClassic/AppData/Services/Database+Migrations.swift +++ b/ConversationsClassic/AppData/Services/Database+Migrations.swift @@ -63,15 +63,15 @@ extension Database { try db.create(table: "omemo_sessions", options: [.ifNotExists]) { table in table.column("account", .text).notNull() table.column("name", .text).notNull() - table.column("device_id", .integer).notNull() + table.column("deviceId", .integer).notNull() table.column("key", .text).notNull() - table.primaryKey(["account", "name", "device_id"], onConflict: .replace) + table.primaryKey(["account", "name", "deviceId"], onConflict: .replace) } try db.create(table: "omemo_identities", options: [.ifNotExists]) { table in table.column("account", .text).notNull() table.column("name", .text).notNull() - table.column("device_id", .integer).notNull() + table.column("deviceId", .integer).notNull() table.column("fingerprint", .text).notNull() table.column("key", .blob).notNull() table.column("own", .integer).notNull() @@ -98,7 +98,7 @@ extension Database { // table.add(column: "encryption", .text) // } // - // try db.alter(table: "chat_history") { table in + // try db.alter(table: "messages") { table in // table.add(column: "encryption", .integer) // table.add(column: "fingerprint", .text) // }