|
|
@ -3,13 +3,15 @@ import { queueAttachmentDownloads } from './attachments';
|
|
|
|
import { Quote } from './types';
|
|
|
|
import { Quote } from './types';
|
|
|
|
import { ConversationModel } from '../../js/models/conversations';
|
|
|
|
import { ConversationModel } from '../../js/models/conversations';
|
|
|
|
import { MessageModel } from '../../js/models/messages';
|
|
|
|
import { MessageModel } from '../../js/models/messages';
|
|
|
|
|
|
|
|
import { PrimaryPubKey, PubKey } from '../session/types';
|
|
|
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
|
|
|
import { MultiDeviceProtocol } from '../session/protocols';
|
|
|
|
|
|
|
|
|
|
|
|
async function handleGroups(
|
|
|
|
async function handleGroups(
|
|
|
|
conversation: ConversationModel,
|
|
|
|
conversation: ConversationModel,
|
|
|
|
group: any,
|
|
|
|
group: any,
|
|
|
|
source: any
|
|
|
|
source: any
|
|
|
|
): Promise<any> {
|
|
|
|
): Promise<any> {
|
|
|
|
const _ = window.Lodash;
|
|
|
|
|
|
|
|
const textsecure = window.textsecure;
|
|
|
|
const textsecure = window.textsecure;
|
|
|
|
const GROUP_TYPES = textsecure.protobuf.GroupContext.Type;
|
|
|
|
const GROUP_TYPES = textsecure.protobuf.GroupContext.Type;
|
|
|
|
|
|
|
|
|
|
|
@ -93,7 +95,6 @@ async function copyFromQuotedMessage(
|
|
|
|
quote: Quote,
|
|
|
|
quote: Quote,
|
|
|
|
attemptCount: number = 1
|
|
|
|
attemptCount: number = 1
|
|
|
|
): Promise<void> {
|
|
|
|
): Promise<void> {
|
|
|
|
const _ = window.Lodash;
|
|
|
|
|
|
|
|
const { Whisper, MessageController } = window;
|
|
|
|
const { Whisper, MessageController } = window;
|
|
|
|
const { upgradeMessageSchema } = window.Signal.Migrations;
|
|
|
|
const { upgradeMessageSchema } = window.Signal.Migrations;
|
|
|
|
const { Message: TypedMessage, Errors } = window.Signal.Types;
|
|
|
|
const { Message: TypedMessage, Errors } = window.Signal.Types;
|
|
|
@ -277,10 +278,10 @@ function processProfileKey(
|
|
|
|
function handleMentions(
|
|
|
|
function handleMentions(
|
|
|
|
message: MessageModel,
|
|
|
|
message: MessageModel,
|
|
|
|
conversation: ConversationModel,
|
|
|
|
conversation: ConversationModel,
|
|
|
|
ourPrimaryNumber: string
|
|
|
|
ourPrimaryNumber: PrimaryPubKey
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
const body = message.get('body');
|
|
|
|
const body = message.get('body');
|
|
|
|
if (body && body.indexOf(`@${ourPrimaryNumber}`) !== -1) {
|
|
|
|
if (body && body.indexOf(`@${ourPrimaryNumber.key}`) !== -1) {
|
|
|
|
conversation.set({ mentionedUs: true });
|
|
|
|
conversation.set({ mentionedUs: true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -317,8 +318,6 @@ function handleSyncedReceipts(
|
|
|
|
message: MessageModel,
|
|
|
|
message: MessageModel,
|
|
|
|
conversation: ConversationModel
|
|
|
|
conversation: ConversationModel
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
const _ = window.Lodash;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const readReceipts = window.Whisper.ReadReceipts.forMessage(
|
|
|
|
const readReceipts = window.Whisper.ReadReceipts.forMessage(
|
|
|
|
conversation,
|
|
|
|
conversation,
|
|
|
|
message
|
|
|
|
message
|
|
|
@ -352,8 +351,6 @@ function handleSyncedReceipts(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handleSyncDeliveryReceipts(message: MessageModel, receipts: any) {
|
|
|
|
function handleSyncDeliveryReceipts(message: MessageModel, receipts: any) {
|
|
|
|
const _ = window.Lodash;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const sources = receipts.map((receipt: any) => receipt.get('source'));
|
|
|
|
const sources = receipts.map((receipt: any) => receipt.get('source'));
|
|
|
|
|
|
|
|
|
|
|
|
const deliveredTo = _.union(message.get('delivered_to') || [], sources);
|
|
|
|
const deliveredTo = _.union(message.get('delivered_to') || [], sources);
|
|
|
@ -371,11 +368,9 @@ async function handleRegularMessage(
|
|
|
|
message: MessageModel,
|
|
|
|
message: MessageModel,
|
|
|
|
initialMessage: any,
|
|
|
|
initialMessage: any,
|
|
|
|
source: string,
|
|
|
|
source: string,
|
|
|
|
isGroupMessage: boolean,
|
|
|
|
|
|
|
|
ourNumber: any,
|
|
|
|
ourNumber: any,
|
|
|
|
primarySource: any
|
|
|
|
primarySource: PubKey
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
const _ = window.Lodash;
|
|
|
|
|
|
|
|
const { ConversationController } = window;
|
|
|
|
const { ConversationController } = window;
|
|
|
|
const { upgradeMessageSchema } = window.Signal.Migrations;
|
|
|
|
const { upgradeMessageSchema } = window.Signal.Migrations;
|
|
|
|
|
|
|
|
|
|
|
@ -429,7 +424,9 @@ async function handleRegularMessage(
|
|
|
|
// Handle expireTimer found directly as part of a regular message
|
|
|
|
// Handle expireTimer found directly as part of a regular message
|
|
|
|
handleExpireTimer(source, message, dataMessage.expireTimer, conversation);
|
|
|
|
handleExpireTimer(source, message, dataMessage.expireTimer, conversation);
|
|
|
|
|
|
|
|
|
|
|
|
handleMentions(message, conversation, ourNumber);
|
|
|
|
const ourPrimary = await MultiDeviceProtocol.getPrimaryDevice(ourNumber);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleMentions(message, conversation, ourPrimary);
|
|
|
|
|
|
|
|
|
|
|
|
if (type === 'incoming') {
|
|
|
|
if (type === 'incoming') {
|
|
|
|
updateReadStatus(message, conversation);
|
|
|
|
updateReadStatus(message, conversation);
|
|
|
@ -465,7 +462,7 @@ async function handleRegularMessage(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (source !== ourNumber && primarySource) {
|
|
|
|
if (source !== ourNumber && primarySource) {
|
|
|
|
message.set({ source: primarySource });
|
|
|
|
message.set({ source: primarySource.key });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -506,10 +503,9 @@ export async function handleMessageJob(
|
|
|
|
conversation: ConversationModel,
|
|
|
|
conversation: ConversationModel,
|
|
|
|
initialMessage: any,
|
|
|
|
initialMessage: any,
|
|
|
|
ourNumber: string,
|
|
|
|
ourNumber: string,
|
|
|
|
confirm: any,
|
|
|
|
confirm: () => void,
|
|
|
|
source: string,
|
|
|
|
source: string,
|
|
|
|
isGroupMessage: any,
|
|
|
|
primarySource: PubKey
|
|
|
|
primarySource: any
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
window.log.info(
|
|
|
|
window.log.info(
|
|
|
|
`Starting handleDataMessage for message ${message.idForLogging()} in conversation ${conversation.idForLogging()}`
|
|
|
|
`Starting handleDataMessage for message ${message.idForLogging()} in conversation ${conversation.idForLogging()}`
|
|
|
@ -529,13 +525,12 @@ export async function handleMessageJob(
|
|
|
|
message,
|
|
|
|
message,
|
|
|
|
initialMessage,
|
|
|
|
initialMessage,
|
|
|
|
source,
|
|
|
|
source,
|
|
|
|
isGroupMessage,
|
|
|
|
|
|
|
|
ourNumber,
|
|
|
|
ourNumber,
|
|
|
|
primarySource.key
|
|
|
|
primarySource
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { Whisper, MessageController, ConversationController } = window;
|
|
|
|
const { Whisper, MessageController } = window;
|
|
|
|
|
|
|
|
|
|
|
|
const id = await window.Signal.Data.saveMessage(message.attributes, {
|
|
|
|
const id = await window.Signal.Data.saveMessage(message.attributes, {
|
|
|
|
Message: Whisper.Message,
|
|
|
|
Message: Whisper.Message,
|
|
|
|