Skip to content

Commit

Permalink
fix: sendLinkPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Dec 19, 2021
1 parent 6506d40 commit de3b0a7
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/lib/wapi/functions/send-link-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ export async function sendLinkPreview(chatId, url, text) {
}
};
if (!_Path.Reg().test(url)) {
var text =
'Use a valid HTTP protocol. Example: https://www.youtube.com/watch?v=V1bFr2SWP1';
return WAPI.scope(chatId, true, null, text);
return WAPI.scope(
chatId,
true,
null,
'Use a valid HTTP protocol. Example: https://www.youtube.com/watch?v=atPaQtpx5QQ'
);
}
var chat = await WAPI.sendExist(chatId);
if (!chat.erro) {
Expand All @@ -100,14 +103,22 @@ export async function sendLinkPreview(chatId, url, text) {
t: parseInt(new Date().getTime() / 1000),
isNewMsg: !0,
type: 'chat',
subtype: 'url'
// canonicalUrl: linkPreview.canonicalUrl,
// description: linkPreview.description,
// doNotPlayInline: linkPreview.doNotPlayInline,
// matchedText: linkPreview.matchedText,
// preview: linkPreview.preview,
// thumbnail: linkPreview.thumbnail,
// title: linkPreview.title
subtype: 'url',
canonicalUrl: linkPreview.canonicalUrl
? linkPreview.canonicalUrl
: undefined,
description: linkPreview.description
? linkPreview.description
: undefined,
doNotPlayInline: linkPreview.doNotPlayInline
? linkPreview.doNotPlayInline
: undefined,
matchedText: linkPreview.matchedText
? linkPreview.matchedText
: undefined,
preview: linkPreview.preview ? linkPreview.preview : undefined,
thumbnail: linkPreview.thumbnail ? linkPreview.thumbnail : undefined,
title: linkPreview.title ? linkPreview.title : undefined
};
var result = (
await Promise.all(window.Store.addAndSendMsgToChat(chat, message))
Expand Down

1 comment on commit de3b0a7

@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.