Skip to content

Commit

Permalink
fix: temporary sendLinkPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Apr 28, 2023
1 parent 94ccf62 commit 059df92
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/lib/wapi/functions/send-link-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export async function sendLinkPreview(chatId, url, text) {
Reg: () => {
return new RegExp(
_Path.Protocol +
_Path.Domain +
_Path.IP +
_Path.Port +
_Path.Query +
_Path.End,
_Path.Domain +
_Path.IP +
_Path.Port +
_Path.Query +
_Path.End,
'i'
);
}
},
};
if (!_Path.Reg().test(url)) {
var text =
Expand All @@ -28,13 +28,15 @@ export async function sendLinkPreview(chatId, url, text) {
if (!chat.erro) {
const newMsgId = await window.WAPI.getNewMessageId(chat.id._serialized);
const fromwWid = await Store.MaybeMeUser.getMaybeMeUser();
let inChat = await WAPI.getchatId(chat.id).catch(() => {});
let inChat = await WAPI.getchatId(chat.id).catch(() => { });
if (inChat) {
chat.lastReceivedKey._serialized = inChat._serialized;
chat.lastReceivedKey.id = inChat.id;
}
const link = await window.Store.Validators.findLink(url);
const message = {
id: newMsgId,
links: link,
ack: 0,
body: url,
from: fromwWid,
Expand All @@ -45,11 +47,14 @@ export async function sendLinkPreview(chatId, url, text) {
isNewMsg: !0,
type: 'chat',
subtype: 'url',
preview: true,
disappearingModeInitiator: 'chat',
thumbnail: "iVBORw0KGgoAAAANSUhEUgAAAGMAAABjCAIAAAAAWSnCAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA0SURBVHhe7cExAQAAAMKg9U9tCj8gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADipAXM+AAFcstx4AAAAAElFTkSuQmCC",
content: url,
canonicalUrl: url,
description: url,
matchedText: url,
title: text
title: text,
};
const result = (
await Promise.all(window.Store.addAndSendMsgToChat(chat, message))
Expand All @@ -67,4 +72,4 @@ export async function sendLinkPreview(chatId, url, text) {
} else {
return chat;
}
}
}

0 comments on commit 059df92

Please sign in to comment.