Added clearer debug logging to createOrLookup
This commit is contained in:
parent
bc4f3dcd01
commit
e41252b35e
21 changed files with 55 additions and 4 deletions
|
@ -642,15 +642,19 @@ export class ConversationController {
|
|||
lookupOrCreate({
|
||||
e164,
|
||||
uuid,
|
||||
reason,
|
||||
}: {
|
||||
e164?: string | null;
|
||||
uuid?: string | null;
|
||||
reason: string;
|
||||
}): ConversationModel | undefined {
|
||||
const normalizedUuid = uuid ? uuid.toLowerCase() : undefined;
|
||||
const identifier = normalizedUuid || e164;
|
||||
|
||||
if ((!e164 && !uuid) || !identifier) {
|
||||
log.warn('lookupOrCreate: Called with neither e164 nor uuid!');
|
||||
log.warn(
|
||||
`lookupOrCreate: Called with neither e164 nor uuid! reason: ${reason}`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -684,7 +688,7 @@ export class ConversationController {
|
|||
// are truthy by this point. So we'll throw if that isn't the case.
|
||||
if (!convoE164 || !convoUuid) {
|
||||
throw new Error(
|
||||
'lookupOrCreate: convoE164 or convoUuid are falsey but should both be true!'
|
||||
`lookupOrCreate: convoE164 or convoUuid are falsey but should both be true! reason: ${reason}`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -695,7 +699,7 @@ export class ConversationController {
|
|||
|
||||
// 5. If the two lookups disagree, log and return the UUID match
|
||||
log.warn(
|
||||
`lookupOrCreate: Found a split contact - UUID ${normalizedUuid} and E164 ${e164}. Returning UUID match.`
|
||||
`lookupOrCreate: Found a split contact - UUID ${normalizedUuid} and E164 ${e164}. Returning UUID match. reason: ${reason}`
|
||||
);
|
||||
return convoUuid;
|
||||
}
|
||||
|
|
|
@ -1062,6 +1062,7 @@ export class SignalProtocolStore extends EventEmitter {
|
|||
|
||||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
uuid: uuid.toString(),
|
||||
reason: 'SignalProtocolStore.storeSession',
|
||||
});
|
||||
strictAssert(
|
||||
conversation !== undefined,
|
||||
|
@ -1393,6 +1394,7 @@ export class SignalProtocolStore extends EventEmitter {
|
|||
// First, fetch this conversation
|
||||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
uuid: uuid.toString(),
|
||||
reason: 'SignalProtocolStore.lightSessionReset',
|
||||
});
|
||||
assertDev(conversation, `lightSessionReset/${id}: missing conversation`);
|
||||
|
||||
|
|
|
@ -2964,6 +2964,7 @@ export async function startApp(): Promise<void> {
|
|||
const fromConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: data.source,
|
||||
uuid: data.sourceUuid,
|
||||
reason: 'onMessageReceived:reaction',
|
||||
});
|
||||
strictAssert(fromConversation, 'Reaction without fromConversation');
|
||||
|
||||
|
@ -2997,6 +2998,7 @@ export async function startApp(): Promise<void> {
|
|||
const fromConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: data.source,
|
||||
uuid: data.sourceUuid,
|
||||
reason: 'onMessageReceived:delete',
|
||||
});
|
||||
strictAssert(fromConversation, 'Delete missing fromConversation');
|
||||
|
||||
|
@ -3113,6 +3115,7 @@ export async function startApp(): Promise<void> {
|
|||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
uuid: destinationUuid,
|
||||
e164: destination,
|
||||
reason: 'createSentMessage',
|
||||
});
|
||||
if (!conversation || conversation.id === ourId) {
|
||||
return result;
|
||||
|
@ -3742,6 +3745,7 @@ export async function startApp(): Promise<void> {
|
|||
const senderConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: sender,
|
||||
uuid: senderUuid,
|
||||
reason: 'onReadSync',
|
||||
});
|
||||
const senderId = senderConversation?.id;
|
||||
|
||||
|
@ -3780,6 +3784,7 @@ export async function startApp(): Promise<void> {
|
|||
const senderConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: senderE164,
|
||||
uuid: senderUuid,
|
||||
reason: 'onViewSync',
|
||||
});
|
||||
const senderId = senderConversation?.id;
|
||||
|
||||
|
|
|
@ -2498,6 +2498,7 @@ export function buildMigrationBubble(
|
|||
].map(uuid => {
|
||||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
uuid,
|
||||
reason: 'buildMigrationBubble',
|
||||
});
|
||||
strictAssert(conversation, `Conversation not found for ${uuid}`);
|
||||
return conversation.id;
|
||||
|
|
|
@ -107,6 +107,7 @@ export class MessageRequests extends Collection<MessageRequestModel> {
|
|||
conversation = window.ConversationController.lookupOrCreate({
|
||||
e164: threadE164,
|
||||
uuid: threadUuid,
|
||||
reason: 'MessageRequests.onResponse',
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ export class Reactions extends Collection<ReactionModel> {
|
|||
const reactionsBySource = this.filter(re => {
|
||||
const targetSender = window.ConversationController.lookupOrCreate({
|
||||
uuid: re.get('targetAuthorUuid'),
|
||||
reason: 'Reactions.forMessage',
|
||||
});
|
||||
const targetTimestamp = re.get('targetTimestamp');
|
||||
return targetSender?.id === senderId && targetTimestamp === sentAt;
|
||||
|
@ -92,6 +93,7 @@ export class Reactions extends Collection<ReactionModel> {
|
|||
const targetAuthorConversation =
|
||||
window.ConversationController.lookupOrCreate({
|
||||
uuid: reaction.get('targetAuthorUuid'),
|
||||
reason: 'Reactions.onReaction',
|
||||
});
|
||||
const targetConversationId = targetAuthorConversation?.id;
|
||||
if (!targetConversationId) {
|
||||
|
|
|
@ -62,6 +62,7 @@ export class ReadSyncs extends Collection {
|
|||
const sender = window.ConversationController.lookupOrCreate({
|
||||
e164: message.get('source'),
|
||||
uuid: message.get('sourceUuid'),
|
||||
reason: 'ReadSyncs.forMessage',
|
||||
});
|
||||
const sync = this.find(item => {
|
||||
return (
|
||||
|
@ -88,6 +89,7 @@ export class ReadSyncs extends Collection {
|
|||
const sender = window.ConversationController.lookupOrCreate({
|
||||
e164: item.source,
|
||||
uuid: item.sourceUuid,
|
||||
reason: 'ReadSyncs.onSync',
|
||||
});
|
||||
|
||||
return isIncoming(item) && sender?.id === sync.get('senderId');
|
||||
|
|
|
@ -41,6 +41,7 @@ export class ViewSyncs extends Collection {
|
|||
const sender = window.ConversationController.lookupOrCreate({
|
||||
e164: message.get('source'),
|
||||
uuid: message.get('sourceUuid'),
|
||||
reason: 'ViewSyncs.forMessage',
|
||||
});
|
||||
const syncs = this.filter(item => {
|
||||
return (
|
||||
|
@ -69,6 +70,7 @@ export class ViewSyncs extends Collection {
|
|||
const sender = window.ConversationController.lookupOrCreate({
|
||||
e164: item.source,
|
||||
uuid: item.sourceUuid,
|
||||
reason: 'ViewSyncs.onSync',
|
||||
});
|
||||
|
||||
return sender?.id === sync.get('senderId');
|
||||
|
|
|
@ -121,6 +121,7 @@ export function isQuoteAMatch(
|
|||
const authorConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: 'author' in quote ? quote.author : undefined,
|
||||
uuid: authorUuid,
|
||||
reason: 'helpers.isQuoteAMatch',
|
||||
});
|
||||
|
||||
return (
|
||||
|
@ -143,6 +144,7 @@ export function getContactId(
|
|||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
e164: source,
|
||||
uuid: sourceUuid,
|
||||
reason: 'helpers.getContactId',
|
||||
});
|
||||
return conversation?.id;
|
||||
}
|
||||
|
|
|
@ -1354,6 +1354,7 @@ export class ConversationModel extends window.Backbone
|
|||
const source = window.ConversationController.lookupOrCreate({
|
||||
uuid,
|
||||
e164,
|
||||
reason: 'ConversationModel.onNewMessage',
|
||||
});
|
||||
const typingToken = `${source?.id}.${sourceDevice}`;
|
||||
|
||||
|
|
|
@ -395,6 +395,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
e164: source,
|
||||
uuid: sourceUuid,
|
||||
reason: 'MessageModel.getSenderIdentifier',
|
||||
})!;
|
||||
|
||||
return `${conversation?.id}.${sourceDevice}-${sentAt}`;
|
||||
|
@ -2458,6 +2459,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
const sender = window.ConversationController.lookupOrCreate({
|
||||
e164: source,
|
||||
uuid: sourceUuid,
|
||||
reason: 'handleDataMessage',
|
||||
})!;
|
||||
const hasGroupV2Prop = Boolean(initialMessage.groupV2);
|
||||
const isV1GroupUpdate =
|
||||
|
@ -2959,6 +2961,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
const local = window.ConversationController.lookupOrCreate({
|
||||
e164: source,
|
||||
uuid: sourceUuid,
|
||||
reason: 'handleDataMessage:setProfileKey',
|
||||
});
|
||||
local?.setProfileKey(profileKey);
|
||||
}
|
||||
|
|
|
@ -1257,7 +1257,17 @@ export async function mergeAccountRecord(
|
|||
let conversation: ConversationModel | undefined;
|
||||
|
||||
if (contact) {
|
||||
conversation = window.ConversationController.lookupOrCreate(contact);
|
||||
if (!contact.uuid && !contact.e164) {
|
||||
log.error(
|
||||
'storageService.mergeAccountRecord: No uuid or e164 on contact'
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
conversation = window.ConversationController.lookupOrCreate({
|
||||
uuid: contact.uuid,
|
||||
e164: contact.e164,
|
||||
reason: 'storageService.mergeAccountRecord',
|
||||
});
|
||||
} else if (legacyGroupId && legacyGroupId.length) {
|
||||
const groupId = Bytes.toBinary(legacyGroupId);
|
||||
conversation = window.ConversationController.get(groupId);
|
||||
|
|
|
@ -124,6 +124,7 @@ const mapStateToActiveCallProp = (
|
|||
>(uuid => {
|
||||
const convoForUuid = window.ConversationController.lookupOrCreate({
|
||||
uuid,
|
||||
reason: 'CallManager.mapStateToActiveCallProp',
|
||||
});
|
||||
return convoForUuid ? conversationSelector(convoForUuid.id) : undefined;
|
||||
});
|
||||
|
|
|
@ -71,6 +71,7 @@ function isStoryAMatch(
|
|||
const authorConversation = window.ConversationController.lookupOrCreate({
|
||||
e164: undefined,
|
||||
uuid: authorUuid,
|
||||
reason: 'isStoryAMatch',
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
@ -8,6 +8,7 @@ export async function getProfile(uuid?: string, e164?: string): Promise<void> {
|
|||
const c = window.ConversationController.lookupOrCreate({
|
||||
uuid,
|
||||
e164,
|
||||
reason: 'getProfile',
|
||||
});
|
||||
if (!c) {
|
||||
log.error('getProfile: failed to find conversation; doing nothing');
|
||||
|
|
|
@ -729,6 +729,7 @@ function startAutomaticSessionReset(decryptionError: DecryptionErrorEventData) {
|
|||
|
||||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
uuid: senderUuid,
|
||||
reason: 'startAutomaticSessionReset',
|
||||
});
|
||||
if (!conversation) {
|
||||
log.warn(
|
||||
|
|
|
@ -89,6 +89,7 @@ export async function lookupConversationWithoutUuid(
|
|||
if (foundUsername) {
|
||||
const convo = window.ConversationController.lookupOrCreate({
|
||||
uuid: foundUsername.uuid,
|
||||
reason: 'lookupConversationWithoutUuid',
|
||||
});
|
||||
|
||||
strictAssert(convo, 'We just ensured conversation existence');
|
||||
|
|
|
@ -93,6 +93,7 @@ export async function markConversationRead(
|
|||
senderId: window.ConversationController.lookupOrCreate({
|
||||
e164: messageSyncData.source,
|
||||
uuid: messageSyncData.sourceUuid,
|
||||
reason: 'markConversationRead',
|
||||
})?.id,
|
||||
timestamp: messageSyncData.sent_at,
|
||||
isDirectConversation: isDirectConversation(conversationAttrs),
|
||||
|
|
|
@ -66,6 +66,7 @@ export async function sendReceipts({
|
|||
const sender = window.ConversationController.lookupOrCreate({
|
||||
e164: senderE164,
|
||||
uuid: senderUuid,
|
||||
reason: 'sendReceipts',
|
||||
});
|
||||
if (!sender) {
|
||||
throw new Error(
|
||||
|
|
|
@ -1327,6 +1327,12 @@ async function fetchKeysForIdentifier(
|
|||
await markIdentifierUnregistered(identifier);
|
||||
return;
|
||||
}
|
||||
log.error(
|
||||
`fetchKeysForIdentifier: Error fetching ${
|
||||
devices || 'all'
|
||||
} devices for ${identifier}`,
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1346,6 +1346,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||
window.ConversationController.lookupOrCreate({
|
||||
uuid: message.sourceUuid,
|
||||
e164: message.source,
|
||||
reason: 'conversation_view.showAllMedia',
|
||||
})?.id || message.conversationId,
|
||||
id: message.id,
|
||||
received_at: message.received_at,
|
||||
|
@ -1824,6 +1825,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||
window.ConversationController.lookupOrCreate({
|
||||
uuid: message.get('sourceUuid'),
|
||||
e164: message.get('source'),
|
||||
reason: 'conversation_view.showLightBox',
|
||||
})?.id || message.get('conversationId'),
|
||||
received_at: message.get('received_at'),
|
||||
received_at_ms: Number(message.get('received_at_ms')),
|
||||
|
@ -2122,6 +2124,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||
const conversation = window.ConversationController.lookupOrCreate({
|
||||
e164,
|
||||
uuid,
|
||||
reason: 'conversation_view.startConversation',
|
||||
});
|
||||
strictAssert(
|
||||
conversation,
|
||||
|
|
Loading…
Reference in a new issue