Add linkPreviewTypeBackground.background_type.
This commit is contained in:
parent
9ec8b37493
commit
31249fa0c2
@ -2660,8 +2660,10 @@ linkPreviewTypeArticle photo:photo author:string = LinkPreviewType;
|
||||
//@author Author of the audio
|
||||
linkPreviewTypeAudio url:string mime_type:string audio:audio duration:int32 author:string = LinkPreviewType;
|
||||
|
||||
//@description The link is a link to a background. Link preview title and description are available only for filled backgrounds @document Document with the background; may be null for filled backgrounds
|
||||
linkPreviewTypeBackground document:document = LinkPreviewType;
|
||||
//@description The link is a link to a background. Link preview title and description are available only for filled backgrounds
|
||||
//@document Document with the background; may be null for filled backgrounds
|
||||
//@background_type Type of the background; may be null if unknown
|
||||
linkPreviewTypeBackground document:document background_type:BackgroundType = LinkPreviewType;
|
||||
|
||||
//@description The link is a link to boost a channel chat @photo Photo of the chat; may be null
|
||||
linkPreviewTypeChannelBoost photo:chatPhoto = LinkPreviewType;
|
||||
|
@ -2684,6 +2684,27 @@ Result<string> LinkManager::get_background_url(const string &name,
|
||||
return url;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::BackgroundType> LinkManager::get_background_type_object(const string &link) {
|
||||
auto parsed_link = parse_internal_link(link);
|
||||
if (parsed_link == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto parsed_object = parsed_link->get_internal_link_type_object();
|
||||
if (parsed_object->get_id() != td_api::internalLinkTypeBackground::ID) {
|
||||
return nullptr;
|
||||
}
|
||||
auto background_name =
|
||||
std::move(static_cast<td_api::internalLinkTypeBackground *>(parsed_object.get())->background_name_);
|
||||
if (!BackgroundType::is_background_name_local(background_name)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto r_background_type = BackgroundType::get_local_background_type(background_name);
|
||||
if (r_background_type.is_error()) {
|
||||
return nullptr;
|
||||
}
|
||||
return r_background_type.ok().get_background_type_object();
|
||||
}
|
||||
|
||||
string LinkManager::get_dialog_filter_invite_link_slug(Slice invite_link) {
|
||||
auto link_info = get_link_info(invite_link);
|
||||
if (link_info.type_ != LinkType::Tg && link_info.type_ != LinkType::TMe) {
|
||||
|
@ -84,6 +84,8 @@ class LinkManager final : public Actor {
|
||||
static Result<string> get_background_url(const string &name,
|
||||
td_api::object_ptr<td_api::BackgroundType> background_type);
|
||||
|
||||
static td_api::object_ptr<td_api::BackgroundType> get_background_type_object(const string &link);
|
||||
|
||||
static string get_dialog_filter_invite_link_slug(Slice invite_link);
|
||||
|
||||
static string get_dialog_filter_invite_link(Slice slug, bool is_internal);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileSourceId.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
@ -1457,7 +1458,8 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
|
||||
return td_api::make_object<td_api::linkPreviewTypeBackground>(
|
||||
web_page->document_.type == Document::Type::General
|
||||
? td_->documents_manager_->get_document_object(web_page->document_.file_id, PhotoFormat::Png)
|
||||
: nullptr);
|
||||
: nullptr,
|
||||
LinkManager::get_background_type_object(web_page->url_));
|
||||
}
|
||||
if (type == "bot") {
|
||||
LOG_IF(ERROR, web_page->document_.type != Document::Type::Unknown)
|
||||
|
Loading…
Reference in New Issue
Block a user