mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
Merge pull request #378 from moraisamilton/develop
Implemented a function to synchronize message deletions on WhatsApp, automatically reflecting in Chatwoot.
This commit is contained in:
commit
6b2d4e2585
12
package.json
12
package.json
@ -46,11 +46,11 @@
|
|||||||
"@figuro/chatwoot-sdk": "^1.1.16",
|
"@figuro/chatwoot-sdk": "^1.1.16",
|
||||||
"@hapi/boom": "^10.0.1",
|
"@hapi/boom": "^10.0.1",
|
||||||
"@sentry/node": "^7.59.2",
|
"@sentry/node": "^7.59.2",
|
||||||
"@whiskeysockets/baileys": "6.5.0",
|
"@whiskeysockets/baileys": "6.6.0",
|
||||||
"amqplib": "^0.10.3",
|
"amqplib": "^0.10.3",
|
||||||
"aws-sdk": "^2.1499.0",
|
"aws-sdk": "^2.1499.0",
|
||||||
"axios": "^1.3.5",
|
"axios": "^1.6.5",
|
||||||
"class-validator": "^0.13.2",
|
"class-validator": "^0.14.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
@ -67,22 +67,24 @@
|
|||||||
"join": "^3.0.0",
|
"join": "^3.0.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jsonschema": "^1.4.1",
|
"jsonschema": "^1.4.1",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"libphonenumber-js": "^1.10.39",
|
"libphonenumber-js": "^1.10.39",
|
||||||
"link-preview-js": "^3.0.4",
|
"link-preview-js": "^3.0.4",
|
||||||
"mongoose": "^6.10.5",
|
"mongoose": "^6.10.5",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
"node-mime-types": "^1.1.0",
|
"node-mime-types": "^1.1.0",
|
||||||
"node-windows": "^1.0.0-beta.8",
|
"node-windows": "^1.0.0-beta.8",
|
||||||
|
"parse-bmfont-xml": "^1.1.4",
|
||||||
"pino": "^8.11.0",
|
"pino": "^8.11.0",
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
"qrcode-terminal": "^0.12.0",
|
"qrcode-terminal": "^0.12.0",
|
||||||
"redis": "^4.6.5",
|
"redis": "^4.6.5",
|
||||||
"sharp": "^0.30.7",
|
"sharp": "^0.32.2",
|
||||||
"socket.io": "^4.7.1",
|
"socket.io": "^4.7.1",
|
||||||
"socks-proxy-agent": "^8.0.1",
|
"socks-proxy-agent": "^8.0.1",
|
||||||
"swagger-ui-express": "^5.0.0",
|
"swagger-ui-express": "^5.0.0",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
|
"xml2js": "^0.6.2",
|
||||||
"yamljs": "^0.3.0"
|
"yamljs": "^0.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -147,6 +147,7 @@ export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
|
|||||||
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
|
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
|
||||||
export type QrCode = { LIMIT: number; COLOR: string };
|
export type QrCode = { LIMIT: number; COLOR: string };
|
||||||
export type Typebot = { API_VERSION: string; KEEP_OPEN: boolean };
|
export type Typebot = { API_VERSION: string; KEEP_OPEN: boolean };
|
||||||
|
export type ChatWoot = { MESSAGE_DELETE: boolean };
|
||||||
export type CacheConf = { REDIS: CacheConfRedis; LOCAL: CacheConfLocal };
|
export type CacheConf = { REDIS: CacheConfRedis; LOCAL: CacheConfLocal };
|
||||||
export type Production = boolean;
|
export type Production = boolean;
|
||||||
|
|
||||||
@ -167,6 +168,7 @@ export interface Env {
|
|||||||
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
||||||
QRCODE: QrCode;
|
QRCODE: QrCode;
|
||||||
TYPEBOT: Typebot;
|
TYPEBOT: Typebot;
|
||||||
|
CHATWOOT: ChatWoot;
|
||||||
CACHE: CacheConf;
|
CACHE: CacheConf;
|
||||||
AUTHENTICATION: Auth;
|
AUTHENTICATION: Auth;
|
||||||
PRODUCTION?: Production;
|
PRODUCTION?: Production;
|
||||||
@ -330,6 +332,9 @@ export class ConfigService {
|
|||||||
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'old',
|
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'old',
|
||||||
KEEP_OPEN: process.env.TYPEBOT_KEEP_OPEN === 'true',
|
KEEP_OPEN: process.env.TYPEBOT_KEEP_OPEN === 'true',
|
||||||
},
|
},
|
||||||
|
CHATWOOT: {
|
||||||
|
MESSAGE_DELETE: process.env.CHATWOOT_MESSAGE_DELETE === 'false',
|
||||||
|
},
|
||||||
CACHE: {
|
CACHE: {
|
||||||
REDIS: {
|
REDIS: {
|
||||||
ENABLED: process.env?.CACHE_REDIS_ENABLED === 'true',
|
ENABLED: process.env?.CACHE_REDIS_ENABLED === 'true',
|
||||||
|
@ -153,6 +153,10 @@ TYPEBOT:
|
|||||||
API_VERSION: 'old' # old | latest
|
API_VERSION: 'old' # old | latest
|
||||||
KEEP_OPEN: false
|
KEEP_OPEN: false
|
||||||
|
|
||||||
|
# If you leave this option as false, when deleting the message for everyone on WhatsApp, it will not be deleted on Chatwoot.
|
||||||
|
CHATWOOT:
|
||||||
|
MESSAGE_DELETE: true # false | true
|
||||||
|
|
||||||
# Cache to optimize application performance
|
# Cache to optimize application performance
|
||||||
CACHE:
|
CACHE:
|
||||||
REDIS:
|
REDIS:
|
||||||
|
@ -26,7 +26,7 @@ export class MessageRaw {
|
|||||||
messageType?: string;
|
messageType?: string;
|
||||||
messageTimestamp?: number | Long.Long;
|
messageTimestamp?: number | Long.Long;
|
||||||
owner: string;
|
owner: string;
|
||||||
source?: 'android' | 'web' | 'ios';
|
source?: 'android' | 'web' | 'ios' | 'unknown' | 'desktop';
|
||||||
source_id?: string;
|
source_id?: string;
|
||||||
source_reply_id?: string;
|
source_reply_id?: string;
|
||||||
chatwoot?: ChatwootMessage;
|
chatwoot?: ChatwootMessage;
|
||||||
@ -45,7 +45,7 @@ const messageSchema = new Schema<MessageRaw>({
|
|||||||
participant: { type: String },
|
participant: { type: String },
|
||||||
messageType: { type: String },
|
messageType: { type: String },
|
||||||
message: { type: Object },
|
message: { type: Object },
|
||||||
source: { type: String, minlength: 3, enum: ['android', 'web', 'ios'] },
|
source: { type: String, minlength: 3, enum: ['android', 'web', 'ios','unknown','desktop' ] },
|
||||||
messageTimestamp: { type: Number, required: true },
|
messageTimestamp: { type: Number, required: true },
|
||||||
owner: { type: String, required: true, minlength: 1 },
|
owner: { type: String, required: true, minlength: 1 },
|
||||||
chatwoot: {
|
chatwoot: {
|
||||||
|
@ -7,7 +7,7 @@ import Jimp from 'jimp';
|
|||||||
import mimeTypes from 'mime-types';
|
import mimeTypes from 'mime-types';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { ConfigService, HttpServer } from '../../config/env.config';
|
import { ConfigService, HttpServer, ChatWoot} from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { ICache } from '../abstract/abstract.cache';
|
import { ICache } from '../abstract/abstract.cache';
|
||||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||||
@ -1894,6 +1894,9 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event === Events.MESSAGES_DELETE) {
|
if (event === Events.MESSAGES_DELETE) {
|
||||||
|
|
||||||
|
const chatwootDelete = this.configService.get<ChatWoot>('CHATWOOT').MESSAGE_DELETE
|
||||||
|
if (chatwootDelete === true) {
|
||||||
this.logger.verbose('deleting message from instance: ' + instance.instanceName);
|
this.logger.verbose('deleting message from instance: ' + instance.instanceName);
|
||||||
|
|
||||||
if (!body?.key?.id) {
|
if (!body?.key?.id) {
|
||||||
@ -1921,6 +1924,7 @@ export class ChatwootService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event === 'messages.read') {
|
if (event === 'messages.read') {
|
||||||
this.logger.verbose('read message from instance: ' + instance.instanceName);
|
this.logger.verbose('read message from instance: ' + instance.instanceName);
|
||||||
|
Loading…
Reference in New Issue
Block a user