Add feedback_link to WebPageInstantView.

This commit is contained in:
levlam 2021-08-21 10:22:41 +03:00
parent 6393923d3a
commit 1a2faf5ae6
3 changed files with 11 additions and 7 deletions

View File

@ -1259,7 +1259,8 @@ pageBlockMap location:location zoom:int32 width:int32 height:int32 caption:pageB
//@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
webPageInstantView page_blocks:vector<PageBlock> view_count:int32 version:int32 is_rtl:Bool is_full:Bool = WebPageInstantView;
//@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;
//@description Describes a web page preview

View File

@ -1286,11 +1286,11 @@ tl_object_ptr<td_api::webPage> WebPagesManager::get_web_page_object(WebPageId we
tl_object_ptr<td_api::webPageInstantView> WebPagesManager::get_web_page_instant_view_object(
WebPageId web_page_id) const {
return get_web_page_instant_view_object(get_web_page_instant_view(web_page_id));
return get_web_page_instant_view_object(web_page_id, get_web_page_instant_view(web_page_id));
}
tl_object_ptr<td_api::webPageInstantView> WebPagesManager::get_web_page_instant_view_object(
const WebPageInstantView *web_page_instant_view) const {
WebPageId web_page_id, const WebPageInstantView *web_page_instant_view) const {
if (web_page_instant_view == nullptr) {
return nullptr;
}
@ -1298,10 +1298,12 @@ tl_object_ptr<td_api::webPageInstantView> WebPagesManager::get_web_page_instant_
LOG(ERROR) << "Trying to get not loaded web page instant view";
return nullptr;
}
auto feedback_link =
td_api::make_object<td_api::internalLinkTypeBotStart>("previews", PSTRING() << "webpage" << web_page_id.get());
return td_api::make_object<td_api::webPageInstantView>(
get_page_block_objects(web_page_instant_view->page_blocks, td_, web_page_instant_view->url),
web_page_instant_view->view_count, web_page_instant_view->is_v2 ? 2 : 1, web_page_instant_view->is_rtl,
web_page_instant_view->is_full);
web_page_instant_view->is_full, std::move(feedback_link));
}
void WebPagesManager::on_web_page_changed(WebPageId web_page_id, bool have_web_page) {
@ -1479,7 +1481,7 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_
web_page->instant_view.is_loaded = true;
LOG(DEBUG) << "Receive web page instant view: "
<< to_string(get_web_page_instant_view_object(&web_page->instant_view));
<< to_string(get_web_page_instant_view_object(WebPageId(), &web_page->instant_view));
}
class WebPagesManager::WebPageLogEvent {
@ -1701,7 +1703,8 @@ int32 WebPagesManager::get_web_page_media_duration(WebPageId web_page_id) const
int32 WebPagesManager::get_web_page_media_duration(const WebPage *web_page) {
if (web_page->document.type == Document::Type::Audio || web_page->document.type == Document::Type::Video ||
web_page->document.type == Document::Type::VideoNote || web_page->document.type == Document::Type::VoiceNote || web_page->embed_type == "iframe") {
web_page->document.type == Document::Type::VideoNote || web_page->document.type == Document::Type::VoiceNote ||
web_page->embed_type == "iframe") {
return web_page->duration;
}

View File

@ -126,7 +126,7 @@ class WebPagesManager final : public Actor {
WebPageId get_web_page_instant_view(WebPageId web_page_id, bool force_full, Promise<Unit> &&promise);
tl_object_ptr<td_api::webPageInstantView> get_web_page_instant_view_object(
const WebPageInstantView *web_page_instant_view) const;
WebPageId web_page_id, const WebPageInstantView *web_page_instant_view) const;
static void on_pending_web_page_timeout_callback(void *web_pages_manager_ptr, int64 web_page_id);
void on_pending_web_page_timeout(WebPageId web_page_id);