Move to MessageCache.saveMessage, queue downloads piecemeal
This commit is contained in:
parent
197660a966
commit
ed30059bd5
32 changed files with 138 additions and 298 deletions
|
@ -3437,10 +3437,7 @@ async function appendChangeMessages(
|
||||||
strictAssert(first !== undefined, 'First message must be there');
|
strictAssert(first !== undefined, 'First message must be there');
|
||||||
|
|
||||||
log.info(`appendChangeMessages/${logId}: updating ${first.id}`);
|
log.info(`appendChangeMessages/${logId}: updating ${first.id}`);
|
||||||
await DataWriter.saveMessage(first, {
|
await window.MessageCache.saveMessage(first, {
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
|
|
||||||
// We don't use forceSave here because this is an update of existing
|
// We don't use forceSave here because this is an update of existing
|
||||||
// message.
|
// message.
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,6 @@ import {
|
||||||
import { safeParsePartial } from '../util/schemas';
|
import { safeParsePartial } from '../util/schemas';
|
||||||
import { deleteDownloadsJobQueue } from './deleteDownloadsJobQueue';
|
import { deleteDownloadsJobQueue } from './deleteDownloadsJobQueue';
|
||||||
import { createBatcher } from '../util/batcher';
|
import { createBatcher } from '../util/batcher';
|
||||||
import { postSaveUpdates } from '../util/cleanup';
|
|
||||||
|
|
||||||
export enum AttachmentDownloadUrgency {
|
export enum AttachmentDownloadUrgency {
|
||||||
IMMEDIATE = 'immediate',
|
IMMEDIATE = 'immediate',
|
||||||
|
@ -431,10 +430,7 @@ async function runDownloadAttachmentJob({
|
||||||
} finally {
|
} finally {
|
||||||
// This will fail if the message has been deleted before the download finished, which
|
// This will fail if the message has been deleted before the download finished, which
|
||||||
// is good
|
// is good
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
} from './handleMultipleSendErrors';
|
} from './handleMultipleSendErrors';
|
||||||
import { ourProfileKeyService } from '../../services/ourProfileKey';
|
import { ourProfileKeyService } from '../../services/ourProfileKey';
|
||||||
import { wrapWithSyncMessageSend } from '../../util/wrapWithSyncMessageSend';
|
import { wrapWithSyncMessageSend } from '../../util/wrapWithSyncMessageSend';
|
||||||
import { DataWriter } from '../../sql/Client';
|
|
||||||
|
|
||||||
import type { ConversationModel } from '../../models/conversations';
|
import type { ConversationModel } from '../../models/conversations';
|
||||||
import type {
|
import type {
|
||||||
|
@ -38,7 +37,6 @@ import type { LoggerType } from '../../types/Logging';
|
||||||
import type { ServiceIdString } from '../../types/ServiceId';
|
import type { ServiceIdString } from '../../types/ServiceId';
|
||||||
import { isStory } from '../../messages/helpers';
|
import { isStory } from '../../messages/helpers';
|
||||||
import { sendToGroup } from '../../util/sendToGroup';
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
|
|
||||||
export async function sendDeleteForEveryone(
|
export async function sendDeleteForEveryone(
|
||||||
conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
|
@ -306,10 +304,7 @@ async function updateMessageWithSuccessfulSends(
|
||||||
deletedForEveryoneSendStatus: {},
|
deletedForEveryoneSendStatus: {},
|
||||||
deletedForEveryoneFailed: undefined,
|
deletedForEveryoneFailed: undefined,
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -330,10 +325,7 @@ async function updateMessageWithSuccessfulSends(
|
||||||
deletedForEveryoneSendStatus,
|
deletedForEveryoneSendStatus,
|
||||||
deletedForEveryoneFailed: undefined,
|
deletedForEveryoneFailed: undefined,
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateMessageWithFailure(
|
async function updateMessageWithFailure(
|
||||||
|
@ -347,8 +339,5 @@ async function updateMessageWithFailure(
|
||||||
);
|
);
|
||||||
|
|
||||||
message.set({ deletedForEveryoneFailed: true });
|
message.set({ deletedForEveryoneFailed: true });
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
maybeExpandErrors,
|
maybeExpandErrors,
|
||||||
} from './handleMultipleSendErrors';
|
} from './handleMultipleSendErrors';
|
||||||
import { ourProfileKeyService } from '../../services/ourProfileKey';
|
import { ourProfileKeyService } from '../../services/ourProfileKey';
|
||||||
import { DataWriter } from '../../sql/Client';
|
|
||||||
|
|
||||||
import type { ConversationModel } from '../../models/conversations';
|
import type { ConversationModel } from '../../models/conversations';
|
||||||
import type {
|
import type {
|
||||||
|
@ -29,7 +28,6 @@ import { SendMessageProtoError } from '../../textsecure/Errors';
|
||||||
import { strictAssert } from '../../util/assert';
|
import { strictAssert } from '../../util/assert';
|
||||||
import type { LoggerType } from '../../types/Logging';
|
import type { LoggerType } from '../../types/Logging';
|
||||||
import { isStory } from '../../messages/helpers';
|
import { isStory } from '../../messages/helpers';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
|
|
||||||
export async function sendDeleteStoryForEveryone(
|
export async function sendDeleteStoryForEveryone(
|
||||||
ourConversation: ConversationModel,
|
ourConversation: ConversationModel,
|
||||||
|
@ -280,10 +278,7 @@ async function updateMessageWithSuccessfulSends(
|
||||||
deletedForEveryoneSendStatus: {},
|
deletedForEveryoneSendStatus: {},
|
||||||
deletedForEveryoneFailed: undefined,
|
deletedForEveryoneFailed: undefined,
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -304,10 +299,7 @@ async function updateMessageWithSuccessfulSends(
|
||||||
deletedForEveryoneSendStatus,
|
deletedForEveryoneSendStatus,
|
||||||
deletedForEveryoneFailed: undefined,
|
deletedForEveryoneFailed: undefined,
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateMessageWithFailure(
|
async function updateMessageWithFailure(
|
||||||
|
@ -321,8 +313,5 @@ async function updateMessageWithFailure(
|
||||||
);
|
);
|
||||||
|
|
||||||
message.set({ deletedForEveryoneFailed: true });
|
message.set({ deletedForEveryoneFailed: true });
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
import PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
|
|
||||||
import { DataWriter } from '../../sql/Client';
|
|
||||||
import * as Errors from '../../types/errors';
|
import * as Errors from '../../types/errors';
|
||||||
import { strictAssert } from '../../util/assert';
|
import { strictAssert } from '../../util/assert';
|
||||||
import type { MessageModel } from '../../models/messages';
|
import type { MessageModel } from '../../models/messages';
|
||||||
|
@ -61,7 +60,6 @@ import {
|
||||||
saveErrorsOnMessage,
|
saveErrorsOnMessage,
|
||||||
} from '../../test-node/util/messageFailures';
|
} from '../../test-node/util/messageFailures';
|
||||||
import { getMessageIdForLogging } from '../../util/idForLogging';
|
import { getMessageIdForLogging } from '../../util/idForLogging';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
import { send, sendSyncMessageOnly } from '../../messages/send';
|
import { send, sendSyncMessageOnly } from '../../messages/send';
|
||||||
|
|
||||||
const MAX_CONCURRENT_ATTACHMENT_UPLOADS = 5;
|
const MAX_CONCURRENT_ATTACHMENT_UPLOADS = 5;
|
||||||
|
@ -667,10 +665,7 @@ async function getMessageSendData({
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Save message after uploading attachments
|
// Save message after uploading attachments
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
|
|
||||||
const storyReaction = message.get('storyReaction');
|
const storyReaction = message.get('storyReaction');
|
||||||
const storySourceServiceId = storyMessage?.get('sourceServiceId');
|
const storySourceServiceId = storyMessage?.get('sourceServiceId');
|
||||||
|
|
|
@ -10,7 +10,6 @@ import type { CallbackResultType } from '../../textsecure/Types.d';
|
||||||
import { MessageModel } from '../../models/messages';
|
import { MessageModel } from '../../models/messages';
|
||||||
import type { MessageReactionType } from '../../model-types.d';
|
import type { MessageReactionType } from '../../model-types.d';
|
||||||
import type { ConversationModel } from '../../models/conversations';
|
import type { ConversationModel } from '../../models/conversations';
|
||||||
import { DataWriter } from '../../sql/Client';
|
|
||||||
|
|
||||||
import * as reactionUtil from '../../reactions/util';
|
import * as reactionUtil from '../../reactions/util';
|
||||||
import { isSent, SendStatus } from '../../messages/MessageSendState';
|
import { isSent, SendStatus } from '../../messages/MessageSendState';
|
||||||
|
@ -42,7 +41,6 @@ import { isConversationUnregistered } from '../../util/isConversationUnregistere
|
||||||
import type { LoggerType } from '../../types/Logging';
|
import type { LoggerType } from '../../types/Logging';
|
||||||
import { sendToGroup } from '../../util/sendToGroup';
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
import { hydrateStoryContext } from '../../util/hydrateStoryContext';
|
import { hydrateStoryContext } from '../../util/hydrateStoryContext';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
import { send, sendSyncMessageOnly } from '../../messages/send';
|
import { send, sendSyncMessageOnly } from '../../messages/send';
|
||||||
|
|
||||||
export async function sendReaction(
|
export async function sendReaction(
|
||||||
|
@ -90,10 +88,7 @@ export async function sendReaction(
|
||||||
if (!canReact(message.attributes, ourConversationId, findAndFormatContact)) {
|
if (!canReact(message.attributes, ourConversationId, findAndFormatContact)) {
|
||||||
log.info(`could not react to ${messageId}. Removing this pending reaction`);
|
log.info(`could not react to ${messageId}. Removing this pending reaction`);
|
||||||
markReactionFailed(message, pendingReaction);
|
markReactionFailed(message, pendingReaction);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +97,7 @@ export async function sendReaction(
|
||||||
`reacting to message ${messageId} ran out of time. Giving up on sending it`
|
`reacting to message ${messageId} ran out of time. Giving up on sending it`
|
||||||
);
|
);
|
||||||
markReactionFailed(message, pendingReaction);
|
markReactionFailed(message, pendingReaction);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,10 +339,8 @@ export async function sendReaction(
|
||||||
await hydrateStoryContext(reactionMessage.id, message.attributes, {
|
await hydrateStoryContext(reactionMessage.id, message.attributes, {
|
||||||
shouldSave: false,
|
shouldSave: false,
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(reactionMessage.attributes, {
|
await window.MessageCache.saveMessage(reactionMessage.attributes, {
|
||||||
ourAci,
|
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.MessageCache.register(reactionMessage);
|
window.MessageCache.register(reactionMessage);
|
||||||
|
@ -382,10 +372,7 @@ export async function sendReaction(
|
||||||
toThrow: originalError || thrownError,
|
toThrow: originalError || thrownError,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import type { ServiceIdString } from '../../types/ServiceId';
|
||||||
import type { StoryDistributionIdString } from '../../types/StoryDistributionId';
|
import type { StoryDistributionIdString } from '../../types/StoryDistributionId';
|
||||||
import * as Errors from '../../types/errors';
|
import * as Errors from '../../types/errors';
|
||||||
import type { StoryMessageRecipientsType } from '../../types/Stories';
|
import type { StoryMessageRecipientsType } from '../../types/Stories';
|
||||||
import { DataReader, DataWriter } from '../../sql/Client';
|
import { DataReader } from '../../sql/Client';
|
||||||
import { SignalService as Proto } from '../../protobuf';
|
import { SignalService as Proto } from '../../protobuf';
|
||||||
import { getMessagesById } from '../../messages/getMessagesById';
|
import { getMessagesById } from '../../messages/getMessagesById';
|
||||||
import {
|
import {
|
||||||
|
@ -44,7 +44,6 @@ import {
|
||||||
notifyStorySendFailed,
|
notifyStorySendFailed,
|
||||||
saveErrorsOnMessage,
|
saveErrorsOnMessage,
|
||||||
} from '../../test-node/util/messageFailures';
|
} from '../../test-node/util/messageFailures';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
import { send } from '../../messages/send';
|
import { send } from '../../messages/send';
|
||||||
|
|
||||||
export async function sendStory(
|
export async function sendStory(
|
||||||
|
@ -550,10 +549,7 @@ export async function sendStory(
|
||||||
}
|
}
|
||||||
|
|
||||||
message.set({ sendStateByConversationId: newSendStateByConversationId });
|
message.set({ sendStateByConversationId: newSendStateByConversationId });
|
||||||
return DataWriter.saveMessage(message.attributes, {
|
return window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import {
|
||||||
} from '../types/Receipt';
|
} from '../types/Receipt';
|
||||||
import { drop } from '../util/drop';
|
import { drop } from '../util/drop';
|
||||||
import { getMessageById } from '../messages/getMessageById';
|
import { getMessageById } from '../messages/getMessageById';
|
||||||
import { postSaveUpdates } from '../util/cleanup';
|
|
||||||
import { MessageModel } from '../models/messages';
|
import { MessageModel } from '../models/messages';
|
||||||
|
|
||||||
const { deleteSentProtoRecipient, removeSyncTaskById } = DataWriter;
|
const { deleteSentProtoRecipient, removeSyncTaskById } = DataWriter;
|
||||||
|
@ -200,8 +199,7 @@ async function processReceiptsForMessage(
|
||||||
|
|
||||||
const { validReceipts } = await updateMessageWithReceipts(message, receipts);
|
const { validReceipts } = await updateMessageWithReceipts(message, receipts);
|
||||||
|
|
||||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
await DataWriter.saveMessage(message.attributes, { ourAci, postSaveUpdates });
|
|
||||||
|
|
||||||
// Confirm/remove receipts, and delete sent protos
|
// Confirm/remove receipts, and delete sent protos
|
||||||
for (const receipt of validReceipts) {
|
for (const receipt of validReceipts) {
|
||||||
|
|
|
@ -39,7 +39,6 @@ import {
|
||||||
conversationJobQueue,
|
conversationJobQueue,
|
||||||
conversationQueueJobEnum,
|
conversationQueueJobEnum,
|
||||||
} from '../jobs/conversationJobQueue';
|
} from '../jobs/conversationJobQueue';
|
||||||
import { postSaveUpdates } from '../util/cleanup';
|
|
||||||
|
|
||||||
export type ReactionAttributesType = {
|
export type ReactionAttributesType = {
|
||||||
emoji: string;
|
emoji: string;
|
||||||
|
@ -389,10 +388,8 @@ export async function handleReaction(
|
||||||
shouldSave: false,
|
shouldSave: false,
|
||||||
});
|
});
|
||||||
// Note: generatedMessage comes with an id, so we have to force this save
|
// Note: generatedMessage comes with an id, so we have to force this save
|
||||||
await DataWriter.saveMessage(generatedMessage.attributes, {
|
await window.MessageCache.saveMessage(generatedMessage.attributes, {
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info('Reactions.onReaction adding reaction to story', {
|
log.info('Reactions.onReaction adding reaction to story', {
|
||||||
|
@ -555,10 +552,8 @@ export async function handleReaction(
|
||||||
await hydrateStoryContext(generatedMessage.id, message.attributes, {
|
await hydrateStoryContext(generatedMessage.id, message.attributes, {
|
||||||
shouldSave: false,
|
shouldSave: false,
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(generatedMessage.attributes, {
|
await window.MessageCache.saveMessage(generatedMessage.attributes, {
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.MessageCache.register(generatedMessage);
|
window.MessageCache.register(generatedMessage);
|
||||||
|
@ -586,20 +581,15 @@ export async function handleReaction(
|
||||||
jobToInsert.id
|
jobToInsert.id
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes, {
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await conversationJobQueue.add(jobData);
|
await conversationJobQueue.add(jobData);
|
||||||
}
|
}
|
||||||
} else if (shouldPersist && !isStory(message.attributes)) {
|
} else if (shouldPersist && !isStory(message.attributes)) {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
window.reduxActions.conversations.markOpenConversationRead(conversation.id);
|
window.reduxActions.conversations.markOpenConversationRead(conversation.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,12 +124,11 @@ export async function onSync(sync: ViewSyncAttributesType): Promise<void> {
|
||||||
|
|
||||||
const attachments = message.get('attachments');
|
const attachments = message.get('attachments');
|
||||||
if (!attachments?.every(isDownloaded)) {
|
if (!attachments?.every(isDownloaded)) {
|
||||||
const updatedFields = await queueAttachmentDownloads(
|
const didQueueDownload = await queueAttachmentDownloads(message, {
|
||||||
message.attributes,
|
urgency: AttachmentDownloadUrgency.STANDARD,
|
||||||
{ urgency: AttachmentDownloadUrgency.STANDARD }
|
});
|
||||||
);
|
if (didQueueDownload) {
|
||||||
if (updatedFields) {
|
didChangeMessage = true;
|
||||||
message.set(updatedFields);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {
|
||||||
SendStatus,
|
SendStatus,
|
||||||
} from './MessageSendState';
|
} from './MessageSendState';
|
||||||
import { DataReader, DataWriter } from '../sql/Client';
|
import { DataReader, DataWriter } from '../sql/Client';
|
||||||
import { eraseMessageContents, postSaveUpdates } from '../util/cleanup';
|
import { eraseMessageContents } from '../util/cleanup';
|
||||||
import {
|
import {
|
||||||
isDirectConversation,
|
isDirectConversation,
|
||||||
isGroup,
|
isGroup,
|
||||||
|
@ -200,10 +200,7 @@ export async function handleDataMessage(
|
||||||
sendStateByConversationId,
|
sendStateByConversationId,
|
||||||
unidentifiedDeliveries: [...unidentifiedDeliveriesSet],
|
unidentifiedDeliveries: [...unidentifiedDeliveriesSet],
|
||||||
});
|
});
|
||||||
await DataWriter.saveMessage(toUpdate.attributes, {
|
await window.MessageCache.saveMessage(toUpdate.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
|
|
||||||
confirm();
|
confirm();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import { isGroup } from '../util/whatTypeOfConversation';
|
||||||
import { handleMessageSend } from '../util/handleMessageSend';
|
import { handleMessageSend } from '../util/handleMessageSend';
|
||||||
import { getSendOptions } from '../util/getSendOptions';
|
import { getSendOptions } from '../util/getSendOptions';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { DataWriter } from '../sql/Client';
|
|
||||||
import {
|
import {
|
||||||
getPropForTimestamp,
|
getPropForTimestamp,
|
||||||
getChangesForPropAtTimestamp,
|
getChangesForPropAtTimestamp,
|
||||||
|
@ -21,7 +20,6 @@ import {
|
||||||
notifyStorySendFailed,
|
notifyStorySendFailed,
|
||||||
saveErrorsOnMessage,
|
saveErrorsOnMessage,
|
||||||
} from '../test-node/util/messageFailures';
|
} from '../test-node/util/messageFailures';
|
||||||
import { postSaveUpdates } from '../util/cleanup';
|
|
||||||
import { isCustomError } from './helpers';
|
import { isCustomError } from './helpers';
|
||||||
import { SendActionType, isSent, sendStateReducer } from './MessageSendState';
|
import { SendActionType, isSent, sendStateReducer } from './MessageSendState';
|
||||||
|
|
||||||
|
@ -77,10 +75,7 @@ export async function send(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message.doNotSave) {
|
if (!message.doNotSave) {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendStateByConversationId = {
|
const sendStateByConversationId = {
|
||||||
|
@ -317,10 +312,7 @@ export async function sendSyncMessageOnly(
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (updateLeftPane) {
|
if (updateLeftPane) {
|
||||||
updateLeftPane();
|
updateLeftPane();
|
||||||
|
@ -476,10 +468,7 @@ export async function sendSyncMessage(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -190,7 +190,7 @@ import { migrateLegacyReadStatus } from '../messages/migrateLegacyReadStatus';
|
||||||
import { migrateLegacySendAttributes } from '../messages/migrateLegacySendAttributes';
|
import { migrateLegacySendAttributes } from '../messages/migrateLegacySendAttributes';
|
||||||
import { getIsInitialSync } from '../services/contactSync';
|
import { getIsInitialSync } from '../services/contactSync';
|
||||||
import { queueAttachmentDownloadsForMessage } from '../util/queueAttachmentDownloads';
|
import { queueAttachmentDownloadsForMessage } from '../util/queueAttachmentDownloads';
|
||||||
import { cleanupMessages, postSaveUpdates } from '../util/cleanup';
|
import { cleanupMessages } from '../util/cleanup';
|
||||||
import { MessageModel } from './messages';
|
import { MessageModel } from './messages';
|
||||||
|
|
||||||
/* eslint-disable more/no-then */
|
/* eslint-disable more/no-then */
|
||||||
|
@ -2015,11 +2015,7 @@ export class ConversationModel extends window.Backbone
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
upgraded += 1;
|
upgraded += 1;
|
||||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
await window.MessageCache.saveMessage(model.attributes);
|
||||||
await DataWriter.saveMessage(model.attributes, {
|
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.attributes;
|
return model.attributes;
|
||||||
|
@ -2270,7 +2266,6 @@ export class ConversationModel extends window.Backbone
|
||||||
options: { isLocalAction?: boolean } = {}
|
options: { isLocalAction?: boolean } = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { isLocalAction } = options;
|
const { isLocalAction } = options;
|
||||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
|
||||||
|
|
||||||
let messages: Array<MessageAttributesType> | undefined;
|
let messages: Array<MessageAttributesType> | undefined;
|
||||||
do {
|
do {
|
||||||
|
@ -2324,10 +2319,7 @@ export class ConversationModel extends window.Backbone
|
||||||
const shouldSave =
|
const shouldSave =
|
||||||
await queueAttachmentDownloadsForMessage(registered);
|
await queueAttachmentDownloadsForMessage(registered);
|
||||||
if (shouldSave) {
|
if (shouldSave) {
|
||||||
await DataWriter.saveMessage(registered.attributes, {
|
await window.MessageCache.saveMessage(registered.attributes);
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -131,6 +131,7 @@ import { isConversationAccepted } from '../../util/isConversationAccepted';
|
||||||
import { saveBackupsSubscriberData } from '../../util/backupSubscriptionData';
|
import { saveBackupsSubscriberData } from '../../util/backupSubscriptionData';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
import { postSaveUpdates } from '../../util/cleanup';
|
||||||
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
||||||
|
import { MessageModel } from '../../models/messages';
|
||||||
|
|
||||||
const MAX_CONCURRENCY = 10;
|
const MAX_CONCURRENCY = 10;
|
||||||
|
|
||||||
|
@ -641,8 +642,9 @@ export class BackupImportStream extends Writable {
|
||||||
if (hasAttachmentDownloads(attributes)) {
|
if (hasAttachmentDownloads(attributes)) {
|
||||||
const conversation = this.#conversations.get(attributes.conversationId);
|
const conversation = this.#conversations.get(attributes.conversationId);
|
||||||
if (conversation && isConversationAccepted(conversation)) {
|
if (conversation && isConversationAccepted(conversation)) {
|
||||||
|
const model = new MessageModel(attributes);
|
||||||
attachmentDownloadJobPromises.push(
|
attachmentDownloadJobPromises.push(
|
||||||
queueAttachmentDownloads(attributes, {
|
queueAttachmentDownloads(model, {
|
||||||
source: AttachmentDownloadSource.BACKUP_IMPORT,
|
source: AttachmentDownloadSource.BACKUP_IMPORT,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import type { ReadonlyMessageAttributesType } from '../model-types.d';
|
||||||
import type { StoryDataType } from '../state/ducks/stories';
|
import type { StoryDataType } from '../state/ducks/stories';
|
||||||
import * as durations from '../util/durations';
|
import * as durations from '../util/durations';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { DataReader, DataWriter } from '../sql/Client';
|
import { DataReader } from '../sql/Client';
|
||||||
import type { GetAllStoriesResultType } from '../sql/Interface';
|
import type { GetAllStoriesResultType } from '../sql/Interface';
|
||||||
import {
|
import {
|
||||||
getAttachmentsForMessage,
|
getAttachmentsForMessage,
|
||||||
|
@ -18,7 +18,6 @@ import { strictAssert } from '../util/assert';
|
||||||
import { dropNull } from '../util/dropNull';
|
import { dropNull } from '../util/dropNull';
|
||||||
import { DurationInSeconds } from '../util/durations';
|
import { DurationInSeconds } from '../util/durations';
|
||||||
import { SIGNAL_ACI } from '../types/SignalConversation';
|
import { SIGNAL_ACI } from '../types/SignalConversation';
|
||||||
import { postSaveUpdates } from '../util/cleanup';
|
|
||||||
|
|
||||||
let storyData: GetAllStoriesResultType | undefined;
|
let storyData: GetAllStoriesResultType | undefined;
|
||||||
|
|
||||||
|
@ -173,10 +172,7 @@ async function repairUnexpiredStories(): Promise<void> {
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
storiesWithExpiry.map(messageAttributes => {
|
storiesWithExpiry.map(messageAttributes => {
|
||||||
return DataWriter.saveMessage(messageAttributes, {
|
return window.MessageCache.saveMessage(messageAttributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ import {
|
||||||
sendStateReducer,
|
sendStateReducer,
|
||||||
} from '../../messages/MessageSendState';
|
} from '../../messages/MessageSendState';
|
||||||
import { markFailed } from '../../test-node/util/messageFailures';
|
import { markFailed } from '../../test-node/util/messageFailures';
|
||||||
import { cleanupMessages, postSaveUpdates } from '../../util/cleanup';
|
import { cleanupMessages } from '../../util/cleanup';
|
||||||
import { MessageModel } from '../../models/messages';
|
import { MessageModel } from '../../models/messages';
|
||||||
// State
|
// State
|
||||||
|
|
||||||
|
@ -2312,12 +2312,7 @@ function kickOffAttachmentDownload(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (didUpdateValues) {
|
if (didUpdateValues) {
|
||||||
drop(
|
drop(window.MessageCache.saveMessage(message.attributes));
|
||||||
DataWriter.saveMessage(message.attributes, {
|
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -2347,11 +2342,7 @@ function cancelAttachmentDownload({
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
|
|
||||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A click kicks off downloads for every attachment in a message, so cancel does too
|
// A click kicks off downloads for every attachment in a message, so cancel does too
|
||||||
|
@ -2486,10 +2477,8 @@ function retryMessageSend(
|
||||||
timestamp: message.attributes.timestamp,
|
timestamp: message.attributes.timestamp,
|
||||||
},
|
},
|
||||||
async jobToInsert => {
|
async jobToInsert => {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes, {
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -2502,10 +2491,8 @@ function retryMessageSend(
|
||||||
revision: conversation.get('revision'),
|
revision: conversation.get('revision'),
|
||||||
},
|
},
|
||||||
async jobToInsert => {
|
async jobToInsert => {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes, {
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -284,13 +284,12 @@ function showLightbox(opts: {
|
||||||
|
|
||||||
if (isIncremental(attachment)) {
|
if (isIncremental(attachment)) {
|
||||||
// Queue all attachments, but this target attachment should be IMMEDIATE
|
// Queue all attachments, but this target attachment should be IMMEDIATE
|
||||||
const updatedFields = await queueAttachmentDownloads(message.attributes, {
|
const wasUpdated = await queueAttachmentDownloads(message, {
|
||||||
urgency: AttachmentDownloadUrgency.STANDARD,
|
urgency: AttachmentDownloadUrgency.STANDARD,
|
||||||
attachmentDigestForImmediate: attachment.digest,
|
attachmentDigestForImmediate: attachment.digest,
|
||||||
});
|
});
|
||||||
if (updatedFields) {
|
if (wasUpdated) {
|
||||||
message.set(updatedFields);
|
await window.MessageCache.saveMessage(message);
|
||||||
await window.MessageCache.saveMessage(message.attributes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ import {
|
||||||
conversationQueueJobEnum,
|
conversationQueueJobEnum,
|
||||||
} from '../../jobs/conversationJobQueue';
|
} from '../../jobs/conversationJobQueue';
|
||||||
import { ReceiptType } from '../../types/Receipt';
|
import { ReceiptType } from '../../types/Receipt';
|
||||||
import { cleanupMessages, postSaveUpdates } from '../../util/cleanup';
|
import { cleanupMessages } from '../../util/cleanup';
|
||||||
|
|
||||||
export type StoryDataType = ReadonlyDeep<
|
export type StoryDataType = ReadonlyDeep<
|
||||||
{
|
{
|
||||||
|
@ -421,12 +421,7 @@ function markStoryRead(
|
||||||
const storyReadDate = Date.now();
|
const storyReadDate = Date.now();
|
||||||
|
|
||||||
message.set(markViewed(message.attributes, storyReadDate));
|
message.set(markViewed(message.attributes, storyReadDate));
|
||||||
drop(
|
drop(window.MessageCache.saveMessage(message.attributes));
|
||||||
DataWriter.saveMessage(message.attributes, {
|
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const conversationId = message.get('conversationId');
|
const conversationId = message.get('conversationId');
|
||||||
|
|
||||||
|
@ -534,10 +529,11 @@ function queueStoryDownload(
|
||||||
payload: storyId,
|
payload: storyId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatedFields = await queueAttachmentDownloads(message.attributes);
|
const wasUpdated = await queueAttachmentDownloads(message);
|
||||||
if (updatedFields) {
|
if (wasUpdated) {
|
||||||
message.set(updatedFields);
|
await window.MessageCache.saveMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
messageReceiptTypeSchema,
|
messageReceiptTypeSchema,
|
||||||
} from '../messageModifiers/MessageReceipts';
|
} from '../messageModifiers/MessageReceipts';
|
||||||
import { ReadStatus } from '../messages/MessageReadStatus';
|
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||||
import { postSaveUpdates } from '../util/cleanup';
|
|
||||||
|
|
||||||
describe('MessageReceipts', () => {
|
describe('MessageReceipts', () => {
|
||||||
let ourAci: AciString;
|
let ourAci: AciString;
|
||||||
|
@ -79,10 +78,8 @@ describe('MessageReceipts', () => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
await DataWriter.saveMessage(messageAttributes, {
|
await window.MessageCache.saveMessage(messageAttributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
@ -157,10 +154,8 @@ describe('MessageReceipts', () => {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
await DataWriter.saveMessage(messageAttributes, {
|
await window.MessageCache.saveMessage(messageAttributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
await DataWriter.saveEditedMessage(messageAttributes, ourAci, {
|
await DataWriter.saveEditedMessage(messageAttributes, ourAci, {
|
||||||
conversationId: messageAttributes.conversationId,
|
conversationId: messageAttributes.conversationId,
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { DataWriter } from '../../sql/Client';
|
||||||
import { SendStatus } from '../../messages/MessageSendState';
|
import { SendStatus } from '../../messages/MessageSendState';
|
||||||
import { IMAGE_PNG } from '../../types/MIME';
|
import { IMAGE_PNG } from '../../types/MIME';
|
||||||
import { generateAci, generatePni } from '../../types/ServiceId';
|
import { generateAci, generatePni } from '../../types/ServiceId';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
import { MessageModel } from '../../models/messages';
|
import { MessageModel } from '../../models/messages';
|
||||||
|
|
||||||
describe('Conversations', () => {
|
describe('Conversations', () => {
|
||||||
|
@ -84,10 +83,8 @@ describe('Conversations', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Saving to db and updating the convo's last message
|
// Saving to db and updating the convo's last message
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
message = window.MessageCache.register(message);
|
message = window.MessageCache.register(message);
|
||||||
await DataWriter.updateConversation(conversation.attributes);
|
await DataWriter.updateConversation(conversation.attributes);
|
||||||
|
|
|
@ -17,12 +17,10 @@ import {
|
||||||
import type { AttachmentDownloadJobType } from '../../types/AttachmentDownload';
|
import type { AttachmentDownloadJobType } from '../../types/AttachmentDownload';
|
||||||
import { DataReader, DataWriter } from '../../sql/Client';
|
import { DataReader, DataWriter } from '../../sql/Client';
|
||||||
import { MINUTE } from '../../util/durations';
|
import { MINUTE } from '../../util/durations';
|
||||||
import { type AciString } from '../../types/ServiceId';
|
|
||||||
import { type AttachmentType, AttachmentVariant } from '../../types/Attachment';
|
import { type AttachmentType, AttachmentVariant } from '../../types/Attachment';
|
||||||
import { strictAssert } from '../../util/assert';
|
import { strictAssert } from '../../util/assert';
|
||||||
import { AttachmentDownloadSource } from '../../sql/Interface';
|
import { AttachmentDownloadSource } from '../../sql/Interface';
|
||||||
import { getAttachmentCiphertextLength } from '../../AttachmentCrypto';
|
import { getAttachmentCiphertextLength } from '../../AttachmentCrypto';
|
||||||
import { postSaveUpdates } from '../../util/cleanup';
|
|
||||||
|
|
||||||
function composeJob({
|
function composeJob({
|
||||||
messageId,
|
messageId,
|
||||||
|
@ -108,7 +106,7 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
urgency: AttachmentDownloadUrgency
|
urgency: AttachmentDownloadUrgency
|
||||||
) {
|
) {
|
||||||
// Save message first to satisfy foreign key constraint
|
// Save message first to satisfy foreign key constraint
|
||||||
await DataWriter.saveMessage(
|
await window.MessageCache.saveMessage(
|
||||||
{
|
{
|
||||||
id: job.messageId,
|
id: job.messageId,
|
||||||
type: 'incoming',
|
type: 'incoming',
|
||||||
|
@ -118,9 +116,7 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
||||||
conversationId: 'convoId',
|
conversationId: 'convoId',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ourAci: 'ourAci' as AciString,
|
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
postSaveUpdates,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await downloadManager?.addJob({
|
await downloadManager?.addJob({
|
||||||
|
|
|
@ -5,7 +5,6 @@ import * as sinon from 'sinon';
|
||||||
import casual from 'casual';
|
import casual from 'casual';
|
||||||
import { v4 as generateUuid } from 'uuid';
|
import { v4 as generateUuid } from 'uuid';
|
||||||
|
|
||||||
import { DataWriter } from '../../../sql/Client';
|
|
||||||
import type {
|
import type {
|
||||||
DispatchableViewStoryType,
|
DispatchableViewStoryType,
|
||||||
StoryDataType,
|
StoryDataType,
|
||||||
|
@ -27,7 +26,6 @@ import { actions, getEmptyState } from '../../../state/ducks/stories';
|
||||||
import { noopAction } from '../../../state/ducks/noop';
|
import { noopAction } from '../../../state/ducks/noop';
|
||||||
import { reducer as rootReducer } from '../../../state/reducer';
|
import { reducer as rootReducer } from '../../../state/reducer';
|
||||||
import { dropNull } from '../../../util/dropNull';
|
import { dropNull } from '../../../util/dropNull';
|
||||||
import { postSaveUpdates } from '../../../util/cleanup';
|
|
||||||
import { MessageModel } from '../../../models/messages';
|
import { MessageModel } from '../../../models/messages';
|
||||||
|
|
||||||
describe('both/state/ducks/stories', () => {
|
describe('both/state/ducks/stories', () => {
|
||||||
|
@ -928,10 +926,8 @@ describe('both/state/ducks/stories', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
await DataWriter.saveMessage(messageAttributes, {
|
await window.MessageCache.saveMessage(messageAttributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
ourAci: generateAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
const rootState = getEmptyRootState();
|
const rootState = getEmptyRootState();
|
||||||
|
|
||||||
|
@ -991,10 +987,8 @@ describe('both/state/ducks/stories', () => {
|
||||||
preview: [preview],
|
preview: [preview],
|
||||||
};
|
};
|
||||||
|
|
||||||
await DataWriter.saveMessage(messageAttributes, {
|
await window.MessageCache.saveMessage(messageAttributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
ourAci: generateAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
const rootState = getEmptyRootState();
|
const rootState = getEmptyRootState();
|
||||||
|
|
||||||
|
|
|
@ -71,10 +71,7 @@ export async function eraseMessageContents(
|
||||||
)?.debouncedUpdateLastMessage();
|
)?.debouncedUpdateLastMessage();
|
||||||
|
|
||||||
if (shouldPersist) {
|
if (shouldPersist) {
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await DataWriter.deleteSentProtoByMessageId(message.id);
|
await DataWriter.deleteSentProtoByMessageId(message.id);
|
||||||
|
|
|
@ -10,7 +10,6 @@ import type { StoryMessageRecipientsType } from '../types/Stories';
|
||||||
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
||||||
import type { ServiceIdString } from '../types/ServiceId';
|
import type { ServiceIdString } from '../types/ServiceId';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { DataWriter } from '../sql/Client';
|
|
||||||
import { DAY } from './durations';
|
import { DAY } from './durations';
|
||||||
import { StoryRecipientUpdateEvent } from '../textsecure/messageReceiverEvents';
|
import { StoryRecipientUpdateEvent } from '../textsecure/messageReceiverEvents';
|
||||||
import {
|
import {
|
||||||
|
@ -24,7 +23,6 @@ import { getMessageById } from '../messages/getMessageById';
|
||||||
import { strictAssert } from './assert';
|
import { strictAssert } from './assert';
|
||||||
import { repeat, zipObject } from './iterables';
|
import { repeat, zipObject } from './iterables';
|
||||||
import { isOlderThan } from './timestamp';
|
import { isOlderThan } from './timestamp';
|
||||||
import { postSaveUpdates } from './cleanup';
|
|
||||||
|
|
||||||
export async function deleteStoryForEveryone(
|
export async function deleteStoryForEveryone(
|
||||||
stories: ReadonlyArray<StoryDataType>,
|
stories: ReadonlyArray<StoryDataType>,
|
||||||
|
@ -192,10 +190,8 @@ export async function deleteStoryForEveryone(
|
||||||
await conversationJobQueue.add(jobData, async jobToInsert => {
|
await conversationJobQueue.add(jobData, async jobToInsert => {
|
||||||
log.info(`${logId}: Deleting message with job ${jobToInsert.id}`);
|
log.info(`${logId}: Deleting message with job ${jobToInsert.id}`);
|
||||||
|
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes, {
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -289,32 +289,27 @@ export async function handleEditMessage(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Queue up any downloads in case they're different, update the fields if so.
|
// Queue up any downloads in case they're different, update the fields if so.
|
||||||
const updatedFields = await queueAttachmentDownloads(
|
const wasUpdated = await queueAttachmentDownloads(mainMessageModel);
|
||||||
mainMessageModel.attributes
|
|
||||||
);
|
|
||||||
|
|
||||||
// If we've scheduled a bodyAttachment download, we need that edit to know about it
|
// If we've scheduled a bodyAttachment download, we need that edit to know about it
|
||||||
if (updatedFields?.bodyAttachment) {
|
if (wasUpdated && mainMessageModel.get('bodyAttachment')) {
|
||||||
const existing =
|
const existing = mainMessageModel.get('editHistory') || [];
|
||||||
updatedFields.editHistory || mainMessageModel.get('editHistory') || [];
|
|
||||||
|
|
||||||
updatedFields.editHistory = existing.map(item => {
|
mainMessageModel.set({
|
||||||
if (item.timestamp !== editedMessage.timestamp) {
|
editHistory: existing.map(item => {
|
||||||
return item;
|
if (item.timestamp !== editedMessage.timestamp) {
|
||||||
}
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
attachments: updatedFields.attachments,
|
attachments: mainMessageModel.get('attachments'),
|
||||||
bodyAttachment: updatedFields.bodyAttachment,
|
bodyAttachment: mainMessageModel.get('bodyAttachment'),
|
||||||
};
|
};
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatedFields) {
|
|
||||||
mainMessageModel.set(updatedFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
const conversation = window.ConversationController.get(
|
const conversation = window.ConversationController.get(
|
||||||
editAttributes.conversationId
|
editAttributes.conversationId
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,8 +14,6 @@ import { isOlderThan } from './timestamp';
|
||||||
import { DAY } from './durations';
|
import { DAY } from './durations';
|
||||||
import { getMessageById } from '../messages/getMessageById';
|
import { getMessageById } from '../messages/getMessageById';
|
||||||
import { MessageModel } from '../models/messages';
|
import { MessageModel } from '../models/messages';
|
||||||
import { DataWriter } from '../sql/Client';
|
|
||||||
import { postSaveUpdates } from './cleanup';
|
|
||||||
|
|
||||||
export async function hydrateStoryContext(
|
export async function hydrateStoryContext(
|
||||||
messageId: string,
|
messageId: string,
|
||||||
|
@ -82,11 +80,7 @@ export async function hydrateStoryContext(
|
||||||
};
|
};
|
||||||
message.set(newMessageAttributes);
|
message.set(newMessageAttributes);
|
||||||
if (shouldSave) {
|
if (shouldSave) {
|
||||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMessageAttributes;
|
return newMessageAttributes;
|
||||||
|
@ -109,11 +103,7 @@ export async function hydrateStoryContext(
|
||||||
};
|
};
|
||||||
message.set(newMessageAttributes);
|
message.set(newMessageAttributes);
|
||||||
if (shouldSave) {
|
if (shouldSave) {
|
||||||
const ourAci = window.textsecure.storage.user.getCheckedAci();
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMessageAttributes;
|
return newMessageAttributes;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { DataWriter } from '../sql/Client';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { postSaveUpdates } from './cleanup';
|
import { postSaveUpdates } from './cleanup';
|
||||||
import { MessageModel } from '../models/messages';
|
import { MessageModel } from '../models/messages';
|
||||||
|
import { drop } from './drop';
|
||||||
|
|
||||||
const updateMessageBatcher = createBatcher<ReadonlyMessageAttributesType>({
|
const updateMessageBatcher = createBatcher<ReadonlyMessageAttributesType>({
|
||||||
name: 'messageBatcher.updateMessageBatcher',
|
name: 'messageBatcher.updateMessageBatcher',
|
||||||
|
@ -36,10 +37,7 @@ export function queueUpdateMessage(
|
||||||
if (shouldBatch) {
|
if (shouldBatch) {
|
||||||
updateMessageBatcher.add(messageAttr);
|
updateMessageBatcher.add(messageAttr);
|
||||||
} else {
|
} else {
|
||||||
void DataWriter.saveMessage(messageAttr, {
|
drop(window.MessageCache.saveMessage(messageAttr));
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import type { SendStateByConversationId } from '../messages/MessageSendState';
|
||||||
|
|
||||||
import * as Edits from '../messageModifiers/Edits';
|
import * as Edits from '../messageModifiers/Edits';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { DataWriter } from '../sql/Client';
|
|
||||||
import * as Deletes from '../messageModifiers/Deletes';
|
import * as Deletes from '../messageModifiers/Deletes';
|
||||||
import * as DeletesForMe from '../messageModifiers/DeletesForMe';
|
import * as DeletesForMe from '../messageModifiers/DeletesForMe';
|
||||||
import * as MessageReceipts from '../messageModifiers/MessageReceipts';
|
import * as MessageReceipts from '../messageModifiers/MessageReceipts';
|
||||||
|
@ -38,7 +37,6 @@ import {
|
||||||
import { getMessageIdForLogging } from './idForLogging';
|
import { getMessageIdForLogging } from './idForLogging';
|
||||||
import { markViewOnceMessageViewed } from '../services/MessageUpdater';
|
import { markViewOnceMessageViewed } from '../services/MessageUpdater';
|
||||||
import { handleReaction } from '../messageModifiers/Reactions';
|
import { handleReaction } from '../messageModifiers/Reactions';
|
||||||
import { postSaveUpdates } from './cleanup';
|
|
||||||
|
|
||||||
export enum ModifyTargetMessageResult {
|
export enum ModifyTargetMessageResult {
|
||||||
Modified = 'Modified',
|
Modified = 'Modified',
|
||||||
|
@ -326,10 +324,7 @@ export async function modifyTargetMessage(
|
||||||
// We save here before handling any edits because handleEditMessage does its own saves
|
// We save here before handling any edits because handleEditMessage does its own saves
|
||||||
if (changed && !isFirstRun) {
|
if (changed && !isFirstRun) {
|
||||||
log.info(`${logId}: Changes in second run; saving.`);
|
log.info(`${logId}: Changes in second run; saving.`);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes);
|
||||||
ourAci,
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to make sure the message is saved first before applying any edits
|
// We want to make sure the message is saved first before applying any edits
|
||||||
|
|
|
@ -90,14 +90,13 @@ export async function queueAttachmentDownloadsForMessage(
|
||||||
message: MessageModel,
|
message: MessageModel,
|
||||||
urgency?: AttachmentDownloadUrgency
|
urgency?: AttachmentDownloadUrgency
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const updates = await queueAttachmentDownloads(message.attributes, {
|
const updated = await queueAttachmentDownloads(message, {
|
||||||
urgency,
|
urgency,
|
||||||
});
|
});
|
||||||
if (!updates) {
|
if (!updated) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.set(updates);
|
|
||||||
queueUpdateMessage(message.attributes);
|
queueUpdateMessage(message.attributes);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,7 +106,7 @@ export async function queueAttachmentDownloadsForMessage(
|
||||||
// NOTE: If you're changing any logic in this function that deals with the
|
// NOTE: If you're changing any logic in this function that deals with the
|
||||||
// count then you'll also have to modify ./hasAttachmentsDownloads
|
// count then you'll also have to modify ./hasAttachmentsDownloads
|
||||||
export async function queueAttachmentDownloads(
|
export async function queueAttachmentDownloads(
|
||||||
message: MessageAttributesType,
|
message: MessageModel,
|
||||||
{
|
{
|
||||||
urgency = AttachmentDownloadUrgency.STANDARD,
|
urgency = AttachmentDownloadUrgency.STANDARD,
|
||||||
source = AttachmentDownloadSource.STANDARD,
|
source = AttachmentDownloadSource.STANDARD,
|
||||||
|
@ -117,13 +116,12 @@ export async function queueAttachmentDownloads(
|
||||||
source?: AttachmentDownloadSource;
|
source?: AttachmentDownloadSource;
|
||||||
attachmentDigestForImmediate?: string;
|
attachmentDigestForImmediate?: string;
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<MessageAttachmentsDownloadedType | undefined> {
|
): Promise<boolean> {
|
||||||
const attachmentsToQueue = message.attachments || [];
|
const attachmentsToQueue = message.get('attachments') || [];
|
||||||
const messageId = message.id;
|
const messageId = message.id;
|
||||||
const idForLogging = getMessageIdForLogging(message);
|
const idForLogging = getMessageIdForLogging(message.attributes);
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let bodyAttachment;
|
|
||||||
|
|
||||||
const idLog = `queueAttachmentDownloads(${idForLogging}})`;
|
const idLog = `queueAttachmentDownloads(${idForLogging}})`;
|
||||||
const log = getLogger(source);
|
const log = getLogger(source);
|
||||||
|
@ -138,16 +136,13 @@ export async function queueAttachmentDownloads(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (longMessageAttachments.length > 0) {
|
if (longMessageAttachments.length > 0) {
|
||||||
[bodyAttachment] = longMessageAttachments;
|
message.set({ bodyAttachment: longMessageAttachments[0] });
|
||||||
}
|
|
||||||
|
|
||||||
if (!bodyAttachment && message.bodyAttachment) {
|
|
||||||
bodyAttachment = message.bodyAttachment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bodyAttachmentsToDownload = [
|
const bodyAttachmentsToDownload = [
|
||||||
bodyAttachment,
|
message.get('bodyAttachment'),
|
||||||
...(message.editHistory
|
...(message
|
||||||
|
.get('editHistory')
|
||||||
?.slice(1) // first entry is the same as the root level message!
|
?.slice(1) // first entry is the same as the root level message!
|
||||||
.map(editHistory => editHistory.bodyAttachment) ?? []),
|
.map(editHistory => editHistory.bodyAttachment) ?? []),
|
||||||
]
|
]
|
||||||
|
@ -164,8 +159,8 @@ export async function queueAttachmentDownloads(
|
||||||
attachment,
|
attachment,
|
||||||
messageId,
|
messageId,
|
||||||
attachmentType: 'long-message',
|
attachmentType: 'long-message',
|
||||||
receivedAt: message.received_at,
|
receivedAt: message.get('received_at'),
|
||||||
sentAt: message.sent_at,
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
})
|
})
|
||||||
|
@ -184,17 +179,22 @@ export async function queueAttachmentDownloads(
|
||||||
idLog,
|
idLog,
|
||||||
messageId,
|
messageId,
|
||||||
attachments: normalAttachments,
|
attachments: normalAttachments,
|
||||||
otherAttachments: message.editHistory?.flatMap(x => x.attachments ?? []),
|
otherAttachments: message
|
||||||
receivedAt: message.received_at,
|
.get('editHistory')
|
||||||
sentAt: message.sent_at,
|
?.flatMap(x => x.attachments ?? []),
|
||||||
|
receivedAt: message.get('received_at'),
|
||||||
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
attachmentDigestForImmediate,
|
attachmentDigestForImmediate,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if (attachmentsCount > 0) {
|
||||||
|
message.set({ attachments });
|
||||||
|
}
|
||||||
count += attachmentsCount;
|
count += attachmentsCount;
|
||||||
|
|
||||||
const previewsToQueue = message.preview || [];
|
const previewsToQueue = message.get('preview') || [];
|
||||||
if (previewsToQueue.length > 0) {
|
if (previewsToQueue.length > 0) {
|
||||||
log.info(
|
log.info(
|
||||||
`${idLog}: Queueing ${previewsToQueue.length} preview attachment downloads`
|
`${idLog}: Queueing ${previewsToQueue.length} preview attachment downloads`
|
||||||
|
@ -204,15 +204,18 @@ export async function queueAttachmentDownloads(
|
||||||
idLog,
|
idLog,
|
||||||
messageId,
|
messageId,
|
||||||
previews: previewsToQueue,
|
previews: previewsToQueue,
|
||||||
otherPreviews: message.editHistory?.flatMap(x => x.preview ?? []),
|
otherPreviews: message.get('editHistory')?.flatMap(x => x.preview ?? []),
|
||||||
receivedAt: message.received_at,
|
receivedAt: message.get('received_at'),
|
||||||
sentAt: message.sent_at,
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
|
if (previewCount > 0) {
|
||||||
|
message.set({ preview });
|
||||||
|
}
|
||||||
count += previewCount;
|
count += previewCount;
|
||||||
|
|
||||||
const numQuoteAttachments = message.quote?.attachments?.length ?? 0;
|
const numQuoteAttachments = message.get('quote')?.attachments?.length ?? 0;
|
||||||
if (numQuoteAttachments > 0) {
|
if (numQuoteAttachments > 0) {
|
||||||
log.info(
|
log.info(
|
||||||
`${idLog}: Queueing ${numQuoteAttachments} ` +
|
`${idLog}: Queueing ${numQuoteAttachments} ` +
|
||||||
|
@ -222,16 +225,23 @@ export async function queueAttachmentDownloads(
|
||||||
const { quote, count: thumbnailCount } = await queueQuoteAttachments({
|
const { quote, count: thumbnailCount } = await queueQuoteAttachments({
|
||||||
idLog,
|
idLog,
|
||||||
messageId,
|
messageId,
|
||||||
quote: message.quote,
|
quote: message.get('quote'),
|
||||||
otherQuotes: message.editHistory?.map(x => x.quote).filter(isNotNil) ?? [],
|
otherQuotes:
|
||||||
receivedAt: message.received_at,
|
message
|
||||||
sentAt: message.sent_at,
|
.get('editHistory')
|
||||||
|
?.map(x => x.quote)
|
||||||
|
.filter(isNotNil) ?? [],
|
||||||
|
receivedAt: message.get('received_at'),
|
||||||
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
|
if (thumbnailCount > 0) {
|
||||||
|
message.set({ quote });
|
||||||
|
}
|
||||||
count += thumbnailCount;
|
count += thumbnailCount;
|
||||||
|
|
||||||
const contactsToQueue = message.contact || [];
|
const contactsToQueue = message.get('contact') || [];
|
||||||
if (contactsToQueue.length > 0) {
|
if (contactsToQueue.length > 0) {
|
||||||
log.info(
|
log.info(
|
||||||
`${idLog}: Queueing ${contactsToQueue.length} contact attachment downloads`
|
`${idLog}: Queueing ${contactsToQueue.length} contact attachment downloads`
|
||||||
|
@ -257,8 +267,8 @@ export async function queueAttachmentDownloads(
|
||||||
attachment: item.avatar.avatar,
|
attachment: item.avatar.avatar,
|
||||||
messageId,
|
messageId,
|
||||||
attachmentType: 'contact',
|
attachmentType: 'contact',
|
||||||
receivedAt: message.received_at,
|
receivedAt: message.get('received_at'),
|
||||||
sentAt: message.sent_at,
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
}),
|
}),
|
||||||
|
@ -266,8 +276,9 @@ export async function queueAttachmentDownloads(
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
message.set({ contact });
|
||||||
|
|
||||||
let { sticker } = message;
|
let sticker = message.get('sticker');
|
||||||
if (sticker && sticker.data && sticker.data.path) {
|
if (sticker && sticker.data && sticker.data.path) {
|
||||||
log.info(`${idLog}: Sticker attachment already downloaded`);
|
log.info(`${idLog}: Sticker attachment already downloaded`);
|
||||||
} else if (sticker) {
|
} else if (sticker) {
|
||||||
|
@ -294,8 +305,8 @@ export async function queueAttachmentDownloads(
|
||||||
attachment: sticker.data,
|
attachment: sticker.data,
|
||||||
messageId,
|
messageId,
|
||||||
attachmentType: 'sticker',
|
attachmentType: 'sticker',
|
||||||
receivedAt: message.received_at,
|
receivedAt: message.get('received_at'),
|
||||||
sentAt: message.sent_at,
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
|
@ -320,8 +331,9 @@ export async function queueAttachmentDownloads(
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
message.set({ sticker });
|
||||||
|
|
||||||
let { editHistory } = message;
|
let editHistory = message.get('editHistory');
|
||||||
if (editHistory) {
|
if (editHistory) {
|
||||||
log.info(`${idLog}: Looping through ${editHistory.length} edits`);
|
log.info(`${idLog}: Looping through ${editHistory.length} edits`);
|
||||||
editHistory = await Promise.all(
|
editHistory = await Promise.all(
|
||||||
|
@ -332,8 +344,8 @@ export async function queueAttachmentDownloads(
|
||||||
messageId,
|
messageId,
|
||||||
attachments: edit.attachments,
|
attachments: edit.attachments,
|
||||||
otherAttachments: attachments,
|
otherAttachments: attachments,
|
||||||
receivedAt: message.received_at,
|
receivedAt: message.get('received_at'),
|
||||||
sentAt: message.sent_at,
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
|
@ -351,8 +363,8 @@ export async function queueAttachmentDownloads(
|
||||||
messageId,
|
messageId,
|
||||||
previews: edit.preview,
|
previews: edit.preview,
|
||||||
otherPreviews: preview,
|
otherPreviews: preview,
|
||||||
receivedAt: message.received_at,
|
receivedAt: message.get('received_at'),
|
||||||
sentAt: message.sent_at,
|
sentAt: message.get('sent_at'),
|
||||||
urgency,
|
urgency,
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
|
@ -372,22 +384,15 @@ export async function queueAttachmentDownloads(
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
message.set({ editHistory });
|
||||||
|
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(`${idLog}: Queued ${count} total attachment downloads`);
|
log.info(`${idLog}: Queued ${count} total attachment downloads`);
|
||||||
|
|
||||||
return {
|
return true;
|
||||||
attachments,
|
|
||||||
bodyAttachment,
|
|
||||||
contact,
|
|
||||||
editHistory,
|
|
||||||
preview,
|
|
||||||
quote,
|
|
||||||
sticker,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function queueNormalAttachments({
|
export async function queueNormalAttachments({
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
import type { ConversationAttributesType } from '../model-types.d';
|
import type { ConversationAttributesType } from '../model-types.d';
|
||||||
import type { ConversationQueueJobData } from '../jobs/conversationJobQueue';
|
import type { ConversationQueueJobData } from '../jobs/conversationJobQueue';
|
||||||
import { DataWriter } from '../sql/Client';
|
|
||||||
import * as Errors from '../types/errors';
|
import * as Errors from '../types/errors';
|
||||||
import { DAY } from './durations';
|
import { DAY } from './durations';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
@ -21,7 +20,6 @@ import { getRecipientConversationIds } from './getRecipientConversationIds';
|
||||||
import { getRecipients } from './getRecipients';
|
import { getRecipients } from './getRecipients';
|
||||||
import { repeat, zipObject } from './iterables';
|
import { repeat, zipObject } from './iterables';
|
||||||
import { isMe } from './whatTypeOfConversation';
|
import { isMe } from './whatTypeOfConversation';
|
||||||
import { postSaveUpdates } from './cleanup';
|
|
||||||
|
|
||||||
export async function sendDeleteForEveryoneMessage(
|
export async function sendDeleteForEveryoneMessage(
|
||||||
conversationAttributes: ConversationAttributesType,
|
conversationAttributes: ConversationAttributesType,
|
||||||
|
@ -83,10 +81,8 @@ export async function sendDeleteForEveryoneMessage(
|
||||||
`sendDeleteForEveryoneMessage: Deleting message ${idForLogging} ` +
|
`sendDeleteForEveryoneMessage: Deleting message ${idForLogging} ` +
|
||||||
`in conversation ${conversationIdForLogging} with job ${jobToInsert.id}`
|
`in conversation ${conversationIdForLogging} with job ${jobToInsert.id}`
|
||||||
);
|
);
|
||||||
await DataWriter.saveMessage(message.attributes, {
|
await window.MessageCache.saveMessage(message.attributes, {
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import { strictAssert } from './assert';
|
||||||
import { timeAndLogIfTooLong } from './timeAndLogIfTooLong';
|
import { timeAndLogIfTooLong } from './timeAndLogIfTooLong';
|
||||||
import { makeQuote } from './makeQuote';
|
import { makeQuote } from './makeQuote';
|
||||||
import { getMessageSentTimestamp } from './getMessageSentTimestamp';
|
import { getMessageSentTimestamp } from './getMessageSentTimestamp';
|
||||||
import { postSaveUpdates } from './cleanup';
|
|
||||||
|
|
||||||
const SEND_REPORT_THRESHOLD_MS = 25;
|
const SEND_REPORT_THRESHOLD_MS = 25;
|
||||||
|
|
||||||
|
@ -224,10 +223,8 @@ export async function sendEditedMessage(
|
||||||
log.info(
|
log.info(
|
||||||
`${idLog}: saving message ${targetMessageId} and job ${jobToInsert.id}`
|
`${idLog}: saving message ${targetMessageId} and job ${jobToInsert.id}`
|
||||||
);
|
);
|
||||||
await DataWriter.saveMessage(targetMessage.attributes, {
|
await window.MessageCache.saveMessage(targetMessage.attributes, {
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
|
@ -31,7 +31,6 @@ import { collect } from './iterables';
|
||||||
import { DurationInSeconds } from './durations';
|
import { DurationInSeconds } from './durations';
|
||||||
import { sanitizeLinkPreview } from '../services/LinkPreview';
|
import { sanitizeLinkPreview } from '../services/LinkPreview';
|
||||||
import type { DraftBodyRanges } from '../types/BodyRange';
|
import type { DraftBodyRanges } from '../types/BodyRange';
|
||||||
import { postSaveUpdates } from './cleanup';
|
|
||||||
import { MessageModel } from '../models/messages';
|
import { MessageModel } from '../models/messages';
|
||||||
|
|
||||||
export async function sendStoryMessage(
|
export async function sendStoryMessage(
|
||||||
|
@ -315,10 +314,8 @@ export async function sendStoryMessage(
|
||||||
void ourConversation.addSingleMessage(message, { isJustSent: true });
|
void ourConversation.addSingleMessage(message, { isJustSent: true });
|
||||||
|
|
||||||
log.info(`stories.sendStoryMessage: saving message ${message.timestamp}`);
|
log.info(`stories.sendStoryMessage: saving message ${message.timestamp}`);
|
||||||
return DataWriter.saveMessage(message, {
|
return window.MessageCache.saveMessage(message, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -368,11 +365,9 @@ export async function sendStoryMessage(
|
||||||
log.info(
|
log.info(
|
||||||
`stories.sendStoryMessage: saving message ${messageAttributes.timestamp}`
|
`stories.sendStoryMessage: saving message ${messageAttributes.timestamp}`
|
||||||
);
|
);
|
||||||
await DataWriter.saveMessage(messageAttributes, {
|
await window.MessageCache.saveMessage(messageAttributes, {
|
||||||
forceSave: true,
|
forceSave: true,
|
||||||
jobToInsert,
|
jobToInsert,
|
||||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
|
||||||
postSaveUpdates,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue