Added support for messaging with ads on chatwoot

This commit is contained in:
Davidson Gomes
2023-09-17 13:48:27 -03:00
parent 32da15fa8a
commit 707aa22a6d
4 changed files with 26 additions and 149 deletions

View File

@@ -6,7 +6,7 @@ import cors from 'cors';
import express, { json, NextFunction, Request, Response, urlencoded } from 'express';
import { join } from 'path';
import { configService, Cors, HttpServer, Rabbitmq, Webhook } from './config/env.config';
import { Auth, configService, Cors, HttpServer, Rabbitmq, Webhook } from './config/env.config';
import { onUnexpectedError } from './config/error.config';
import { Logger } from './config/logger.config';
import { ROOT_DIR } from './config/path.config';
@@ -61,6 +61,8 @@ function bootstrap() {
const tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
const localISOTime = new Date(Date.now() - tzoffset).toISOString();
const now = localISOTime;
const globalApiKey = configService.get<Auth>('AUTHENTICATION').API_KEY.KEY;
const serverUrl = configService.get<HttpServer>('SERVER').URL;
const errorData = {
event: 'error',
@@ -73,6 +75,8 @@ function bootstrap() {
},
},
date_time: now,
api_key: globalApiKey,
server_url: serverUrl,
};
logger.error(errorData);
@@ -83,11 +87,6 @@ function bootstrap() {
httpService.post('', errorData);
}
if (err['message'].includes('No sessions')) {
console.log(err['message']);
process.exit(1);
}
return res.status(err['status'] || 500).json({
status: err['status'] || 500,
error: err['error'] || 'Internal Server Error',