Support cashtags in getSearchedForHashtags and removeSearchedForHashtag.
This commit is contained in:
parent
4f35dbd418
commit
5f6bb81e28
@ -8071,10 +8071,10 @@ 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
|
||||
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
|
||||
//@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;
|
||||
|
||||
//@description Removes a hashtag from the list of recently searched for hashtags @hashtag Hashtag to delete
|
||||
//@description Removes a hashtag or a cashtag from the list of recently searched for hashtags or cashtags @hashtag Hashtag or cashtag to delete
|
||||
removeSearchedForHashtag hashtag:string = Ok;
|
||||
|
||||
//@description Clears the list of recently searched for hashtags
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
HashtagHints::HashtagHints(string mode, ActorShared<> parent) : mode_(std::move(mode)), parent_(std::move(parent)) {
|
||||
HashtagHints::HashtagHints(string mode, char first_character, ActorShared<> parent)
|
||||
: mode_(std::move(mode)), first_character_(first_character), parent_(std::move(parent)) {
|
||||
}
|
||||
|
||||
void HashtagHints::start_up() {
|
||||
@ -43,7 +44,7 @@ void HashtagHints::remove_hashtag(string hashtag, Promise<Unit> promise) {
|
||||
if (!sync_with_db_) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
if (hashtag[0] == '#') {
|
||||
if (hashtag[0] == first_character_) {
|
||||
hashtag = hashtag.substr(1);
|
||||
}
|
||||
auto key = Hash<string>()(hashtag);
|
||||
@ -72,7 +73,8 @@ void HashtagHints::query(const string &prefix, int32 limit, Promise<vector<strin
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = prefix.empty() ? hints_.search_empty(limit) : hints_.search(prefix, limit);
|
||||
auto query = Slice(prefix).substr(prefix[0] == first_character_ ? 1 : 0);
|
||||
auto result = query.empty() ? hints_.search_empty(limit) : hints_.search(query, limit);
|
||||
promise.set_value(keys_to_strings(result.second));
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace td {
|
||||
|
||||
class HashtagHints final : public Actor {
|
||||
public:
|
||||
HashtagHints(string mode, ActorShared<> parent);
|
||||
HashtagHints(string mode, char first_character, ActorShared<> parent);
|
||||
|
||||
void hashtag_used(const string &hashtag);
|
||||
|
||||
@ -30,6 +30,7 @@ class HashtagHints final : public Actor {
|
||||
private:
|
||||
string mode_;
|
||||
Hints hints_;
|
||||
char first_character_ = '#';
|
||||
bool sync_with_db_ = false;
|
||||
int64 counter_ = 0;
|
||||
|
||||
|
@ -3926,10 +3926,10 @@ void Td::init_managers() {
|
||||
void Td::init_pure_actor_managers() {
|
||||
call_manager_ = create_actor<CallManager>("CallManager", create_reference());
|
||||
G()->set_call_manager(call_manager_.get());
|
||||
cashtag_search_hints_ = create_actor<HashtagHints>("CashtagSearchHints", "cashtag_search", create_reference());
|
||||
cashtag_search_hints_ = create_actor<HashtagHints>("CashtagSearchHints", "cashtag_search", '$', create_reference());
|
||||
device_token_manager_ = create_actor<DeviceTokenManager>("DeviceTokenManager", create_reference());
|
||||
hashtag_hints_ = create_actor<HashtagHints>("HashtagHints", "text", create_reference());
|
||||
hashtag_search_hints_ = create_actor<HashtagHints>("HashtagSearchHints", "search", 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());
|
||||
G()->set_language_pack_manager(language_pack_manager_.get());
|
||||
password_manager_ = create_actor<PasswordManager>("PasswordManager", create_reference());
|
||||
@ -5385,15 +5385,16 @@ void Td::on_request(uint64 id, td_api::getSearchedForHashtags &request) {
|
||||
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));
|
||||
send_closure(request.prefix_[0] == '$' ? cashtag_search_hints_ : hashtag_search_hints_, &HashtagHints::query,
|
||||
std::move(request.prefix_), request.limit_, std::move(query_promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::removeSearchedForHashtag &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.hashtag_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
send_closure(hashtag_search_hints_, &HashtagHints::remove_hashtag, std::move(request.hashtag_), std::move(promise));
|
||||
send_closure(request.hashtag_[0] == '$' ? cashtag_search_hints_ : hashtag_search_hints_,
|
||||
&HashtagHints::remove_hashtag, std::move(request.hashtag_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::clearSearchedForHashtags &request) {
|
||||
|
Loading…
Reference in New Issue
Block a user