Send message: Pull expireTimer, recipients, dest before queueJob

This commit is contained in:
Scott Nonnenberg 2018-06-13 16:29:35 -07:00
parent dfa1f0797c
commit 5fca44d1b1

View file

@ -749,6 +749,15 @@
}, },
sendMessage(body, attachments, quote) { sendMessage(body, attachments, quote) {
const destination = this.id;
const expireTimer = this.get('expireTimer');
const recipients = this.getRecipients();
let profileKey;
if (this.get('profileSharing')) {
profileKey = storage.get('profileKey');
}
this.queueJob(async () => { this.queueJob(async () => {
const now = Date.now(); const now = Date.now();
@ -762,18 +771,18 @@
const messageWithSchema = await upgradeMessageSchema({ const messageWithSchema = await upgradeMessageSchema({
type: 'outgoing', type: 'outgoing',
body, body,
conversationId: this.id, conversationId: destination,
quote, quote,
attachments, attachments,
sent_at: now, sent_at: now,
received_at: now, received_at: now,
expireTimer: this.get('expireTimer'), expireTimer,
recipients: this.getRecipients(), recipients,
}); });
const message = this.addSingleMessage(messageWithSchema); const message = this.addSingleMessage(messageWithSchema);
if (this.isPrivate()) { if (this.isPrivate()) {
message.set({ destination: this.id }); message.set({ destination });
} }
message.save(); message.save();
@ -797,22 +806,17 @@
} }
})(); })();
let profileKey;
if (this.get('profileSharing')) {
profileKey = storage.get('profileKey');
}
const attachmentsWithData = await Promise.all( const attachmentsWithData = await Promise.all(
messageWithSchema.attachments.map(loadAttachmentData) messageWithSchema.attachments.map(loadAttachmentData)
); );
message.send( message.send(
sendFunction( sendFunction(
this.get('id'), destination,
body, body,
attachmentsWithData, attachmentsWithData,
quote, quote,
now, now,
this.get('expireTimer'), expireTimer,
profileKey profileKey
) )
); );