Support messageOriginChannel in replied message info.

This commit is contained in:
levlam 2023-10-27 02:18:49 +03:00
parent 10e2decf4b
commit 84edd20cfd

View File

@ -46,9 +46,8 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
if (reply_header->reply_to_scheduled_) {
message_id_ = MessageId(ScheduledServerMessageId(reply_header->reply_to_msg_id_), date);
if (message_id.is_valid_scheduled()) {
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
if (reply_to_peer_id != nullptr) {
dialog_id_ = DialogId(reply_to_peer_id);
if (reply_header->reply_to_peer_id_ != nullptr) {
dialog_id_ = DialogId(reply_header->reply_to_peer_id_);
LOG(ERROR) << "Receive reply to " << MessageFullId{dialog_id_, message_id_} << " in "
<< MessageFullId{dialog_id, message_id};
message_id_ = MessageId();
@ -69,11 +68,10 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
} else {
if (reply_header->reply_to_msg_id_ != 0) {
message_id_ = MessageId(ServerMessageId(reply_header->reply_to_msg_id_));
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
if (reply_to_peer_id != nullptr) {
dialog_id_ = DialogId(reply_to_peer_id);
if (reply_header->reply_to_peer_id_ != nullptr) {
dialog_id_ = DialogId(reply_header->reply_to_peer_id_);
if (!dialog_id_.is_valid()) {
LOG(ERROR) << "Receive reply in invalid " << to_string(reply_to_peer_id);
LOG(ERROR) << "Receive reply in invalid " << to_string(reply_header->reply_to_peer_id_);
message_id_ = MessageId();
dialog_id_ = DialogId();
}
@ -95,13 +93,11 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
}
if (reply_header->reply_from_ != nullptr) {
origin_date_ = reply_header->reply_from_->date_;
if (reply_header->reply_from_->channel_post_ != 0) {
LOG(ERROR) << "Receive " << to_string(reply_header) << " in " << MessageFullId{dialog_id, message_id};
auto r_reply_origin = MessageOrigin::get_message_origin(td, std::move(reply_header->reply_from_));
if (r_reply_origin.is_error()) {
origin_date_ = 0;
} else {
auto r_reply_origin = MessageOrigin::get_message_origin(td, std::move(reply_header->reply_from_));
if (r_reply_origin.is_error()) {
origin_date_ = 0;
}
origin_ = r_reply_origin.move_as_ok();
}
}
if (reply_header->reply_media_ != nullptr &&
@ -277,7 +273,6 @@ td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_messag
if (!origin_.is_empty()) {
origin = origin_.get_message_origin_object(td);
CHECK(origin != nullptr);
CHECK(origin->get_id() != td_api::messageOriginChannel::ID);
}
td_api::object_ptr<td_api::MessageContent> content;