Fix closed group message status handling
This commit is contained in:
parent
3cf87d40ab
commit
21810a0c4c
|
@ -79,7 +79,7 @@ public final class MessageSender : NSObject {
|
|||
// Stop here if this is a self-send
|
||||
guard !isSelfSend else {
|
||||
storage.withAsync({ transaction in
|
||||
MessageSender.handleSuccessfulMessageSend(message, using: transaction)
|
||||
MessageSender.handleSuccessfulMessageSend(message, to: destination, using: transaction)
|
||||
}, completion: { })
|
||||
seal.fulfill(())
|
||||
return promise
|
||||
|
@ -192,7 +192,7 @@ public final class MessageSender : NSObject {
|
|||
// Handle completion
|
||||
let _ = promise.done(on: DispatchQueue.main) {
|
||||
storage.withAsync({ transaction in
|
||||
MessageSender.handleSuccessfulMessageSend(message, using: transaction)
|
||||
MessageSender.handleSuccessfulMessageSend(message, to: destination,X using: transaction)
|
||||
}, completion: { })
|
||||
if case .contact(_) = destination, message is VisibleMessage, !isSelfSend {
|
||||
NotificationCenter.default.post(name: .messageSent, object: NSNumber(value: message.sentTimestamp!))
|
||||
|
@ -252,7 +252,7 @@ public final class MessageSender : NSObject {
|
|||
// Handle completion
|
||||
let _ = promise.done(on: DispatchQueue.global(qos: .userInitiated)) {
|
||||
storage.withAsync({ transaction in
|
||||
MessageSender.handleSuccessfulMessageSend(message, using: transaction)
|
||||
MessageSender.handleSuccessfulMessageSend(message, to: destination, using: transaction)
|
||||
}, completion: { })
|
||||
}
|
||||
// Return
|
||||
|
|
|
@ -74,11 +74,18 @@ extension MessageSender : SharedSenderKeysDelegate {
|
|||
|
||||
// MARK: - Success & Failure Handling
|
||||
|
||||
public static func handleSuccessfulMessageSend(_ message: Message, using transaction: Any) {
|
||||
public static func handleSuccessfulMessageSend(_ message: Message, to destination: Message.Destination, using transaction: Any) {
|
||||
guard let tsMessage = TSOutgoingMessage.find(withTimestamp: message.sentTimestamp!) else { return }
|
||||
tsMessage.openGroupServerMessageID = message.openGroupServerMessageID ?? 0
|
||||
tsMessage.isOpenGroupMessage = tsMessage.openGroupServerMessageID != 0
|
||||
tsMessage.update(withSentRecipient: message.recipient!, wasSentByUD: true, transaction: transaction as! YapDatabaseReadWriteTransaction)
|
||||
var recipients = [ message.recipient! ]
|
||||
if case .closedGroup(_) = destination, let threadID = message.threadID, // threadID should always be set at this point
|
||||
let thread = TSGroupThread.fetch(uniqueId: threadID, transaction: transaction as! YapDatabaseReadTransaction), thread.usesSharedSenderKeys {
|
||||
recipients = thread.groupModel.groupMemberIds
|
||||
}
|
||||
recipients.forEach { recipient in
|
||||
tsMessage.update(withSentRecipient: recipient, wasSentByUD: true, transaction: transaction as! YapDatabaseReadWriteTransaction)
|
||||
}
|
||||
OWSDisappearingMessagesJob.shared().startAnyExpiration(for: tsMessage, expirationStartedAt: NSDate.millisecondTimestamp(), transaction: transaction as! YapDatabaseReadWriteTransaction)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue