hydrateStoryContext: Let through in more situations
This commit is contained in:
parent
90d345549a
commit
9ae3485334
1 changed files with 13 additions and 3 deletions
|
@ -2,12 +2,16 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import omit from 'lodash/omit';
|
import omit from 'lodash/omit';
|
||||||
|
import * as log from '../logging/log';
|
||||||
import type { AttachmentType } from '../types/Attachment';
|
import type { AttachmentType } from '../types/Attachment';
|
||||||
import type { MessageAttributesType } from '../model-types.d';
|
import type { MessageAttributesType } from '../model-types.d';
|
||||||
import { getAttachmentsForMessage } from '../state/selectors/message';
|
import { getAttachmentsForMessage } from '../state/selectors/message';
|
||||||
import { isAciString } from './isAciString';
|
import { isAciString } from './isAciString';
|
||||||
import { isDirectConversation } from './whatTypeOfConversation';
|
import { isDirectConversation } from './whatTypeOfConversation';
|
||||||
import { softAssert, strictAssert } from './assert';
|
import { softAssert, strictAssert } from './assert';
|
||||||
|
import { getMessageSentTimestamp } from './getMessageSentTimestamp';
|
||||||
|
import { isOlderThan } from './timestamp';
|
||||||
|
import { DAY } from './durations';
|
||||||
|
|
||||||
export async function hydrateStoryContext(
|
export async function hydrateStoryContext(
|
||||||
messageId: string,
|
messageId: string,
|
||||||
|
@ -36,11 +40,17 @@ export async function hydrateStoryContext(
|
||||||
}
|
}
|
||||||
|
|
||||||
const { storyReplyContext: context } = messageAttributes;
|
const { storyReplyContext: context } = messageAttributes;
|
||||||
// We'll continue trying to get the attachment as long as the message still exists
|
const sentTimestamp = getMessageSentTimestamp(messageAttributes, {
|
||||||
|
includeEdits: false,
|
||||||
|
log,
|
||||||
|
});
|
||||||
|
const olderThanADay = isOlderThan(sentTimestamp, DAY);
|
||||||
|
const didNotFindMessage = context && !context.messageId;
|
||||||
|
const weHaveData = context && context.attachment?.url;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!isStoryErased &&
|
!isStoryErased &&
|
||||||
context &&
|
((!olderThanADay && weHaveData) || (olderThanADay && didNotFindMessage))
|
||||||
(context.attachment?.url || !context.messageId)
|
|
||||||
) {
|
) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue