Reload chats to send stories once a day.

This commit is contained in:
levlam 2023-09-27 13:31:09 +03:00
parent a4016cef70
commit bb8070ed44
2 changed files with 11 additions and 0 deletions

View File

@ -1506,6 +1506,11 @@ void StoryManager::start_up() {
void StoryManager::timeout_expired() {
load_expired_database_stories();
if (channels_to_send_stories_inited_ && get_dialogs_to_send_stories_queries_.empty() &&
Time::now() > next_reload_channels_to_send_stories_time_ && !td_->auth_manager_->is_bot()) {
reload_dialogs_to_send_stories(Auto());
}
}
void StoryManager::hangup() {
@ -1630,6 +1635,9 @@ void StoryManager::on_story_can_get_viewers_timeout(int64 story_global_id) {
void StoryManager::load_expired_database_stories() {
if (!G()->use_message_database()) {
if (!td_->auth_manager_->is_bot()) {
set_timeout_in(Random::fast(300, 420));
}
return;
}
@ -4666,6 +4674,8 @@ void StoryManager::finish_get_dialogs_to_send_stories(Result<Unit> &&result) {
return fail_promises(promises, result.move_as_error());
}
next_reload_channels_to_send_stories_time_ = Time::now() + 86400;
CHECK(channels_to_send_stories_inited_);
for (auto &promise : promises) {
return_dialogs_to_send_stories(std::move(promise), channels_to_send_stories_);

View File

@ -675,6 +675,7 @@ class StoryManager final : public Actor {
bool channels_to_send_stories_inited_ = false;
vector<ChannelId> channels_to_send_stories_;
vector<Promise<td_api::object_ptr<td_api::chats>>> get_dialogs_to_send_stories_queries_;
double next_reload_channels_to_send_stories_time_ = 0.0;
FlatHashMap<StoryFullId, int32, StoryFullIdHash> being_set_story_reactions_;