Skip to content

Commit

Permalink
Use just the timestamp for story expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Aug 17, 2022
1 parent 16222f6 commit 5ec7837
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
8 changes: 1 addition & 7 deletions ts/models/messages.ts
Expand Up @@ -3042,13 +3042,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}

if (!message.get('expirationStartTimestamp')) {
message.set(
'expirationStartTimestamp',
Math.min(
message.get('serverTimestamp') || message.get('timestamp'),
Date.now()
)
);
message.set('expirationStartTimestamp', message.get('timestamp'));
changed = true;
}
}
Expand Down
5 changes: 1 addition & 4 deletions ts/services/storyLoader.ts
Expand Up @@ -80,10 +80,7 @@ async function repairUnexpiredStories(): Promise<void> {
)
.map(story => ({
...story,
expirationStartTimestamp: Math.min(
story.serverTimestamp || story.timestamp,
Date.now()
),
expirationStartTimestamp: Math.min(story.timestamp, Date.now()),
expireTimer: Math.min(
Math.floor((story.timestamp + durations.DAY - Date.now()) / 1000),
DAY_AS_SECONDS
Expand Down
6 changes: 2 additions & 4 deletions ts/textsecure/MessageReceiver.ts
Expand Up @@ -1949,9 +1949,7 @@ export default class MessageReceiver
}

const expireTimer = Math.min(
Math.floor(
(envelope.serverTimestamp + durations.DAY - Date.now()) / 1000
),
Math.floor((envelope.timestamp + durations.DAY - Date.now()) / 1000),
durations.DAY / 1000
);

Expand All @@ -1964,7 +1962,7 @@ export default class MessageReceiver
return;
}

const message = {
const message: ProcessedDataMessage = {
attachments,
canReplyToStory: Boolean(msg.allowsReplies),
expireTimer,
Expand Down

0 comments on commit 5ec7837

Please sign in to comment.