Add sendStory.protect_content.

This commit is contained in:
levlam 2023-06-27 17:19:10 +03:00
parent 7571f90a98
commit 47d30cc7dc
5 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -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<Unit> &&result
void StoryManager::send_story(td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
td_api::object_ptr<td_api::formattedText> &&input_caption,
td_api::object_ptr<td_api::userPrivacySettingRules> &&rules, int32 active_period,
bool is_pinned, Promise<td_api::object_ptr<td_api::story>> &&promise) {
bool is_pinned, bool protect_content,
Promise<td_api::object_ptr<td_api::story>> &&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<td_api::InputStoryContent> &&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);

View File

@ -104,7 +104,7 @@ class StoryManager final : public Actor {
void send_story(td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
td_api::object_ptr<td_api::formattedText> &&input_caption,
td_api::object_ptr<td_api::userPrivacySettingRules> &&rules, int32 active_period, bool is_pinned,
Promise<td_api::object_ptr<td_api::story>> &&promise);
bool protect_content, Promise<td_api::object_ptr<td_api::story>> &&promise);
void on_send_story_file_part_missing(unique_ptr<PendingStory> &&pending_story, int bad_part);

View File

@ -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) {

View File

@ -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::sendStory>(
td_api::make_object<td_api::inputStoryContentPhoto>(as_input_file(photo),
to_integers<int32>(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::sendStory>(
td_api::make_object<td_api::inputStoryContentVideo>(as_input_file(video),
to_integers<int32>(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;