Force set expirationStartTimestamp on story messages
This commit is contained in:
parent
7f89f6162f
commit
9f7ee9ae79
4 changed files with 60 additions and 2 deletions
|
@ -38,7 +38,11 @@ import { normalizeUuid } from './util/normalizeUuid';
|
|||
import { filter } from './util/iterables';
|
||||
import { isNotNil } from './util/isNotNil';
|
||||
import { IdleDetector } from './IdleDetector';
|
||||
import { loadStories, getStoriesForRedux } from './services/storyLoader';
|
||||
import {
|
||||
getStoriesForRedux,
|
||||
loadStories,
|
||||
repairUnexpiredStories,
|
||||
} from './services/storyLoader';
|
||||
import { senderCertificateService } from './services/senderCertificate';
|
||||
import { GROUP_CREDENTIALS_KEY } from './services/groupCredentialFetcher';
|
||||
import * as KeyboardLayout from './services/keyboardLayout';
|
||||
|
@ -707,6 +711,13 @@ export async function startApp(): Promise<void> {
|
|||
window.storage.remove('remoteBuildExpiration');
|
||||
}
|
||||
|
||||
if (
|
||||
window.isBeforeVersion(lastVersion, 'v5.40.0') &&
|
||||
window.isAfterVersion(lastVersion, 'v5.36.0')
|
||||
) {
|
||||
await repairUnexpiredStories();
|
||||
}
|
||||
|
||||
if (window.isBeforeVersion(lastVersion, 'v1.29.2-beta.1')) {
|
||||
// Stickers flags
|
||||
await Promise.all([
|
||||
|
|
|
@ -2790,6 +2790,20 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
}
|
||||
}
|
||||
|
||||
if (
|
||||
isStory(message.attributes) &&
|
||||
!message.get('expirationStartTimestamp')
|
||||
) {
|
||||
message.set(
|
||||
'expirationStartTimestamp',
|
||||
Math.min(
|
||||
message.get('serverTimestamp') || message.get('timestamp'),
|
||||
Date.now()
|
||||
)
|
||||
);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Does this message have any pending, previously-received associated reactions?
|
||||
const reactions = Reactions.getSingleton().forMessage(message);
|
||||
await Promise.all(
|
||||
|
|
|
@ -65,3 +65,34 @@ export function getStoriesForRedux(): Array<StoryDataType> {
|
|||
|
||||
return stories;
|
||||
}
|
||||
|
||||
export async function repairUnexpiredStories(): Promise<void> {
|
||||
if (!storyData) {
|
||||
await loadStories();
|
||||
}
|
||||
|
||||
strictAssert(storyData, 'Could not load stories');
|
||||
|
||||
const storiesWithExpiry = storyData
|
||||
.filter(story => !story.expirationStartTimestamp)
|
||||
.map(story => ({
|
||||
...story,
|
||||
expirationStartTimestamp: Math.min(
|
||||
story.serverTimestamp || story.timestamp,
|
||||
Date.now()
|
||||
),
|
||||
}));
|
||||
|
||||
log.info(
|
||||
'repairUnexpiredStories: repairing number of stories',
|
||||
storiesWithExpiry.length
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
storiesWithExpiry.map(messageAttributes => {
|
||||
return window.Signal.Data.saveMessage(messageAttributes, {
|
||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1814,7 +1814,9 @@ export default class MessageReceiver
|
|||
}
|
||||
|
||||
const expireTimer = Math.min(
|
||||
(envelope.serverTimestamp + durations.DAY - Date.now()) / 1000,
|
||||
Math.floor(
|
||||
(envelope.serverTimestamp + durations.DAY - Date.now()) / 1000
|
||||
),
|
||||
durations.DAY / 1000
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue