Add message.link_preview_options.

This commit is contained in:
levlam 2023-11-13 22:08:07 +03:00
parent c39cc1b0ca
commit 00d351c85c
2 changed files with 33 additions and 0 deletions

View File

@ -939,6 +939,35 @@ class Client::JsonMessages final : public td::Jsonable {
const td::vector<td::string> &messages_;
};
class Client::JsonLinkPreviewOptions final : public td::Jsonable {
public:
JsonLinkPreviewOptions(const td_api::linkPreviewOptions *link_preview_options, const Client *client)
: link_preview_options_(link_preview_options), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
if (link_preview_options_->is_disabled_) {
object("is_disabled", td::JsonTrue());
}
if (!link_preview_options_->url_.empty()) {
object("url", link_preview_options_->url_);
}
if (link_preview_options_->force_small_media_) {
object("prefer_small_media", td::JsonTrue());
}
if (link_preview_options_->force_large_media_) {
object("prefer_large_media", td::JsonTrue());
}
if (link_preview_options_->show_above_text_) {
object("show_above_text", td::JsonTrue());
}
}
private:
const td_api::linkPreviewOptions *link_preview_options_;
const Client *client_;
};
class Client::JsonAnimation final : public td::Jsonable {
public:
JsonAnimation(const td_api::animation *animation, bool as_document, const Client *client)
@ -2052,6 +2081,9 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
if (!content->text_->entities_.empty()) {
object("entities", JsonVectorEntities(content->text_->entities_, client_));
}
if (content->link_preview_options_ != nullptr) {
object("link_preview_options", JsonLinkPreviewOptions(content->link_preview_options_.get(), client_));
}
break;
}
case td_api::messageAnimation::ID: {

View File

@ -97,6 +97,7 @@ class Client final : public WebhookActor::Callback {
class JsonChatInviteLink;
class JsonChat;
class JsonMessageSender;
class JsonLinkPreviewOptions;
class JsonAnimation;
class JsonAudio;
class JsonDocument;