Add limit to get_scheduled_messages.

GitOrigin-RevId: e49616784f920b526611ac44dd7c5c5d7b599318
This commit is contained in:
levlam 2019-12-04 21:52:53 +03:00
parent 4b3c36e924
commit 6b6d9e509b
3 changed files with 10 additions and 9 deletions

View File

@ -587,8 +587,8 @@ class MessagesDbImpl : public MessagesDbSyncInterface {
return get_messages_impl(get_messages_stmt_, query.dialog_id, query.from_message_id, query.offset, query.limit); return get_messages_impl(get_messages_stmt_, query.dialog_id, query.from_message_id, query.offset, query.limit);
} }
Result<std::vector<BufferSlice>> get_scheduled_messages(DialogId dialog_id) override { Result<std::vector<BufferSlice>> get_scheduled_messages(DialogId dialog_id, int32 limit) override {
return get_messages_inner(get_scheduled_messages_stmt_, dialog_id, std::numeric_limits<int64>::max(), 1000); return get_messages_inner(get_scheduled_messages_stmt_, dialog_id, std::numeric_limits<int64>::max(), limit);
} }
Result<vector<BufferSlice>> get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, Result<vector<BufferSlice>> get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id,
@ -979,8 +979,8 @@ class MessagesDbAsync : public MessagesDbAsyncInterface {
void get_messages(MessagesDbMessagesQuery query, Promise<std::vector<BufferSlice>> promise) override { void get_messages(MessagesDbMessagesQuery query, Promise<std::vector<BufferSlice>> promise) override {
send_closure_later(impl_, &Impl::get_messages, std::move(query), std::move(promise)); send_closure_later(impl_, &Impl::get_messages, std::move(query), std::move(promise));
} }
void get_scheduled_messages(DialogId dialog_id, Promise<std::vector<BufferSlice>> promise) override { void get_scheduled_messages(DialogId dialog_id, int32 limit, Promise<std::vector<BufferSlice>> promise) override {
send_closure_later(impl_, &Impl::get_scheduled_messages, dialog_id, std::move(promise)); send_closure_later(impl_, &Impl::get_scheduled_messages, dialog_id, limit, std::move(promise));
} }
void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit, void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit,
Promise<vector<BufferSlice>> promise) override { Promise<vector<BufferSlice>> promise) override {
@ -1068,9 +1068,9 @@ class MessagesDbAsync : public MessagesDbAsyncInterface {
add_read_query(); add_read_query();
promise.set_result(sync_db_->get_messages(std::move(query))); promise.set_result(sync_db_->get_messages(std::move(query)));
} }
void get_scheduled_messages(DialogId dialog_id, Promise<std::vector<BufferSlice>> promise) { void get_scheduled_messages(DialogId dialog_id, int32 limit, Promise<std::vector<BufferSlice>> promise) {
add_read_query(); add_read_query();
promise.set_result(sync_db_->get_scheduled_messages(dialog_id)); promise.set_result(sync_db_->get_scheduled_messages(dialog_id, limit));
} }
void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit, void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit,
Promise<vector<BufferSlice>> promise) { Promise<vector<BufferSlice>> promise) {

View File

@ -105,7 +105,7 @@ class MessagesDbSyncInterface {
MessageId last_message_id, int32 date) = 0; MessageId last_message_id, int32 date) = 0;
virtual Result<std::vector<BufferSlice>> get_messages(MessagesDbMessagesQuery query) = 0; virtual Result<std::vector<BufferSlice>> get_messages(MessagesDbMessagesQuery query) = 0;
virtual Result<std::vector<BufferSlice>> get_scheduled_messages(DialogId dialog_id) = 0; virtual Result<std::vector<BufferSlice>> get_scheduled_messages(DialogId dialog_id, int32 limit) = 0;
virtual Result<vector<BufferSlice>> get_messages_from_notification_id(DialogId dialog_id, virtual Result<vector<BufferSlice>> get_messages_from_notification_id(DialogId dialog_id,
NotificationId from_notification_id, NotificationId from_notification_id,
int32 limit) = 0; int32 limit) = 0;
@ -153,7 +153,7 @@ class MessagesDbAsyncInterface {
int32 date, Promise<BufferSlice> promise) = 0; int32 date, Promise<BufferSlice> promise) = 0;
virtual void get_messages(MessagesDbMessagesQuery query, Promise<std::vector<BufferSlice>> promise) = 0; virtual void get_messages(MessagesDbMessagesQuery query, Promise<std::vector<BufferSlice>> promise) = 0;
virtual void get_scheduled_messages(DialogId dialog_id, Promise<std::vector<BufferSlice>> promise) = 0; virtual void get_scheduled_messages(DialogId dialog_id, int32 limit, Promise<std::vector<BufferSlice>> promise) = 0;
virtual void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit, virtual void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit,
Promise<vector<BufferSlice>> promise) = 0; Promise<vector<BufferSlice>> promise) = 0;

View File

@ -16896,7 +16896,8 @@ void MessagesManager::load_dialog_scheduled_messages(DialogId dialog_id, bool fr
queries.push_back(std::move(promise)); queries.push_back(std::move(promise));
if (queries.size() == 1) { if (queries.size() == 1) {
G()->td_db()->get_messages_db_async()->get_scheduled_messages( G()->td_db()->get_messages_db_async()->get_scheduled_messages(
dialog_id, PromiseCreator::lambda([dialog_id, actor_id = actor_id(this)](std::vector<BufferSlice> messages) { dialog_id, 1000,
PromiseCreator::lambda([dialog_id, actor_id = actor_id(this)](std::vector<BufferSlice> messages) {
send_closure(actor_id, &MessagesManager::on_get_scheduled_messages_from_database, dialog_id, send_closure(actor_id, &MessagesManager::on_get_scheduled_messages_from_database, dialog_id,
std::move(messages)); std::move(messages));
})); }));