diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 10384129f..aca06dca0 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -12048,8 +12048,10 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( auto message = move_tl_object_as(message_ptr); message_info.dialog_id = DialogId(message->peer_id_); - if (message->flags_ & MESSAGE_FLAG_HAS_FROM_ID) { + if (message->from_id_ != nullptr) { message_info.sender_dialog_id = DialogId(message->from_id_); + } else { + message_info.sender_dialog_id = message_info.dialog_id; } message_info.date = message->date_; message_info.forward_header = std::move(message->fwd_from_); @@ -12101,8 +12103,10 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message( auto message = move_tl_object_as(message_ptr); message_info.dialog_id = DialogId(message->peer_id_); - if (message->flags_ & MESSAGE_FLAG_HAS_FROM_ID) { + if (message->from_id_ != nullptr) { message_info.sender_dialog_id = DialogId(message->from_id_); + } else { + message_info.sender_dialog_id = message_info.dialog_id; } message_info.date = message->date_; message_info.flags = message->flags_; @@ -23193,7 +23197,7 @@ unique_ptr MessagesManager::get_message_for DialogId from_dialog_id; MessageId from_message_id; string sender_name; - if ((flags & telegram_api::messageFwdHeader::FROM_ID_MASK) != 0) { + if (forward_header->from_id_ != nullptr) { sender_dialog_id = DialogId(forward_header->from_id_); if (!sender_dialog_id.is_valid()) { LOG(ERROR) << "Receive invalid sender id in message forward header: " << oneline(to_string(forward_header)); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 2b06a3332..22aa960a0 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -3778,7 +3778,9 @@ void Td::inc_actor_refcnt() { void Td::dec_actor_refcnt() { actor_refcnt_--; - LOG(DEBUG) << "Decrease reference count to " << actor_refcnt_; + if (actor_refcnt_ < 3) { + LOG(DEBUG) << "Decrease reference count to " << actor_refcnt_; + } if (actor_refcnt_ == 0) { if (close_flag_ == 2) { create_reference(); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 884689b47..1bbe3cd06 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -414,17 +414,11 @@ bool UpdatesManager::is_acceptable_message_forward_header( return true; } - if (header->from_id_ != nullptr) { - DialogId dialog_id(header->from_id_); - if (!is_acceptable_dialog(dialog_id)) { - return false; - } + if (header->from_id_ != nullptr && !is_acceptable_dialog(DialogId(header->from_id_))) { + return false; } - if (header->saved_from_peer_ != nullptr) { - DialogId dialog_id(header->saved_from_peer_); - if (!is_acceptable_dialog(dialog_id)) { - return false; - } + if (header->saved_from_peer_ != nullptr && !is_acceptable_dialog(DialogId(header->saved_from_peer_))) { + return false; } return true; } @@ -534,10 +528,8 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ if (!is_acceptable_dialog(DialogId(message->peer_id_))) { return false; } - if (message->flags_ & MessagesManager::MESSAGE_FLAG_HAS_FROM_ID) { - if (!is_acceptable_dialog(DialogId(message->from_id_))) { - return false; - } + if (message->from_id_ != nullptr && !is_acceptable_dialog(DialogId(message->from_id_))) { + return false; } const telegram_api::MessageAction *action = message->action_.get(); @@ -707,16 +699,13 @@ void UpdatesManager::on_get_updates(tl_object_ptr &&updat auto from_id = update->flags_ & MessagesManager::MESSAGE_FLAG_IS_OUT ? td_->contacts_manager_->get_my_id().get() : update->user_id_; - auto peer_id = update->flags_ & MessagesManager::MESSAGE_FLAG_IS_OUT ? update->user_id_ - : td_->contacts_manager_->get_my_id().get(); - update->flags_ |= MessagesManager::MESSAGE_FLAG_HAS_FROM_ID; on_pending_update(make_tl_object( make_tl_object( update->flags_, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, update->id_, make_tl_object(from_id), - make_tl_object(peer_id), std::move(update->fwd_from_), + make_tl_object(update->user_id_), std::move(update->fwd_from_), update->via_bot_id_, std::move(update->reply_to_), update->date_, update->message_, nullptr, nullptr, std::move(update->entities_), 0, 0, nullptr, 0, string(), 0, Auto()), update->pts_, update->pts_count_), diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 72582c342..d299187c8 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -505,6 +505,10 @@ class CliClient final : public Actor { return transform(full_split(trim(message_ids), get_delimiter(message_ids)), as_message_id); } + static int64 as_message_thread_id(Slice str) { + return as_message_id(str); + } + static int32 as_button_id(Slice str) { return to_integer(trim(str)); } @@ -1860,6 +1864,12 @@ class CliClient final : public Actor { send_request(td_api::make_object(get_history_chat_id_, std::numeric_limits::max(), 0, 100, false)); + } else if (op == "replies") { + string chat_id; + string message_thread_id; + + send_request(td_api::make_object(as_chat_id(chat_id), "", 0, 0, 0, 100, nullptr, + as_message_thread_id(message_thread_id))); } else if (op == "spvf") { search_chat_id_ = as_chat_id(args);