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

@ -7,6 +7,7 @@
* Fixed in the postman collection the webhookByEvent parameter by webhook_by_events * Fixed in the postman collection the webhookByEvent parameter by webhook_by_events
* Now it's getting the API URL directly in the request, no longer need the variable in the env file * Now it's getting the API URL directly in the request, no longer need the variable in the env file
* Removed link preview endpoint, now it's done automatically from sending conventional text * Removed link preview endpoint, now it's done automatically from sending conventional text
* Added group membership validation before sending message to groups
# 1.2.2 (2023-07-15 09:36) # 1.2.2 (2023-07-15 09:36)

View File

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

View File

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