From 8e666c2d7a2a194498a489fc8a519377b64a8e4b Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 28 Mar 2020 01:49:59 +0300 Subject: [PATCH] Add has_message_content_web_page. GitOrigin-RevId: 3bc382c77754a6a517616235d7b2572cfdfda607 --- td/telegram/MessageContent.cpp | 11 ++++++++--- td/telegram/MessageContent.h | 2 ++ td/telegram/MessagesManager.cpp | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 4c1e20c7..0d51f33f 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2512,11 +2512,16 @@ bool get_message_content_poll_is_anonymous(const Td *td, const MessageContent *c } } +void has_message_content_web_page(const MessageContent *content) { + if (content->get_type() == MessageContentType::Text) { + return static_cast(content)->web_page_id.is_valid(); + } + return false; +} + void remove_message_content_web_page(MessageContent *content) { CHECK(content->get_type() == MessageContentType::Text); - auto &web_page_id = static_cast(content)->web_page_id; - CHECK(web_page_id.is_valid()); - web_page_id = WebPageId(); + static_cast(content)->web_page_id = WebPageId(); } void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id, diff --git a/td/telegram/MessageContent.h b/td/telegram/MessageContent.h index 4c679f81..2980e6c6 100644 --- a/td/telegram/MessageContent.h +++ b/td/telegram/MessageContent.h @@ -135,6 +135,8 @@ bool get_message_content_poll_is_closed(const Td *td, const MessageContent *cont bool get_message_content_poll_is_anonymous(const Td *td, const MessageContent *content); +void has_message_content_web_page(const MessageContent *content); + void remove_message_content_web_page(MessageContent *content); void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id, diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c43ed61f..752a3969 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -12021,6 +12021,7 @@ void MessagesManager::delete_pending_message_web_page(FullMessageId full_message CHECK(m != nullptr); MessageContent *content = m->content.get(); + CHECK(has_message_content_web_page(content)); unregister_message_content(td_, content, full_message_id, "delete_pending_message_web_page"); remove_message_content_web_page(content); register_message_content(td_, content, full_message_id, "delete_pending_message_web_page");