feat: renamed isLegacyMessage to isLegacyDataMessage

all works except modern to modern stage 2
pull/2660/head
William Grant 2 years ago
parent 89c70760a5
commit 8dc7d48c52

@ -1098,7 +1098,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
}
// TODO legacy messages support will be removed in a future release
const isLegacyMessage = Boolean(
const isLegacyDataMessage = Boolean(
(dataMessage.expireTimer && dataMessage.expireTimer > -1) ||
(!content.expirationTimer &&
dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE)
@ -1106,10 +1106,10 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
const expirationType = content.expirationType
? DisappearingMessageConversationSetting[content.expirationType]
: isLegacyMessage
: isLegacyDataMessage
? DisappearingMessageConversationSetting[3]
: 'off';
const expirationTimer = isLegacyMessage
const expirationTimer = isLegacyDataMessage
? Number(dataMessage.expireTimer)
: content.expirationTimer;
const lastDisappearingMessageChangeTimestamp = content.lastDisappearingMessageChangeTimestamp

@ -351,8 +351,13 @@ export async function handleMessageJob(
}
if (messageModel.isExpirationTimerUpdate()) {
// TODO legacy messages support will be removed in a future release
// NOTE if we turn off disappearing messages from a legacy client expirationTimerUpdate can be undefined but the flags value is correctly set
const expirationTimerUpdate = messageModel.get('expirationTimerUpdate');
if (!expirationTimerUpdate || isEmpty(expirationTimerUpdate)) {
if (
messageModel.get('flags') !== SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE &&
(!expirationTimerUpdate || isEmpty(expirationTimerUpdate))
) {
window.log.info(
`WIP: There is a problem with the expiration timer update`,
messageModel,
@ -361,10 +366,10 @@ export async function handleMessageJob(
return;
}
const expirationType = expirationTimerUpdate.expirationType || 'off';
const expireTimer = expirationTimerUpdate.expireTimer;
const expirationType = expirationTimerUpdate?.expirationType || 'off';
const expireTimer = expirationTimerUpdate?.expireTimer || 0;
const lastDisappearingMessageChangeTimestamp =
expirationTimerUpdate.lastDisappearingMessageChangeTimestamp || getNowWithNetworkOffset();
expirationTimerUpdate?.lastDisappearingMessageChangeTimestamp || getNowWithNetworkOffset();
// Compare mode and timestamp
const oldTypeValue = conversation.get('expirationType');

@ -33,7 +33,7 @@ export type DisappearingMessageUpdate = {
lastDisappearingMessageChangeTimestamp?: number;
// TODO legacy messages support will be removed in a future release
isLegacyConversationSettingMessage?: boolean;
isLegacyMessage?: boolean;
isLegacyDataMessage?: boolean;
isDisappearingMessagesV2Released?: boolean;
isMismatchedMessage?: boolean;
};
@ -283,27 +283,32 @@ export async function checkForExpireUpdate(
convoToUpdate: ConversationModel,
content: SignalService.Content
): Promise<DisappearingMessageUpdate | undefined> {
// debugger;
const dataMessage = content.dataMessage as SignalService.DataMessage;
// We will only support legacy disappearing messages for a short period before disappearing messages v2 is unlocked
const isDisappearingMessagesV2Released = await checkIsFeatureReleased('Disappearing Messages V2');
const isLegacyContentMessage = checkIsLegacyContentMessage(content);
const isLegacyMessage = Boolean(
const isLegacyDataMessage = Boolean(
isLegacyContentMessage && checkIsLegacyDataMessage(dataMessage as SignalService.DataMessage)
);
const isLegacyConversationSettingMessage =
isLegacyContentMessage &&
isLegacyDataMessage &&
dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
let expirationTimer = isLegacyMessage ? Number(dataMessage.expireTimer) : content.expirationTimer;
let expirationTimer = isLegacyDataMessage
? Number(dataMessage.expireTimer)
: content.expirationTimer;
let expirationType =
expirationTimer > 0
? DisappearingMessageConversationSetting[isLegacyContentMessage ? 3 : content.expirationType]
? DisappearingMessageConversationSetting[
!isDisappearingMessagesV2Released || isLegacyContentMessage ? 3 : content.expirationType
]
: DisappearingMessageConversationSetting[0];
const lastDisappearingMessageChangeTimestamp = content.lastDisappearingMessageChangeTimestamp
? Number(content.lastDisappearingMessageChangeTimestamp)
: undefined;
const isLegacyConversationSettingMessage =
isLegacyContentMessage &&
isLegacyMessage &&
dataMessage.flags === SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
const isMismatchedMessage =
(!isLegacyConversationSettingMessage &&
@ -315,9 +320,9 @@ export async function checkForExpireUpdate(
// If it is a legacy message and disappearing messages v2 is released then we ignore it and use the local client's conversation settings
if (
isDisappearingMessagesV2Released &&
(isLegacyMessage ||
(isLegacyDataMessage ||
isLegacyConversationSettingMessage ||
(!isLegacyConversationSettingMessage && isMismatchedMessage))
(isLegacyDataMessage && isMismatchedMessage))
) {
window.log.info(`WIP: received a legacy disappearing message after v2 was released.`);
expirationType = convoToUpdate.get('expirationType');
@ -329,11 +334,13 @@ export async function checkForExpireUpdate(
expirationTimer,
lastDisappearingMessageChangeTimestamp,
isLegacyConversationSettingMessage,
isLegacyMessage,
isLegacyDataMessage,
isDisappearingMessagesV2Released,
isMismatchedMessage,
};
window.log.info(`WIP: checkForExpireUpdate`, expireUpdate);
return expireUpdate;
}
@ -389,7 +396,7 @@ export function checkHasOutdatedClient(
if (convoToUpdate.get('hasOutdatedClient')) {
// trigger notice banner
if (
expireUpdate.isLegacyMessage ||
expireUpdate.isLegacyDataMessage ||
expireUpdate.isLegacyConversationSettingMessage ||
(expireUpdate.isDisappearingMessagesV2Released && expireUpdate.isMismatchedMessage)
) {
@ -406,7 +413,7 @@ export function checkHasOutdatedClient(
convoToUpdate.commit();
} else {
if (
expireUpdate.isLegacyMessage ||
expireUpdate.isLegacyDataMessage ||
expireUpdate.isLegacyConversationSettingMessage ||
(expireUpdate.isDisappearingMessagesV2Released && expireUpdate.isMismatchedMessage)
) {

Loading…
Cancel
Save