Check stories capability when sending replies

This commit is contained in:
Fedor Indutny 2022-10-25 17:03:51 -07:00 committed by GitHub
parent 3beccbfd31
commit d6afae64d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -3661,13 +3661,16 @@ export class ConversationModel extends window.Backbone
getRecipients({
includePendingMembers,
extraConversationsForSend,
isStoryReply = false,
}: {
includePendingMembers?: boolean;
extraConversationsForSend?: Array<string>;
isStoryReply?: boolean;
} = {}): Array<string> {
return getRecipients(this.attributes, {
includePendingMembers,
extraConversationsForSend,
isStoryReply,
});
}
@ -3939,8 +3942,11 @@ export class ConversationModel extends window.Backbone
const expireTimer = this.get('expireTimer');
const recipientMaybeConversations = map(this.getRecipients(), identifier =>
window.ConversationController.get(identifier)
const recipientMaybeConversations = map(
this.getRecipients({
isStoryReply: storyId !== undefined,
}),
identifier => window.ConversationController.get(identifier)
);
const recipientConversations = filter(
recipientMaybeConversations,

View file

@ -15,9 +15,11 @@ export function getRecipients(
{
includePendingMembers,
extraConversationsForSend,
isStoryReply = false,
}: {
includePendingMembers?: boolean;
extraConversationsForSend?: Array<string>;
isStoryReply?: boolean;
} = {}
): Array<string> {
if (isDirectConversation(conversationAttributes)) {
@ -25,10 +27,14 @@ export function getRecipients(
return [getSendTarget(conversationAttributes)!];
}
const members = getConversationMembers(conversationAttributes, {
let members = getConversationMembers(conversationAttributes, {
includePendingMembers,
});
if (isStoryReply) {
members = members.filter(({ capabilities }) => capabilities?.stories);
}
// There are cases where we need to send to someone we just removed from the group, to
// let them know that we removed them. In that case, we need to send to more than
// are currently in the group.