feat: fixed 1-1s and added more logging

pull/2971/head
William Grant 2 years ago
parent 6031db308d
commit bb6eb3e84e

@ -810,7 +810,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
shouldCommit = true,
existingMessage,
}: {
providedExpirationType: DisappearingMessageConversationType;
providedExpirationType?: DisappearingMessageConversationType;
providedExpireTimer?: number;
providedChangeTimestamp: number;
providedSource?: string;
@ -838,7 +838,11 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (
this.get('lastDisappearingMessageChangeTimestamp') > lastDisappearingMessageChangeTimestamp
) {
window.log.info('WIP: updateExpireTimer() This is an outdated disappearing message setting');
window.log.info(
'WIP: updateExpireTimer() This is an outdated disappearing message setting',
`fromConfigMessage = ${fromConfigMessage}`,
`fromSync: ${fromSync}`
);
return;
}
@ -877,6 +881,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
let message: MessageModel | undefined = existingMessage || undefined;
const messageExpirationType = changeToDisappearingMessageType(this, expirationType);
window.log.debug(`WIP: updateExpireTimer() messageExpirationType: ${messageExpirationType}`);
// we don't have info about who made the change and when, when we get a change from a config message, so do not add a control message
// TODO NOTE We might not show it in the UI but still need to process it using the senttimestamp as the lastchange timestamp for config messages
@ -925,7 +930,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}
// if change was made remotely, don't send it to the contact/group
if (receivedAt || fromSync || fromConfigMessage) {
if (fromSync || fromConfigMessage) {
window.log.debug(
`WIP: updateExpireTimer() Not sending an ExpireTimerUpdate message because the change was made remotely receivedAt:${receivedAt} fromSync:${fromSync} fromConfigMessage:${fromConfigMessage} `
);
@ -948,17 +953,22 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}
const expirationTimerMessage = new ExpirationTimerUpdateMessage(expireUpdate);
window.log.debug(
`WIP: Sending ExpirationTimerUpdate message to Note to Self expirationTimerMessage:${JSON.stringify(
expirationTimerMessage
)}`
`WIP: updateExpireTimer() isMe() expirationTimerMessage`,
JSON.stringify(expirationTimerMessage)
);
await message?.sendSyncMessageOnly(expirationTimerMessage);
return;
}
if (this.isPrivate()) {
const expirationTimerMessage = new ExpirationTimerUpdateMessage(expireUpdate);
window.log.debug(
`WIP: updateExpireTimer() isPrivate() expirationTimerMessage`,
JSON.stringify(expirationTimerMessage)
);
const pubkey = new PubKey(this.get('id'));
await getMessageQueue().sendToPubKey(
pubkey,
@ -975,6 +985,11 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const expirationTimerMessage = new ExpirationTimerUpdateMessage(expireUpdateForGroup);
window.log.debug(
`WIP: updateExpireTimer() isClosedGroup() expirationTimerMessage`,
JSON.stringify(expirationTimerMessage)
);
await getMessageQueue().sendToGroup({
message: expirationTimerMessage,
namespace: SnodeNamespaces.ClosedGroupMessage,

@ -1126,6 +1126,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
}
public markMessageReadNoCommit(readAt: number) {
window.log.debug(`WIP: markMessageReadNoCommit ${this.idForLogging()}`, this);
this.set({ unread: READ_MESSAGE_STATE.read });
const convo = this.getConversation();
@ -1134,6 +1135,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
const expireTimer = this.get('expireTimer');
if (canBeDeleteAfterRead && expirationType && expireTimer > 0) {
window.log.debug(`WIP: markMessageReadNoCommit ${this.idForLogging()} is deleteAfterRead`);
const expirationMode = changeToDisappearingMessageConversationType(
convo,
expirationType,

@ -386,8 +386,8 @@ async function handleContactsUpdate(result: IncomingConfResult): Promise<Incomin
wrapperConvo.expirationMode !== contactConvo.get('expirationType')
) {
await contactConvo.updateExpireTimer({
providedExpirationType: wrapperConvo.expirationMode || 'off',
providedExpireTimer: wrapperConvo.expirationTimerSeconds || 0,
providedExpirationType: wrapperConvo.expirationMode,
providedExpireTimer: wrapperConvo.expirationTimerSeconds,
providedChangeTimestamp: result.latestEnvelopeTimestamp,
providedSource: wrapperConvo.id,
shouldCommit: false,

@ -193,6 +193,10 @@ function updateReadStatus(message: MessageModel) {
);
if (expirationMode === 'legacy' || expirationMode === 'deleteAfterRead') {
window.log.debug(
`WIP: updateReadStatus ${message.idForLogging()} is deleteAfterRead`,
message
);
message.set({
expirationStartTimestamp: setExpirationStartTimestamp(expirationMode),
});

@ -148,6 +148,10 @@ async function handleMessageSentSuccess(
// NOTE we treat all outbound disappearing messages as read as soon as they are sent.
if (expirationMode !== 'off') {
window.log.debug(
`WIP: handleMessageSentSuccess ${fetchedMessage.idForLogging()} is deleteAfterRead`,
fetchedMessage
);
fetchedMessage.set({
expirationStartTimestamp: setExpirationStartTimestamp(
expirationMode,

@ -26,6 +26,7 @@ export type IncomingConfResult = {
needsDump: boolean;
kind: SignalService.SharedConfigMessage.Kind;
publicKey: string;
// NOTE this is the latest sent timestamp of the config message
latestEnvelopeTimestamp: number;
};

@ -391,17 +391,12 @@ export async function checkForExpireUpdateInContentMessage(
? Number(dataMessage.expireTimer)
: content.expirationTimer;
// NOTE This starts are a DisappearingMessageConversationType but we will convert it to a DisappearingMessageType
let expirationType: any =
expirationTimer > 0
? DisappearingMessageConversationSetting[
!isDisappearingMessagesV2Released || isLegacyContentMessage
? changeToDisappearingMessageType(convoToUpdate) === 'deleteAfterRead'
? 1
: 2
: content.expirationType
]
: DisappearingMessageConversationSetting[0];
// NOTE This starts are a DisappearingMessageConversationType but we will convert it to a DisappearingMessageType for the final return
let expirationMode: any = changeToDisappearingMessageConversationType(
convoToUpdate,
DisappearingMessageMode[content.expirationType],
expirationTimer
);
const lastDisappearingMessageChangeTimestamp = content.lastDisappearingMessageChangeTimestamp
? Number(content.lastDisappearingMessageChangeTimestamp)
@ -410,7 +405,7 @@ export async function checkForExpireUpdateInContentMessage(
// TODO should review this
const shouldDisappearButIsntMessage =
dataMessage.flags !== SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE &&
expirationType === 'off' &&
expirationMode === 'off' &&
expirationTimer === 0 &&
convoToUpdate.get('expirationType') !== 'off' &&
convoToUpdate.get('expireTimer') !== 0;
@ -423,15 +418,16 @@ export async function checkForExpireUpdateInContentMessage(
convoToUpdate.get('expirationType') !== 'off'
) {
if (
expirationType !== convoToUpdate.get('expirationType') ||
expirationMode !== convoToUpdate.get('expirationType') ||
expirationTimer !== convoToUpdate.get('expireTimer')
) {
window.log.debug(
'WIP: Received a legacy disappearing message before v2 was released without values set. Using the conversation settings.',
content
content,
convoToUpdate
);
expirationTimer = convoToUpdate.get('expireTimer');
expirationType = changeToDisappearingMessageType(
expirationMode = changeToDisappearingMessageType(
convoToUpdate,
convoToUpdate.get('expirationType')
);
@ -443,19 +439,16 @@ export async function checkForExpireUpdateInContentMessage(
isDisappearingMessagesV2Released &&
(isLegacyDataMessage || isLegacyConversationSettingMessage || shouldDisappearButIsntMessage)
) {
window.log.warn(
'Received a legacy disappearing message after v2 was released. Overriding it with the conversation settings',
window.log.debug(
'WIP: Received a legacy disappearing message after v2 was released. Overriding it with the conversation settings',
content
);
expirationTimer = convoToUpdate.get('expireTimer');
expirationType = changeToDisappearingMessageType(
convoToUpdate,
convoToUpdate.get('expirationType')
);
expirationMode = convoToUpdate.get('expirationType');
}
const expireUpdate: DisappearingMessageUpdate = {
expirationType,
expirationType: changeToDisappearingMessageType(convoToUpdate, expirationMode),
expirationTimer,
lastDisappearingMessageChangeTimestamp,
isLegacyConversationSettingMessage,

Loading…
Cancel
Save