Fix incorrect open group message timestamp
This commit is contained in:
parent
e8661cf4d7
commit
71df0b84f0
|
@ -11,16 +11,12 @@ internal extension OpenGroupMessage {
|
||||||
let quote: OpenGroupMessage.Quote? = {
|
let quote: OpenGroupMessage.Quote? = {
|
||||||
if let quote = message.quote {
|
if let quote = message.quote {
|
||||||
guard quote.isValid else { return nil }
|
guard quote.isValid else { return nil }
|
||||||
var quotedMessageServerID: UInt64?
|
|
||||||
TSDatabaseSecondaryIndexes.enumerateMessages(withTimestamp: quote.timestamp!, with: { _, key, _ in
|
|
||||||
guard let message = TSInteraction.fetch(uniqueId: key, transaction: transaction) as? TSMessage else { return }
|
|
||||||
quotedMessageServerID = message.openGroupServerMessageID
|
|
||||||
}, using: transaction)
|
|
||||||
let quotedMessageBody = quote.text ?? String(quote.timestamp!) // The back-end doesn't accept messages without a body so we use this as a workaround
|
let quotedMessageBody = quote.text ?? String(quote.timestamp!) // The back-end doesn't accept messages without a body so we use this as a workaround
|
||||||
if let quotedAttachmentID = quote.attachmentID, let index = attachmentIDs.firstIndex(of: quotedAttachmentID) {
|
if let quotedAttachmentID = quote.attachmentID, let index = attachmentIDs.firstIndex(of: quotedAttachmentID) {
|
||||||
attachmentIDs.remove(at: index)
|
attachmentIDs.remove(at: index)
|
||||||
}
|
}
|
||||||
return OpenGroupMessage.Quote(quotedMessageTimestamp: quote.timestamp!, quoteePublicKey: quote.publicKey!, quotedMessageBody: quotedMessageBody, quotedMessageServerID: quotedMessageServerID)
|
// FIXME: For some reason the server always returns a 500 if quotedMessageServerID is set...
|
||||||
|
return OpenGroupMessage.Quote(quotedMessageTimestamp: quote.timestamp!, quoteePublicKey: quote.publicKey!, quotedMessageBody: quotedMessageBody, quotedMessageServerID: nil)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,9 @@ public final class MessageSender : NSObject {
|
||||||
internal static func sendToOpenGroupDestination(_ destination: Message.Destination, message: Message, using transaction: Any) -> Promise<Void> {
|
internal static func sendToOpenGroupDestination(_ destination: Message.Destination, message: Message, using transaction: Any) -> Promise<Void> {
|
||||||
let (promise, seal) = Promise<Void>.pending()
|
let (promise, seal) = Promise<Void>.pending()
|
||||||
let storage = Configuration.shared.storage
|
let storage = Configuration.shared.storage
|
||||||
|
if message.sentTimestamp == nil { // Visible messages will already have their sent timestamp set
|
||||||
message.sentTimestamp = NSDate.millisecondTimestamp()
|
message.sentTimestamp = NSDate.millisecondTimestamp()
|
||||||
|
}
|
||||||
message.sender = storage.getUserPublicKey()
|
message.sender = storage.getUserPublicKey()
|
||||||
switch destination {
|
switch destination {
|
||||||
case .contact(_): preconditionFailure()
|
case .contact(_): preconditionFailure()
|
||||||
|
|
Loading…
Reference in New Issue