Pequenas adições de console.log

pull/21/head
adriano 2023-04-08 18:31:37 -03:00
parent 6d9bef094f
commit b43e76938f
4 changed files with 26 additions and 9 deletions

View File

@ -70,8 +70,8 @@ export const initIO = (httpServer: Server): SocketIO => {
}); });
socket.on("media_uploaded", async (data: any) => { socket.on("media_uploaded", async (data: any) => {
handleMessage(data.msg, data); handleMessage(data.msg, data);
}); });

View File

@ -12,7 +12,8 @@ import { loadSchedulesCache } from "./helpers/SchedulingNotifyCache";
import { delRestoreControllFile } from "./helpers/RestoreControll"; import { delRestoreControllFile } from "./helpers/RestoreControll";
import "./helpers/SchedulingNotifySendMessage" import "./helpers/SchedulingNotifySendMessage"
import axios from "axios";
import os from 'os';
const server = app.listen(process.env.PORT, () => { const server = app.listen(process.env.PORT, () => {
logger.info(`Server started on port: ${process.env.PORT}`); logger.info(`Server started on port: ${process.env.PORT}`);
@ -30,9 +31,11 @@ initIO(server);
// StartAllWhatsAppsSessions(); // StartAllWhatsAppsSessions();
gracefulShutdown(server); gracefulShutdown(server);
(async () => { (async () => {
console.log('os.tmpdir(): ', os.tmpdir())
let whatsapps: any = await Whatsapp.findAll({ attributes: ['id', 'url'] }) let whatsapps: any = await Whatsapp.findAll({ attributes: ['id', 'url'] })
// console.log('whatsapps: ', whatsapps) // console.log('whatsapps: ', whatsapps)
@ -43,12 +46,20 @@ gracefulShutdown(server);
try { try {
const response = await endPointQuery(`${whatsapps[i].dataValues.url}/api/status`, {}) console.log(`API URL: ${whatsapps[i].dataValues.url}/api/connection/status`)
const response = await axios.get(`${whatsapps[i].dataValues.url}/api/connection/status`, {});
console.log(`-------> Response: ${response.data.data}`)
if (!response) { if (!response) {
throw new Error('Response null'); throw new Error('Response null');
} }
if (response.data.data && response.data.data == 'CONNECTED') {
await whatsapps[i].update({ status: 'CONNECTED' });
}
} catch (error: any) { } catch (error: any) {
await whatsapps[i].update({ status: 'OPENING' }); await whatsapps[i].update({ status: 'OPENING' });

View File

@ -19,7 +19,7 @@ interface Request {
const CreateMessageService = async ({ messageData }: Request): Promise<Message> => { const CreateMessageService = async ({ messageData }: Request): Promise<Message> => {
// console.log('UPSERT MESSAGE messageData: ', messageData) console.log('UPSERT MESSAGE messageData: ', messageData)
await Message.upsert(messageData); await Message.upsert(messageData);

View File

@ -167,7 +167,7 @@ const verifyMediaMessage = async (
}; };
await ticket.update({ lastMessage: msg.body || media.filename }); await ticket.update({ lastMessage: msg.body || media.filename });
const newMessage = await CreateMessageService({ messageData }); const newMessage = await CreateMessageService({ messageData });
return newMessage; return newMessage;
}; };
@ -198,7 +198,7 @@ const verifyMessage = async (
}; };
await ticket.update({ lastMessage: msg.body }); await ticket.update({ lastMessage: msg.body });
await CreateMessageService({ messageData }); await CreateMessageService({ messageData });
}; };
@ -418,6 +418,8 @@ const handleMessage = async (
msg: any, msg: any,
wbot: any wbot: any
): Promise<void> => { ): Promise<void> => {
console.log('kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk')
if (!msg.fromMe) { if (!msg.fromMe) {
@ -557,7 +559,11 @@ const handleMessage = async (
} }
// //
if(msg.fromMe){
console.log('====> msg.fromMe: ',msg.fromMe)
}
if (msg.hasMedia) { if (msg.hasMedia) {
await verifyMediaMessage(msg, ticket, contact, wbot.media, wbot.quotedMsg); await verifyMediaMessage(msg, ticket, contact, wbot.media, wbot.quotedMsg);