Fix synced messages not being marked as sent

This commit is contained in:
Niels Andriesse 2021-01-27 11:04:29 +11:00
parent e38aaa4e0e
commit f84f94de60
1 changed files with 11 additions and 1 deletions

View File

@ -31,7 +31,17 @@ extension Storage {
let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction) else { return nil }
let tsMessage: TSMessage
if message.sender == getUserPublicKey() {
tsMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction)
let tsOutgoingMessage = TSOutgoingMessage.from(message, associatedWith: thread, using: transaction)
var recipients: [String] = []
if let syncTarget = message.syncTarget {
recipients.append(syncTarget)
} else if let thread = thread as? TSGroupThread, thread.isClosedGroup {
recipients = thread.groupModel.groupMemberIds
}
recipients.forEach { recipient in
tsOutgoingMessage.update(withSentRecipient: recipient, wasSentByUD: true, transaction: transaction)
}
tsMessage = tsOutgoingMessage
} else {
tsMessage = TSIncomingMessage.from(message, quotedMessage: quotedMessage, linkPreview: linkPreview, associatedWith: thread)
}