forked from danielcardeenas/sulla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend-location.js
43 lines (42 loc) Β· 1.14 KB
/
send-location.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Sends location to given chat id
* @param {string} chatId Chat id
* @param {string} latitude
* @param {string} longitude
* @param {string} caption
*/
export async function sendLocation(chatId, latitude, longitude, caption) {
const chat = Store.Chat.get(chatId);
let tempMsg = Object.create(chat.msgs.filter((msg) => msg.__x_isSentByMe)[0]);
const newId = window.WAPI.getNewMessageId(chatId);
const extend = {
ack: 0,
id: newId,
local: !0,
self: 'out',
t: parseInt(new Date().getTime() / 1000),
to: chatId,
isNewMsg: !0,
type: 'location',
lat: latitude,
lng: longitude,
loc: caption,
clientUrl: undefined,
directPath: undefined,
filehash: undefined,
uploadhash: undefined,
mediaKey: undefined,
isQuotedMsgAvailable: false,
invis: false,
mediaKeyTimestamp: undefined,
mimetype: undefined,
height: undefined,
width: undefined,
ephemeralStartTimestamp: undefined,
body: undefined,
mediaData: undefined,
isQuotedMsgAvailable: false,
};
Object.assign(tempMsg, extend);
return await Promise.all(Store.addAndSendMsgToChat(chat, tempMsg));
}