parent
7953c7dbbd
commit
46caaba6bd
|
@ -12,6 +12,7 @@ import {
|
|||
} from './whatsapp.constant';
|
||||
import axios from 'axios';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { apm } from 'src/core/apm';
|
||||
|
||||
export class WhatsappService {
|
||||
async sendMessage(data) {
|
||||
|
@ -25,8 +26,14 @@ export class WhatsappService {
|
|||
data: data,
|
||||
};
|
||||
|
||||
const response = await axios(config);
|
||||
return response.data;
|
||||
try {
|
||||
const response = await axios(config);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
apm?.captureError(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async queueRegister(data: WhatsappQueue) {
|
||||
|
@ -91,8 +98,11 @@ export class WhatsappService {
|
|||
},
|
||||
};
|
||||
|
||||
await this.sendMessage(payload);
|
||||
Logger.log(`Notification register for ${data.code} send to ${data.phone}`);
|
||||
const response = await this.sendMessage(payload);
|
||||
if (response)
|
||||
Logger.log(
|
||||
`Notification register for ${data.code} send to ${data.phone}`,
|
||||
);
|
||||
}
|
||||
|
||||
async queueProcess(data: WhatsappQueue) {
|
||||
|
@ -152,7 +162,8 @@ export class WhatsappService {
|
|||
},
|
||||
};
|
||||
|
||||
await this.sendMessage(payload);
|
||||
Logger.log(`Notification process for ${data.code} send to ${data.phone}`);
|
||||
const response = await this.sendMessage(payload);
|
||||
if (response)
|
||||
Logger.log(`Notification process for ${data.code} send to ${data.phone}`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue