Add logging to help in debugging sealedSender state

This commit is contained in:
Scott Nonnenberg 2018-11-01 12:43:05 -07:00
parent 0297279084
commit 486932048c

View file

@ -831,6 +831,9 @@
conversation && conversation &&
conversation.get('sealedSender') !== SEALED_SENDER.DISABLED conversation.get('sealedSender') !== SEALED_SENDER.DISABLED
) { ) {
window.log.info(
`Setting sealedSender to DISABLED for conversation ${conversation.idForLogging()}`
);
conversation.set({ conversation.set({
sealedSender: SEALED_SENDER.DISABLED, sealedSender: SEALED_SENDER.DISABLED,
}); });
@ -852,10 +855,16 @@
conversation.get('sealedSender') === SEALED_SENDER.UNKNOWN conversation.get('sealedSender') === SEALED_SENDER.UNKNOWN
) { ) {
if (conversation.get('accessKey')) { if (conversation.get('accessKey')) {
window.log.info(
`Setting sealedSender to ENABLED for conversation ${conversation.idForLogging()}`
);
conversation.set({ conversation.set({
sealedSender: SEALED_SENDER.ENABLED, sealedSender: SEALED_SENDER.ENABLED,
}); });
} else { } else {
window.log.info(
`Setting sealedSender to UNRESTRICTED for conversation ${conversation.idForLogging()}`
);
conversation.set({ conversation.set({
sealedSender: SEALED_SENDER.UNRESTRICTED, sealedSender: SEALED_SENDER.UNRESTRICTED,
}); });
@ -1306,6 +1315,9 @@
}); });
} catch (error) { } catch (error) {
if (error.code === 401 || error.code === 403) { if (error.code === 401 || error.code === 403) {
window.log.info(
`Setting sealedSender to DISABLED for conversation ${c.idForLogging()}`
);
c.set({ sealedSender: SEALED_SENDER.DISABLED }); c.set({ sealedSender: SEALED_SENDER.DISABLED });
profile = await textsecure.messaging.getProfile(id); profile = await textsecure.messaging.getProfile(id);
} else { } else {
@ -1341,6 +1353,9 @@
profile.unrestrictedUnidentifiedAccess && profile.unrestrictedUnidentifiedAccess &&
profile.unidentifiedAccess profile.unidentifiedAccess
) { ) {
window.log.info(
`Setting sealedSender to UNRESTRICTED for conversation ${c.idForLogging()}`
);
c.set({ c.set({
sealedSender: SEALED_SENDER.UNRESTRICTED, sealedSender: SEALED_SENDER.UNRESTRICTED,
}); });
@ -1351,15 +1366,24 @@
); );
if (haveCorrectKey) { if (haveCorrectKey) {
window.log.info(
`Setting sealedSender to ENABLED for conversation ${c.idForLogging()}`
);
c.set({ c.set({
sealedSender: SEALED_SENDER.ENABLED, sealedSender: SEALED_SENDER.ENABLED,
}); });
} else { } else {
window.log.info(
`Setting sealedSender to DISABLED for conversation ${c.idForLogging()}`
);
c.set({ c.set({
sealedSender: SEALED_SENDER.DISABLED, sealedSender: SEALED_SENDER.DISABLED,
}); });
} }
} else { } else {
window.log.info(
`Setting sealedSender to DISABLED for conversation ${c.idForLogging()}`
);
c.set({ c.set({
sealedSender: SEALED_SENDER.DISABLED, sealedSender: SEALED_SENDER.DISABLED,
}); });
@ -1442,6 +1466,9 @@
async setProfileKey(profileKey) { async setProfileKey(profileKey) {
// profileKey is a string so we can compare it directly // profileKey is a string so we can compare it directly
if (this.get('profileKey') !== profileKey) { if (this.get('profileKey') !== profileKey) {
window.log.info(
`Setting sealedSender to UNKNOWN for conversation ${this.idForLogging()}`
);
this.set({ this.set({
profileKey, profileKey,
accessKey: null, accessKey: null,