Skip to content

Commit

Permalink
fix: sendLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Apr 11, 2022
1 parent d00634a commit 921e2f0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/wapi/functions/send-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ export async function sendLocation(
location = null
) {
const chat = await WAPI.sendExist(chatId);

if (chat && chat.status != 404 && chat.id) {
if (isNaN(Number(latitude)) || isNaN(Number(longitude))) {
return WAPI.scope(
chatId,
true,
null,
'latitude and longitude must be numbers'
);
}
if (!chat.erro) {
const newMsgId = await window.WAPI.getNewMessageId(chat.id._serialized);
const inChat = await WAPI.getchatId(chat.id).catch(() => {});
const fromwWid = await Store.MaybeMeUser.getMaybeMeUser();
Expand All @@ -80,8 +87,8 @@ export async function sendLocation(
from: fromwWid,
isNewMsg: !0,
type: 'location',
lat: latitude,
lng: longitude,
lat: Number(latitude),
lng: Number(longitude),
loc: location
};

Expand Down

1 comment on commit 921e2f0

@jonalan7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.