diff --git a/ts/state/selectors/stories.ts b/ts/state/selectors/stories.ts index e0dfacac52..02700630f8 100644 --- a/ts/state/selectors/stories.ts +++ b/ts/state/selectors/stories.ts @@ -36,6 +36,7 @@ import { getDistributionListSelector } from './storyDistributionLists'; import { getStoriesEnabled } from './items'; import { calculateExpirationTimestamp } from '../../util/expirationTimer'; import { getMessageIdForLogging } from '../../util/idForLogging'; +import * as log from '../../logging/log'; export const getStoriesState = (state: StateType): StoriesStateType => state.stories; @@ -343,6 +344,21 @@ export const getStories = createSelector( return; } + // if for some reason this story is already experied (bug) + // log it and skip it + if ((calculateExpirationTimestamp(story) ?? 0) < Date.now()) { + const messageIdForLogging = getMessageIdForLogging({ + ...pick(story, 'type', 'sourceUuid', 'sourceDevice'), + sent_at: story.timestamp, + }); + log.warn('selectors/getStories: story already expired', { + message: messageIdForLogging, + expireTimer: story.expireTimer, + expirationStartTimestamp: story.expirationStartTimestamp, + }); + return; + } + const conversationStory = getConversationStory( conversationSelector, ourConversationId,