Avoid mute timeouts with invalid delay values
This commit is contained in:
parent
a793285e3c
commit
2001e4d7b3
2 changed files with 10 additions and 1 deletions
|
@ -26,7 +26,7 @@ import { getNotificationTextForMessage } from '../util/getNotificationTextForMes
|
|||
import { getNotificationDataForMessage } from '../util/getNotificationDataForMessage';
|
||||
import type { ProfileNameChangeType } from '../util/getStringForProfileChange';
|
||||
import type { AttachmentType, ThumbnailType } from '../types/Attachment';
|
||||
import { toDayMillis } from '../util/timestamp';
|
||||
import { MAX_SAFE_TIMEOUT_DELAY, toDayMillis } from '../util/timestamp';
|
||||
import { areWeAdmin } from '../util/areWeAdmin';
|
||||
import { isBlocked } from '../util/isBlocked';
|
||||
import { getAboutText } from '../util/getAboutText';
|
||||
|
@ -5386,6 +5386,13 @@ export class ConversationModel extends window.Backbone
|
|||
return;
|
||||
}
|
||||
|
||||
if (delay > MAX_SAFE_TIMEOUT_DELAY) {
|
||||
log.warn(
|
||||
'startMuteTimer: timeout is larger than maximum setTimeout delay'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.#muteTimer = setTimeout(() => this.setMuteExpiration(0), delay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,8 @@ export function formatDate(
|
|||
export const MAX_SAFE_DATE = 8640000000000000;
|
||||
export const MIN_SAFE_DATE = -8640000000000000;
|
||||
|
||||
export const MAX_SAFE_TIMEOUT_DELAY = 2147483647; // max 32-bit signed integer
|
||||
|
||||
export function toBoundedDate(timestamp: number): Date {
|
||||
return new Date(Math.max(MIN_SAFE_DATE, Math.min(timestamp, MAX_SAFE_DATE)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue