Upgrade message schema before sending

This commit is contained in:
Daniel Gasienica 2018-03-14 16:00:12 -04:00
parent a5edbf8328
commit cd3aee962d

View file

@ -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