Move attachment processing closer to sending
This helps ensure processing happens uniformly, regardless of which code paths are taken to send an attachment.
This commit is contained in:
parent
532ac3e273
commit
d70d70e52c
|
@ -5,6 +5,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
|
const { Attachment } = window.Whisper;
|
||||||
|
|
||||||
// TODO: Factor out private and group subclasses of Conversation
|
// TODO: Factor out private and group subclasses of Conversation
|
||||||
|
|
||||||
var COLORS = [
|
var COLORS = [
|
||||||
|
@ -599,7 +601,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
sendMessage: function(body, attachments) {
|
sendMessage: function(body, attachments) {
|
||||||
this.queueJob(function() {
|
this.queueJob(async () => {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -609,11 +611,14 @@
|
||||||
now
|
now
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const processedAttachments = await Promise.all(
|
||||||
|
attachments.map(Attachment.process)
|
||||||
|
);
|
||||||
var message = this.messageCollection.add({
|
var message = this.messageCollection.add({
|
||||||
body : body,
|
body : body,
|
||||||
conversationId : this.id,
|
conversationId : this.id,
|
||||||
type : 'outgoing',
|
type : 'outgoing',
|
||||||
attachments : attachments,
|
attachments : processedAttachments,
|
||||||
sent_at : now,
|
sent_at : now,
|
||||||
received_at : now,
|
received_at : now,
|
||||||
expireTimer : this.get('expireTimer'),
|
expireTimer : this.get('expireTimer'),
|
||||||
|
@ -643,8 +648,17 @@
|
||||||
profileKey = storage.get('profileKey');
|
profileKey = storage.get('profileKey');
|
||||||
}
|
}
|
||||||
|
|
||||||
message.send(sendFunc(this.get('id'), body, attachments, now, this.get('expireTimer'), profileKey));
|
message.send(
|
||||||
}.bind(this));
|
sendFunc(
|
||||||
|
this.get('id'),
|
||||||
|
body,
|
||||||
|
processedAttachments,
|
||||||
|
now,
|
||||||
|
this.get('expireTimer'),
|
||||||
|
profileKey
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
updateLastMessage: function() {
|
updateLastMessage: function() {
|
||||||
|
|
|
@ -216,8 +216,7 @@
|
||||||
|
|
||||||
return this.autoScale(file)
|
return this.autoScale(file)
|
||||||
.then(this.readFile)
|
.then(this.readFile)
|
||||||
.then(setFlags(attachmentFlags))
|
.then(setFlags(attachmentFlags));
|
||||||
.then(Attachment.process);
|
|
||||||
},
|
},
|
||||||
/* jshint ignore:end */
|
/* jshint ignore:end */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
Loading…
Reference in New Issue