Add td_api::getSearchedForHashtags.

This commit is contained in:
levlam 2024-05-25 20:18:29 +03:00
parent d624f49e43
commit 57186fca18
5 changed files with 30 additions and 0 deletions

View File

@ -8071,6 +8071,9 @@ searchOutgoingDocumentMessages query:string limit:int32 = FoundMessages;
//@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
searchPublicHashtagMessages hashtag:string offset:string limit:int32 = FoundMessages; searchPublicHashtagMessages hashtag:string offset:string limit:int32 = FoundMessages;
//@description Returns recently searched for hashtags by their prefix @prefix Prefix of hashtags to return @limit The maximum number of hashtags to be returned
getSearchedForHashtags prefix:string limit:int32 = Hashtags;
//@description Deletes all call messages @revoke Pass true to delete the messages for all users //@description Deletes all call messages @revoke Pass true to delete the messages for all users
deleteAllCallMessages revoke:Bool = Ok; deleteAllCallMessages revoke:Bool = Ok;

View File

@ -38,6 +38,7 @@
#include "td/telegram/ForumTopicManager.h" #include "td/telegram/ForumTopicManager.h"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/GroupCallManager.h" #include "td/telegram/GroupCallManager.h"
#include "td/telegram/HashtagHints.h"
#include "td/telegram/InlineQueriesManager.h" #include "td/telegram/InlineQueriesManager.h"
#include "td/telegram/InputDialogId.h" #include "td/telegram/InputDialogId.h"
#include "td/telegram/InputMessageText.h" #include "td/telegram/InputMessageText.h"
@ -20705,6 +20706,7 @@ void MessagesManager::search_hashtag_posts(string hashtag, string offset_str, in
if (hashtag.empty()) { if (hashtag.empty()) {
return promise.set_value(get_found_messages_object({}, "search_hashtag_posts")); return promise.set_value(get_found_messages_object({}, "search_hashtag_posts"));
} }
send_closure(td_->hashtag_search_hints_, &HashtagHints::hashtag_used, hashtag);
td_->create_handler<SearchPostsQuery>(std::move(promise))->send(hashtag, offset, limit); td_->create_handler<SearchPostsQuery>(std::move(promise))->send(hashtag, offset, limit);
} }

View File

@ -3279,6 +3279,7 @@ void Td::clear() {
reset_actor(ActorOwn<Actor>(std::move(config_manager_))); reset_actor(ActorOwn<Actor>(std::move(config_manager_)));
reset_actor(ActorOwn<Actor>(std::move(device_token_manager_))); reset_actor(ActorOwn<Actor>(std::move(device_token_manager_)));
reset_actor(ActorOwn<Actor>(std::move(hashtag_hints_))); reset_actor(ActorOwn<Actor>(std::move(hashtag_hints_)));
reset_actor(ActorOwn<Actor>(std::move(hashtag_search_hints_)));
reset_actor(ActorOwn<Actor>(std::move(language_pack_manager_))); reset_actor(ActorOwn<Actor>(std::move(language_pack_manager_)));
reset_actor(ActorOwn<Actor>(std::move(net_stats_manager_))); reset_actor(ActorOwn<Actor>(std::move(net_stats_manager_)));
reset_actor(ActorOwn<Actor>(std::move(password_manager_))); reset_actor(ActorOwn<Actor>(std::move(password_manager_)));
@ -3920,6 +3921,7 @@ void Td::init_pure_actor_managers() {
G()->set_call_manager(call_manager_.get()); G()->set_call_manager(call_manager_.get());
device_token_manager_ = create_actor<DeviceTokenManager>("DeviceTokenManager", create_reference()); device_token_manager_ = create_actor<DeviceTokenManager>("DeviceTokenManager", create_reference());
hashtag_hints_ = create_actor<HashtagHints>("HashtagHints", "text", create_reference()); hashtag_hints_ = create_actor<HashtagHints>("HashtagHints", "text", create_reference());
hashtag_search_hints_ = create_actor<HashtagHints>("HashtagSearchHints", "search", create_reference());
language_pack_manager_ = create_actor<LanguagePackManager>("LanguagePackManager", create_reference()); language_pack_manager_ = create_actor<LanguagePackManager>("LanguagePackManager", create_reference());
G()->set_language_pack_manager(language_pack_manager_.get()); G()->set_language_pack_manager(language_pack_manager_.get());
password_manager_ = create_actor<PasswordManager>("PasswordManager", create_reference()); password_manager_ = create_actor<PasswordManager>("PasswordManager", create_reference());
@ -5364,6 +5366,21 @@ void Td::on_request(uint64 id, td_api::searchPublicHashtagMessages &request) {
std::move(promise)); std::move(promise));
} }
void Td::on_request(uint64 id, td_api::getSearchedForHashtags &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.prefix_);
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<vector<string>> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
promise.set_value(td_api::make_object<td_api::hashtags>(result.move_as_ok()));
}
});
send_closure(hashtag_search_hints_, &HashtagHints::query, std::move(request.prefix_), request.limit_,
std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::deleteAllCallMessages &request) { void Td::on_request(uint64 id, const td_api::deleteAllCallMessages &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();

View File

@ -275,6 +275,7 @@ class Td final : public Actor {
ActorOwn<ConfigManager> config_manager_; ActorOwn<ConfigManager> config_manager_;
ActorOwn<DeviceTokenManager> device_token_manager_; ActorOwn<DeviceTokenManager> device_token_manager_;
ActorOwn<HashtagHints> hashtag_hints_; ActorOwn<HashtagHints> hashtag_hints_;
ActorOwn<HashtagHints> hashtag_search_hints_;
ActorOwn<LanguagePackManager> language_pack_manager_; ActorOwn<LanguagePackManager> language_pack_manager_;
ActorOwn<NetStatsManager> net_stats_manager_; ActorOwn<NetStatsManager> net_stats_manager_;
ActorOwn<PasswordManager> password_manager_; ActorOwn<PasswordManager> password_manager_;
@ -795,6 +796,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::searchPublicHashtagMessages &request); void on_request(uint64 id, td_api::searchPublicHashtagMessages &request);
void on_request(uint64 id, td_api::getSearchedForHashtags &request);
void on_request(uint64 id, const td_api::deleteAllCallMessages &request); void on_request(uint64 id, const td_api::deleteAllCallMessages &request);
void on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request); void on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request);

View File

@ -3064,6 +3064,11 @@ class CliClient final : public Actor {
string offset; string offset;
get_args(args, hashtag, limit, offset); get_args(args, hashtag, limit, offset);
send_request(td_api::make_object<td_api::searchPublicHashtagMessages>(hashtag, offset, as_limit(limit))); send_request(td_api::make_object<td_api::searchPublicHashtagMessages>(hashtag, offset, as_limit(limit)));
} else if (op == "gsfh") {
string hashtag;
string limit;
get_args(args, hashtag, limit);
send_request(td_api::make_object<td_api::getSearchedForHashtags>(hashtag, as_limit(limit)));
} else if (op == "DeleteAllCallMessages") { } else if (op == "DeleteAllCallMessages") {
bool revoke = as_bool(args); bool revoke = as_bool(args);
send_request(td_api::make_object<td_api::deleteAllCallMessages>(revoke)); send_request(td_api::make_object<td_api::deleteAllCallMessages>(revoke));