diff --git a/js/models/conversations.js b/js/models/conversations.js index cfb935f86..d24882a77 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -617,18 +617,17 @@ now ); - const upgradedAttachments = - await Promise.all(attachments.map(Attachment.upgradeSchema)); - const message = this.messageCollection.add({ + const messageWithSchema = await Message.upgradeSchema({ + type: 'outgoing', body, conversationId: this.id, - type: 'outgoing', - attachments: upgradedAttachments, + attachments, sent_at: now, received_at: now, expireTimer: this.get('expireTimer'), recipients: this.getRecipients(), }); + const message = this.messageCollection.add(messageWithSchema); if (this.isPrivate()) { message.set({ destination: this.id }); } @@ -641,7 +640,7 @@ }); const conversationType = this.get('type'); - const sendFunc = (() => { + const sendFunction = (() => { switch (conversationType) { case Message.PRIVATE: return textsecure.messaging.sendMessageToNumber; @@ -657,10 +656,10 @@ profileKey = storage.get('profileKey'); } - message.send(sendFunc( + message.send(sendFunction( this.get('id'), body, - upgradedAttachments, + messageWithSchema.attachments, now, this.get('expireTimer'), profileKey