feat: fixed closed groups legacy mode

pull/2660/head
William Grant 2 years ago
parent 8117e631d0
commit a3a0c3f9de

@ -635,11 +635,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (this.isPrivate()) {
if (this.isMe()) {
if (this.isDisappearingMode) {
// TODO legacy messages support will be removed in a future release
if (!this.isDisappearingMode('legacy') || !this.isDisappearingMode('deleteAfterSend')) {
return;
}
// TODO legacy messages support will be removed in a future release
if (!this.isDisappearingMode('legacy') && !this.isDisappearingMode('deleteAfterSend')) {
return;
}
chatMessageParams.syncTarget = this.id;
const chatMessageMe = new VisibleMessage(chatMessageParams);
@ -670,9 +668,11 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}
if (this.isMediumGroup()) {
if (!this.isDisappearingMode('deleteAfterSend')) {
// TODO legacy messages support will be removed in a future release
if (!this.isDisappearingMode('legacy') && !this.isDisappearingMode('disappearAfterSend')) {
return;
}
const chatMessageMediumGroup = new VisibleMessage(chatMessageParams);
const closedGroupVisibleMessage = new ClosedGroupVisibleMessage({
chatMessage: chatMessageMediumGroup,
@ -2237,6 +2237,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return [];
}
// TODO I think this is flawed
private isDisappearingMode(mode: DisappearingMessageType) {
// TODO legacy messages support will be removed in a future release
const success =
@ -2247,7 +2248,12 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
: this.get('expirationType') === 'deleteAfterSend';
if (!success) {
window.log.info(`WIP: This message should be disappear after ${mode}`, this);
window.log.info(
`WIP: This message should be ${
mode === 'legacy' ? ' a legacy disappearing message' : ` disappear after ${mode}`
}`,
this
);
}
return success;

@ -382,7 +382,7 @@ export async function innerHandleSwarmContentMessage(
* For a closed group message, this holds the conversation with that specific user outside of the closed group.
* For a private conversation message, this is just the conversation with that user
*/
const senderConversationModel = await getConversationController().getOrCreateAndWait(
let conversationModel = await getConversationController().getOrCreateAndWait(
isPrivateConversationMessage ? envelope.source : envelope.senderIdentity,
ConversationTypeEnum.PRIVATE
);
@ -393,7 +393,7 @@ export async function innerHandleSwarmContentMessage(
*/
if (!isPrivateConversationMessage) {
// this is a closed group message, we have a second conversation to make sure exists
await getConversationController().getOrCreateAndWait(
conversationModel = await getConversationController().getOrCreateAndWait(
envelope.source,
ConversationTypeEnum.GROUP
);
@ -416,14 +416,22 @@ export async function innerHandleSwarmContentMessage(
// TODO account for outdated groups separately probably
if (isLegacyMessage) {
window.log.info('WIP: Received a legacy disappearing message', content);
window.log.info(
'WIP: Received a legacy disappearing message',
content,
`${
!isPrivateConversationMessage
? ` in closed group ${conversationModel.get('displayNameInProfile')}`
: ''
}`
);
// trigger notice banner
if (!senderConversationModel.get('hasOutdatedClient')) {
senderConversationModel.set({ hasOutdatedClient: true });
if (!conversationModel.get('hasOutdatedClient')) {
conversationModel.set({ hasOutdatedClient: true });
}
} else {
if (senderConversationModel.get('hasOutdatedClient')) {
senderConversationModel.set({ hasOutdatedClient: false });
if (conversationModel.get('hasOutdatedClient')) {
conversationModel.set({ hasOutdatedClient: false });
}
}
@ -449,7 +457,7 @@ export async function innerHandleSwarmContentMessage(
sentAtTimestamp,
dataMessage as SignalService.DataMessage,
messageHash,
senderConversationModel,
conversationModel,
expireUpdate
);
perfEnd(`handleSwarmDataMessage-${envelope.id}`, 'handleSwarmDataMessage');

@ -45,6 +45,11 @@ export class ClosedGroupVisibleMessage extends ClosedGroupMessage {
dataProto.group = groupMessage;
// TODO legacy messages support will be removed in a future release
if (this.expirationType === 'legacy' && this.expireTimer) {
dataProto.expireTimer = this.expireTimer;
}
return dataProto;
}
}

@ -125,8 +125,9 @@ async function handleMessageSentSuccess(
const expirationType = fetchedMessage.get('expirationType');
// TODO legacy messages support will be removed in a future release
const convo = fetchedMessage.getConversation();
const isLegacyMode = convo && convo.isPrivate() && expirationType === 'legacy';
const markAsUnread = isLegacyMode || expirationType === 'deleteAfterRead';
const isLegacyReadMode = convo && convo.isPrivate() && expirationType === 'legacy';
const isLegacySentMode = convo && convo.isMediumGroup() && expirationType === 'legacy';
const markAsUnread = isLegacyReadMode || expirationType === 'deleteAfterRead';
fetchedMessage.set({
sent_to: sentTo,
@ -136,16 +137,16 @@ async function handleMessageSentSuccess(
unread: markAsUnread ? 1 : 0,
});
// TODO legacy messages support will be removed in a future release
if (
fetchedMessage.get('expirationType') === 'deleteAfterSend' &&
(isLegacySentMode || expirationType === 'deleteAfterSend') &&
Boolean(fetchedMessage.get('expirationStartTimestamp')) === false
) {
const expirationType = fetchedMessage.get('expirationType');
if (expirationType === 'deleteAfterSend') {
if (expirationType === 'legacy' || expirationType === 'deleteAfterSend') {
// TODO message timer start is a few seconds less than the amount due to it's position in the pipeline, not sure on a fix yet
fetchedMessage.set({
expirationStartTimestamp: setExpirationStartTimestamp(
expirationType,
'deleteAfterSend',
fetchedMessage.get('sent_at')
),
});

Loading…
Cancel
Save