mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-24 17:38:40 -06:00
Configuration to update source_id only when desired
This commit is contained in:
parent
cb942e512d
commit
72dae22ef4
@ -70,6 +70,10 @@ export type Websocket = {
|
|||||||
ENABLED: boolean;
|
ENABLED: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Chatwoot = {
|
||||||
|
USE_REPLY_ID: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type EventsWebhook = {
|
export type EventsWebhook = {
|
||||||
APPLICATION_STARTUP: boolean;
|
APPLICATION_STARTUP: boolean;
|
||||||
QRCODE_UPDATED: boolean;
|
QRCODE_UPDATED: boolean;
|
||||||
@ -134,6 +138,7 @@ export interface Env {
|
|||||||
QRCODE: QrCode;
|
QRCODE: QrCode;
|
||||||
AUTHENTICATION: Auth;
|
AUTHENTICATION: Auth;
|
||||||
PRODUCTION?: Production;
|
PRODUCTION?: Production;
|
||||||
|
CHATWOOT?: Chatwoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Key = keyof Env;
|
export type Key = keyof Env;
|
||||||
@ -224,9 +229,7 @@ export class ConfigService {
|
|||||||
COLOR: process.env?.LOG_COLOR === 'true',
|
COLOR: process.env?.LOG_COLOR === 'true',
|
||||||
BAILEYS: (process.env?.LOG_BAILEYS as LogBaileys) || 'error',
|
BAILEYS: (process.env?.LOG_BAILEYS as LogBaileys) || 'error',
|
||||||
},
|
},
|
||||||
DEL_INSTANCE: process.env?.DEL_INSTANCE === 'true'
|
DEL_INSTANCE: process.env?.DEL_INSTANCE === 'true' ? 5 : Number.parseInt(process.env.DEL_INSTANCE) || false,
|
||||||
? 5
|
|
||||||
: Number.parseInt(process.env.DEL_INSTANCE) || false,
|
|
||||||
WEBHOOK: {
|
WEBHOOK: {
|
||||||
GLOBAL: {
|
GLOBAL: {
|
||||||
URL: process.env?.WEBHOOK_GLOBAL_URL,
|
URL: process.env?.WEBHOOK_GLOBAL_URL,
|
||||||
@ -278,6 +281,9 @@ export class ConfigService {
|
|||||||
SECRET: process.env.AUTHENTICATION_JWT_SECRET,
|
SECRET: process.env.AUTHENTICATION_JWT_SECRET,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
CHATWOOT: {
|
||||||
|
USE_REPLY_ID: process.env?.USE_REPLY_ID === 'true',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,4 +145,8 @@ AUTHENTICATION:
|
|||||||
# Set the secret key to encrypt and decrypt your token and its expiration time.
|
# Set the secret key to encrypt and decrypt your token and its expiration time.
|
||||||
JWT:
|
JWT:
|
||||||
EXPIRIN_IN: 0 # seconds - 3600s === 1h | zero (0) - never expires
|
EXPIRIN_IN: 0 # seconds - 3600s === 1h | zero (0) - never expires
|
||||||
SECRET: L=0YWt]b2w[WF>#>:&E`
|
SECRET: L=0YWt]b2w[WF>#>:&E`
|
||||||
|
|
||||||
|
# Configure to chatwoot
|
||||||
|
CHATWOOT:
|
||||||
|
USE_REPLY_ID: false
|
@ -5,7 +5,7 @@ import { createReadStream, readFileSync, unlinkSync, writeFileSync } from 'fs';
|
|||||||
import mimeTypes from 'mime-types';
|
import mimeTypes from 'mime-types';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { ConfigService } from '../../config/env.config';
|
import { Chatwoot, ConfigService } from '../../config/env.config';
|
||||||
import { Logger } from '../../config/logger.config';
|
import { Logger } from '../../config/logger.config';
|
||||||
import { ROOT_DIR } from '../../config/path.config';
|
import { ROOT_DIR } from '../../config/path.config';
|
||||||
import { ChatwootDto } from '../dto/chatwoot.dto';
|
import { ChatwootDto } from '../dto/chatwoot.dto';
|
||||||
@ -966,25 +966,29 @@ export class ChatwootService {
|
|||||||
messageId: number,
|
messageId: number,
|
||||||
sourceId: string | null,
|
sourceId: string | null,
|
||||||
) {
|
) {
|
||||||
this.logger.verbose('update message to chatwoot instance: ' + instance.instanceName);
|
// const useReplyId = this.configService.get<DelInstance>('DEL_INSTANCE');
|
||||||
const client = await this.clientCw(instance);
|
const useReplyId = this.configService.get<Chatwoot>('CHATWOOT')?.USE_REPLY_ID;
|
||||||
|
if (useReplyId === true) {
|
||||||
|
this.logger.verbose('update message to chatwoot instance: ' + instance.instanceName);
|
||||||
|
const client = await this.clientCw(instance);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
this.logger.warn('client not found');
|
this.logger.warn('client not found');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
this.logger.verbose('check if sourceId to update');
|
this.logger.verbose('check if sourceId to update');
|
||||||
if (sourceId) {
|
if (sourceId) {
|
||||||
this.logger.verbose('update message to chatwoot');
|
this.logger.verbose('update message to chatwoot');
|
||||||
const dataUpdated = {
|
const dataUpdated = {
|
||||||
source_id: sourceId,
|
source_id: sourceId,
|
||||||
};
|
};
|
||||||
await client.messages.update({
|
await client.messages.update({
|
||||||
accountId,
|
accountId,
|
||||||
conversationId,
|
conversationId,
|
||||||
data: dataUpdated,
|
data: dataUpdated,
|
||||||
messageId,
|
messageId,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user