Add webPage.show_above_text.

This commit is contained in:
levlam 2023-10-21 21:33:46 +03:00
parent d32319cf75
commit cb51944cb7
7 changed files with 21 additions and 17 deletions

View File

@ -2087,7 +2087,7 @@ pageBlockMap location:location zoom:int32 width:int32 height:int32 caption:pageB
webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32 is_rtl:Bool is_full:Bool feedback_link:InternalLinkType = WebPageInstantView;
//@description Describes a web page preview
//@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
@ -2105,6 +2105,7 @@ webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32
//@force_small_media True, if shown media preview must be small
//@force_large_media True, if shown media preview must be large
//@skip_confirmation True, if there is no need to show an ordinary open URL confirmation, when opening the URL from the preview, because the URL is shown in the message text in clear
//@show_above_text True, if the link preview must be shown above message text; otherwise, the link preview must be shown below the message text
//@animation Preview of the content as an animation, if available; may be null
//@audio Preview of the content as an audio file, if available; may be null
//@document Preview of the content as a document, if available; may be null
@ -2115,7 +2116,7 @@ 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
//@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 force_small_media:Bool force_large_media:Bool skip_confirmation: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 instant_view_version:int32 = WebPage;
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 force_small_media:Bool force_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 instant_view_version:int32 = WebPage;
//@description Contains information about a country

View File

@ -3926,8 +3926,8 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
const auto *old_ = static_cast<const MessageText *>(old_content);
const auto *new_ = static_cast<const MessageText *>(new_content);
auto get_content_object = [td, dialog_id](const MessageContent *content) {
return to_string(
get_message_content_object(content, td, dialog_id, -1, false, false, std::numeric_limits<int32>::max()));
return to_string(get_message_content_object(content, td, dialog_id, -1, false, false,
std::numeric_limits<int32>::max(), false));
};
if (old_->text.text != new_->text.text) {
if (need_message_changed_warning && need_message_text_changed_warning(old_, new_)) {
@ -6096,7 +6096,7 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageContent *content, Td *td,
DialogId dialog_id, int32 message_date,
bool is_content_secret, bool skip_bot_commands,
int32 max_media_timestamp) {
int32 max_media_timestamp, bool invert_media) {
CHECK(content != nullptr);
switch (content->get_type()) {
case MessageContentType::Animation: {
@ -6172,8 +6172,8 @@ 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(m->web_page_id, m->force_small_media,
m->force_large_media, m->skip_web_page_confirmation);
auto web_page = td->web_pages_manager_->get_web_page_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

@ -224,7 +224,7 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageContent *content, Td *td,
DialogId dialog_id, int32 message_date,
bool is_content_secret, bool skip_bot_commands,
int32 max_media_timestamp);
int32 max_media_timestamp, bool invert_media);
FormattedText *get_message_content_text_mutable(MessageContent *content);

View File

@ -6564,7 +6564,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateServiceNotification>(
update->type_, get_message_content_object(content.get(), td_, owner_dialog_id, date,
is_content_secret, true, -1)));
is_content_secret, true, -1, false)));
}
if (has_date && is_user) {
Dialog *d = get_service_notifications_dialog();
@ -23981,7 +23981,8 @@ td_api::object_ptr<td_api::MessageContent> MessagesManager::get_message_message_
const Message *m) const {
auto live_location_date = m->is_failed_to_send ? 0 : m->date;
return get_message_content_object(m->content.get(), td_, dialog_id, live_location_date, m->is_content_secret,
need_skip_bot_commands(dialog_id, m), get_message_max_media_timestamp(m));
need_skip_bot_commands(dialog_id, m), get_message_max_media_timestamp(m),
m->invert_media);
}
td_api::object_ptr<td_api::message> MessagesManager::get_dialog_event_log_message_object(
@ -24005,7 +24006,7 @@ td_api::object_ptr<td_api::message> MessagesManager::get_dialog_event_log_messag
auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
auto reply_markup = get_reply_markup_object(td_->contacts_manager_.get(), m->reply_markup);
auto content = get_message_content_object(m->content.get(), td_, dialog_id, 0, false, true,
get_message_own_max_media_timestamp(m));
get_message_own_max_media_timestamp(m), m->invert_media);
return td_api::make_object<td_api::message>(
m->message_id.get(), std::move(sender), get_chat_id_object(dialog_id, "get_dialog_event_log_message_object"),
nullptr, nullptr, m->is_outgoing, false, false, false, can_be_saved, false, false, false, false, false, false,

View File

@ -291,7 +291,7 @@ td_api::object_ptr<td_api::sponsoredMessage> SponsoredMessageManager::get_sponso
}
return td_api::make_object<td_api::sponsoredMessage>(
sponsored_message.local_id, sponsored_message.is_recommended,
get_message_content_object(sponsored_message.content.get(), td_, dialog_id, 0, false, true, -1),
get_message_content_object(sponsored_message.content.get(), td_, dialog_id, 0, false, true, -1, false),
std::move(sponsor), sponsored_message.additional_info);
}

View File

@ -872,7 +872,7 @@ void WebPagesManager::on_get_web_page_preview_success(const string &first_url, W
on_get_web_page_by_url(first_url, web_page_id, true);
}
promise.set_value(get_web_page_object(web_page_id, false, false, false));
promise.set_value(get_web_page_object(web_page_id, false, false, false, false));
}
void WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedText> &&text,
@ -890,7 +890,7 @@ void WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formattedT
auto web_page_id = get_web_page_by_url(first_url);
if (web_page_id.is_valid()) {
return promise.set_value(get_web_page_object(web_page_id, false, false, false));
return promise.set_value(get_web_page_object(web_page_id, false, false, false, false));
}
td_->create_handler<GetWebPagePreviewQuery>(std::move(promise))
->send(formatted_text.text,
@ -1232,8 +1232,8 @@ bool WebPagesManager::have_web_page(WebPageId web_page_id) const {
}
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) const {
bool force_large_media, bool skip_confirmation,
bool invert_media) const {
if (!web_page_id.is_valid()) {
return nullptr;
}
@ -1338,6 +1338,7 @@ tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId we
get_photo_object(td_->file_manager_.get(), web_page->photo_), web_page->embed_url_, web_page->embed_type_,
web_page->embed_dimensions_.width, web_page->embed_dimensions_.height, web_page->duration_, web_page->author_,
web_page->has_large_media_, force_small_media, web_page->has_large_media_ && force_large_media, skip_confirmation,
invert_media,
web_page->document_.type == Document::Type::Animation
? td_->animations_manager_->get_animation_object(web_page->document_.file_id)
: nullptr,

View File

@ -63,7 +63,8 @@ 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) const;
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;