Fix creator in ForumTopicInfo.

This commit is contained in:
levlam 2023-02-04 17:59:17 +03:00
parent e9aa2fd64b
commit f6616f6ba3
5 changed files with 18 additions and 11 deletions

View File

@ -364,7 +364,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionCreateTopic::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionCreateTopic>(action_ptr);
auto topic_info = ForumTopicInfo(action->topic_);
auto topic_info = ForumTopicInfo(td, action->topic_);
if (topic_info.is_empty()) {
return nullptr;
}
@ -373,8 +373,8 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionEditTopic::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionEditTopic>(action_ptr);
auto old_topic_info = ForumTopicInfo(action->prev_topic_);
auto new_topic_info = ForumTopicInfo(action->new_topic_);
auto old_topic_info = ForumTopicInfo(td, action->prev_topic_);
auto new_topic_info = ForumTopicInfo(td, action->new_topic_);
if (old_topic_info.is_empty() || new_topic_info.is_empty() ||
old_topic_info.get_top_thread_message_id() != new_topic_info.get_top_thread_message_id()) {
LOG(ERROR) << "Receive " << to_string(action);
@ -395,7 +395,7 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
}
case telegram_api::channelAdminLogEventActionDeleteTopic::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionDeleteTopic>(action_ptr);
auto topic_info = ForumTopicInfo(action->topic_);
auto topic_info = ForumTopicInfo(td, action->topic_);
if (topic_info.is_empty()) {
return nullptr;
}
@ -406,10 +406,10 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
ForumTopicInfo old_topic_info;
ForumTopicInfo new_topic_info;
if (action->prev_topic_ != nullptr) {
old_topic_info = ForumTopicInfo(action->prev_topic_);
old_topic_info = ForumTopicInfo(td, action->prev_topic_);
}
if (action->new_topic_ != nullptr) {
new_topic_info = ForumTopicInfo(action->new_topic_);
new_topic_info = ForumTopicInfo(td, action->new_topic_);
}
if (old_topic_info.is_empty() && new_topic_info.is_empty()) {
return nullptr;

View File

@ -7,13 +7,15 @@
#include "td/telegram/ForumTopicInfo.h"
#include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/Td.h"
#include "td/utils/logging.h"
namespace td {
ForumTopicInfo::ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &forum_topic_ptr) {
ForumTopicInfo::ForumTopicInfo(Td *td, const tl_object_ptr<telegram_api::ForumTopic> &forum_topic_ptr) {
CHECK(forum_topic_ptr != nullptr);
if (forum_topic_ptr->get_id() != telegram_api::forumTopic::ID) {
LOG(ERROR) << "Receive " << to_string(forum_topic_ptr);
@ -26,6 +28,10 @@ ForumTopicInfo::ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &fo
icon_ = ForumTopicIcon(forum_topic->icon_color_, forum_topic->icon_emoji_id_);
creation_date_ = forum_topic->date_;
creator_dialog_id_ = DialogId(forum_topic->from_id_);
if (creator_dialog_id_.is_valid() && creator_dialog_id_.get_type() != DialogType::User &&
td->messages_manager_->have_dialog_info_force(creator_dialog_id_)) {
td->messages_manager_->force_create_dialog(creator_dialog_id_, "ForumTopicInfo", true);
}
is_outgoing_ = forum_topic->my_;
is_closed_ = forum_topic->closed_;
is_hidden_ = forum_topic->hidden_;

View File

@ -38,7 +38,7 @@ class ForumTopicInfo {
public:
ForumTopicInfo() = default;
explicit ForumTopicInfo(const tl_object_ptr<telegram_api::ForumTopic> &forum_topic_ptr);
ForumTopicInfo(Td *td, const tl_object_ptr<telegram_api::ForumTopic> &forum_topic_ptr);
ForumTopicInfo(MessageId top_thread_message_id, string title, ForumTopicIcon icon, int32 creation_date,
DialogId creator_dialog_id, bool is_outgoing, bool is_closed, bool is_hidden)

View File

@ -945,7 +945,7 @@ void ForumTopicManager::on_get_forum_topic_infos(DialogId dialog_id,
auto dialog_topics = add_dialog_topics(dialog_id);
CHECK(dialog_topics != nullptr);
for (auto &forum_topic : forum_topics) {
auto forum_topic_info = td::make_unique<ForumTopicInfo>(forum_topic);
auto forum_topic_info = td::make_unique<ForumTopicInfo>(td_, forum_topic);
MessageId top_thread_message_id = forum_topic_info->get_top_thread_message_id();
if (can_be_message_thread_id(top_thread_message_id).is_error()) {
continue;
@ -973,7 +973,7 @@ MessageId ForumTopicManager::on_get_forum_topic_impl(DialogId dialog_id,
return MessageId();
}
case telegram_api::forumTopic::ID: {
auto forum_topic_info = td::make_unique<ForumTopicInfo>(forum_topic);
auto forum_topic_info = td::make_unique<ForumTopicInfo>(td_, forum_topic);
MessageId top_thread_message_id = forum_topic_info->get_top_thread_message_id();
Topic *topic = add_topic(dialog_id, top_thread_message_id);
if (topic == nullptr) {

View File

@ -14934,7 +14934,8 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
bool has_forward_info = message_info.forward_header != nullptr;
if (sender_dialog_id.is_valid() && sender_dialog_id != dialog_id && have_dialog_info_force(sender_dialog_id)) {
force_create_dialog(sender_dialog_id, "create_message", sender_dialog_id.get_type() != DialogType::User);
CHECK(sender_dialog_id.get_type() != DialogType::User);
force_create_dialog(sender_dialog_id, "create_message", true);
}
LOG(INFO) << "Receive " << message_id << " in " << dialog_id << " from " << sender_user_id << "/" << sender_dialog_id;