Clear web_page_url in outgoing messages if preview is disabled.
This commit is contained in:
parent
6917503e5e
commit
c6a4510779
@ -6,8 +6,10 @@
|
||||
//
|
||||
#include "td/telegram/InputMessageText.h"
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
|
||||
@ -44,6 +46,12 @@ Result<InputMessageText> process_input_message_text(const Td *td, DialogId dialo
|
||||
if (!clean_input_string(web_page_url)) {
|
||||
return Status::Error(400, "Link preview URL must be encoded in UTF-8");
|
||||
}
|
||||
|
||||
if (disable_web_page_preview ||
|
||||
(dialog_id.get_type() == DialogType::Channel &&
|
||||
!td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_add_web_page_previews())) {
|
||||
web_page_url.clear();
|
||||
}
|
||||
if (web_page_url.empty()) {
|
||||
force_small_media = false;
|
||||
force_large_media = false;
|
||||
|
@ -129,6 +129,10 @@ class MessageText final : public MessageContent {
|
||||
, force_small_media(force_small_media)
|
||||
, force_large_media(force_large_media)
|
||||
, web_page_url(std::move(web_page_url)) {
|
||||
if (web_page_url.empty()) {
|
||||
force_small_media = false;
|
||||
force_large_media = false;
|
||||
}
|
||||
}
|
||||
|
||||
MessageContentType get_type() const final {
|
||||
|
Loading…
Reference in New Issue
Block a user