Add td_api::openStory.
This commit is contained in:
parent
29a1b7e3d6
commit
e040b63fd8
@ -7259,6 +7259,11 @@ getUserPinnedStories user_id:int53 from_story_id:int32 limit:int32 = Stories;
|
||||
//-For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
|
||||
getArchivedStories from_story_id:int32 limit:int32 = Stories;
|
||||
|
||||
//@description Informs TDLib that a story is opened and is being viewed by the user
|
||||
//@story_sender_user_id The identifier of the sender of the opened story
|
||||
//@story_id The identifier of the story
|
||||
openStory story_sender_user_id:int53 story_id:int32 = Ok;
|
||||
|
||||
|
||||
//@description Returns information about a bot that can be added to attachment menu @bot_user_id Bot's user identifier
|
||||
getAttachmentMenuBot bot_user_id:int53 = AttachmentMenuBot;
|
||||
|
@ -610,6 +610,30 @@ void StoryManager::on_get_dialog_expiring_stories(DialogId owner_dialog_id,
|
||||
})));
|
||||
}
|
||||
|
||||
void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) {
|
||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||
}
|
||||
if (!td_->messages_manager_->have_input_peer(owner_dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Can't access the story sender"));
|
||||
}
|
||||
if (!story_id.is_valid()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid story identifier specified"));
|
||||
}
|
||||
|
||||
StoryFullId story_full_id{owner_dialog_id, story_id};
|
||||
const Story *story = get_story(story_full_id);
|
||||
if (story == nullptr) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
for (auto file_id : get_story_file_ids(story)) {
|
||||
td_->file_manager_->check_local_location_async(file_id, true);
|
||||
}
|
||||
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
bool StoryManager::have_story(StoryFullId story_full_id) const {
|
||||
return get_story(story_full_id) != nullptr;
|
||||
}
|
||||
|
@ -104,6 +104,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
void get_dialog_expiring_stories(DialogId owner_dialog_id, Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise);
|
||||
|
||||
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::StoryItem> &&story_item_ptr);
|
||||
|
||||
std::pair<int32, vector<StoryId>> on_get_stories(DialogId owner_dialog_id, vector<int32> &&expected_story_ids,
|
||||
|
@ -6443,6 +6443,13 @@ void Td::on_request(uint64 id, const td_api::getArchivedStories &request) {
|
||||
story_manager_->get_story_archive(StoryId(request.from_story_id_), request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::openStory &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
story_manager_->open_story(DialogId(UserId(request.story_sender_user_id_)), StoryId(request.story_id_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -1006,6 +1006,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::getArchivedStories &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::openStory &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getAttachmentMenuBot &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &request);
|
||||
|
@ -4058,6 +4058,11 @@ class CliClient final : public Actor {
|
||||
UserId user_id;
|
||||
get_args(args, user_id);
|
||||
send_request(td_api::make_object<td_api::getUserActiveStories>(user_id));
|
||||
} else if (op == "os") {
|
||||
UserId story_sender_user_id;
|
||||
StoryId story_id;
|
||||
get_args(args, story_sender_user_id, story_id);
|
||||
send_request(td_api::make_object<td_api::openStory>(story_sender_user_id, story_id));
|
||||
} else if (op == "gamb") {
|
||||
UserId user_id;
|
||||
get_args(args, user_id);
|
||||
|
Loading…
Reference in New Issue
Block a user