Parse new MessageReplyHeader.
This commit is contained in:
parent
4027e73309
commit
abca2962f2
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
MessageReplyHeader::MessageReplyHeader(tl_object_ptr<telegram_api::MessageReplyHeader> &&reply_header_ptr,
|
MessageReplyHeader::MessageReplyHeader(Td *td, tl_object_ptr<telegram_api::MessageReplyHeader> &&reply_header_ptr,
|
||||||
DialogId dialog_id, MessageId message_id, int32 date, bool can_have_thread) {
|
DialogId dialog_id, MessageId message_id, int32 date, bool can_have_thread) {
|
||||||
if (reply_header_ptr == nullptr) {
|
if (reply_header_ptr == nullptr) {
|
||||||
return;
|
return;
|
||||||
@ -49,7 +49,13 @@ MessageReplyHeader::MessageReplyHeader(tl_object_ptr<telegram_api::MessageReplyH
|
|||||||
LOG(ERROR) << "Receive reply to " << reply_to_message_id_ << " in " << MessageFullId{dialog_id, message_id};
|
LOG(ERROR) << "Receive reply to " << reply_to_message_id_ << " in " << MessageFullId{dialog_id, message_id};
|
||||||
reply_to_message_id_ = MessageId();
|
reply_to_message_id_ = MessageId();
|
||||||
}
|
}
|
||||||
} else if (reply_header->reply_to_msg_id_ > 0 && reply_header->reply_from_ == nullptr) {
|
if (reply_header->reply_from_ != nullptr || reply_header->reply_media_ != nullptr ||
|
||||||
|
!reply_header->quote_text_.empty() || !reply_header->quote_entities_.empty()) {
|
||||||
|
LOG(ERROR) << "Receive reply from other chat " << to_string(reply_header) << " in "
|
||||||
|
<< MessageFullId{dialog_id, message_id};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (reply_header->reply_to_msg_id_ != 0) {
|
||||||
reply_to_message_id_ = MessageId(ServerMessageId(reply_header->reply_to_msg_id_));
|
reply_to_message_id_ = MessageId(ServerMessageId(reply_header->reply_to_msg_id_));
|
||||||
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
|
auto reply_to_peer_id = std::move(reply_header->reply_to_peer_id_);
|
||||||
if (reply_to_peer_id != nullptr) {
|
if (reply_to_peer_id != nullptr) {
|
||||||
@ -63,15 +69,33 @@ MessageReplyHeader::MessageReplyHeader(tl_object_ptr<telegram_api::MessageReplyH
|
|||||||
reply_in_dialog_id_ = DialogId(); // just in case
|
reply_in_dialog_id_ = DialogId(); // just in case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reply_to_message_id_.is_valid() && !message_id.is_scheduled() && !reply_in_dialog_id_.is_valid() &&
|
if (!reply_to_message_id_.is_valid()) {
|
||||||
can_have_thread) {
|
LOG(ERROR) << "Receive " << to_string(reply_header) << " in " << MessageFullId{dialog_id, message_id};
|
||||||
|
reply_to_message_id_ = MessageId();
|
||||||
|
reply_in_dialog_id_ = DialogId();
|
||||||
|
}
|
||||||
|
} else if (reply_header->reply_to_peer_id_ != nullptr) {
|
||||||
|
LOG(ERROR) << "Receive " << to_string(reply_header) << " in " << MessageFullId{dialog_id, message_id};
|
||||||
|
}
|
||||||
|
if (reply_header->reply_from_ != nullptr) {
|
||||||
|
reply_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};
|
||||||
|
} else {
|
||||||
|
auto r_reply_origin = MessageOrigin::get_message_origin(td, std::move(reply_header->reply_from_));
|
||||||
|
if (r_reply_origin.is_error()) {
|
||||||
|
reply_date_ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!message_id.is_scheduled() && can_have_thread) {
|
||||||
if ((reply_header->flags_ & telegram_api::messageReplyHeader::REPLY_TO_TOP_ID_MASK) != 0) {
|
if ((reply_header->flags_ & telegram_api::messageReplyHeader::REPLY_TO_TOP_ID_MASK) != 0) {
|
||||||
top_thread_message_id_ = MessageId(ServerMessageId(reply_header->reply_to_top_id_));
|
top_thread_message_id_ = MessageId(ServerMessageId(reply_header->reply_to_top_id_));
|
||||||
} else {
|
} else if (reply_to_message_id_.is_valid() && !reply_in_dialog_id_.is_valid() && reply_date_ == 0) {
|
||||||
top_thread_message_id_ = reply_to_message_id_;
|
top_thread_message_id_ = reply_to_message_id_;
|
||||||
}
|
}
|
||||||
is_topic_message_ = reply_header->forum_topic_;
|
is_topic_message_ = top_thread_message_id_.is_valid() && reply_header->forum_topic_;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
|
#include "td/telegram/MessageOrigin.h"
|
||||||
#include "td/telegram/StoryFullId.h"
|
#include "td/telegram/StoryFullId.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
@ -15,9 +16,13 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
class Td;
|
||||||
|
|
||||||
struct MessageReplyHeader {
|
struct MessageReplyHeader {
|
||||||
MessageId reply_to_message_id_;
|
MessageId reply_to_message_id_;
|
||||||
DialogId reply_in_dialog_id_;
|
DialogId reply_in_dialog_id_;
|
||||||
|
int32 reply_date_ = 0; // for replies in other chats
|
||||||
|
MessageOrigin reply_origin_; // for replies in other chats
|
||||||
MessageId top_thread_message_id_;
|
MessageId top_thread_message_id_;
|
||||||
bool is_topic_message_ = false;
|
bool is_topic_message_ = false;
|
||||||
|
|
||||||
@ -27,7 +32,7 @@ struct MessageReplyHeader {
|
|||||||
|
|
||||||
MessageReplyHeader() = default;
|
MessageReplyHeader() = default;
|
||||||
|
|
||||||
MessageReplyHeader(tl_object_ptr<telegram_api::MessageReplyHeader> &&reply_header_ptr, DialogId dialog_id,
|
MessageReplyHeader(Td *td, tl_object_ptr<telegram_api::MessageReplyHeader> &&reply_header_ptr, DialogId dialog_id,
|
||||||
MessageId message_id, int32 date, bool can_have_thread);
|
MessageId message_id, int32 date, bool can_have_thread);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14246,7 +14246,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
|
|||||||
message_info.forward_header = std::move(message->fwd_from_);
|
message_info.forward_header = std::move(message->fwd_from_);
|
||||||
bool can_have_thread =
|
bool can_have_thread =
|
||||||
message_info.dialog_id.get_type() == DialogType::Channel && !is_broadcast_channel(message_info.dialog_id);
|
message_info.dialog_id.get_type() == DialogType::Channel && !is_broadcast_channel(message_info.dialog_id);
|
||||||
message_info.reply_header = MessageReplyHeader(std::move(message->reply_to_), message_info.dialog_id,
|
message_info.reply_header = MessageReplyHeader(td_, std::move(message->reply_to_), message_info.dialog_id,
|
||||||
message_info.message_id, message_info.date, can_have_thread);
|
message_info.message_id, message_info.date, can_have_thread);
|
||||||
if (message->flags_ & telegram_api::message::VIA_BOT_ID_MASK) {
|
if (message->flags_ & telegram_api::message::VIA_BOT_ID_MASK) {
|
||||||
message_info.via_bot_user_id = UserId(message->via_bot_id_);
|
message_info.via_bot_user_id = UserId(message->via_bot_id_);
|
||||||
@ -14315,7 +14315,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
|
|||||||
message_info.has_unread_content = message->media_unread_;
|
message_info.has_unread_content = message->media_unread_;
|
||||||
bool can_have_thread =
|
bool can_have_thread =
|
||||||
message_info.dialog_id.get_type() == DialogType::Channel && !is_broadcast_channel(message_info.dialog_id);
|
message_info.dialog_id.get_type() == DialogType::Channel && !is_broadcast_channel(message_info.dialog_id);
|
||||||
message_info.reply_header = MessageReplyHeader(std::move(message->reply_to_), message_info.dialog_id,
|
message_info.reply_header = MessageReplyHeader(td_, std::move(message->reply_to_), message_info.dialog_id,
|
||||||
message_info.message_id, message_info.date, can_have_thread);
|
message_info.message_id, message_info.date, can_have_thread);
|
||||||
message_info.content = get_action_message_content(td_, std::move(message->action_), message_info.dialog_id,
|
message_info.content = get_action_message_content(td_, std::move(message->action_), message_info.dialog_id,
|
||||||
message_info.reply_header.reply_in_dialog_id_,
|
message_info.reply_header.reply_in_dialog_id_,
|
||||||
|
Loading…
Reference in New Issue
Block a user