Upgrade message schema before sending
This commit is contained in:
parent
a5edbf8328
commit
cd3aee962d
1 changed files with 7 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue