Add story.has_expired_viewers.

This commit is contained in:
levlam 2023-07-08 09:32:30 +03:00
parent 5819c049a3
commit 186f496a54
2 changed files with 9 additions and 7 deletions

View File

@ -4946,11 +4946,12 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector<int53> = Sto
//@can_be_forwarded True, if the story can be forwarded as a message. Otherwise, screenshots and saving of the story content must be also forbidden
//@can_be_replied True, if the story can be replied in the chat with the story sender
//@can_get_viewers True, if users viewed the story can be received through getStoryViewers
//@has_expired_viewers True, if users viewed the story can't be received, because the story has expired more than getOption("story_viewers_expiration_delay") seconds ago
//@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions
//@privacy_rules Privacy rules affecting story visibility; may be null if the story isn't owned
//@content Content of the story
//@caption Caption of the story
story id:int32 sender_chat_id:int53 date:int32 is_edited:Bool is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded:Bool can_be_replied:Bool can_get_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story;
story id:int32 sender_chat_id:int53 date:int32 is_edited:Bool is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded:Bool can_be_replied:Bool can_get_viewers:Bool has_expired_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story;
//@description Represents a list of stories @total_count Approximate total number of stories found @stories The list of stories
stories total_count:int32 stories:vector<story> = Stories;

View File

@ -1802,9 +1802,10 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
bool is_edited = story->is_edited_;
auto story_id = story_full_id.get_story_id();
auto *content = story->content_.get();
auto *caption = &story->caption_;
if (is_owned && story_full_id.get_story_id().is_server()) {
if (is_owned && story_id.is_server()) {
auto it = being_edited_stories_.find(story_full_id);
if (it != being_edited_stories_.end()) {
if (it->second->content_ != nullptr) {
@ -1817,7 +1818,6 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
}
}
auto story_id = story_full_id.get_story_id();
auto changelog_dialog_id = get_changelog_story_dialog_id();
bool is_visible_only_for_self =
!story_id.is_server() || dialog_id == changelog_dialog_id || (!story->is_pinned_ && !is_active_story(story));
@ -1825,14 +1825,15 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
privacy_rules->rules_.size() == 1u &&
privacy_rules->rules_[0]->get_id() == td_api::userPrivacySettingRuleAllowAll::ID;
bool can_be_replied = story_id.is_server() && dialog_id != changelog_dialog_id;
bool can_get_viewers = can_get_story_viewers(story_full_id, story).is_ok();
bool has_expired_viewers = !can_get_viewers && is_story_owned(dialog_id) && story_id.is_server();
story->is_update_sent_ = true;
return td_api::make_object<td_api::story>(
story_full_id.get_story_id().get(), td_->messages_manager_->get_chat_id_object(dialog_id, "get_story_object"),
story->date_, is_edited, story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied,
can_get_story_viewers(story_full_id, story).is_ok(),
story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
story_id.get(), td_->messages_manager_->get_chat_id_object(dialog_id, "get_story_object"), story->date_,
is_edited, story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied, can_get_viewers,
has_expired_viewers, story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
get_story_content_object(td_, content),
get_formatted_text_object(*caption, true, get_story_content_duration(td_, content)));
}