Rename webPage to linkPreview.

This commit is contained in:
levlam 2024-07-03 15:15:06 +03:00
parent f39b10d8ef
commit 51d0e70b9e
9 changed files with 56 additions and 53 deletions

View File

@ -770,12 +770,12 @@ inputChatPhotoSticker sticker:chatPhotoSticker = InputChatPhoto;
//@can_send_voice_notes True, if the user can send voice notes
//@can_send_polls True, if the user can send polls
//@can_send_other_messages True, if the user can send animations, games, stickers, and dice and use inline bots
//@can_add_web_page_previews True, if the user may add a web page preview to their messages
//@can_add_link_previews True, if the user may add a link preview to their messages
//@can_change_info True, if the user can change the chat title, photo, and other settings
//@can_invite_users True, if the user can invite new users to the chat
//@can_pin_messages True, if the user can pin messages
//@can_create_topics True, if the user can create topics
chatPermissions can_send_basic_messages:Bool can_send_audios:Bool can_send_documents:Bool can_send_photos:Bool can_send_videos:Bool can_send_video_notes:Bool can_send_voice_notes:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool can_create_topics:Bool = ChatPermissions;
chatPermissions can_send_basic_messages:Bool can_send_audios:Bool can_send_documents:Bool can_send_photos:Bool can_send_videos:Bool can_send_video_notes:Bool can_send_voice_notes:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_link_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool can_create_topics:Bool = ChatPermissions;
//@description Describes rights of the administrator
//@can_manage_chat True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report supergroup spam messages and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only
@ -1588,7 +1588,7 @@ factCheck text:formattedText country_code:string = FactCheck;
//@can_get_message_thread True, if information about the message thread is available through getMessageThread and getMessageThreadHistory
//@can_get_read_date True, if read date of the message can be received through getMessageReadDate
//@can_get_viewers True, if chat members already viewed the message can be received through getMessageViewers
//@can_get_media_timestamp_links True, if media timestamp links can be generated for media timestamp entities in the message text, caption or web page description through getMessageLink
//@can_get_media_timestamp_links True, if media timestamp links can be generated for media timestamp entities in the message text, caption or link preview description through getMessageLink
//@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions
//@has_timestamped_media True, if media timestamp entities refers to a media in this message as opposed to a media in the replied message
//@is_channel_post True, if the message is a channel post. All messages to channels are channel posts, all other messages are not channel posts
@ -2292,7 +2292,7 @@ sharedUser user_id:int53 first_name:string last_name:string username:string phot
sharedChat chat_id:int53 title:string username:string photo:photo = SharedChat;
//@class RichText @description Describes a text object inside an instant-view web page
//@class RichText @description Describes a formatted text object
//@description A plain text @text Text
richTextPlain text:string = RichText;
@ -2336,20 +2336,20 @@ richTextPhoneNumber text:RichText phone_number:string = RichText;
//@height Height of a bounding box in which the image must be shown; 0 if unknown
richTextIcon document:document width:int32 height:int32 = RichText;
//@description A reference to a richTexts object on the same web page @text The text @anchor_name The name of a richTextAnchor object, which is the first element of the target richTexts object @url An HTTP URL, opening the reference
//@description A reference to a richTexts object on the same page @text The text @anchor_name The name of a richTextAnchor object, which is the first element of the target richTexts object @url An HTTP URL, opening the reference
richTextReference text:RichText anchor_name:string url:string = RichText;
//@description An anchor @name Anchor name
richTextAnchor name:string = RichText;
//@description A link to an anchor on the same web page @text The link text @anchor_name The anchor name. If the name is empty, the link must bring back to top @url An HTTP URL, opening the anchor
//@description A link to an anchor on the same page @text The link text @anchor_name The anchor name. If the name is empty, the link must bring back to top @url An HTTP URL, opening the anchor
richTextAnchorLink text:RichText anchor_name:string url:string = RichText;
//@description A concatenation of rich texts @texts Texts
richTexts texts:vector<RichText> = RichText;
//@description Contains a caption of an instant view web page block, consisting of a text and a trailing credit @text Content of the caption @credit Block credit (like HTML tag <cite>)
//@description Contains a caption of another block @text Content of the caption @credit Block credit (like HTML tag <cite>)
pageBlockCaption text:RichText credit:RichText = PageBlockCaption;
//@description Describes an item of a list page block @label Item label @page_blocks Item blocks
@ -2396,7 +2396,7 @@ pageBlockTableCell text:RichText is_header:Bool colspan:int32 rowspan:int32 alig
pageBlockRelatedArticle url:string title:string description:string photo:photo author:string publish_date:int32 = PageBlockRelatedArticle;
//@class PageBlock @description Describes a block of an instant view web page
//@class PageBlock @description Describes a block of an instant view for a web page
//@description The title of a page @title Title
pageBlockTitle title:RichText = PageBlock;
@ -2478,7 +2478,7 @@ pageBlockVoiceNote voice_note:voiceNote caption:pageBlockCaption = PageBlock;
pageBlockCover cover:PageBlock = PageBlock;
//@description An embedded web page
//@url Web page URL, if available
//@url URL of the embedded page, if available
//@html HTML-markup of the embedded page
//@poster_photo Poster photo, if available; may be null
//@width Block width; 0 if unknown
@ -2489,7 +2489,7 @@ pageBlockCover cover:PageBlock = PageBlock;
pageBlockEmbedded url:string html:string poster_photo:photo width:int32 height:int32 caption:pageBlockCaption is_full_width:Bool allow_scrolling:Bool = PageBlock;
//@description An embedded post
//@url Web page URL
//@url URL of the embedded post
//@author Post author
//@author_photo Post author photo; may be null
//@date Point in time (Unix timestamp) when the post was created; 0 if unknown
@ -2542,11 +2542,11 @@ pageBlockMap location:location zoom:int32 width:int32 height:int32 caption:pageB
//@description Describes an instant view page for a web page
//@page_blocks Content of the web page
//@page_blocks Content of the instant view page
//@view_count Number of the instant view views; 0 if unknown
//@version Version of the instant view; currently, can be 1 or 2
//@is_rtl True, if the instant view must be shown from right to left
//@is_full True, if the instant view contains the full page. A network request might be needed to get the full web page instant view
//@is_full True, if the instant view contains the full page. A network request might be needed to get the full instant view
//@feedback_link An internal link to be opened to leave feedback about the instant view
webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32 is_rtl:Bool is_full:Bool feedback_link:InternalLinkType = WebPageInstantView;
@ -2554,7 +2554,7 @@ webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32
//@description Describes a link preview
//@url Original URL of the link
//@display_url URL to display
//@type Type of the web page. Can be: article, photo, audio, video, document, profile, app, or something else
//@type Type of the link preview. Can be: article, photo, audio, video, document, profile, app, or something else
//@site_name Short name of the site (e.g., Google Docs, App Store)
//@title Title of the content
//@param_description Description of the content
@ -2579,8 +2579,8 @@ webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32
//@story_sender_chat_id The identifier of the sender of the previewed story; 0 if none
//@story_id The identifier of the previewed story; 0 if none
//@stickers Up to 4 stickers from the sticker set available via the link
//@instant_view_version Version of web page instant view (currently, can be 1 or 2); 0 if none
webPage url:string display_url:string type:string site_name:string title:string description:formattedText photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string has_large_media:Bool show_large_media:Bool skip_confirmation:Bool show_above_text:Bool animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote story_sender_chat_id:int53 story_id:int32 stickers:vector<sticker> instant_view_version:int32 = WebPage;
//@instant_view_version Version of instant view (currently, can be 1 or 2) for the web page; 0 if none
linkPreview url:string display_url:string type:string site_name:string title:string description:formattedText photo:photo embed_url:string embed_type:string embed_width:int32 embed_height:int32 duration:int32 author:string has_large_media:Bool show_large_media:Bool skip_confirmation:Bool show_above_text:Bool animation:animation audio:audio document:document sticker:sticker video:video video_note:videoNote voice_note:voiceNote story_sender_chat_id:int53 story_id:int32 stickers:vector<sticker> instant_view_version:int32 = LinkPreview;
//@description Contains information about a country
@ -3119,9 +3119,9 @@ inputPassportElementError type:PassportElementType message:string source:InputPa
//@description A text message
//@text Text of the message
//@web_page A link preview attached to the message; may be null
//@link_preview A link preview attached to the message; may be null
//@link_preview_options Options which were used for generation of the link preview; may be null if default options were used
messageText text:formattedText web_page:webPage link_preview_options:linkPreviewOptions = MessageContent;
messageText text:formattedText link_preview:linkPreview link_preview_options:linkPreviewOptions = MessageContent;
//@description An animation message (GIF-style).
//@animation The animation description
@ -3494,7 +3494,7 @@ textEntityTypeMentionName user_id:int53 = TextEntityType;
//@description A custom emoji. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji @custom_emoji_id Unique identifier of the custom emoji
textEntityTypeCustomEmoji custom_emoji_id:int64 = TextEntityType;
//@description A media timestamp @media_timestamp Timestamp from which a video/audio/video note/voice note/story playing must start, in seconds. The media can be in the content or the web page preview of the current message, or in the same places in the replied message
//@description A media timestamp @media_timestamp Timestamp from which a video/audio/video note/voice note/story playing must start, in seconds. The media can be in the content or the link preview of the current message, or in the same places in the replied message
textEntityTypeMediaTimestamp media_timestamp:int32 = TextEntityType;
@ -6429,7 +6429,7 @@ messageLink link:string is_public:Bool = MessageLink;
//@chat_id If found, identifier of the chat to which the link points, 0 otherwise
//@message_thread_id If found, identifier of the message thread in which to open the message, or a forum topic to open if the message is missing
//@message If found, the linked message; may be null
//@media_timestamp Timestamp from which the video/audio/video note/voice note/story playing must start, in seconds; 0 if not specified. The media can be in the message content or in its web page preview
//@media_timestamp Timestamp from which the video/audio/video note/voice note/story playing must start, in seconds; 0 if not specified. The media can be in the message content or in its link preview
//@for_album True, if the whole media album to which the message belongs is linked
messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:message media_timestamp:int32 for_album:Bool = MessageLinkInfo;
@ -8298,7 +8298,7 @@ removeNotificationGroup notification_group_id:int32 max_notification_id:int32 =
//@description Returns an HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels, or if message.can_get_media_timestamp_links and a media timestamp link is generated. This is an offline request
//@chat_id Identifier of the chat to which the message belongs
//@message_id Identifier of the message
//@media_timestamp If not 0, timestamp from which the video/audio/video note/voice note/story playing must start, in seconds. The media can be in the message content or in its web page preview
//@media_timestamp If not 0, timestamp from which the video/audio/video note/voice note/story playing must start, in seconds. The media can be in the message content or in its link preview
//@for_album Pass true to create a link for the whole media album
//@in_message_thread Pass true to create a link to the message as a channel post comment, in a message thread, or a forum topic
getMessageLink chat_id:int53 message_id:int53 media_timestamp:int32 for_album:Bool in_message_thread:Bool = MessageLink;
@ -9048,7 +9048,7 @@ getInternalLink type:InternalLinkType is_http:Bool = HttpUrl;
//@description Returns information about the type of internal link. Returns a 404 error if the link is not internal. Can be called before authorization @link The link
getInternalLinkType link:string = InternalLinkType;
//@description Returns information about an action to be done when the current user clicks an external link. Don't use this method for links from secret chats if web page preview is disabled in secret chats @link The link
//@description Returns information about an action to be done when the current user clicks an external link. Don't use this method for links from secret chats if link preview is disabled in secret chats @link The link
getExternalLinkInfo link:string = LoginUrlInfo;
//@description Returns an HTTP URL which can be used to automatically authorize the current user on a website after clicking an HTTP link. Use the method getExternalLinkInfo to find whether a prior user confirmation is needed
@ -10221,7 +10221,7 @@ removeRecentHashtag hashtag:string = Ok;
//@description Returns a link preview by the text of a message. Do not call this function too often. Returns a 404 error if the text has no link preview
//@text Message text with formatting
//@link_preview_options Options to be used for generation of the link preview; pass null to use default link preview options
getWebPagePreview text:formattedText link_preview_options:linkPreviewOptions = WebPage;
getLinkPreview text:formattedText link_preview_options:linkPreviewOptions = LinkPreview;
//@description Returns an instant view version of a web page if available. Returns a 404 error if the web page has no instant view page @url The web page URL @force_full Pass true to get full instant view for the web page
getWebPageInstantView url:string force_full:Bool = WebPageInstantView;

View File

@ -241,9 +241,9 @@ RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissi
rights->can_send_photos_, rights->can_send_videos_, rights->can_send_video_notes_,
rights->can_send_voice_notes_, rights->can_send_other_messages_,
rights->can_send_other_messages_, rights->can_send_other_messages_,
rights->can_send_other_messages_, rights->can_add_web_page_previews_,
rights->can_send_polls_, rights->can_change_info_, rights->can_invite_users_,
rights->can_pin_messages_, rights->can_create_topics_, channel_type);
rights->can_send_other_messages_, rights->can_add_link_previews_, rights->can_send_polls_,
rights->can_change_info_, rights->can_invite_users_, rights->can_pin_messages_,
rights->can_create_topics_, channel_type);
}
RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_audios, bool can_send_documents,

View File

@ -7373,7 +7373,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
return td_api::make_object<td_api::messageAnimatedEmoji>(std::move(animated_emoji), m->text.text);
}
}
auto web_page = td->web_pages_manager_->get_web_page_object(
auto web_page = td->web_pages_manager_->get_link_preview_object(
m->web_page_id, m->force_small_media, m->force_large_media, m->skip_web_page_confirmation, invert_media);
if (web_page != nullptr && !web_page->skip_confirmation_ && is_visible_url(m->text, web_page->url_)) {
web_page->skip_confirmation_ = true;

View File

@ -298,7 +298,7 @@ td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_messag
break;
case td_api::messageText::ID: {
const auto *message_text = static_cast<const td_api::messageText *>(content.get());
if (message_text->web_page_ == nullptr && message_text->link_preview_options_ == nullptr) {
if (message_text->link_preview_ == nullptr && message_text->link_preview_options_ == nullptr) {
content = nullptr;
}
break;

View File

@ -6185,7 +6185,7 @@ void Td::on_request(uint64 id, td_api::resendMessages &request) {
messages_manager_->get_messages_object(-1, dialog_id, r_message_ids.ok(), false, "resendMessages"));
}
void Td::on_request(uint64 id, td_api::getWebPagePreview &request) {
void Td::on_request(uint64 id, td_api::getLinkPreview &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
web_pages_manager_->get_web_page_preview(std::move(request.text_), std::move(request.link_preview_options_),

View File

@ -1013,7 +1013,7 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::resendMessages &request);
void on_request(uint64 id, td_api::getWebPagePreview &request);
void on_request(uint64 id, td_api::getLinkPreview &request);
void on_request(uint64 id, td_api::getWebPageInstantView &request);

View File

@ -65,11 +65,11 @@
namespace td {
class GetWebPagePreviewQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::webPage>> promise_;
Promise<td_api::object_ptr<td_api::linkPreview>> promise_;
unique_ptr<WebPagesManager::GetWebPagePreviewOptions> options_;
public:
explicit GetWebPagePreviewQuery(Promise<td_api::object_ptr<td_api::webPage>> &&promise)
explicit GetWebPagePreviewQuery(Promise<td_api::object_ptr<td_api::linkPreview>> &&promise)
: promise_(std::move(promise)) {
}
@ -918,7 +918,7 @@ void WebPagesManager::unregister_quick_reply_web_page(WebPageId web_page_id, Qui
void WebPagesManager::on_get_web_page_preview(unique_ptr<GetWebPagePreviewOptions> &&options,
tl_object_ptr<telegram_api::MessageMedia> &&message_media_ptr,
Promise<td_api::object_ptr<td_api::webPage>> &&promise) {
Promise<td_api::object_ptr<td_api::linkPreview>> &&promise) {
CHECK(message_media_ptr != nullptr);
int32 constructor_id = message_media_ptr->get_id();
if (constructor_id != telegram_api::messageMediaWebPage::ID) {
@ -945,7 +945,7 @@ void WebPagesManager::on_get_web_page_preview(unique_ptr<GetWebPagePreviewOption
void WebPagesManager::on_get_web_page_preview_success(unique_ptr<GetWebPagePreviewOptions> &&options,
WebPageId web_page_id,
Promise<td_api::object_ptr<td_api::webPage>> &&promise) {
Promise<td_api::object_ptr<td_api::linkPreview>> &&promise) {
CHECK(web_page_id == WebPageId() || have_web_page(web_page_id));
CHECK(options != nullptr);
CHECK(options->link_preview_options_ != nullptr);
@ -954,14 +954,15 @@ void WebPagesManager::on_get_web_page_preview_success(unique_ptr<GetWebPagePrevi
on_get_web_page_by_url(options->first_url_, web_page_id, true);
}
promise.set_value(get_web_page_object(web_page_id, options->link_preview_options_->force_small_media_,
options->link_preview_options_->force_large_media_, options->skip_confirmation_,
options->link_preview_options_->show_above_text_));
promise.set_value(get_link_preview_object(web_page_id, options->link_preview_options_->force_small_media_,
options->link_preview_options_->force_large_media_,
options->skip_confirmation_,
options->link_preview_options_->show_above_text_));
}
void WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedText> &&text,
td_api::object_ptr<td_api::linkPreviewOptions> &&link_preview_options,
Promise<td_api::object_ptr<td_api::webPage>> &&promise) {
Promise<td_api::object_ptr<td_api::linkPreview>> &&promise) {
TRY_RESULT_PROMISE(
promise, formatted_text,
get_formatted_text(td_, DialogId(), std::move(text), td_->auth_manager_->is_bot(), true, true, true));
@ -982,9 +983,9 @@ void WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedT
auto web_page_id = get_web_page_by_url(url);
bool skip_confirmation = is_visible_url(formatted_text, url);
if (web_page_id.is_valid()) {
return promise.set_value(get_web_page_object(web_page_id, link_preview_options->force_small_media_,
link_preview_options->force_large_media_, skip_confirmation,
link_preview_options->show_above_text_));
return promise.set_value(get_link_preview_object(web_page_id, link_preview_options->force_small_media_,
link_preview_options->force_large_media_, skip_confirmation,
link_preview_options->show_above_text_));
}
if (!link_preview_options->url_.empty()) {
formatted_text.text = link_preview_options->url_, formatted_text.entities.clear();
@ -1332,9 +1333,11 @@ bool WebPagesManager::have_web_page(WebPageId web_page_id) const {
return get_web_page(web_page_id) != nullptr;
}
tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId web_page_id, bool force_small_media,
bool force_large_media, bool skip_confirmation,
bool invert_media) const {
tl_object_ptr<td_api::linkPreview> WebPagesManager::get_link_preview_object(WebPageId web_page_id,
bool force_small_media,
bool force_large_media,
bool skip_confirmation,
bool invert_media) const {
if (!web_page_id.is_valid()) {
return nullptr;
}
@ -1469,7 +1472,7 @@ tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId we
}();
auto stickers = transform(web_page->sticker_ids_,
[&](FileId sticker_id) { return td_->stickers_manager_->get_sticker_object(sticker_id); });
return td_api::make_object<td_api::webPage>(
return td_api::make_object<td_api::linkPreview>(
web_page->url_, web_page->display_url_, web_page->type_, web_page->site_name_, web_page->title_,
get_formatted_text_object(description, true, duration == 0 ? std::numeric_limits<int32>::max() : duration),
get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->embed_url_, web_page->embed_type_,

View File

@ -75,15 +75,15 @@ class WebPagesManager final : public Actor {
bool have_web_page_force(WebPageId web_page_id);
tl_object_ptr<td_api::webPage> get_web_page_object(WebPageId web_page_id, bool force_small_media,
bool force_large_media, bool skip_confirmation,
bool invert_media) const;
tl_object_ptr<td_api::linkPreview> get_link_preview_object(WebPageId web_page_id, bool force_small_media,
bool force_large_media, bool skip_confirmation,
bool invert_media) const;
tl_object_ptr<td_api::webPageInstantView> get_web_page_instant_view_object(WebPageId web_page_id) const;
void get_web_page_preview(td_api::object_ptr<td_api::formattedText> &&text,
td_api::object_ptr<td_api::linkPreviewOptions> &&link_preview_options,
Promise<td_api::object_ptr<td_api::webPage>> &&promise);
Promise<td_api::object_ptr<td_api::linkPreview>> &&promise);
void get_web_page_instant_view(const string &url, bool force_full, Promise<WebPageId> &&promise);
@ -97,7 +97,7 @@ class WebPagesManager final : public Actor {
void on_get_web_page_preview(unique_ptr<GetWebPagePreviewOptions> &&options,
tl_object_ptr<telegram_api::MessageMedia> &&message_media_ptr,
Promise<td_api::object_ptr<td_api::webPage>> &&promise);
Promise<td_api::object_ptr<td_api::linkPreview>> &&promise);
void on_binlog_web_page_event(BinlogEvent &&event);
@ -146,7 +146,7 @@ class WebPagesManager final : public Actor {
void on_pending_web_page_timeout(WebPageId web_page_id);
void on_get_web_page_preview_success(unique_ptr<GetWebPagePreviewOptions> &&options, WebPageId web_page_id,
Promise<td_api::object_ptr<td_api::webPage>> &&promise);
Promise<td_api::object_ptr<td_api::linkPreview>> &&promise);
void on_get_web_page_instant_view(WebPage *web_page, tl_object_ptr<telegram_api::page> &&page, int32 hash,
DialogId owner_dialog_id);
@ -209,7 +209,7 @@ class WebPagesManager final : public Actor {
web_page_quick_reply_messages_;
FlatHashMap<WebPageId,
vector<std::pair<unique_ptr<GetWebPagePreviewOptions>, Promise<td_api::object_ptr<td_api::webPage>>>>,
vector<std::pair<unique_ptr<GetWebPagePreviewOptions>, Promise<td_api::object_ptr<td_api::linkPreview>>>>,
WebPageIdHash>
pending_get_web_pages_;

View File

@ -6492,8 +6492,8 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::clearRecentlyFoundChats>());
} else if (op == "groc") {
send_request(td_api::make_object<td_api::getRecentlyOpenedChats>(as_limit(args)));
} else if (op == "gwpp") {
send_request(td_api::make_object<td_api::getWebPagePreview>(as_formatted_text(args), get_link_preview_options()));
} else if (op == "glp") {
send_request(td_api::make_object<td_api::getLinkPreview>(as_formatted_text(args), get_link_preview_options()));
} else if (op == "gwpiv") {
string url;
bool force_full;