Use `Message` type to determine send function
Throws on invalid message type.
This commit is contained in:
parent
5203d945c9
commit
879b6f58f4
|
@ -11,7 +11,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
const { Attachment } = window.Whisper.Types;
|
const { Attachment, Message } = window.Whisper.Types;
|
||||||
|
|
||||||
// TODO: Factor out private and group subclasses of Conversation
|
// TODO: Factor out private and group subclasses of Conversation
|
||||||
|
|
||||||
|
@ -643,12 +643,17 @@
|
||||||
lastMessage: message.getNotificationText(),
|
lastMessage: message.getNotificationText(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let sendFunc;
|
const conversationType = this.get('type');
|
||||||
if (this.get('type') === 'private') {
|
const sendFunc = (() => {
|
||||||
sendFunc = textsecure.messaging.sendMessageToNumber;
|
switch (conversationType) {
|
||||||
} else {
|
case Message.PRIVATE:
|
||||||
sendFunc = textsecure.messaging.sendMessageToGroup;
|
return textsecure.messaging.sendMessageToNumber;
|
||||||
}
|
case Message.GROUP:
|
||||||
|
return textsecure.messaging.sendMessageToGroup;
|
||||||
|
default:
|
||||||
|
throw new TypeError(`Invalid conversation type: '${conversationType}'`);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
let profileKey;
|
let profileKey;
|
||||||
if (this.get('profileSharing')) {
|
if (this.get('profileSharing')) {
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
window.Whisper.Types = window.Whisper.Types || {};
|
window.Whisper.Types = window.Whisper.Types || {};
|
||||||
window.Whisper.Types.Attachment = require('./js/modules/types/attachment');
|
window.Whisper.Types.Attachment = require('./js/modules/types/attachment');
|
||||||
|
window.Whisper.Types.Message = require('./js/modules/types/message');
|
||||||
|
|
||||||
// We pull this in last, because the native module involved appears to be sensitive to
|
// We pull this in last, because the native module involved appears to be sensitive to
|
||||||
// /tmp mounted as noexec on Linux.
|
// /tmp mounted as noexec on Linux.
|
||||||
|
|
Loading…
Reference in New Issue