Skip to content

Commit

Permalink
Generate a better room message for media
Browse files Browse the repository at this point in the history
Mainly, set originId to fix ChatSecure#523 (isDuplicate returned false for MAM
catchup, because of this)
  • Loading branch information
N-Pex committed Feb 9, 2018
1 parent bd79464 commit 06432f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ChatSecure/Classes/Controllers/FileTransferManager.swift
Expand Up @@ -428,13 +428,14 @@ public class FileTransferManager: NSObject, OTRServerCapabilitiesDelegate {
message.messageSecurityInfo = OTRMessageEncryptionInfo(messageSecurity: security)
return message
} else if let room = thread as? OTRXMPPRoom {
let message = OTRXMPPRoomMessage()!
message.messageDate = Date()
message.roomUniqueId = room.threadIdentifier
message.roomJID = room.jid
message.senderJID = room.ownJID
message.state = .needsSending
message.mediaItemId = mediaItem.uniqueId
var message:OTRXMPPRoomMessage? = nil
self.connection.read({ (transaction) in
message = room.outgoingMessage(withText: "", transaction: transaction) as? OTRXMPPRoomMessage
})
if let message = message {
message.messageText = nil
message.mediaItemId = mediaItem.uniqueId
}
return message
}
return nil
Expand Down
5 changes: 5 additions & 0 deletions ChatSecure/Classes/Controllers/XMPP/Storage/RoomStorage.swift
Expand Up @@ -72,6 +72,11 @@ import YapDatabase
// TODO unify this with the non-MUC receipt logic
OTRXMPPRoomMessage.handleDeliveryReceiptRequest(message: xmppMessage, xmppStream: xmppStream)

// If this is a receipt, we are done
if xmppMessage.hasReceiptResponse {
return
}

let stanzaId = xmppMessage.extractStanzaId(account: account, capabilities: self.capabilities)
let originId = xmppMessage.originId

Expand Down

0 comments on commit 06432f2

Please sign in to comment.