feat(chatwoot): import history messages to chatwoot on whatsapp connection

Messages are imported direct to chatwoot database. Media and group messages are ignored.

New env.yml variables:
CHATWOOT_IMPORT_DATABASE_CONNECTION_URI: URI to connect direct on chatwoot database.
CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE: Indicates to use a text placeholder on media messages.

New instance setting:
sync_full_history: Indicates to request a full history sync to baileys.

New chatwoot options:
import_contacts: Indicates to import contacts.
import_messages: Indicates to import messages.
days_limit_import_messages: Number of days to limit history messages to import.
This commit is contained in:
jaison-x
2024-01-31 11:20:29 -03:00
parent b09546577a
commit 8a5ebe83a3
23 changed files with 992 additions and 111 deletions

View File

@@ -149,7 +149,18 @@ export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
export type QrCode = { LIMIT: number; COLOR: string };
export type Typebot = { API_VERSION: string; KEEP_OPEN: boolean };
export type ChatWoot = { MESSAGE_DELETE: boolean };
export type Chatwoot = {
MESSAGE_DELETE: boolean;
IMPORT: {
DATABASE: {
CONNECTION: {
URI: string;
};
};
PLACEHOLDER_MEDIA_MESSAGE: boolean;
};
};
export type CacheConf = { REDIS: CacheConfRedis; LOCAL: CacheConfLocal };
export type Production = boolean;
@@ -171,7 +182,7 @@ export interface Env {
CONFIG_SESSION_PHONE: ConfigSessionPhone;
QRCODE: QrCode;
TYPEBOT: Typebot;
CHATWOOT: ChatWoot;
CHATWOOT: Chatwoot;
CACHE: CacheConf;
AUTHENTICATION: Auth;
PRODUCTION?: Production;
@@ -338,6 +349,14 @@ export class ConfigService {
},
CHATWOOT: {
MESSAGE_DELETE: process.env.CHATWOOT_MESSAGE_DELETE === 'false',
IMPORT: {
DATABASE: {
CONNECTION: {
URI: process.env.CHATWOOT_DATABASE_CONNECTION_URI || '',
},
},
PLACEHOLDER_MEDIA_MESSAGE: process.env?.CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE === 'true',
},
},
CACHE: {
REDIS: {