Add messageReplyToMessage.quote.
This commit is contained in:
parent
3531481591
commit
f0d166cbdc
@ -1227,9 +1227,11 @@ messageSendingStateFailed error:error can_retry:Bool need_another_sender:Bool re
|
||||
//@class MessageReplyTo @description Contains information about the message or the story a message is replying to
|
||||
|
||||
//@description Describes a message replied by a given message
|
||||
//@chat_id The identifier of the chat to which the message belongs
|
||||
//@message_id The identifier of the message
|
||||
messageReplyToMessage chat_id:int53 message_id:int53 = MessageReplyTo;
|
||||
//@chat_id The identifier of the chat to which the message belongs; may be 0 if the replied message is in another chat and isn't accessible
|
||||
//@message_id The identifier of the message; may be 0 if the replied message is in another chat and isn't accessible
|
||||
//@quote Manually or automatically chosen quote from the replied message; may be null if none
|
||||
//@is_quote_manual True, if the quote was manually chosen by the message sender
|
||||
messageReplyToMessage chat_id:int53 message_id:int53 quote:formattedText is_quote_manual:Bool = MessageReplyTo;
|
||||
|
||||
//@description Describes a story replied by a given message @story_sender_chat_id The identifier of the sender of the story @story_id The identifier of the story
|
||||
messageReplyToStory story_sender_chat_id:int53 story_id:int32 = MessageReplyTo;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/MessageFullId.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ScheduledServerMessageId.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
@ -57,8 +58,7 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
|
||||
LOG(ERROR) << "Receive reply to " << message_id_ << " in " << MessageFullId{dialog_id, message_id};
|
||||
message_id_ = MessageId();
|
||||
}
|
||||
if (reply_header->reply_from_ != nullptr || reply_header->reply_media_ != nullptr ||
|
||||
!reply_header->quote_text_.empty() || !reply_header->quote_entities_.empty()) {
|
||||
if (reply_header->reply_from_ != nullptr || reply_header->reply_media_ != nullptr) {
|
||||
LOG(ERROR) << "Receive reply from other chat " << to_string(reply_header) << " in "
|
||||
<< MessageFullId{dialog_id, message_id};
|
||||
}
|
||||
@ -101,6 +101,19 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!reply_header->quote_text_.empty()) {
|
||||
is_quote_manual_ = reply_header->quote_;
|
||||
auto entities = get_message_entities(td->contacts_manager_.get(), std::move(reply_header->quote_entities_),
|
||||
"RepliedMessageInfo");
|
||||
auto status = fix_formatted_text(reply_header->quote_text_, entities, true, true, true, true, false);
|
||||
if (status.is_error()) {
|
||||
if (!clean_input_string(reply_header->quote_text_)) {
|
||||
reply_header->quote_text_.clear();
|
||||
}
|
||||
entities.clear();
|
||||
}
|
||||
quote_ = FormattedText{std::move(reply_header->quote_text_), std::move(entities)};
|
||||
}
|
||||
}
|
||||
|
||||
RepliedMessageInfo::RepliedMessageInfo(Td *td, const MessageInputReplyTo &input_reply_to) {
|
||||
@ -166,6 +179,7 @@ bool RepliedMessageInfo::need_reply_changed_warning(
|
||||
void RepliedMessageInfo::add_dependencies(Dependencies &dependencies) const {
|
||||
dependencies.add_dialog_and_dependencies(dialog_id_);
|
||||
origin_.add_dependencies(dependencies);
|
||||
add_formatted_text_dependencies(dependencies, "e_);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_message_reply_to_message_object(
|
||||
@ -175,8 +189,13 @@ td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_messag
|
||||
} else {
|
||||
CHECK(dialog_id.is_valid());
|
||||
}
|
||||
td_api::object_ptr<td_api::formattedText> quote;
|
||||
if (!quote_.text.empty()) {
|
||||
quote = get_formatted_text_object(quote_, true, -1);
|
||||
}
|
||||
return td_api::make_object<td_api::messageReplyToMessage>(
|
||||
td->messages_manager_->get_chat_id_object(dialog_id, "messageReplyToMessage"), message_id_.get());
|
||||
td->messages_manager_->get_chat_id_object(dialog_id, "messageReplyToMessage"), message_id_.get(),
|
||||
std::move(quote), is_quote_manual_);
|
||||
}
|
||||
|
||||
MessageId RepliedMessageInfo::get_same_chat_reply_to_message_id() const {
|
||||
@ -192,7 +211,8 @@ MessageFullId RepliedMessageInfo::get_reply_message_full_id(DialogId owner_dialo
|
||||
|
||||
bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs) {
|
||||
return lhs.message_id_ == rhs.message_id_ && lhs.dialog_id_ == rhs.dialog_id_ &&
|
||||
lhs.origin_date_ == rhs.origin_date_ && lhs.origin_ == rhs.origin_;
|
||||
lhs.origin_date_ == rhs.origin_date_ && lhs.origin_ == rhs.origin_ && lhs.quote_ == rhs.quote_ &&
|
||||
lhs.is_quote_manual_ == rhs.is_quote_manual_;
|
||||
}
|
||||
|
||||
bool operator!=(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs) {
|
||||
@ -207,6 +227,10 @@ StringBuilder &operator<<(StringBuilder &string_builder, const RepliedMessageInf
|
||||
if (info.origin_date_ != 0) {
|
||||
string_builder << " sent at " << info.origin_date_ << " by " << info.origin_;
|
||||
}
|
||||
if (!info.quote_.text.empty()) {
|
||||
string_builder << " with " << info.quote_.text.size() << (info.is_quote_manual_ ? " manually" : "")
|
||||
<< " quoted bytes";
|
||||
}
|
||||
return string_builder;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/MessageInputReplyTo.h"
|
||||
#include "td/telegram/MessageOrigin.h"
|
||||
@ -28,6 +29,8 @@ class RepliedMessageInfo {
|
||||
DialogId dialog_id_; // DialogId() if reply is to a message in the same chat
|
||||
int32 origin_date_ = 0; // for replies in other chats
|
||||
MessageOrigin origin_; // for replies in other chats
|
||||
FormattedText quote_;
|
||||
bool is_quote_manual_ = false;
|
||||
|
||||
friend bool operator==(const RepliedMessageInfo &lhs, const RepliedMessageInfo &rhs);
|
||||
|
||||
@ -53,7 +56,8 @@ class RepliedMessageInfo {
|
||||
}
|
||||
|
||||
bool is_empty() const {
|
||||
return message_id_ == MessageId() && dialog_id_ == DialogId() && origin_date_ == 0 && origin_.is_empty();
|
||||
return message_id_ == MessageId() && dialog_id_ == DialogId() && origin_date_ == 0 && origin_.is_empty() &&
|
||||
quote_.text.empty();
|
||||
}
|
||||
|
||||
static bool need_reply_changed_warning(
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/RepliedMessageInfo.h"
|
||||
|
||||
#include "td/telegram/MessageEntity.hpp"
|
||||
#include "td/telegram/MessageOrigin.hpp"
|
||||
|
||||
#include "td/utils/tl_helpers.h"
|
||||
@ -20,11 +21,14 @@ void RepliedMessageInfo::store(StorerT &storer) const {
|
||||
bool has_dialog_id = dialog_id_.is_valid();
|
||||
bool has_origin_date = origin_date_ != 0;
|
||||
bool has_origin = !origin_.is_empty();
|
||||
bool has_quote = !quote_.text.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_message_id);
|
||||
STORE_FLAG(has_dialog_id);
|
||||
STORE_FLAG(has_origin_date);
|
||||
STORE_FLAG(has_origin);
|
||||
STORE_FLAG(has_quote);
|
||||
STORE_FLAG(is_quote_manual_);
|
||||
END_STORE_FLAGS();
|
||||
if (has_message_id) {
|
||||
td::store(message_id_, storer);
|
||||
@ -46,11 +50,14 @@ void RepliedMessageInfo::parse(ParserT &parser) {
|
||||
bool has_dialog_id;
|
||||
bool has_origin_date;
|
||||
bool has_origin;
|
||||
bool has_quote;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_message_id);
|
||||
PARSE_FLAG(has_dialog_id);
|
||||
PARSE_FLAG(has_origin_date);
|
||||
PARSE_FLAG(has_origin);
|
||||
PARSE_FLAG(has_quote);
|
||||
PARSE_FLAG(is_quote_manual_);
|
||||
END_PARSE_FLAGS();
|
||||
if (has_message_id) {
|
||||
td::parse(message_id_, parser);
|
||||
@ -64,6 +71,9 @@ void RepliedMessageInfo::parse(ParserT &parser) {
|
||||
if (has_origin) {
|
||||
td::parse(origin_, parser);
|
||||
}
|
||||
if (has_quote) {
|
||||
td::parse(quote_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user