Always allow to get viewers of stories with reaction.

This commit is contained in:
levlam 2023-08-14 00:37:39 +03:00
parent 03c8bf0cd3
commit a867badcaf
2 changed files with 9 additions and 1 deletions

View File

@ -58,6 +58,10 @@ class StoryInteractionInfo {
return view_count_; return view_count_;
} }
int32 get_reaction_count() const {
return reaction_count_;
}
bool definitely_has_no_user(UserId user_id) const; bool definitely_has_no_user(UserId user_id) const;
bool set_recent_viewer_user_ids(vector<UserId> &&user_ids); bool set_recent_viewer_user_ids(vector<UserId> &&user_ids);

View File

@ -1292,6 +1292,7 @@ void StoryManager::on_story_can_get_viewers_timeout(int64 story_global_id) {
LOG(INFO) << "Have expired viewers in " << story_full_id; LOG(INFO) << "Have expired viewers in " << story_full_id;
if (can_get_story_viewers(story_full_id, story, true).is_ok()) { if (can_get_story_viewers(story_full_id, story, true).is_ok()) {
// timeout used monotonic time instead of wall clock time // timeout used monotonic time instead of wall clock time
// also a reaction could have been added on the story
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();
@ -2424,6 +2425,9 @@ Status StoryManager::can_get_story_viewers(StoryFullId story_full_id, const Stor
if (!story_full_id.get_story_id().is_server()) { if (!story_full_id.get_story_id().is_server()) {
return Status::Error(400, "Story is not sent yet"); return Status::Error(400, "Story is not sent yet");
} }
if (story->interaction_info_.get_reaction_count() > 0) {
return Status::OK();
}
if (G()->unix_time() >= get_story_viewers_expire_date(story) && if (G()->unix_time() >= get_story_viewers_expire_date(story) &&
(ignore_premium || story->interaction_info_.has_hidden_viewers())) { (ignore_premium || story->interaction_info_.has_hidden_viewers())) {
return Status::Error(400, "Story is too old"); return Status::Error(400, "Story is too old");
@ -3103,7 +3107,7 @@ void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *stor
CHECK(story->global_id_ > 0); CHECK(story->global_id_ > 0);
story_expire_timeout_.set_timeout_in(story->global_id_, story->expire_date_ - G()->unix_time()); 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()) { if (can_get_story_viewers(story_full_id, story, true).is_ok() && story->interaction_info_.get_reaction_count() == 0) {
CHECK(story->global_id_ > 0); CHECK(story->global_id_ > 0);
story_can_get_viewers_timeout_.set_timeout_in(story->global_id_, story_can_get_viewers_timeout_.set_timeout_in(story->global_id_,
get_story_viewers_expire_date(story) - G()->unix_time() + 2); get_story_viewers_expire_date(story) - G()->unix_time() + 2);