mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
feat: added messages.delete event
This commit is contained in:
parent
c00f132145
commit
e6b0addb6c
@ -8,6 +8,7 @@
|
|||||||
* 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
|
* Added group membership validation before sending message to groups
|
||||||
|
* Added messages.delete event
|
||||||
|
|
||||||
# 1.2.2 (2023-07-15 09:36)
|
# 1.2.2 (2023-07-15 09:36)
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ WEBHOOK_EVENTS_QRCODE_UPDATED=true
|
|||||||
WEBHOOK_EVENTS_MESSAGES_SET=true
|
WEBHOOK_EVENTS_MESSAGES_SET=true
|
||||||
WEBHOOK_EVENTS_MESSAGES_UPSERT=true
|
WEBHOOK_EVENTS_MESSAGES_UPSERT=true
|
||||||
WEBHOOK_EVENTS_MESSAGES_UPDATE=true
|
WEBHOOK_EVENTS_MESSAGES_UPDATE=true
|
||||||
|
WEBHOOK_EVENTS_MESSAGES_DELETE=true
|
||||||
WEBHOOK_EVENTS_SEND_MESSAGE=true
|
WEBHOOK_EVENTS_SEND_MESSAGE=true
|
||||||
WEBHOOK_EVENTS_CONTACTS_SET=true
|
WEBHOOK_EVENTS_CONTACTS_SET=true
|
||||||
WEBHOOK_EVENTS_CONTACTS_UPSERT=true
|
WEBHOOK_EVENTS_CONTACTS_UPSERT=true
|
||||||
|
@ -59,6 +59,7 @@ ENV WEBHOOK_EVENTS_QRCODE_UPDATED=$WEBHOOK_EVENTS_QRCODE_UPDATED
|
|||||||
ENV WEBHOOK_EVENTS_MESSAGES_SET=$WEBHOOK_EVENTS_MESSAGES_SET
|
ENV WEBHOOK_EVENTS_MESSAGES_SET=$WEBHOOK_EVENTS_MESSAGES_SET
|
||||||
ENV WEBHOOK_EVENTS_MESSAGES_UPSERT=$WEBHOOK_EVENTS_MESSAGES_UPSERT
|
ENV WEBHOOK_EVENTS_MESSAGES_UPSERT=$WEBHOOK_EVENTS_MESSAGES_UPSERT
|
||||||
ENV WEBHOOK_EVENTS_MESSAGES_UPDATE=$WEBHOOK_EVENTS_MESSAGES_UPDATE
|
ENV WEBHOOK_EVENTS_MESSAGES_UPDATE=$WEBHOOK_EVENTS_MESSAGES_UPDATE
|
||||||
|
ENV WEBHOOK_EVENTS_MESSAGES_DELETE=$WEBHOOK_EVENTS_MESSAGES_DELETE
|
||||||
ENV WEBHOOK_EVENTS_SEND_MESSAGE=$WEBHOOK_EVENTS_SEND_MESSAGE
|
ENV WEBHOOK_EVENTS_SEND_MESSAGE=$WEBHOOK_EVENTS_SEND_MESSAGE
|
||||||
ENV WEBHOOK_EVENTS_CONTACTS_SET=$WEBHOOK_EVENTS_CONTACTS_SET
|
ENV WEBHOOK_EVENTS_CONTACTS_SET=$WEBHOOK_EVENTS_CONTACTS_SET
|
||||||
ENV WEBHOOK_EVENTS_CONTACTS_UPSERT=$WEBHOOK_EVENTS_CONTACTS_UPSERT
|
ENV WEBHOOK_EVENTS_CONTACTS_UPSERT=$WEBHOOK_EVENTS_CONTACTS_UPSERT
|
||||||
|
@ -76,6 +76,7 @@ export type EventsWebhook = {
|
|||||||
MESSAGES_SET: boolean;
|
MESSAGES_SET: boolean;
|
||||||
MESSAGES_UPSERT: boolean;
|
MESSAGES_UPSERT: boolean;
|
||||||
MESSAGES_UPDATE: boolean;
|
MESSAGES_UPDATE: boolean;
|
||||||
|
MESSAGES_DELETE: boolean;
|
||||||
SEND_MESSAGE: boolean;
|
SEND_MESSAGE: boolean;
|
||||||
CONTACTS_SET: boolean;
|
CONTACTS_SET: boolean;
|
||||||
CONTACTS_UPDATE: boolean;
|
CONTACTS_UPDATE: boolean;
|
||||||
@ -238,6 +239,7 @@ export class ConfigService {
|
|||||||
MESSAGES_SET: process.env?.WEBHOOK_EVENTS_MESSAGES_SET === 'true',
|
MESSAGES_SET: process.env?.WEBHOOK_EVENTS_MESSAGES_SET === 'true',
|
||||||
MESSAGES_UPSERT: process.env?.WEBHOOK_EVENTS_MESSAGES_UPSERT === 'true',
|
MESSAGES_UPSERT: process.env?.WEBHOOK_EVENTS_MESSAGES_UPSERT === 'true',
|
||||||
MESSAGES_UPDATE: process.env?.WEBHOOK_EVENTS_MESSAGES_UPDATE === 'true',
|
MESSAGES_UPDATE: process.env?.WEBHOOK_EVENTS_MESSAGES_UPDATE === 'true',
|
||||||
|
MESSAGES_DELETE: process.env?.WEBHOOK_EVENTS_MESSAGES_DELETE === 'true',
|
||||||
SEND_MESSAGE: process.env?.WEBHOOK_EVENTS_SEND_MESSAGE === 'true',
|
SEND_MESSAGE: process.env?.WEBHOOK_EVENTS_SEND_MESSAGE === 'true',
|
||||||
CONTACTS_SET: process.env?.WEBHOOK_EVENTS_CONTACTS_SET === 'true',
|
CONTACTS_SET: process.env?.WEBHOOK_EVENTS_CONTACTS_SET === 'true',
|
||||||
CONTACTS_UPDATE: process.env?.WEBHOOK_EVENTS_CONTACTS_UPDATE === 'true',
|
CONTACTS_UPDATE: process.env?.WEBHOOK_EVENTS_CONTACTS_UPDATE === 'true',
|
||||||
|
@ -96,6 +96,7 @@ WEBHOOK:
|
|||||||
MESSAGES_SET: true
|
MESSAGES_SET: true
|
||||||
MESSAGES_UPSERT: true
|
MESSAGES_UPSERT: true
|
||||||
MESSAGES_UPDATE: true
|
MESSAGES_UPDATE: true
|
||||||
|
MESSAGES_DELETE: true
|
||||||
SEND_MESSAGE: true
|
SEND_MESSAGE: true
|
||||||
CONTACTS_SET: true
|
CONTACTS_SET: true
|
||||||
CONTACTS_UPSERT: true
|
CONTACTS_UPSERT: true
|
||||||
|
@ -39,6 +39,7 @@ export const instanceNameSchema: JSONSchema7 = {
|
|||||||
'MESSAGES_SET',
|
'MESSAGES_SET',
|
||||||
'MESSAGES_UPSERT',
|
'MESSAGES_UPSERT',
|
||||||
'MESSAGES_UPDATE',
|
'MESSAGES_UPDATE',
|
||||||
|
'MESSAGES_DELETE',
|
||||||
'SEND_MESSAGE',
|
'SEND_MESSAGE',
|
||||||
'CONTACTS_SET',
|
'CONTACTS_SET',
|
||||||
'CONTACTS_UPSERT',
|
'CONTACTS_UPSERT',
|
||||||
@ -828,6 +829,7 @@ export const webhookSchema: JSONSchema7 = {
|
|||||||
'MESSAGES_SET',
|
'MESSAGES_SET',
|
||||||
'MESSAGES_UPSERT',
|
'MESSAGES_UPSERT',
|
||||||
'MESSAGES_UPDATE',
|
'MESSAGES_UPDATE',
|
||||||
|
'MESSAGES_DELETE',
|
||||||
'SEND_MESSAGE',
|
'SEND_MESSAGE',
|
||||||
'CONTACTS_SET',
|
'CONTACTS_SET',
|
||||||
'CONTACTS_UPSERT',
|
'CONTACTS_UPSERT',
|
||||||
|
@ -1116,6 +1116,7 @@ export class WAStartupService {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'messages.update': async (args: WAMessageUpdate[], database: Database) => {
|
'messages.update': async (args: WAMessageUpdate[], database: Database) => {
|
||||||
|
console.log(args);
|
||||||
this.logger.verbose('Event received: messages.update');
|
this.logger.verbose('Event received: messages.update');
|
||||||
const status: Record<number, wa.StatusMessage> = {
|
const status: Record<number, wa.StatusMessage> = {
|
||||||
0: 'ERROR',
|
0: 'ERROR',
|
||||||
@ -1126,11 +1127,7 @@ export class WAStartupService {
|
|||||||
5: 'PLAYED',
|
5: 'PLAYED',
|
||||||
};
|
};
|
||||||
for await (const { key, update } of args) {
|
for await (const { key, update } of args) {
|
||||||
if (
|
if (key.remoteJid !== 'status@broadcast' && !key?.remoteJid?.match(/(:\d+)/)) {
|
||||||
key.remoteJid !== 'status@broadcast' &&
|
|
||||||
!key?.remoteJid?.match(/(:\d+)/) &&
|
|
||||||
key.fromMe
|
|
||||||
) {
|
|
||||||
this.logger.verbose('Message update is valid');
|
this.logger.verbose('Message update is valid');
|
||||||
|
|
||||||
let pollUpdates: any;
|
let pollUpdates: any;
|
||||||
@ -1150,6 +1147,16 @@ export class WAStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status[update.status] === 'READ' && !key.fromMe) return;
|
||||||
|
|
||||||
|
if (update.message === null && update.status === undefined) {
|
||||||
|
this.logger.verbose('Message deleted');
|
||||||
|
|
||||||
|
this.logger.verbose('Sending data to webhook in event MESSAGE_DELETE');
|
||||||
|
await this.sendDataWebhook(Events.MESSAGES_DELETE, key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const message: MessageUpdateRaw = {
|
const message: MessageUpdateRaw = {
|
||||||
...key,
|
...key,
|
||||||
status: status[update.status],
|
status: status[update.status],
|
||||||
|
@ -9,6 +9,7 @@ export enum Events {
|
|||||||
MESSAGES_SET = 'messages.set',
|
MESSAGES_SET = 'messages.set',
|
||||||
MESSAGES_UPSERT = 'messages.upsert',
|
MESSAGES_UPSERT = 'messages.upsert',
|
||||||
MESSAGES_UPDATE = 'messages.update',
|
MESSAGES_UPDATE = 'messages.update',
|
||||||
|
MESSAGES_DELETE = 'messages.delete',
|
||||||
SEND_MESSAGE = 'send.message',
|
SEND_MESSAGE = 'send.message',
|
||||||
CONTACTS_SET = 'contacts.set',
|
CONTACTS_SET = 'contacts.set',
|
||||||
CONTACTS_UPSERT = 'contacts.upsert',
|
CONTACTS_UPSERT = 'contacts.upsert',
|
||||||
|
Loading…
Reference in New Issue
Block a user