Skip to content

Commit

Permalink
🐍 bug fix: webhook events
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Jan 6, 2024
1 parent 5e9f180 commit f30cb9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/whatsapp/controllers/instance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class InstanceController {
throw new InternalServerErrorException(error?.message);
}
}

public async reloadConnection({ instanceName }: InstanceDto) {
try {
const instance = this.waMonitor.waInstances[instanceName];
Expand Down
8 changes: 6 additions & 2 deletions src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ export class WAStartupService {
const eventDesc = WebhookEventsEnum[event];

try {
if (this.webhook?.enabled && isURL(this.webhook?.url)) {
if (
this.webhook?.enabled &&
isURL(this.webhook?.url, { protocols: ['http', 'https'] })
) {
if (this.webhook?.events && this.webhook?.events[event]) {
await axios.post(
this.webhook.url,
Expand All @@ -263,7 +266,8 @@ export class WAStartupService {
},
{ headers: { 'Resource-Owner': this.instance.ownerJid } },
);
} else {
}
if (!this.webhook?.events) {
await axios.post(
this.webhook.url,
{
Expand Down

0 comments on commit f30cb9d

Please sign in to comment.