Add td_api::searchPublicVenueStories.

This commit is contained in:
levlam 2024-06-05 15:27:16 +03:00
parent 7c5ee12a0e
commit f5a9be27b8
6 changed files with 54 additions and 2 deletions

View File

@ -8080,6 +8080,13 @@ searchPublicHashtagMessages hashtag:string offset:string limit:int32 = FoundMess
//@limit The maximum number of stories to be returned; up to 100. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
searchPublicHashtagStories hashtag:string offset:string limit:int32 = FoundStories;
//@description Searches for public stories from the given venue. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
//@venue_provider Provider of the venue
//@venue_id Identifier of the venue in the provider database
//@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
//@limit The maximum number of stories to be returned; up to 100. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit
searchPublicVenueStories venue_provider:string venue_id:string offset:string limit:int32 = FoundStories;
//@description Returns recently searched for hashtags or cashtags by their prefix @prefix Prefix of hashtags or cashtags to return @limit The maximum number of items to be returned
getSearchedForHashtags prefix:string limit:int32 = Hashtags;

View File

@ -712,12 +712,22 @@ class SearchStoriesQuery final : public Td::ResultHandler {
: promise_(std::move(promise)) {
}
void send(string hashtag, string offset, int32 limit) {
void send(string hashtag, const string &offset, int32 limit) {
int32 flags = telegram_api::stories_searchPosts::HASHTAG_MASK;
send_query(
G()->net_query_creator().create(telegram_api::stories_searchPosts(flags, hashtag, nullptr, offset, limit)));
}
void send(const string &venue_provider, const string &venue_id, const string &offset, int32 limit) {
int32 flags = telegram_api::stories_searchPosts::AREA_MASK;
auto area = telegram_api::make_object<telegram_api::mediaAreaVenue>(
telegram_api::make_object<telegram_api::mediaAreaCoordinates>(0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
telegram_api::make_object<telegram_api::geoPoint>(0, 0.0, 0.0, 0, 0), string(), string(), venue_provider,
venue_id, string());
send_query(G()->net_query_creator().create(
telegram_api::stories_searchPosts(flags, string(), std::move(area), offset, limit)));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stories_searchPosts>(packet);
if (result_ptr.is_error()) {
@ -2616,7 +2626,19 @@ void StoryManager::search_hashtag_posts(string hashtag, string offset, int32 lim
hashtag);
td_->create_handler<SearchStoriesQuery>(std::move(promise))
->send(PSTRING() << (is_cashtag ? '$' : '#') << hashtag, std::move(offset), limit);
->send(PSTRING() << (is_cashtag ? '$' : '#') << hashtag, offset, limit);
}
void StoryManager::search_venue_posts(string venue_provider, string venue_id, string offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundStories>> &&promise) {
if (limit <= 0) {
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
}
if (limit > MAX_SEARCH_STORIES) {
limit = MAX_SEARCH_STORIES;
}
td_->create_handler<SearchStoriesQuery>(std::move(promise))->send(venue_provider, venue_id, offset, limit);
}
void StoryManager::set_pinned_stories(DialogId owner_dialog_id, vector<StoryId> story_ids, Promise<Unit> &&promise) {

View File

@ -256,6 +256,9 @@ class StoryManager final : public Actor {
void search_hashtag_posts(string hashtag, string offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundStories>> &&promise);
void search_venue_posts(string venue_provider, string venue_id, string offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundStories>> &&promise);
void set_pinned_stories(DialogId owner_dialog_id, vector<StoryId> story_ids, Promise<Unit> &&promise);
void open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise);

View File

@ -5324,6 +5324,16 @@ void Td::on_request(uint64 id, td_api::searchPublicHashtagStories &request) {
std::move(promise));
}
void Td::on_request(uint64 id, td_api::searchPublicVenueStories &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.venue_provider_);
CLEAN_INPUT_STRING(request.venue_id_);
CLEAN_INPUT_STRING(request.offset_);
CREATE_REQUEST_PROMISE();
story_manager_->search_venue_posts(std::move(request.venue_provider_), std::move(request.venue_id_),
std::move(request.offset_), request.limit_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::getSearchedForHashtags &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.prefix_);

View File

@ -802,6 +802,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::searchPublicHashtagStories &request);
void on_request(uint64 id, td_api::searchPublicVenueStories &request);
void on_request(uint64 id, td_api::getSearchedForHashtags &request);
void on_request(uint64 id, td_api::removeSearchedForHashtag &request);

View File

@ -3070,6 +3070,14 @@ class CliClient final : public Actor {
string offset;
get_args(args, hashtag, limit, offset);
send_request(td_api::make_object<td_api::searchPublicHashtagStories>(hashtag, offset, as_limit(limit)));
} else if (op == "spvs") {
string venue_provider;
string venue_id;
string limit;
string offset;
get_args(args, venue_provider, venue_id, limit, offset);
send_request(
td_api::make_object<td_api::searchPublicVenueStories>(venue_provider, venue_id, offset, as_limit(limit)));
} else if (op == "gsfh") {
string hashtag;
string limit;