Better logging for expiration timer updates
This commit is contained in:
parent
f9163f410e
commit
35e5eb847a
7 changed files with 84 additions and 54 deletions
|
@ -3288,7 +3288,9 @@ export class ConversationModel extends window.Backbone
|
|||
`maybeApplyUniversalTimer(${this.idForLogging()}): applying timer`
|
||||
);
|
||||
|
||||
await this.updateExpirationTimer(expireTimer);
|
||||
await this.updateExpirationTimer(expireTimer, {
|
||||
reason: 'maybeApplyUniversalTimer',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4446,19 +4448,27 @@ export class ConversationModel extends window.Backbone
|
|||
|
||||
async updateExpirationTimer(
|
||||
providedExpireTimer: number | undefined,
|
||||
providedSource?: unknown,
|
||||
initiatingMessage?: MessageModel,
|
||||
{
|
||||
reason,
|
||||
receivedAt,
|
||||
receivedAtMS = Date.now(),
|
||||
sentAt: providedSentAt,
|
||||
source: providedSource,
|
||||
fromSync = false,
|
||||
isInitialSync = false,
|
||||
fromGroupUpdate = false,
|
||||
}: {
|
||||
reason: string;
|
||||
receivedAt?: number;
|
||||
receivedAtMS?: number;
|
||||
sentAt?: number;
|
||||
source?: string;
|
||||
fromSync?: boolean;
|
||||
isInitialSync?: boolean;
|
||||
fromGroupUpdate?: boolean;
|
||||
} = {}
|
||||
}
|
||||
): Promise<boolean | null | MessageModel | void> {
|
||||
const isSetByOther = providedSource || initiatingMessage;
|
||||
const isSetByOther = providedSource || providedSentAt !== undefined;
|
||||
|
||||
if (isGroupV2(this.attributes)) {
|
||||
if (isSetByOther) {
|
||||
|
@ -4496,11 +4506,12 @@ export class ConversationModel extends window.Backbone
|
|||
return null;
|
||||
}
|
||||
|
||||
log.info("Update conversation 'expireTimer'", {
|
||||
id: this.idForLogging(),
|
||||
expireTimer,
|
||||
source,
|
||||
});
|
||||
const logId =
|
||||
`updateExpirationTimer(${this.idForLogging()}, ` +
|
||||
`${expireTimer || 'disabled'}) ` +
|
||||
`source=${source ?? '?'} reason=${reason}`;
|
||||
|
||||
log.info(`${logId}: updating`);
|
||||
|
||||
// if change wasn't made remotely, send it to the number/group
|
||||
if (!isSetByOther) {
|
||||
|
@ -4512,7 +4523,7 @@ export class ConversationModel extends window.Backbone
|
|||
});
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'updateExpirationTimer: Failed to queue expiration timer update',
|
||||
`${logId}: Failed to queue expiration timer update`,
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
throw error;
|
||||
|
@ -4521,14 +4532,6 @@ export class ConversationModel extends window.Backbone
|
|||
|
||||
source = source || window.ConversationController.getOurConversationId();
|
||||
|
||||
// When we add a disappearing messages notification to the conversation, we want it
|
||||
// to be above the message that initiated that change, hence the subtraction.
|
||||
const receivedAt =
|
||||
initiatingMessage?.get('received_at') ||
|
||||
window.Signal.Util.incrementMessageCounter();
|
||||
const receivedAtMS = initiatingMessage?.get('received_at_ms') || Date.now();
|
||||
const sentAt = (initiatingMessage?.get('sent_at') || receivedAtMS) - 1;
|
||||
|
||||
this.set({ expireTimer });
|
||||
|
||||
// This call actually removes universal timer notification and clears
|
||||
|
@ -4537,6 +4540,10 @@ export class ConversationModel extends window.Backbone
|
|||
|
||||
window.Signal.Data.updateConversation(this.attributes);
|
||||
|
||||
// When we add a disappearing messages notification to the conversation, we want it
|
||||
// to be above the message that initiated that change, hence the subtraction.
|
||||
const sentAt = (providedSentAt || receivedAtMS) - 1;
|
||||
|
||||
const model = new window.Whisper.Message({
|
||||
conversationId: this.id,
|
||||
expirationTimerUpdate: {
|
||||
|
@ -4548,7 +4555,7 @@ export class ConversationModel extends window.Backbone
|
|||
flags: Proto.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
||||
readStatus: isInitialSync ? ReadStatus.Read : ReadStatus.Unread,
|
||||
received_at_ms: receivedAtMS,
|
||||
received_at: receivedAt,
|
||||
received_at: receivedAt ?? window.Signal.Util.incrementMessageCounter(),
|
||||
seenStatus: isInitialSync ? SeenStatus.Seen : SeenStatus.Unseen,
|
||||
sent_at: sentAt,
|
||||
type: 'timer-notification',
|
||||
|
@ -4566,6 +4573,10 @@ export class ConversationModel extends window.Backbone
|
|||
this.addSingleMessage(message);
|
||||
this.updateUnread();
|
||||
|
||||
log.info(
|
||||
`${logId}: added a notification received_at=${model.get('received_at')}`
|
||||
);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue