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