diff --git a/ts/models/message.ts b/ts/models/message.ts index 30639d171..1760d6c19 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -19,7 +19,6 @@ import { import autoBind from 'auto-bind'; import { saveMessage } from '../../ts/data/data'; import { ConversationModel, ConversationTypeEnum } from './conversation'; -import { getSuggestedFilenameSending } from '../types/Attachment'; import { actions as conversationActions } from '../state/ducks/conversations'; import { VisibleMessage } from '../session/messages/outgoing/visibleMessage/VisibleMessage'; import { buildSyncMessage } from '../session/utils/syncUtils'; @@ -742,15 +741,7 @@ export class MessageModel extends Backbone.Model { (this.get('attachments') || []).map(window.Signal.Migrations.loadAttachmentData) ); const body = this.get('body'); - const finalAttachments = attachmentsWithData; - - const filenameOverridenAttachments = finalAttachments.map((attachment: any) => ({ - ...attachment, - fileName: getSuggestedFilenameSending({ - attachment, - timestamp: Date.now(), - }), - })); + const finalAttachments = attachmentsWithData as Array; const quoteWithData = await window.Signal.Migrations.loadQuoteData(this.get('quote')); const previewWithData = await window.Signal.Migrations.loadPreviewData(this.get('preview')); @@ -765,7 +756,7 @@ export class MessageModel extends Backbone.Model { // we want to go for the v1, if this is an OpenGroupV1 or not an open group at all if (conversation?.isOpenGroupV2()) { const openGroupV2 = conversation.toOpenGroupV2(); - attachmentPromise = uploadAttachmentsV2(filenameOverridenAttachments, openGroupV2); + attachmentPromise = uploadAttachmentsV2(finalAttachments, openGroupV2); linkPreviewPromise = uploadLinkPreviewsV2(previewWithData, openGroupV2); quotePromise = uploadQuoteThumbnailsV2(openGroupV2, quoteWithData); } else { @@ -774,7 +765,7 @@ export class MessageModel extends Backbone.Model { const openGroupV1 = conversation?.isOpenGroupV1() ? conversation?.toOpenGroupV1() : undefined; attachmentPromise = AttachmentFsV2Utils.uploadAttachmentsToFsV2( - filenameOverridenAttachments, + finalAttachments, openGroupV1 ); linkPreviewPromise = AttachmentFsV2Utils.uploadLinkPreviewsToFsV2( diff --git a/ts/types/Attachment.ts b/ts/types/Attachment.ts index cdb632a37..bc2984fb0 100644 --- a/ts/types/Attachment.ts +++ b/ts/types/Attachment.ts @@ -346,22 +346,6 @@ export const getSuggestedFilename = ({ return `${prefix}${suffix}${indexSuffix}${extension}`; }; -// Used for overriden the sent filename of an attachment, but keeping the file extension the same -export const getSuggestedFilenameSending = ({ - attachment, - timestamp, -}: { - attachment: AttachmentType; - timestamp?: number | Date; -}): string => { - const prefix = 'session-attachment'; - const suffix = timestamp ? moment(timestamp).format('-YYYY-MM-DD-HHmmss') : ''; - const fileType = getFileExtension(attachment); - const extension = fileType ? `.${fileType}` : ''; - - return `${prefix}${suffix}${extension}`; -}; - export const getFileExtension = (attachment: AttachmentType): string | undefined => { // we override textplain to the extension of the file // for contenttype starting with application, the mimetype is probably wrong so just use the extension of the file instead