diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 4ae72d425..67baeff3e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -8104,6 +8104,12 @@ searchPublicMessagesByTag tag:string offset:string limit:int32 = FoundMessages; //@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 searchPublicStoriesByTag tag:string offset:string limit:int32 = FoundStories; +//@description Searches for public stories by the given address location. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit +//@address Address of the location +//@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 +searchPublicStoriesByLocation address:locationAddress 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 diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 0c27ca781..d5d4b2b99 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -718,6 +718,30 @@ class SearchStoriesQuery final : public Td::ResultHandler { G()->net_query_creator().create(telegram_api::stories_searchPosts(flags, hashtag, nullptr, offset, limit))); } + void send(td_api::object_ptr &&address, const string &offset, int32 limit) { + int32 flags = telegram_api::stories_searchPosts::AREA_MASK; + + int32 address_flags = 0; + if (!address->state_.empty()) { + address_flags |= telegram_api::geoPointAddress::STATE_MASK; + } + if (!address->city_.empty()) { + address_flags |= telegram_api::geoPointAddress::CITY_MASK; + } + if (!address->street_.empty()) { + address_flags |= telegram_api::geoPointAddress::STREET_MASK; + } + + auto area = telegram_api::make_object( + telegram_api::mediaAreaGeoPoint::ADDRESS_MASK, + telegram_api::make_object(0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), + telegram_api::make_object(0, 0.0, 0.0, 0, 0), + telegram_api::make_object(address_flags, address->country_code_, address->state_, + address->city_, address->street_)); + send_query(G()->net_query_creator().create( + telegram_api::stories_searchPosts(flags, string(), std::move(area), 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( @@ -2629,6 +2653,18 @@ void StoryManager::search_hashtag_posts(string hashtag, string offset, int32 lim ->send(PSTRING() << (is_cashtag ? '$' : '#') << hashtag, offset, limit); } +void StoryManager::search_location_posts(td_api::object_ptr &&address, string offset, + int32 limit, Promise> &&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(std::move(promise))->send(std::move(address), offset, limit); +} + void StoryManager::search_venue_posts(string venue_provider, string venue_id, string offset, int32 limit, Promise> &&promise) { if (limit <= 0) { diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index eef5aa18d..fdc2738af 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -256,6 +256,9 @@ class StoryManager final : public Actor { void search_hashtag_posts(string hashtag, string offset, int32 limit, Promise> &&promise); + void search_location_posts(td_api::object_ptr &&address, string offset, int32 limit, + Promise> &&promise); + void search_venue_posts(string venue_provider, string venue_id, string offset, int32 limit, Promise> &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 7cb4821d4..7e3a8f244 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5325,6 +5325,21 @@ void Td::on_request(uint64 id, td_api::searchPublicStoriesByTag &request) { std::move(promise)); } +void Td::on_request(uint64 id, td_api::searchPublicStoriesByLocation &request) { + CHECK_IS_USER(); + if (request.address_ == nullptr) { + return send_error_raw(id, 400, "Address must be non-empty"); + } + CLEAN_INPUT_STRING(request.address_->country_code_); + CLEAN_INPUT_STRING(request.address_->state_); + CLEAN_INPUT_STRING(request.address_->city_); + CLEAN_INPUT_STRING(request.address_->street_); + CLEAN_INPUT_STRING(request.offset_); + CREATE_REQUEST_PROMISE(); + story_manager_->search_location_posts(std::move(request.address_), std::move(request.offset_), request.limit_, + std::move(promise)); +} + void Td::on_request(uint64 id, td_api::searchPublicStoriesByVenue &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.venue_provider_); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 694e39e76..a9fb22e44 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -802,6 +802,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::searchPublicStoriesByTag &request); + void on_request(uint64 id, td_api::searchPublicStoriesByLocation &request); + void on_request(uint64 id, td_api::searchPublicStoriesByVenue &request); void on_request(uint64 id, td_api::getSearchedForTags &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 782928146..5922b5c41 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3073,6 +3073,17 @@ class CliClient final : public Actor { string offset; get_args(args, tag, limit, offset); send_request(td_api::make_object(tag, offset, as_limit(limit))); + } else if (op == "spsbl") { + string country_code; + string state; + string city; + string street; + string venue_id; + string limit; + string offset; + get_args(args, country_code, state, city, street, limit, offset); + send_request(td_api::make_object( + td_api::make_object(country_code, state, city, street), offset, as_limit(limit))); } else if (op == "spsbv") { string venue_provider; string venue_id;