Skip to content

Commit 6104249

Browse files
matheusmartinsInspermatheusmartinsInsper
authored andcommitted
feat: add message location support meta
1 parent a54b5a5 commit 6104249

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/api/integrations/channel/meta/whatsapp.business.service.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ export class BusinessStartupService extends ChannelStartupService {
200200
return content;
201201
}
202202

203+
private messageLocationJson(received: any) {
204+
const message = received.messages[0];
205+
let content: any = {
206+
locationMessage: {
207+
degreesLatitude: message.location.latitude,
208+
degreesLongitude: message.location.longitude,
209+
name: message.location?.name,
210+
address: message.location?.address,
211+
},
212+
};
213+
message.context ? (content = { ...content, contextInfo: { stanzaId: message.context.id } }) : content;
214+
return content;
215+
}
216+
203217
private messageContactsJson(received: any) {
204218
const message = received.messages[0];
205219
let content: any = {};
@@ -277,6 +291,9 @@ export class BusinessStartupService extends ChannelStartupService {
277291
case 'template':
278292
messageType = 'conversation';
279293
break;
294+
case 'location':
295+
messageType = 'locationMessage';
296+
break;
280297
default:
281298
messageType = 'conversation';
282299
break;
@@ -432,6 +449,17 @@ export class BusinessStartupService extends ChannelStartupService {
432449
source: 'unknown',
433450
instanceId: this.instanceId,
434451
};
452+
} else if (received?.messages[0].location) {
453+
messageRaw = {
454+
key,
455+
pushName,
456+
message: this.messageLocationJson(received),
457+
contextInfo: this.messageLocationJson(received)?.contextInfo,
458+
messageType: this.renderMessageType(received.messages[0].type),
459+
messageTimestamp: parseInt(received.messages[0].timestamp) as number,
460+
source: 'unknown',
461+
instanceId: this.instanceId,
462+
};
435463
} else {
436464
messageRaw = {
437465
key,

0 commit comments

Comments
 (0)