File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,22 @@ function isCombinableFileMessage(message: ChatMessage): boolean {
4949 return file . mimetype !== 'text/vcard' && ! file . mimetype . startsWith ( 'audio/' )
5050}
5151
52+ /**
53+ * Checks whether file share message referenceId follows the group pattern
54+ * (see prepareTemporaryMessage.ts for the format)
55+ *
56+ * @param id referenceId
57+ * @return uploadHash (repeating part for single context upload) or original referenceId
58+ */
59+ function getUploadHashFromReferenceId ( id : string ) : string {
60+ const [ uploadHash , order ] = id . split ( '-' )
61+ if ( uploadHash . length === 60 && Number . isInteger ( + order ) ) {
62+ return uploadHash
63+ } else {
64+ return id
65+ }
66+ }
67+
5268/**
5369 * Check whether two file shares belong to each other: they are replies to the same message
5470 * (or no replies at all) and they were shared together in a single context
@@ -58,10 +74,8 @@ function isCombinableFileMessage(message: ChatMessage): boolean {
5874 */
5975function canBeCombinedWith ( message1 : ChatMessage , message2 : ChatMessage ) : boolean {
6076 return message1 . parent ?. id === message2 . parent ?. id
61- // FIXME the timestamp is not a reliable indicator here, should instead
62- // create referenceId differently (e.g. as `${SHA(uploadId) + SHA(Math.random())}`)
63- // and base splitting on this (should be aligned with mobile clients as well)
64- && message1 . timestamp - message2 . timestamp <= 30
77+ && ! ! message1 . referenceId && ! ! message2 . referenceId
78+ && getUploadHashFromReferenceId ( message1 . referenceId ) === getUploadHashFromReferenceId ( message2 . referenceId )
6579}
6680
6781/**
You can’t perform that action at this time.
0 commit comments