Add getStory.only_local.

This commit is contained in:
levlam 2023-07-11 12:29:10 +03:00
parent 53ea5b0fa1
commit 4b3de26c0c
5 changed files with 15 additions and 7 deletions

View File

@ -7263,8 +7263,11 @@ setPinnedChats chat_list:ChatList chat_ids:vector<int53> = Ok;
readChatList chat_list:ChatList = Ok;
//@description Returns a story @story_sender_chat_id Identifier of the chat that posted the story @story_id Story identifier
getStory story_sender_chat_id:int53 story_id:int32 = Story;
//@description Returns a story
//@story_sender_chat_id Identifier of the chat that posted the story
//@story_id Story identifier
//@only_local Pass true to get only locally available information without sending network requests
getStory story_sender_chat_id:int53 story_id:int32 only_local:Bool = Story;
//@description Sends a new story. Returns a temporary story with identifier 0
//@content Content of the story

View File

@ -2832,7 +2832,7 @@ void StoryManager::on_reload_story(StoryFullId story_full_id, Result<Unit> &&res
}
}
void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id,
void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id, bool only_local,
Promise<td_api::object_ptr<td_api::story>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(owner_dialog_id, "get_story")) {
return promise.set_error(Status::Error(400, "Story sender not found"));
@ -2852,6 +2852,9 @@ void StoryManager::get_story(DialogId owner_dialog_id, StoryId story_id,
if (story != nullptr && story->content_ != nullptr) {
return promise.set_value(get_story_object(story_full_id, story));
}
if (only_local) {
return promise.set_value(nullptr);
}
auto query_promise = PromiseCreator::lambda(
[actor_id = actor_id(this), story_full_id, promise = std::move(promise)](Result<Unit> &&result) mutable {

View File

@ -146,7 +146,8 @@ class StoryManager final : public Actor {
StoryManager &operator=(StoryManager &&) = delete;
~StoryManager() final;
void get_story(DialogId owner_dialog_id, StoryId story_id, Promise<td_api::object_ptr<td_api::story>> &&promise);
void get_story(DialogId owner_dialog_id, StoryId story_id, bool only_local,
Promise<td_api::object_ptr<td_api::story>> &&promise);
void send_story(td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
td_api::object_ptr<td_api::formattedText> &&input_caption,

View File

@ -5626,7 +5626,8 @@ void Td::on_request(uint64 id, td_api::editMessageSchedulingState &request) {
void Td::on_request(uint64 id, const td_api::getStory &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
story_manager_->get_story(DialogId(request.story_sender_chat_id_), StoryId(request.story_id_), std::move(promise));
story_manager_->get_story(DialogId(request.story_sender_chat_id_), StoryId(request.story_id_), request.only_local_,
std::move(promise));
}
void Td::on_request(uint64 id, td_api::sendStory &request) {

View File

@ -3982,11 +3982,11 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setPinnedChats>(as_chat_list(op), as_chat_ids(args)));
} else if (op == "rcl" || op == "rcla" || begins_with(op, "rcl-")) {
send_request(td_api::make_object<td_api::readChatList>(as_chat_list(op)));
} else if (op == "gst") {
} else if (op == "gst" || op == "gstl") {
ChatId story_sender_chat_id;
StoryId story_id;
get_args(args, story_sender_chat_id, story_id);
send_request(td_api::make_object<td_api::getStory>(story_sender_chat_id, story_id));
send_request(td_api::make_object<td_api::getStory>(story_sender_chat_id, story_id, op == "gstl"));
} else if (op == "ssp" || op == "sspp") {
string photo;
string caption;