diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 32b099045..2c8849868 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -7243,7 +7243,8 @@ getStory user_id:int53 story_id:int32 = Story; //@privacy_rules The privacy rules for the story //@active_period Period after which the story is moved to archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, 2 * 86400, 3 * 86400, or 7 * 86400 for Telegram Premium users, and 86400 otherwise //@is_pinned Pass true to keep the story accessible after expiration -sendStory content:InputStoryContent caption:formattedText privacy_rules:userPrivacySettingRules active_period:int32 is_pinned:Bool = Story; +//@protect_content Pass true if the content of the story must be protected from forwarding and screenshotting +sendStory content:InputStoryContent caption:formattedText privacy_rules:userPrivacySettingRules active_period:int32 is_pinned:Bool protect_content:Bool = Story; //@description Changes content and caption of a previously sent story //@story_id Identifier of the story to edit diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 1e110a156..13ce364f0 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -505,6 +505,9 @@ class StoryManager::SendStoryQuery final : public Td::ResultHandler { if (period != 86400) { flags |= telegram_api::stories_sendStory::PERIOD_MASK; } + if (story->noforwards_) { + flags |= telegram_api::stories_sendStory::NOFORWARDS_MASK; + } send_query(G()->net_query_creator().create( telegram_api::stories_sendStory(flags, false /*ignored*/, false /*ignored*/, std::move(input_media), @@ -2044,7 +2047,8 @@ void StoryManager::do_get_story(StoryFullId story_full_id, Result &&result void StoryManager::send_story(td_api::object_ptr &&input_story_content, td_api::object_ptr &&input_caption, td_api::object_ptr &&rules, int32 active_period, - bool is_pinned, Promise> &&promise) { + bool is_pinned, bool protect_content, + Promise> &&promise) { bool is_bot = td_->auth_manager_->is_bot(); DialogId dialog_id(td_->contacts_manager_->get_my_id()); TRY_RESULT_PROMISE(promise, content, get_input_story_content(td_, std::move(input_story_content), dialog_id)); @@ -2064,6 +2068,7 @@ void StoryManager::send_story(td_api::object_ptr &&in story->date_ = G()->unix_time(); story->expire_date_ = story->date_ + active_period; story->is_pinned_ = is_pinned; + story->noforwards_ = protect_content; story->privacy_rules_ = std::move(privacy_rules); story->content_ = std::move(content); story->caption_ = std::move(caption); diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index d9b21d432..934d446a0 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -104,7 +104,7 @@ class StoryManager final : public Actor { void send_story(td_api::object_ptr &&input_story_content, td_api::object_ptr &&input_caption, td_api::object_ptr &&rules, int32 active_period, bool is_pinned, - Promise> &&promise); + bool protect_content, Promise> &&promise); void on_send_story_file_part_missing(unique_ptr &&pending_story, int bad_part); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 3fed15667..b052476e8 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5631,7 +5631,7 @@ void Td::on_request(uint64 id, td_api::sendStory &request) { CREATE_REQUEST_PROMISE(); story_manager_->send_story(std::move(request.content_), std::move(request.caption_), std::move(request.privacy_rules_), request.active_period_, request.is_pinned_, - std::move(promise)); + request.protect_content_, std::move(promise)); } void Td::on_request(uint64 id, td_api::editStory &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 2caf2e10c..d21bd11c8 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3979,11 +3979,12 @@ class CliClient final : public Actor { PrivacyRules rules; int32 active_period; string sticker_file_ids; - get_args(args, photo, caption, rules, active_period, sticker_file_ids); + bool protect_content; + get_args(args, photo, caption, rules, active_period, sticker_file_ids, protect_content); send_request(td_api::make_object( td_api::make_object(as_input_file(photo), to_integers(sticker_file_ids)), - as_caption(caption), rules, active_period ? active_period : 86400, op == "sspp")); + as_caption(caption), rules, active_period ? active_period : 86400, op == "sspp", protect_content)); } else if (op == "ssv" || op == "ssvp") { string video; string caption; @@ -3991,11 +3992,12 @@ class CliClient final : public Actor { int32 active_period; double duration; string sticker_file_ids; - get_args(args, video, caption, rules, active_period, duration, sticker_file_ids); + bool protect_content; + get_args(args, video, caption, rules, active_period, duration, sticker_file_ids, protect_content); send_request(td_api::make_object( td_api::make_object(as_input_file(video), to_integers(sticker_file_ids), duration, true), - as_caption(caption), rules, active_period ? active_period : 86400, op == "ssvp")); + as_caption(caption), rules, active_period ? active_period : 86400, op == "ssvp", protect_content)); } else if (op == "esc") { StoryId story_id; string caption;