diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eda7c55..4a2f5b55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Fixed * Fixed chatwoot line wrap issue +* Solved receive location in chatwoot # 1.4.3 (2023-07-25 10:51) diff --git a/src/whatsapp/services/chatwoot.service.ts b/src/whatsapp/services/chatwoot.service.ts index 39873651..5a981238 100644 --- a/src/whatsapp/services/chatwoot.service.ts +++ b/src/whatsapp/services/chatwoot.service.ts @@ -13,6 +13,7 @@ import { SendAudioDto } from '../dto/sendMessage.dto'; import { SendMediaDto } from '../dto/sendMessage.dto'; import { ROOT_DIR } from '../../config/path.config'; import { ConfigService, HttpServer } from '../../config/env.config'; +import { type } from 'os'; export class ChatwootService { private messageCacheFile: string; @@ -1186,6 +1187,10 @@ export class ChatwootService { audioMessage: msg.audioMessage?.caption, contactMessage: msg.contactMessage?.vcard, contactsArrayMessage: msg.contactsArrayMessage, + locationMessage: + msg.locationMessage?.degreesLatitude + + ',' + + msg.locationMessage?.degreesLongitude, }; this.logger.verbose('type message: ' + types); @@ -1199,6 +1204,20 @@ export class ChatwootService { const result = typeKey ? types[typeKey] : undefined; + if (typeKey === 'locationMessage') { + const [latitude, longitude] = result.split(','); + + const formattedLocation = `**Location:** + **latitude:** ${latitude} + **longitude:** ${longitude} + https://www.google.com/maps/search/?api=1&query=${latitude},${longitude} + `; + + this.logger.verbose('message content: ' + formattedLocation); + + return formattedLocation; + } + if (typeKey === 'contactMessage') { const vCardData = result.split('\n'); const contactInfo = {};