Add Story.is_edited flag.

This commit is contained in:
levlam 2023-06-29 15:15:12 +03:00
parent b8849a2f81
commit cec0ab47b5
3 changed files with 15 additions and 7 deletions

View File

@ -4936,6 +4936,7 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector<int53> = Sto
//@id Unique story identifier among stories of the given sender //@id Unique story identifier among stories of the given sender
//@sender_chat_id Identifier of the chat that posted the story //@sender_chat_id Identifier of the chat that posted the story
//@date Point in time (Unix timestamp) when the story was published //@date Point in time (Unix timestamp) when the story was published
//@is_edited True, if the story was edited
//@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration //@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration
//@is_visible_only_for_self True, if the story is visible only for the current user //@is_visible_only_for_self True, if the story is visible only for the current user
//@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_forwarded True, if the story can be forwarded as a message. Otherwise, screenshots and saving of the story content must be also forbidden
@ -4945,7 +4946,7 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector<int53> = Sto
//@privacy_rules Privacy rules affecting story visibility; may be null if the story isn't owned //@privacy_rules Privacy rules affecting story visibility; may be null if the story isn't owned
//@content Content of the story //@content Content of the story
//@caption Caption of the story //@caption Caption of the story
story id:int32 sender_chat_id:int53 date:int32 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 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 //@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; stories total_count:int32 stories:vector<story> = Stories;

View File

@ -1567,6 +1567,8 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
privacy_rules = story->privacy_rules_.get_user_privacy_setting_rules_object(td_); privacy_rules = story->privacy_rules_.get_user_privacy_setting_rules_object(td_);
} }
bool is_edited = story->is_edited_;
auto *content = story->content_.get(); auto *content = story->content_.get();
auto *caption = &story->caption_; auto *caption = &story->caption_;
if (is_owned && story_full_id.get_story_id().is_server()) { if (is_owned && story_full_id.get_story_id().is_server()) {
@ -1578,6 +1580,7 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
if (it->second->edit_caption_) { if (it->second->edit_caption_) {
caption = &it->second->caption_; caption = &it->second->caption_;
} }
is_edited = true;
} }
} }
@ -1594,7 +1597,7 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
return td_api::make_object<td_api::story>( 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_full_id.get_story_id().get(), td_->messages_manager_->get_chat_id_object(dialog_id, "get_story_object"),
story->date_, story->is_pinned_, is_visible_only_for_self, can_be_forwarded, can_be_replied, story->date_, story->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(), can_get_story_viewers(story_full_id, story).is_ok(),
story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules), story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
get_story_content_object(td_, content), get_story_content_object(td_, content),
@ -1760,9 +1763,11 @@ StoryId StoryManager::on_get_new_story(DialogId owner_dialog_id,
change_story_files(story_full_id, story, old_file_ids); change_story_files(story_full_id, story, old_file_ids);
} }
if (story->is_pinned_ != story_item->pinned_ || story->is_public_ != story_item->public_ || if (story->is_edited_ != story_item->edited_ || story->is_pinned_ != story_item->pinned_ ||
story->is_for_close_friends_ != story_item->close_friends_ || story->noforwards_ != story_item->noforwards_ || story->is_public_ != story_item->public_ || story->is_for_close_friends_ != story_item->close_friends_ ||
story->date_ != story_item->date_ || story->expire_date_ != story_item->expire_date_) { story->noforwards_ != story_item->noforwards_ || story->date_ != story_item->date_ ||
story->expire_date_ != story_item->expire_date_) {
story->is_edited_ = story_item->edited_;
story->is_pinned_ = story_item->pinned_; story->is_pinned_ = story_item->pinned_;
story->is_public_ = story_item->public_; story->is_public_ = story_item->public_;
story->is_for_close_friends_ = story_item->close_friends_; story->is_for_close_friends_ = story_item->close_friends_;
@ -2504,8 +2509,9 @@ void StoryManager::on_story_edited(FileId file_id, unique_ptr<PendingStory> pend
binlog_erase(G()->td_db()->get_binlog(), pending_story->log_event_id_); binlog_erase(G()->td_db()->get_binlog(), pending_story->log_event_id_);
} }
auto promises = std::move(it->second->promises_); auto promises = std::move(it->second->promises_);
bool is_changed = bool is_changed = it->second->content_ != nullptr ||
it->second->content_ != nullptr || (it->second->edit_caption_ && it->second->caption_ != story->caption_); (it->second->edit_caption_ && it->second->caption_ != story->caption_) ||
(result.is_error() && !story->is_edited_);
being_edited_stories_.erase(it); being_edited_stories_.erase(it);
on_story_changed(story_full_id, story, is_changed, true); on_story_changed(story_full_id, story, is_changed, true);

View File

@ -43,6 +43,7 @@ class StoryManager final : public Actor {
int32 date_ = 0; int32 date_ = 0;
int32 expire_date_ = 0; int32 expire_date_ = 0;
int32 receive_date_ = 0; int32 receive_date_ = 0;
bool is_edited_ = false;
bool is_pinned_ = false; bool is_pinned_ = false;
bool is_public_ = false; bool is_public_ = false;
bool is_for_close_friends_ = false; bool is_for_close_friends_ = false;