Skip to content

Commit

Permalink
feat: Added onUpdateLabel event in webhook (close #1172)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed May 31, 2023
1 parent 8dd0801 commit 407f53a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Expand Up @@ -20,6 +20,7 @@ export default {
onReactionMessage: true,
onPollResponse: true,
onRevokedMessage: true,
onLabelUpdated: true,
},
chatwoot: {
sendQrCode: true,
Expand Down
10 changes: 10 additions & 0 deletions src/util/createSessionUtil.ts
Expand Up @@ -126,6 +126,9 @@ export default class CreateSessionUtil {
if (req.serverOptions.webhook.onPollResponse) {
await this.onPollResponse(client, req);
}
if (req.serverOptions.webhook.onLabelUpdated) {
await this.onLabelUpdated(client, req);
}
} catch (e) {
req.logger.error(e);
}
Expand Down Expand Up @@ -270,6 +273,13 @@ export default class CreateSessionUtil {
callWebHook(client, req, 'onpollresponse', response);
});
}
async onLabelUpdated(client: WhatsAppServer, req: Request) {
await client.isConnected();
await client.onUpdateLabel(async (response: any) => {
req.io.emit('onupdatelabel', response);
callWebHook(client, req, 'onupdatelabel', response);
});
}

encodeFunction(data: any, webhook: any) {
data.webhook = webhook;
Expand Down

0 comments on commit 407f53a

Please sign in to comment.