This commit is contained in:
fmodf 2024-09-11 14:37:54 +02:00
parent 61ec1b841e
commit 09d3a6e606
5 changed files with 19 additions and 13 deletions

View file

@ -33,6 +33,7 @@ extension Message {
}
// Try to recognize if message is omemo-encoded and decode it
var secure = false
if let omemo = context?.module(.omemo) {
let decodingResult = omemo.decode(message: martinMessage)
switch decodingResult {
@ -46,6 +47,7 @@ extension Message {
remotePath: oob
))
}
secure = true
case .successTransportKey:
break
@ -76,7 +78,8 @@ extension Message {
body: martinMessage.body,
subject: martinMessage.subject,
thread: martinMessage.thread,
oobUrl: martinMessage.oob
oobUrl: martinMessage.oob,
secure: secure
)
return msg
}

View file

@ -68,6 +68,8 @@ struct Message: DBStorable, Equatable {
var subject: String?
var thread: String?
var oobUrl: String?
var secure: Bool
}
extension Message {
@ -97,7 +99,8 @@ extension Message {
body: nil,
subject: nil,
thread: nil,
oobUrl: nil
oobUrl: nil,
secure: false
)
}
}

View file

@ -94,14 +94,9 @@ extension Database {
table.primaryKey(["account", "id"], onConflict: .replace)
}
// try db.alter(table: "chats") { table in
// table.add(column: "encryption", .text)
// }
//
// try db.alter(table: "messages") { table in
// table.add(column: "encryption", .integer)
// table.add(column: "fingerprint", .text)
// }
try db.alter(table: "messages") { table in
table.add(column: "secure", .boolean).notNull().defaults(to: false)
}
}
migrator.registerMigration("Add settings table") { db in

View file

@ -29,6 +29,7 @@ extension MessagesStore {
msg.from = roster.bareJid
msg.to = roster.contactBareJid
msg.body = message
msg.secure = true
// store as pending on db, and send
do {

View file

@ -41,6 +41,10 @@ struct MessageAttr: View {
Image(systemName: "clock")
.font(.body3)
.foregroundColor(.Material.Shape.separator)
} else if message.secure {
Image(systemName: "lock")
.font(.body3)
.foregroundColor(.Material.Shape.separator)
}
}
}
@ -186,13 +190,13 @@ private struct AttachmentView: View {
switch type {
case .image:
return "photo"
case .audio:
return "music.note"
case .video:
return "film"
case .file:
return "doc"
}