Don't expire incoming expiration timer updates
This commit is contained in:
parent
75cb7b6b13
commit
7dac480df5
3 changed files with 28 additions and 5 deletions
|
@ -2855,7 +2855,10 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
attributes.active_at = now;
|
||||
conversation.set(attributes);
|
||||
|
||||
if (dataMessage.expireTimer) {
|
||||
if (
|
||||
dataMessage.expireTimer &&
|
||||
!isExpirationTimerUpdate(dataMessage)
|
||||
) {
|
||||
message.set({ expireTimer: dataMessage.expireTimer });
|
||||
}
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ export function isMessageHistoryUnsynced(
|
|||
// Expiration Timer Update
|
||||
|
||||
export function isExpirationTimerUpdate(
|
||||
message: MessageAttributesType
|
||||
message: Pick<MessageAttributesType, 'flags'>
|
||||
): boolean {
|
||||
const flag =
|
||||
window.textsecure.protobuf.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
|
||||
|
|
|
@ -41,6 +41,7 @@ import {
|
|||
Sessions,
|
||||
SignedPreKeys,
|
||||
} from '../LibSignalStores';
|
||||
import { assert } from '../util/assert';
|
||||
import { BackOff, FIBONACCI_TIMEOUTS } from '../util/BackOff';
|
||||
import { BatcherType, createBatcher } from '../util/batcher';
|
||||
import { sleep } from '../util/sleep';
|
||||
|
@ -2581,16 +2582,35 @@ class MessageReceiverInner extends EventTarget {
|
|||
decrypted.expireTimer = 0;
|
||||
}
|
||||
|
||||
if (decrypted.flags & FLAGS.END_SESSION) {
|
||||
const isEndSession = Boolean(decrypted.flags & FLAGS.END_SESSION);
|
||||
const isExpirationTimerUpdate = Boolean(
|
||||
decrypted.flags & FLAGS.EXPIRATION_TIMER_UPDATE
|
||||
);
|
||||
const isProfileKeyUpdate = Boolean(
|
||||
decrypted.flags & FLAGS.PROFILE_KEY_UPDATE
|
||||
);
|
||||
// The following assertion codifies an assumption: 0 or 1 flags are set, but never
|
||||
// more. This assumption is fine as of this writing, but may not always be.
|
||||
const flagCount = [
|
||||
isEndSession,
|
||||
isExpirationTimerUpdate,
|
||||
isProfileKeyUpdate,
|
||||
].filter(Boolean).length;
|
||||
assert(
|
||||
flagCount <= 1,
|
||||
`Expected exactly <=1 flags to be set, but got ${flagCount}`
|
||||
);
|
||||
|
||||
if (isEndSession) {
|
||||
decrypted.body = null;
|
||||
decrypted.attachments = [];
|
||||
decrypted.group = null;
|
||||
return Promise.resolve(decrypted);
|
||||
}
|
||||
if (decrypted.flags & FLAGS.EXPIRATION_TIMER_UPDATE) {
|
||||
if (isExpirationTimerUpdate) {
|
||||
decrypted.body = null;
|
||||
decrypted.attachments = [];
|
||||
} else if (decrypted.flags & FLAGS.PROFILE_KEY_UPDATE) {
|
||||
} else if (isProfileKeyUpdate) {
|
||||
decrypted.body = null;
|
||||
decrypted.attachments = [];
|
||||
} else if (decrypted.flags !== 0) {
|
||||
|
|
Loading…
Reference in a new issue