feat: Send and receive location

This commit is contained in:
Pedro Lopez
2020-02-08 00:46:08 -04:00
parent 4b1768450f
commit 7b229a39a4
8 changed files with 66 additions and 3 deletions

View File

@@ -51,7 +51,9 @@ exports.MessageTypes = {
IMAGE: 'image',
VIDEO: 'video',
DOCUMENT: 'document',
STICKER: 'sticker'
STICKER: 'sticker',
LOCATION: 'location',
REDACTED: 'redacted'
};
/**

View File

@@ -24,7 +24,7 @@ exports.ExposeStore = (moduleRaidStr) => {
exports.LoadUtils = () => {
window.WWebJS = {};
window.WWebJS.sendMessage = async (chat, content, options) => {
window.WWebJS.sendMessage = async (chat, content, options={}) => {
let attOptions = {};
if (options.attachment) {
attOptions = await window.WWebJS.processMediaData(options.attachment);
@@ -39,6 +39,17 @@ exports.LoadUtils = () => {
}
delete options.quotedMessageId;
}
let locationOptions = {};
if (options.location) {
locationOptions = {
type: 'location',
loc: options.location.description,
lat: options.location.latitude,
lng: options.location.longitude
};
delete options.location;
}
const newMsgId = new window.Store.MsgKey({
from: window.Store.Conn.me,
@@ -58,6 +69,7 @@ exports.LoadUtils = () => {
t: parseInt(new Date().getTime() / 1000),
isNewMsg: true,
type: 'chat',
...locationOptions,
...attOptions,
...quotedMsgOptions
};