Add td_api::getArchivedStories.
This commit is contained in:
parent
894e246d8f
commit
20901b6ac5
@ -7224,6 +7224,9 @@ deleteStory story_id:int32 = Ok;
|
||||
//@description Toggles whether stories of the user are available on the main chat list @user_id Identifier of the user @are_archived Pass true to make the story unavailable on the main chat list; pass false to make them available
|
||||
toggleUserStoriesAreArchived user_id:int53 are_archived:Bool = Ok;
|
||||
|
||||
//@description Returns the list of expiring stories of a given user. The stories are returned in a reverse chronological order (i.e., in order of decreasing story_id) @user_id User identifier
|
||||
getUserExpiringStories user_id:int53 = Stories;
|
||||
|
||||
//@description Returns the list of pinned stories of a given user. The stories are returned in a reverse chronological order (i.e., in order of decreasing story_id).
|
||||
//-For optimal performance, the number of returned stories is chosen by TDLib
|
||||
//@user_id User identifier
|
||||
@ -7232,8 +7235,12 @@ toggleUserStoriesAreArchived user_id:int53 are_archived:Bool = Ok;
|
||||
//-For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
|
||||
getUserPinnedStories user_id:int53 from_story_id:int32 limit:int32 = Stories;
|
||||
|
||||
//@description Returns the list of expiring stories of a given user. The stories are returned in a reverse chronological order (i.e., in order of decreasing story_id) @user_id User identifier
|
||||
getUserExpiringStories user_id:int53 = Stories;
|
||||
//@description Returns the list of all stories of the current user. The stories are returned in a reverse chronological order (i.e., in order of decreasing story_id).
|
||||
//-For optimal performance, the number of returned stories is chosen by TDLib
|
||||
//@from_story_id Identifier of the story starting from which stories must be returned; use 0 to get results from the last story
|
||||
//@limit The maximum number of stories to be returned
|
||||
//-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 Returns information about a bot that can be added to attachment menu @bot_user_id Bot's user identifier
|
||||
|
@ -141,6 +141,34 @@ class GetPinnedStoriesQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetStoriesArchiveQuery final : public Td::ResultHandler {
|
||||
Promise<telegram_api::object_ptr<telegram_api::stories_stories>> promise_;
|
||||
|
||||
public:
|
||||
explicit GetStoriesArchiveQuery(Promise<telegram_api::object_ptr<telegram_api::stories_stories>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(StoryId offset_story_id, int32 limit) {
|
||||
send_query(G()->net_query_creator().create(telegram_api::stories_getStoriesArchive(offset_story_id.get(), limit)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::stories_getStoriesArchive>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(DEBUG) << "Receive result for GetStoriesArchiveQuery: " << to_string(result);
|
||||
promise_.set_value(std::move(result));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class GetUserStoriesQuery final : public Td::ResultHandler {
|
||||
Promise<telegram_api::object_ptr<telegram_api::stories_userStories>> promise_;
|
||||
|
||||
@ -512,6 +540,37 @@ void StoryManager::on_get_dialog_pinned_stories(DialogId owner_dialog_id,
|
||||
})));
|
||||
}
|
||||
|
||||
void StoryManager::get_story_archive(StoryId from_story_id, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise) {
|
||||
if (limit <= 0) {
|
||||
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
||||
}
|
||||
|
||||
if (from_story_id != StoryId() && !from_story_id.is_server()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid value of parameter from_story_id specified"));
|
||||
}
|
||||
|
||||
auto query_promise =
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
|
||||
Result<telegram_api::object_ptr<telegram_api::stories_stories>> &&result) mutable {
|
||||
if (result.is_error()) {
|
||||
return promise.set_error(result.move_as_error());
|
||||
}
|
||||
send_closure(actor_id, &StoryManager::on_get_story_archive, result.move_as_ok(), std::move(promise));
|
||||
});
|
||||
td_->create_handler<GetStoriesArchiveQuery>(std::move(query_promise))->send(from_story_id, limit);
|
||||
}
|
||||
|
||||
void StoryManager::on_get_story_archive(telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
DialogId dialog_id(td_->contacts_manager_->get_my_id());
|
||||
auto result = on_get_stories(dialog_id, {}, std::move(stories));
|
||||
promise.set_value(get_stories_object(result.first, transform(result.second, [dialog_id](StoryId story_id) {
|
||||
return StoryFullId(dialog_id, story_id);
|
||||
})));
|
||||
}
|
||||
|
||||
void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise) {
|
||||
if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) {
|
||||
|
@ -99,6 +99,8 @@ class StoryManager final : public Actor {
|
||||
void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void get_story_archive(StoryId from_story_id, int32 limit, Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void get_dialog_expiring_stories(DialogId owner_dialog_id, Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::StoryItem> &&story_item_ptr);
|
||||
@ -154,6 +156,9 @@ class StoryManager final : public Actor {
|
||||
telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void on_get_story_archive(telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
||||
void on_get_dialog_expiring_stories(DialogId owner_dialog_id,
|
||||
telegram_api::object_ptr<telegram_api::stories_userStories> &&stories,
|
||||
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
||||
|
@ -6424,6 +6424,12 @@ void Td::on_request(uint64 id, const td_api::readChatList &request) {
|
||||
messages_manager_->read_all_dialogs_from_list(DialogListId(request.chat_list_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getUserExpiringStories &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
story_manager_->get_dialog_expiring_stories(DialogId(UserId(request.user_id_)), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getUserPinnedStories &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
@ -6431,10 +6437,10 @@ void Td::on_request(uint64 id, const td_api::getUserPinnedStories &request) {
|
||||
request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getUserExpiringStories &request) {
|
||||
void Td::on_request(uint64 id, const td_api::getArchivedStories &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
story_manager_->get_dialog_expiring_stories(DialogId(UserId(request.user_id_)), std::move(promise));
|
||||
story_manager_->get_story_archive(StoryId(request.from_story_id_), request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {
|
||||
|
@ -1000,9 +1000,11 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::readChatList &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getUserExpiringStories &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getUserPinnedStories &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getUserExpiringStories &request);
|
||||
void on_request(uint64 id, const td_api::getArchivedStories &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getAttachmentMenuBot &request);
|
||||
|
||||
|
@ -4049,6 +4049,11 @@ class CliClient final : public Actor {
|
||||
string limit;
|
||||
get_args(args, user_id, from_story_id, limit);
|
||||
send_request(td_api::make_object<td_api::getUserPinnedStories>(user_id, from_story_id, as_limit(limit)));
|
||||
} else if (op == "gast") {
|
||||
StoryId from_story_id;
|
||||
string limit;
|
||||
get_args(args, from_story_id, limit);
|
||||
send_request(td_api::make_object<td_api::getArchivedStories>(from_story_id, as_limit(limit)));
|
||||
} else if (op == "gues") {
|
||||
UserId user_id;
|
||||
get_args(args, user_id);
|
||||
|
Loading…
Reference in New Issue
Block a user