fix: Added group membership validation before sending message to groups

This commit is contained in:
Davidson Gomes
2023-07-16 18:01:43 -03:00
parent b9eb8d45b2
commit c00f132145
3 changed files with 7 additions and 2 deletions

View File

@@ -5,7 +5,6 @@ import {
SendAudioDto,
SendButtonDto,
SendContactDto,
SendLinkPreviewDto,
SendListDto,
SendLocationDto,
SendMediaDto,

View File

@@ -1434,6 +1434,12 @@ export class WAStartupService {
let mentions: string[];
if (isJidGroup(sender)) {
try {
const groupMetadata = await this.client.groupMetadata(sender);
if (!groupMetadata) {
throw new NotFoundException('Group not found');
}
if (options?.mentions) {
this.logger.verbose('Mentions defined');
@@ -1448,7 +1454,6 @@ export class WAStartupService {
this.logger.verbose('Mentions everyone');
this.logger.verbose('Getting group metadata');
const groupMetadata = await this.client.groupMetadata(sender);
mentions = groupMetadata.participants.map((participant) => participant.id);
this.logger.verbose('Getting group metadata for mentions');
} else {