Add Story.can_be_forwarded.

This commit is contained in:
levlam 2023-06-27 17:16:22 +03:00
parent 288043556b
commit 7571f90a98
3 changed files with 14 additions and 6 deletions

View File

@ -2928,7 +2928,7 @@ inputMessageInvoice invoice:invoice title:string description:string photo_url:st
//@is_closed True, if the poll needs to be sent already closed; for bots only //@is_closed True, if the poll needs to be sent already closed; for bots only
inputMessagePoll question:string options:vector<string> is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = InputMessageContent; inputMessagePoll question:string options:vector<string> is_anonymous:Bool type:PollType open_period:int32 close_date:int32 is_closed:Bool = InputMessageContent;
//@description A message with a forwarded story. Stories can't be sent to secret chats. A story can be forwarded only if its privacy rules contains exactly one rule userPrivacySettingRuleAllowAll //@description A message with a forwarded story. Stories can't be sent to secret chats. A story can be forwarded only story.can_be_forwarded
//@story_sender_user_id Identifier of the user that created the story //@story_sender_user_id Identifier of the user that created the story
//@story_id Story identifier //@story_id Story identifier
inputMessageStory story_sender_user_id:int53 story_id:int32 = InputMessageContent; inputMessageStory story_sender_user_id:int53 story_id:int32 = InputMessageContent;
@ -4924,12 +4924,13 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector<int53> = Sto
//@date Point in time (Unix timestamp) when the story was published //@date Point in time (Unix timestamp) when the story was published
//@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 of the story must be also forbidden
//@can_get_viewers True, users viewed the story can be received through getStoryViewers //@can_get_viewers True, users viewed the story can be received through getStoryViewers
//@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions //@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions
//@privacy_rules Pryvacy rules affecting story visibility; may be null if the story isn't owned //@privacy_rules Pryvacy 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_user_id:int53 date:int32 is_pinned:Bool is_visible_only_for_self:Bool can_get_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story; story id:int32 sender_user_id:int53 date:int32 is_pinned:Bool is_visible_only_for_self:Bool can_be_forwarded: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

@ -1406,9 +1406,13 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
} }
} }
bool is_visible_only_for_self = !story_full_id.get_story_id().is_server() || auto story_id = story_full_id.get_story_id();
bool is_visible_only_for_self = !story_id.is_server() ||
dialog_id == DialogId(ContactsManager::get_service_notifications_user_id()) || dialog_id == DialogId(ContactsManager::get_service_notifications_user_id()) ||
(!story->is_pinned_ && !is_active_story(story)); (!story->is_pinned_ && !is_active_story(story));
bool can_be_forwarded = !story->noforwards_ && story_id.is_server() && privacy_rules != nullptr &&
privacy_rules->rules_.size() == 1u &&
privacy_rules->rules_[0]->get_id() == td_api::userPrivacySettingRuleAllowAll::ID;
story->is_update_sent_ = true; story->is_update_sent_ = true;
@ -1416,7 +1420,8 @@ 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(), story_full_id.get_story_id().get(),
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "get_story_object"), story->date_, td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "get_story_object"), story->date_,
story->is_pinned_, is_visible_only_for_self, can_get_story_viewers(story_full_id, story).is_ok(), story->is_pinned_, is_visible_only_for_self, can_be_forwarded,
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),
get_formatted_text_object(story->caption_, true, get_story_content_duration(td_, content))); get_formatted_text_object(story->caption_, true, get_story_content_duration(td_, content)));
@ -1570,11 +1575,12 @@ StoryId StoryManager::on_get_story(DialogId owner_dialog_id,
} }
if (story->is_pinned_ != story_item->pinned_ || story->is_public_ != story_item->public_ || if (story->is_pinned_ != story_item->pinned_ || story->is_public_ != story_item->public_ ||
story->is_for_close_friends_ != story_item->close_friends_ || story->date_ != story_item->date_ || story->is_for_close_friends_ != story_item->close_friends_ || story->noforwards_ != story_item->noforwards_ ||
story->expire_date_ != story_item->expire_date_) { story->date_ != story_item->date_ || story->expire_date_ != story_item->expire_date_) {
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_;
story->noforwards_ = story_item->noforwards_;
story->date_ = story_item->date_; story->date_ = story_item->date_;
story->expire_date_ = story_item->expire_date_; story->expire_date_ = story_item->expire_date_;
is_changed = true; is_changed = true;

View File

@ -46,6 +46,7 @@ class StoryManager final : public Actor {
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;
bool noforwards_ = false;
mutable bool is_update_sent_ = false; // whether the story is known to the app mutable bool is_update_sent_ = false; // whether the story is known to the app
StoryInteractionInfo interaction_info_; StoryInteractionInfo interaction_info_;
UserPrivacySettingRules privacy_rules_; UserPrivacySettingRules privacy_rules_;