Hotfix: Ignore iOS group expire timer sync resets (#2086)

Hotfix: Ignore invalid expire timer sync resets

iOS omits `expireTimer` protobuf property to denote disappearing messages have been turned off. However, that doesn’t allow us to distinguish it from old clients that are not aware of this property. This change ignores these invalid values until we consistently use `0` to denote disabled disappearing messages (as Android does).

- [x] Ignore non-numeric `expireTimer` values during contact sync. Long-term, we’ll use `0` to denote turning off expire timers.
- [x] Log what value `expireTimer` is set to.
- [x] Log changes to `expireTimer` in `handleDataMessage` until it uses `ConversationController::updateExpirationTimer`.
pull/749/head
Daniel Gasienica 7 years ago committed by GitHub
parent 65787918bc
commit caa579f3b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -438,17 +438,24 @@
color: details.color, color: details.color,
active_at: activeAt, active_at: activeAt,
})).then(function() { })).then(function() {
// this needs to be inline to get access to conversation model const { expireTimer } = details;
if (typeof details.expireTimer !== 'undefined') { const isValidExpireTimer = typeof expireTimer === 'number';
var source = textsecure.storage.user.getNumber(); if (!isValidExpireTimer) {
var receivedAt = Date.now(); console.log(
return conversation.updateExpirationTimer( 'Ignore invalid expire timer.',
details.expireTimer, 'Expected numeric `expireTimer`, got:', expireTimer
source,
receivedAt,
{fromSync: true}
); );
return;
} }
var source = textsecure.storage.user.getNumber();
var receivedAt = Date.now();
return conversation.updateExpirationTimer(
expireTimer,
source,
receivedAt,
{fromSync: true}
);
}); });
}) })
.then(function() { .then(function() {
@ -498,16 +505,24 @@
} }
return wrapDeferred(conversation.save(updates)).then(function() { return wrapDeferred(conversation.save(updates)).then(function() {
if (typeof details.expireTimer !== 'undefined') { const { expireTimer } = details;
var source = textsecure.storage.user.getNumber(); const isValidExpireTimer = typeof expireTimer === 'number';
var receivedAt = Date.now(); if (!isValidExpireTimer) {
return conversation.updateExpirationTimer( console.log(
details.expireTimer, 'Ignore invalid expire timer.',
source, 'Expected numeric `expireTimer`, got:', expireTimer
receivedAt,
{fromSync: true}
); );
return;
} }
var source = textsecure.storage.user.getNumber();
var receivedAt = Date.now();
return conversation.updateExpirationTimer(
expireTimer,
source,
receivedAt,
{fromSync: true}
);
}).then(ev.confirm); }).then(ev.confirm);
}); });
} }

@ -707,6 +707,8 @@
console.log( console.log(
'Updating expireTimer for conversation', 'Updating expireTimer for conversation',
this.idForLogging(), this.idForLogging(),
'to',
expireTimer,
'via', 'via',
source source
); );

@ -457,6 +457,21 @@
message.set({expireTimer: dataMessage.expireTimer}); message.set({expireTimer: dataMessage.expireTimer});
} }
// NOTE: Remove once the above uses
// `Conversation::updateExpirationTimer`:
const { expireTimer } = dataMessage;
const shouldLogExpireTimerChange =
message.isExpirationTimerUpdate() || expireTimer;
if (shouldLogExpireTimerChange) {
console.log(
'Updating expireTimer for conversation',
conversation.idForLogging(),
'to',
expireTimer,
'via `handleDataMessage`'
);
}
if (!message.isEndSession() && !message.isGroupUpdate()) { if (!message.isEndSession() && !message.isGroupUpdate()) {
if (dataMessage.expireTimer) { if (dataMessage.expireTimer) {
if (dataMessage.expireTimer !== conversation.get('expireTimer')) { if (dataMessage.expireTimer !== conversation.get('expireTimer')) {

Loading…
Cancel
Save