Add separate header for MessagesInfo.
This commit is contained in:
parent
2e139cc895
commit
75453b542f
@ -630,6 +630,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/MessageReplyInfo.h
|
td/telegram/MessageReplyInfo.h
|
||||||
td/telegram/MessageSearchFilter.h
|
td/telegram/MessageSearchFilter.h
|
||||||
td/telegram/MessageSender.h
|
td/telegram/MessageSender.h
|
||||||
|
td/telegram/MessagesInfo.h
|
||||||
td/telegram/MessagesManager.h
|
td/telegram/MessagesManager.h
|
||||||
td/telegram/MessageThreadDb.h
|
td/telegram/MessageThreadDb.h
|
||||||
td/telegram/MessageThreadInfo.h
|
td/telegram/MessageThreadInfo.h
|
||||||
|
21
td/telegram/MessagesInfo.h
Normal file
21
td/telegram/MessagesInfo.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
|
#include "td/utils/common.h"
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
struct MessagesInfo {
|
||||||
|
vector<telegram_api::object_ptr<telegram_api::Message>> messages;
|
||||||
|
int32 total_count = 0;
|
||||||
|
bool is_channel_messages = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace td
|
@ -531,7 +531,7 @@ class GetChannelMessagesQuery final : public Td::ResultHandler {
|
|||||||
td_->messages_manager_->get_channel_difference_if_needed(
|
td_->messages_manager_->get_channel_difference_if_needed(
|
||||||
DialogId(channel_id_), std::move(info),
|
DialogId(channel_id_), std::move(info),
|
||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), source,
|
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), source,
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2122,7 +2122,7 @@ class GetDialogMessageByDateQuery final : public Td::ResultHandler {
|
|||||||
dialog_id_, std::move(info),
|
dialog_id_, std::move(info),
|
||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, date = date_,
|
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, date = date_,
|
||||||
random_id = random_id_,
|
random_id = random_id_,
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2200,7 +2200,7 @@ class GetHistoryQuery final : public Td::ResultHandler {
|
|||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_,
|
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_,
|
||||||
from_message_id = from_message_id_, old_last_new_message_id = old_last_new_message_id_,
|
from_message_id = from_message_id_, old_last_new_message_id = old_last_new_message_id_,
|
||||||
offset = offset_, limit = limit_, from_the_end = from_the_end_,
|
offset = offset_, limit = limit_, from_the_end = from_the_end_,
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2371,7 +2371,7 @@ class GetSearchResultCalendarQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
// unused: inexact:flags.0?true min_date:int min_msg_id:int offset_id_offset:flags.1?int
|
// unused: inexact:flags.0?true min_date:int min_msg_id:int offset_id_offset:flags.1?int
|
||||||
|
|
||||||
MessagesManager::MessagesInfo info;
|
MessagesInfo info;
|
||||||
info.messages = std::move(result->messages_);
|
info.messages = std::move(result->messages_);
|
||||||
info.total_count = result->count_;
|
info.total_count = result->count_;
|
||||||
info.is_channel_messages = dialog_id_.get_type() == DialogType::Channel;
|
info.is_channel_messages = dialog_id_.get_type() == DialogType::Channel;
|
||||||
@ -2381,7 +2381,7 @@ class GetSearchResultCalendarQuery final : public Td::ResultHandler {
|
|||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_,
|
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_,
|
||||||
from_message_id = from_message_id_, filter = filter_, random_id = random_id_,
|
from_message_id = from_message_id_, filter = filter_, random_id = random_id_,
|
||||||
periods = std::move(result->periods_),
|
periods = std::move(result->periods_),
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2588,7 +2588,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
|||||||
query = std::move(query_), sender_dialog_id = sender_dialog_id_,
|
query = std::move(query_), sender_dialog_id = sender_dialog_id_,
|
||||||
from_message_id = from_message_id_, offset = offset_, limit = limit_, filter = filter_,
|
from_message_id = from_message_id_, offset = offset_, limit = limit_, filter = filter_,
|
||||||
top_thread_message_id = top_thread_message_id_, random_id = random_id_,
|
top_thread_message_id = top_thread_message_id_, random_id = random_id_,
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2755,7 +2755,7 @@ class SearchMessagesGlobalQuery final : public Td::ResultHandler {
|
|||||||
offset_date = offset_date_, offset_dialog_id = offset_dialog_id_,
|
offset_date = offset_date_, offset_dialog_id = offset_dialog_id_,
|
||||||
offset_message_id = offset_message_id_, limit = limit_, filter = std::move(filter_),
|
offset_message_id = offset_message_id_, limit = limit_, filter = std::move(filter_),
|
||||||
min_date = min_date_, max_date = max_date_, random_id = random_id_,
|
min_date = min_date_, max_date = max_date_, random_id = random_id_,
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2838,9 +2838,8 @@ class SearchSentMediaQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
auto info = td_->messages_manager_->get_messages_info(DialogId(), result_ptr.move_as_ok(), "SearchSentMediaQuery");
|
auto info = td_->messages_manager_->get_messages_info(DialogId(), result_ptr.move_as_ok(), "SearchSentMediaQuery");
|
||||||
td_->messages_manager_->get_channel_differences_if_needed(
|
td_->messages_manager_->get_channel_differences_if_needed(
|
||||||
std::move(info),
|
std::move(info), PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(),
|
||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(),
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2890,7 +2889,7 @@ class GetRecentLocationsQuery final : public Td::ResultHandler {
|
|||||||
td_->messages_manager_->get_channel_difference_if_needed(
|
td_->messages_manager_->get_channel_difference_if_needed(
|
||||||
dialog_id_, std::move(info),
|
dialog_id_, std::move(info),
|
||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, limit = limit_,
|
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, limit = limit_,
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -2942,9 +2941,8 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler {
|
|||||||
auto info =
|
auto info =
|
||||||
td_->messages_manager_->get_messages_info(DialogId(), result_ptr.move_as_ok(), "GetMessagePublicForwardsQuery");
|
td_->messages_manager_->get_messages_info(DialogId(), result_ptr.move_as_ok(), "GetMessagePublicForwardsQuery");
|
||||||
td_->messages_manager_->get_channel_differences_if_needed(
|
td_->messages_manager_->get_channel_differences_if_needed(
|
||||||
std::move(info),
|
std::move(info), PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(),
|
||||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(),
|
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||||
promise = std::move(promise_)](Result<MessagesManager::MessagesInfo> &&result) mutable {
|
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
promise.set_error(result.move_as_error());
|
promise.set_error(result.move_as_error());
|
||||||
} else {
|
} else {
|
||||||
@ -9800,8 +9798,9 @@ void MessagesManager::on_get_empty_messages(DialogId dialog_id, const vector<Mes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesManager::MessagesInfo MessagesManager::get_messages_info(
|
MessagesInfo MessagesManager::get_messages_info(DialogId dialog_id,
|
||||||
DialogId dialog_id, tl_object_ptr<telegram_api::messages_Messages> &&messages_ptr, const char *source) {
|
tl_object_ptr<telegram_api::messages_Messages> &&messages_ptr,
|
||||||
|
const char *source) {
|
||||||
CHECK(messages_ptr != nullptr);
|
CHECK(messages_ptr != nullptr);
|
||||||
LOG(DEBUG) << "Receive result for " << source << ": " << to_string(messages_ptr);
|
LOG(DEBUG) << "Receive result for " << source << ": " << to_string(messages_ptr);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "td/telegram/MessageReplyHeader.h"
|
#include "td/telegram/MessageReplyHeader.h"
|
||||||
#include "td/telegram/MessageReplyInfo.h"
|
#include "td/telegram/MessageReplyInfo.h"
|
||||||
#include "td/telegram/MessageSearchFilter.h"
|
#include "td/telegram/MessageSearchFilter.h"
|
||||||
|
#include "td/telegram/MessagesInfo.h"
|
||||||
#include "td/telegram/MessageThreadInfo.h"
|
#include "td/telegram/MessageThreadInfo.h"
|
||||||
#include "td/telegram/MessageTtl.h"
|
#include "td/telegram/MessageTtl.h"
|
||||||
#include "td/telegram/net/DcId.h"
|
#include "td/telegram/net/DcId.h"
|
||||||
@ -195,11 +196,6 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids);
|
void on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids);
|
||||||
|
|
||||||
struct MessagesInfo {
|
|
||||||
vector<tl_object_ptr<telegram_api::Message>> messages;
|
|
||||||
int32 total_count = 0;
|
|
||||||
bool is_channel_messages = false;
|
|
||||||
};
|
|
||||||
MessagesInfo get_messages_info(DialogId dialog_id, tl_object_ptr<telegram_api::messages_Messages> &&messages_ptr,
|
MessagesInfo get_messages_info(DialogId dialog_id, tl_object_ptr<telegram_api::messages_Messages> &&messages_ptr,
|
||||||
const char *source);
|
const char *source);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user