Explicitly restart timeout.
This commit is contained in:
parent
93d17802e3
commit
7b9abf3eca
@ -1580,7 +1580,7 @@ void StoryManager::on_story_expire_timeout(int64 story_global_id) {
|
|||||||
// timeout used monotonic time instead of wall clock time
|
// timeout used monotonic time instead of wall clock time
|
||||||
LOG(INFO) << "Receive timeout for non-expired " << story_full_id << ": expire_date = " << story->expire_date_
|
LOG(INFO) << "Receive timeout for non-expired " << story_full_id << ": expire_date = " << story->expire_date_
|
||||||
<< ", current time = " << G()->unix_time();
|
<< ", current time = " << G()->unix_time();
|
||||||
return on_story_changed(story_full_id, story, false, false);
|
return set_story_expire_timeout(story);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Have expired " << story_full_id;
|
LOG(INFO) << "Have expired " << story_full_id;
|
||||||
@ -1626,7 +1626,7 @@ void StoryManager::on_story_can_get_viewers_timeout(int64 story_global_id) {
|
|||||||
LOG(INFO) << "Receive timeout for " << story_full_id
|
LOG(INFO) << "Receive timeout for " << story_full_id
|
||||||
<< " with available viewers: expire_date = " << story->expire_date_
|
<< " with available viewers: expire_date = " << story->expire_date_
|
||||||
<< ", current time = " << G()->unix_time();
|
<< ", current time = " << G()->unix_time();
|
||||||
return on_story_changed(story_full_id, story, false, false);
|
return set_story_can_get_viewers_timeout(story);
|
||||||
}
|
}
|
||||||
|
|
||||||
// can_get_viewers flag could have been changed; reload the story to repair it
|
// can_get_viewers flag could have been changed; reload the story to repair it
|
||||||
@ -3762,19 +3762,27 @@ void StoryManager::delete_story_from_database(StoryFullId story_full_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StoryManager::set_story_expire_timeout(const Story *story) {
|
||||||
|
CHECK(story->global_id_ > 0);
|
||||||
|
story_expire_timeout_.set_timeout_in(story->global_id_, story->expire_date_ - G()->unix_time());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StoryManager::set_story_can_get_viewers_timeout(const Story *story) {
|
||||||
|
CHECK(story->global_id_ > 0);
|
||||||
|
story_can_get_viewers_timeout_.set_timeout_in(story->global_id_,
|
||||||
|
get_story_viewers_expire_date(story) - G()->unix_time() + 2);
|
||||||
|
}
|
||||||
|
|
||||||
void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed,
|
void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed,
|
||||||
bool need_save_to_database, bool from_database) {
|
bool need_save_to_database, bool from_database) {
|
||||||
if (!story_full_id.get_story_id().is_server()) {
|
if (!story_full_id.get_story_id().is_server()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_active_story(story)) {
|
if (is_active_story(story)) {
|
||||||
CHECK(story->global_id_ > 0);
|
set_story_expire_timeout(story);
|
||||||
story_expire_timeout_.set_timeout_in(story->global_id_, story->expire_date_ - G()->unix_time());
|
|
||||||
}
|
}
|
||||||
if (can_get_story_viewers(story_full_id, story, true).is_ok() && story->interaction_info_.get_reaction_count() == 0) {
|
if (can_get_story_viewers(story_full_id, story, true).is_ok()) {
|
||||||
CHECK(story->global_id_ > 0);
|
set_story_can_get_viewers_timeout(story);
|
||||||
story_can_get_viewers_timeout_.set_timeout_in(story->global_id_,
|
|
||||||
get_story_viewers_expire_date(story) - G()->unix_time() + 2);
|
|
||||||
}
|
}
|
||||||
if (story->content_ == nullptr) {
|
if (story->content_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -435,6 +435,10 @@ class StoryManager final : public Actor {
|
|||||||
ActiveStories *on_get_active_stories_from_database(StoryListId story_list_id, DialogId owner_dialog_id,
|
ActiveStories *on_get_active_stories_from_database(StoryListId story_list_id, DialogId owner_dialog_id,
|
||||||
const BufferSlice &value, const char *source);
|
const BufferSlice &value, const char *source);
|
||||||
|
|
||||||
|
void set_story_expire_timeout(const Story *story);
|
||||||
|
|
||||||
|
void set_story_can_get_viewers_timeout(const Story *story);
|
||||||
|
|
||||||
void on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed, bool need_save_to_database,
|
void on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed, bool need_save_to_database,
|
||||||
bool from_database = false);
|
bool from_database = false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user