Delete Sync: Handle and send mostRecentNonExpiringMessages if needed

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2024-06-24 13:39:21 -05:00 committed by GitHub
parent d1b0bd79bc
commit 50e07ec389
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 356 additions and 46 deletions

View file

@ -97,6 +97,7 @@ import {
} from '../types/CallDisposition';
import { getProtoForCallHistory } from '../util/callDisposition';
import { CallMode } from '../types/Calling';
import { MAX_MESSAGE_COUNT } from '../util/deleteForMe.types';
export type SendMetadataType = {
[serviceId: ServiceIdString]: {
@ -1518,13 +1519,16 @@ export default class MessageSender {
} else if (item.type === 'delete-conversation') {
const mostRecentMessages =
item.mostRecentMessages.map(toAddressableMessage);
const mostRecentNonExpiringMessages =
item.mostRecentNonExpiringMessages?.map(toAddressableMessage);
const conversation = toConversationIdentifier(item.conversation);
deleteForMe.conversationDeletes = deleteForMe.conversationDeletes || [];
deleteForMe.conversationDeletes.push({
mostRecentMessages,
conversation,
isFullDelete: true,
mostRecentMessages,
mostRecentNonExpiringMessages,
});
} else if (item.type === 'delete-local-conversation') {
const conversation = toConversationIdentifier(item.conversation);
@ -1544,7 +1548,7 @@ export default class MessageSender {
});
if (messageDeletes.size > 0) {
for (const items of messageDeletes.values()) {
for (const [conversationId, items] of messageDeletes.entries()) {
const first = items[0];
if (!first) {
throw new Error('Failed to fetch first from items');
@ -1552,6 +1556,12 @@ export default class MessageSender {
const messages = items.map(item => toAddressableMessage(item.message));
const conversation = toConversationIdentifier(first.conversation);
if (items.length > MAX_MESSAGE_COUNT) {
log.warn(
`getDeleteForMeSyncMessage: Sending ${items.length} message deletes for conversationId ${conversationId}`
);
}
deleteForMe.messageDeletes = deleteForMe.messageDeletes || [];
deleteForMe.messageDeletes.push({
messages,