Skip to content

Commit 89f40d5

Browse files
committed
fix: Solved receive location in chatwoot
1 parent 4c00697 commit 89f40d5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Fixed
44

55
* Fixed chatwoot line wrap issue
6+
* Solved receive location in chatwoot
67

78
# 1.4.3 (2023-07-25 10:51)
89

src/whatsapp/services/chatwoot.service.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { SendAudioDto } from '../dto/sendMessage.dto';
1313
import { SendMediaDto } from '../dto/sendMessage.dto';
1414
import { ROOT_DIR } from '../../config/path.config';
1515
import { ConfigService, HttpServer } from '../../config/env.config';
16+
import { type } from 'os';
1617

1718
export class ChatwootService {
1819
private messageCacheFile: string;
@@ -1186,6 +1187,10 @@ export class ChatwootService {
11861187
audioMessage: msg.audioMessage?.caption,
11871188
contactMessage: msg.contactMessage?.vcard,
11881189
contactsArrayMessage: msg.contactsArrayMessage,
1190+
locationMessage:
1191+
msg.locationMessage?.degreesLatitude +
1192+
',' +
1193+
msg.locationMessage?.degreesLongitude,
11891194
};
11901195

11911196
this.logger.verbose('type message: ' + types);
@@ -1199,6 +1204,20 @@ export class ChatwootService {
11991204

12001205
const result = typeKey ? types[typeKey] : undefined;
12011206

1207+
if (typeKey === 'locationMessage') {
1208+
const [latitude, longitude] = result.split(',');
1209+
1210+
const formattedLocation = `**Location:**
1211+
**latitude:** ${latitude}
1212+
**longitude:** ${longitude}
1213+
https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}
1214+
`;
1215+
1216+
this.logger.verbose('message content: ' + formattedLocation);
1217+
1218+
return formattedLocation;
1219+
}
1220+
12021221
if (typeKey === 'contactMessage') {
12031222
const vCardData = result.split('\n');
12041223
const contactInfo = {};

0 commit comments

Comments
 (0)