New SignalDebug function: archiveSessionsForCurrentConversation
This commit is contained in:
@@ -39,6 +39,7 @@ import * as StorageService from './services/storage';
|
|||||||
import type { ConversationPropsForUnreadStats } from './util/countUnreadStats';
|
import type { ConversationPropsForUnreadStats } from './util/countUnreadStats';
|
||||||
import { countAllConversationsUnreadStats } from './util/countUnreadStats';
|
import { countAllConversationsUnreadStats } from './util/countUnreadStats';
|
||||||
import { isTestOrMockEnvironment } from './environment';
|
import { isTestOrMockEnvironment } from './environment';
|
||||||
|
import { conversationJobQueue } from './jobs/conversationJobQueue';
|
||||||
|
|
||||||
type ConvoMatchType =
|
type ConvoMatchType =
|
||||||
| {
|
| {
|
||||||
@@ -1532,4 +1533,45 @@ export class ConversationController {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async archiveSessionsForConversation(
|
||||||
|
conversationId: string | undefined
|
||||||
|
): Promise<void> {
|
||||||
|
const conversation = window.ConversationController.get(conversationId);
|
||||||
|
if (!conversation) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const logId = `archiveSessionsForConversation/${conversation.idForLogging()}`;
|
||||||
|
|
||||||
|
log.info(`${logId}: Starting. First archiving sessions...`);
|
||||||
|
const recipients = conversation.getRecipients();
|
||||||
|
const queue = new PQueue({ concurrency: 1 });
|
||||||
|
recipients.forEach(serviceId => {
|
||||||
|
drop(
|
||||||
|
queue.add(async () => {
|
||||||
|
await window.textsecure.storage.protocol.archiveAllSessions(
|
||||||
|
serviceId
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await queue.onEmpty();
|
||||||
|
|
||||||
|
if (conversation.get('senderKeyInfo')) {
|
||||||
|
log.info(`${logId}: Next, clearing senderKeyInfo...`);
|
||||||
|
conversation.set({ senderKeyInfo: undefined });
|
||||||
|
await DataWriter.updateConversation(conversation.attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(`${logId}: Now queuing null message send...`);
|
||||||
|
const job = await conversationJobQueue.add({
|
||||||
|
type: 'NullMessage',
|
||||||
|
conversationId: conversation.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
log.info(`${logId}: Send queued; waiting for send completion...`);
|
||||||
|
await job.completion;
|
||||||
|
|
||||||
|
log.info(`${logId}: Complete!`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@ import {
|
|||||||
UnregisteredUserError,
|
UnregisteredUserError,
|
||||||
} from '../../textsecure/Errors';
|
} from '../../textsecure/Errors';
|
||||||
import MessageSender from '../../textsecure/SendMessage';
|
import MessageSender from '../../textsecure/SendMessage';
|
||||||
|
import { sendToGroup } from '../../util/sendToGroup';
|
||||||
|
|
||||||
async function clearResetsTracking(idForTracking: string | undefined) {
|
async function clearResetsTracking(idForTracking: string | undefined) {
|
||||||
if (!idForTracking) {
|
if (!idForTracking) {
|
||||||
@@ -65,14 +66,12 @@ export async function sendNullMessage(
|
|||||||
const contentHint = ContentHint.RESENDABLE;
|
const contentHint = ContentHint.RESENDABLE;
|
||||||
const sendType = 'nullMessage';
|
const sendType = 'nullMessage';
|
||||||
|
|
||||||
if (!isDirectConversation(conversation.attributes)) {
|
|
||||||
log.info('Failing attempt to send null message to group');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: we will send to blocked users, to those still in message request state, etc.
|
// Note: we will send to blocked users, to those still in message request state, etc.
|
||||||
// Any needed blocking should still apply once the decryption error is fixed.
|
// Any needed blocking should still apply once the decryption error is fixed.
|
||||||
|
|
||||||
|
try {
|
||||||
|
const proto = MessageSender.getNullMessage();
|
||||||
|
if (isDirectConversation(conversation.attributes)) {
|
||||||
if (isConversationUnregistered(conversation.attributes)) {
|
if (isConversationUnregistered(conversation.attributes)) {
|
||||||
await clearResetsTracking(idForTracking);
|
await clearResetsTracking(idForTracking);
|
||||||
log.info(
|
log.info(
|
||||||
@@ -81,10 +80,10 @@ export async function sendNullMessage(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
await conversation.queueJob(
|
||||||
const proto = MessageSender.getNullMessage();
|
'conversationQueue/sendNullMessage/direct',
|
||||||
|
_abortSignal =>
|
||||||
await handleMessageSend(
|
handleMessageSend(
|
||||||
messaging.sendIndividualProto({
|
messaging.sendIndividualProto({
|
||||||
contentHint,
|
contentHint,
|
||||||
serviceId: conversation.getSendTarget(),
|
serviceId: conversation.getSendTarget(),
|
||||||
@@ -97,7 +96,46 @@ export async function sendNullMessage(
|
|||||||
messageIds: [],
|
messageIds: [],
|
||||||
sendType,
|
sendType,
|
||||||
}
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
const groupV2Info = conversation.getGroupV2Info();
|
||||||
|
if (groupV2Info) {
|
||||||
|
groupV2Info.revision = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
await conversation.queueJob(
|
||||||
|
'conversationQueue/sendNullMessage/group',
|
||||||
|
abortSignal =>
|
||||||
|
sendToGroup({
|
||||||
|
abortSignal,
|
||||||
|
contentHint: ContentHint.RESENDABLE,
|
||||||
|
groupSendOptions: {
|
||||||
|
attachments: [],
|
||||||
|
bodyRanges: [],
|
||||||
|
contact: [],
|
||||||
|
deletedForEveryoneTimestamp: undefined,
|
||||||
|
expireTimer: undefined,
|
||||||
|
groupV2: groupV2Info,
|
||||||
|
messageText: undefined,
|
||||||
|
preview: [],
|
||||||
|
profileKey: undefined,
|
||||||
|
quote: undefined,
|
||||||
|
sticker: undefined,
|
||||||
|
storyContext: undefined,
|
||||||
|
reaction: undefined,
|
||||||
|
targetTimestampForEdit: undefined,
|
||||||
|
timestamp,
|
||||||
|
},
|
||||||
|
messageId: undefined,
|
||||||
|
sendOptions,
|
||||||
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
|
sendType,
|
||||||
|
story: false,
|
||||||
|
urgent: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (
|
if (
|
||||||
error instanceof OutgoingIdentityKeyError ||
|
error instanceof OutgoingIdentityKeyError ||
|
||||||
|
@@ -61,9 +61,16 @@ if (
|
|||||||
cdsLookup: (options: CdsLookupOptionsType) =>
|
cdsLookup: (options: CdsLookupOptionsType) =>
|
||||||
window.textsecure.server?.cdsLookup(options),
|
window.textsecure.server?.cdsLookup(options),
|
||||||
getSelectedConversation: () => {
|
getSelectedConversation: () => {
|
||||||
return window.ConversationController.get(
|
const conversationId =
|
||||||
window.reduxStore.getState().conversations.selectedConversationId
|
window.reduxStore.getState().conversations.selectedConversationId;
|
||||||
)?.attributes;
|
return window.ConversationController.get(conversationId)?.attributes;
|
||||||
|
},
|
||||||
|
archiveSessionsForCurrentConversation: async () => {
|
||||||
|
const conversationId =
|
||||||
|
window.reduxStore.getState().conversations.selectedConversationId;
|
||||||
|
await window.ConversationController.archiveSessionsForConversation(
|
||||||
|
conversationId
|
||||||
|
);
|
||||||
},
|
},
|
||||||
getConversation: (id: string) => window.ConversationController.get(id),
|
getConversation: (id: string) => window.ConversationController.get(id),
|
||||||
getMessageById: (id: string) => window.MessageCache.getById(id)?.attributes,
|
getMessageById: (id: string) => window.MessageCache.getById(id)?.attributes,
|
||||||
|
Reference in New Issue
Block a user