From 6b6d9e509b328ed61ee53208f234eb4c6a2f2f22 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 4 Dec 2019 21:52:53 +0300 Subject: [PATCH] Add limit to get_scheduled_messages. GitOrigin-RevId: e49616784f920b526611ac44dd7c5c5d7b599318 --- td/telegram/MessagesDb.cpp | 12 ++++++------ td/telegram/MessagesDb.h | 4 ++-- td/telegram/MessagesManager.cpp | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/td/telegram/MessagesDb.cpp b/td/telegram/MessagesDb.cpp index cfb934ba0..f1986f929 100644 --- a/td/telegram/MessagesDb.cpp +++ b/td/telegram/MessagesDb.cpp @@ -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); } - Result> get_scheduled_messages(DialogId dialog_id) override { - return get_messages_inner(get_scheduled_messages_stmt_, dialog_id, std::numeric_limits::max(), 1000); + Result> get_scheduled_messages(DialogId dialog_id, int32 limit) override { + return get_messages_inner(get_scheduled_messages_stmt_, dialog_id, std::numeric_limits::max(), limit); } Result> 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> promise) override { send_closure_later(impl_, &Impl::get_messages, std::move(query), std::move(promise)); } - void get_scheduled_messages(DialogId dialog_id, Promise> promise) override { - send_closure_later(impl_, &Impl::get_scheduled_messages, dialog_id, std::move(promise)); + void get_scheduled_messages(DialogId dialog_id, int32 limit, Promise> promise) override { + 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, Promise> promise) override { @@ -1068,9 +1068,9 @@ class MessagesDbAsync : public MessagesDbAsyncInterface { add_read_query(); promise.set_result(sync_db_->get_messages(std::move(query))); } - void get_scheduled_messages(DialogId dialog_id, Promise> promise) { + void get_scheduled_messages(DialogId dialog_id, int32 limit, Promise> promise) { 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, Promise> promise) { diff --git a/td/telegram/MessagesDb.h b/td/telegram/MessagesDb.h index 5ac677522..599b00470 100644 --- a/td/telegram/MessagesDb.h +++ b/td/telegram/MessagesDb.h @@ -105,7 +105,7 @@ class MessagesDbSyncInterface { MessageId last_message_id, int32 date) = 0; virtual Result> get_messages(MessagesDbMessagesQuery query) = 0; - virtual Result> get_scheduled_messages(DialogId dialog_id) = 0; + virtual Result> get_scheduled_messages(DialogId dialog_id, int32 limit) = 0; virtual Result> get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit) = 0; @@ -153,7 +153,7 @@ class MessagesDbAsyncInterface { int32 date, Promise promise) = 0; virtual void get_messages(MessagesDbMessagesQuery query, Promise> promise) = 0; - virtual void get_scheduled_messages(DialogId dialog_id, Promise> promise) = 0; + virtual void get_scheduled_messages(DialogId dialog_id, int32 limit, Promise> promise) = 0; virtual void get_messages_from_notification_id(DialogId dialog_id, NotificationId from_notification_id, int32 limit, Promise> promise) = 0; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 65b567d61..405370055 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -16896,7 +16896,8 @@ void MessagesManager::load_dialog_scheduled_messages(DialogId dialog_id, bool fr queries.push_back(std::move(promise)); if (queries.size() == 1) { G()->td_db()->get_messages_db_async()->get_scheduled_messages( - dialog_id, PromiseCreator::lambda([dialog_id, actor_id = actor_id(this)](std::vector messages) { + dialog_id, 1000, + PromiseCreator::lambda([dialog_id, actor_id = actor_id(this)](std::vector messages) { send_closure(actor_id, &MessagesManager::on_get_scheduled_messages_from_database, dialog_id, std::move(messages)); }));