Discard invalid story replies
This commit is contained in:
parent
42a1394039
commit
cd1a1a00a2
2 changed files with 54 additions and 0 deletions
|
@ -109,6 +109,7 @@ export function sendStateReducer(
|
||||||
return newStatus === oldStatus
|
return newStatus === oldStatus
|
||||||
? state
|
? state
|
||||||
: {
|
: {
|
||||||
|
...state,
|
||||||
status: newStatus,
|
status: newStatus,
|
||||||
updatedAt: action.updatedAt,
|
updatedAt: action.updatedAt,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2522,6 +2522,59 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
return;
|
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 = {
|
const withQuoteReference = {
|
||||||
...message.attributes,
|
...message.attributes,
|
||||||
...initialMessage,
|
...initialMessage,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue