diff --git a/src/Client.js b/src/Client.js index 53d9a5f..5a2614a 100644 --- a/src/Client.js +++ b/src/Client.js @@ -381,6 +381,7 @@ class Client extends EventEmitter { */ async sendMessage(chatId, content, options = {}) { let internalOptions = { + linkPreview: options.linkPreview === false ? undefined : true, caption: options.caption, quotedMessageId: options.quotedMessageId, mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [] diff --git a/src/util/Injected.js b/src/util/Injected.js index 0367db1..6ff31f3 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -24,7 +24,7 @@ exports.ExposeStore = (moduleRaidStr) => { window.Store.Cmd = window.mR.findModule('Cmd')[0].default; window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0]; window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default; - + window.Store.Validators = window.mR.findModule('findLinks')[0]; }; exports.LoadUtils = () => { @@ -76,6 +76,17 @@ exports.LoadUtils = () => { delete options.location; } + if (options.linkPreview) { + delete options.linkPreview; + const link = window.Store.Validators.findLink(content); + if (link) { + const preview = await window.Store.Wap.queryLinkPreview(link.url); + if (!preview.status) { + options = { ...options, ...preview}; + } + } + } + const newMsgId = new window.Store.MsgKey({ from: window.Store.Conn.me, to: chat.id,