diff --git a/ts/messages/MessageSendState.ts b/ts/messages/MessageSendState.ts index 4f0fb69b2..38e53f670 100644 --- a/ts/messages/MessageSendState.ts +++ b/ts/messages/MessageSendState.ts @@ -109,6 +109,7 @@ export function sendStateReducer( return newStatus === oldStatus ? state : { + ...state, status: newStatus, updatedAt: action.updatedAt, }; diff --git a/ts/models/messages.ts b/ts/models/messages.ts index b9bea5a33..07752cb10 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -2522,6 +2522,59 @@ export class MessageModel extends window.Backbone.Model { return; } + if (storyQuote) { + const sendStateByConversationId = + storyQuote.get('sendStateByConversationId') || {}; + const sendState = sendStateByConversationId[sender.id]; + + if (!sendState) { + log.warn( + `${idLog}: Received storyContext message but sender was not in sendStateByConversationId. Dropping.` + ); + + confirm(); + return; + } + + if (sendState.isAllowedToReplyToStory === false) { + log.warn( + `${idLog}: Received storyContext message but sender is not allowed to reply. Dropping.` + ); + + confirm(); + return; + } + + const storyDistributionListId = storyQuote.get( + 'storyDistributionListId' + ); + + if (storyDistributionListId) { + const storyDistribution = + await dataInterface.getStoryDistributionWithMembers( + storyDistributionListId + ); + + if (!storyDistribution) { + log.warn( + `${idLog}: Received storyContext message for story with no associated distribution list. Dropping.` + ); + + confirm(); + return; + } + + if (!storyDistribution.allowsReplies) { + log.warn( + `${idLog}: Received storyContext message but distribution list does not allow replies. Dropping.` + ); + + confirm(); + return; + } + } + } + const withQuoteReference = { ...message.attributes, ...initialMessage,