Merge pull request #468 from Hexastack/fix/enforce-getMessage-typing

fix: type getMessage()
This commit is contained in:
Med Marrouchi 2024-12-20 07:46:52 +01:00 committed by GitHub
commit 7b9a2e1977
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -227,7 +227,7 @@ export default abstract class EventWrapper<
* *
* @returns The received message * @returns The received message
*/ */
abstract getMessage(): any; abstract getMessage(): StdIncomingMessage;
/** /**
* Return the text message received * Return the text message received

View File

@ -136,11 +136,13 @@ export class ConversationService extends BaseService<
} }
// Handle attachments (location, ...) // Handle attachments (location, ...)
if (msgType === 'location') { const msg = event.getMessage();
const coordinates = event.getMessage().coordinates; if (msgType === 'location' && 'coordinates' in msg) {
convo.context.user_location = { lat: 0, lon: 0 }; const coordinates = msg.coordinates;
convo.context.user_location.lat = parseFloat(coordinates.lat); convo.context.user_location = {
convo.context.user_location.lon = parseFloat(coordinates.lon); lat: parseFloat(coordinates.lat.toString()),
lon: parseFloat(coordinates.lon.toString()),
};
} else if (msgType === 'attachments') { } else if (msgType === 'attachments') {
// @TODO : deprecated in favor of geolocation msgType // @TODO : deprecated in favor of geolocation msgType
const attachments = event.getAttachments(); const attachments = event.getAttachments();