Add parameter force to get_dialog_scheduled_messages.

GitOrigin-RevId: 1876be0d4de852aa3508810c491e3bb073ae0384
This commit is contained in:
levlam 2020-02-27 21:31:19 +03:00
parent fe462698bc
commit 5fef27af1b
3 changed files with 10 additions and 8 deletions

View File

@ -17432,7 +17432,8 @@ void MessagesManager::load_messages(DialogId dialog_id, MessageId from_message_i
get_history(dialog_id, from_message_id, offset, limit, from_database, only_local, std::move(promise));
}
vector<MessageId> MessagesManager::get_dialog_scheduled_messages(DialogId dialog_id, Promise<Unit> &&promise) {
vector<MessageId> MessagesManager::get_dialog_scheduled_messages(DialogId dialog_id, bool force,
Promise<Unit> &&promise) {
LOG(INFO) << "Get scheduled messages in " << dialog_id;
if (G()->close_flag()) {
promise.set_error(Status::Error(500, "Request aborted"));
@ -17492,8 +17493,8 @@ vector<MessageId> MessagesManager::get_dialog_scheduled_messages(DialogId dialog
}
auto hash = get_vector_hash(numbers);
if (d->has_scheduled_server_messages ||
(d->scheduled_messages_sync_generation == 0 && !G()->parameters().use_message_db)) {
if (!force && (d->has_scheduled_server_messages ||
(d->scheduled_messages_sync_generation == 0 && !G()->parameters().use_message_db))) {
load_dialog_scheduled_messages(dialog_id, false, hash, std::move(promise));
return {};
}
@ -23679,9 +23680,9 @@ void MessagesManager::repair_dialog_scheduled_messages(DialogId dialog_id) {
// TODO create logevent
LOG(INFO) << "Repair scheduled messages in " << dialog_id;
get_dialog_scheduled_messages(dialog_id, PromiseCreator::lambda([actor_id = actor_id(this), dialog_id](Unit) {
get_dialog_scheduled_messages(dialog_id, false, PromiseCreator::lambda([actor_id = actor_id(this), dialog_id](Unit) {
send_closure(G()->messages_manager(), &MessagesManager::get_dialog_scheduled_messages,
dialog_id, Promise<Unit>());
dialog_id, true, Promise<Unit>());
}));
}

View File

@ -646,7 +646,7 @@ class MessagesManager : public Actor {
int32 get_dialog_message_count(DialogId dialog_id, const tl_object_ptr<td_api::SearchMessagesFilter> &filter,
bool return_local, int64 &random_id, Promise<Unit> &&promise);
vector<MessageId> get_dialog_scheduled_messages(DialogId dialog_id, Promise<Unit> &&promise);
vector<MessageId> get_dialog_scheduled_messages(DialogId dialog_id, bool force, Promise<Unit> &&promise);
tl_object_ptr<td_api::message> get_dialog_message_by_date_object(int64 random_id);

View File

@ -1616,7 +1616,8 @@ class GetChatScheduledMessagesRequest : public RequestActor<> {
vector<MessageId> message_ids_;
void do_run(Promise<Unit> &&promise) override {
message_ids_ = td->messages_manager_->get_dialog_scheduled_messages(dialog_id_, std::move(promise));
message_ids_ =
td->messages_manager_->get_dialog_scheduled_messages(dialog_id_, get_tries() < 2, std::move(promise));
}
void do_send_result() override {
@ -1626,7 +1627,7 @@ class GetChatScheduledMessagesRequest : public RequestActor<> {
public:
GetChatScheduledMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id) {
set_tries(3);
set_tries(4);
}
};