Skip to content

Commit

Permalink
[core] Document revoked webhook in swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
allburov committed Oct 13, 2023
1 parent a3ead95 commit a19cede
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/session.webjs.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
} from './exceptions';
import { QR } from './QR';
import { MeInfo } from '../structures/sessions.dto';
import { WAMessageRevokedBody } from '../structures/webhooks.dto';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const QRCode = require('qrcode');
Expand Down Expand Up @@ -457,7 +458,11 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
const beforeMessage = before
? await this.toWAMessage(before)
: null;
handler({ after: afterMessage, before: beforeMessage });
const body: WAMessageRevokedBody = {
after: afterMessage,
before: beforeMessage,
};
handler(body);
},
);
break;
Expand Down
15 changes: 15 additions & 0 deletions src/structures/webhooks.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export class PollVotePayload {
vote: PollVote;
poll: MessageDestination;
}
export class WAMessageRevokedBody {
after: WAMessage | null;
before: WAMessage | null;
}

export class WAHAWebhook {
@ApiProperty({
Expand Down Expand Up @@ -124,6 +128,16 @@ class WAHAWebhookMessageAck extends WAHAWebhook {
payload: WAMessageAckBody;
}

class WAHAWebhookMessageRevoked extends WAHAWebhook {
@ApiProperty({
description:
'The event is triggered when a user, whether it be you or any other participant, ' +
'revokes a previously sent message.',
})
event = WAHAEvents.MESSAGE_REVOKED;
payload: WAMessageRevokedBody;
}

class WAHAWebhookStateChange extends WAHAWebhook {
@ApiProperty({
description: 'It’s an internal engine’s state, not session status.',
Expand Down Expand Up @@ -178,6 +192,7 @@ const WAHA_WEBHOOKS = [
WAHAWebhookMessage,
WAHAWebhookMessageAny,
WAHAWebhookMessageAck,
WAHAWebhookMessageRevoked,
WAHAWebhookStateChange,
WAHAWebhookGroupJoin,
WAHAWebhookGroupLeave,
Expand Down

0 comments on commit a19cede

Please sign in to comment.