refactor: evolution bot

This commit is contained in:
Davidson Gomes
2024-08-25 10:22:22 -03:00
parent 8b7ff37261
commit d776770d09
22 changed files with 509 additions and 189 deletions

View File

@@ -1585,21 +1585,21 @@ export class ChatwootService {
private getMessageContent(types: any) {
const typeKey = Object.keys(types).find((key) => types[key] !== undefined);
let result = typeKey ? types[typeKey] : undefined;
// Remove externalAdReplyBody| in Chatwoot (Already Have)
if (result && typeof result === 'string' && result.includes('externalAdReplyBody|')) {
result = result.split('externalAdReplyBody|').filter(Boolean).join('');
}
if (typeKey === 'locationMessage' || typeKey === 'liveLocationMessage') {
const latitude = result.degreesLatitude;
const longitude = result.degreesLongitude;
const locationName = result?.name;
const locationAddress = result?.address;
const formattedLocation =
`*${i18next.t('cw.locationMessage.location')}:*\n\n` +
`_${i18next.t('cw.locationMessage.latitude')}:_ ${latitude} \n` +
@@ -1608,7 +1608,7 @@ export class ChatwootService {
(locationAddress ? `_${i18next.t('cw.locationMessage.locationAddress')}:_ ${locationAddress} \n` : '') +
`_${i18next.t('cw.locationMessage.locationUrl')}:_ ` +
`https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`;
return formattedLocation;
}