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
*/
abstract getMessage(): any;
abstract getMessage(): StdIncomingMessage;
/**
* Return the text message received

View File

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