mv-experiment #1
|
@ -24,6 +24,8 @@ final class ClientMartinMessagesManager {
|
||||||
print("---")
|
print("---")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Try to recognize if message is omemo-encoded and decode it
|
||||||
|
|
||||||
if let msg = Message.map(message) {
|
if let msg = Message.map(message) {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -43,9 +43,12 @@ final class ClientMartinOMEMO {
|
||||||
let regId = context.generateRegistrationId()
|
let regId = context.generateRegistrationId()
|
||||||
let address = SignalAddress(name: credentials.bareJid, deviceId: Int32(regId))
|
let address = SignalAddress(name: credentials.bareJid, deviceId: Int32(regId))
|
||||||
|
|
||||||
var settings = Settings.getFor(credentials.bareJid)
|
if var settings = Settings.getFor(credentials.bareJid) {
|
||||||
settings?.omemoRegId = Int(regId)
|
settings.omemoRegId = Int(regId)
|
||||||
settings?.save()
|
settings.save()
|
||||||
|
} else {
|
||||||
|
Settings(bareJid: credentials.bareJid, omemoRegId: Int(regId)).save()
|
||||||
|
}
|
||||||
|
|
||||||
guard let keyPair = SignalIdentityKeyPair.generateKeyPair(context: context), let publicKey = keyPair.publicKey else {
|
guard let keyPair = SignalIdentityKeyPair.generateKeyPair(context: context), let publicKey = keyPair.publicKey else {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -63,15 +63,15 @@ extension Database {
|
||||||
try db.create(table: "omemo_sessions", options: [.ifNotExists]) { table in
|
try db.create(table: "omemo_sessions", options: [.ifNotExists]) { table in
|
||||||
table.column("account", .text).notNull()
|
table.column("account", .text).notNull()
|
||||||
table.column("name", .text).notNull()
|
table.column("name", .text).notNull()
|
||||||
table.column("device_id", .integer).notNull()
|
table.column("deviceId", .integer).notNull()
|
||||||
table.column("key", .text).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
|
try db.create(table: "omemo_identities", options: [.ifNotExists]) { table in
|
||||||
table.column("account", .text).notNull()
|
table.column("account", .text).notNull()
|
||||||
table.column("name", .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("fingerprint", .text).notNull()
|
||||||
table.column("key", .blob).notNull()
|
table.column("key", .blob).notNull()
|
||||||
table.column("own", .integer).notNull()
|
table.column("own", .integer).notNull()
|
||||||
|
@ -98,7 +98,7 @@ extension Database {
|
||||||
// table.add(column: "encryption", .text)
|
// 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: "encryption", .integer)
|
||||||
// table.add(column: "fingerprint", .text)
|
// table.add(column: "fingerprint", .text)
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in a new issue