2018-12-31 20:04:05 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Hints.h"
|
2022-06-27 12:30:18 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
2019-04-26 20:26:48 +02:00
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class HashtagHints final : public Actor {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
HashtagHints(string mode, ActorShared<> parent);
|
|
|
|
|
|
|
|
void hashtag_used(const string &hashtag);
|
|
|
|
|
2024-05-25 19:35:21 +02:00
|
|
|
void remove_hashtag(string hashtag, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-25 19:35:21 +02:00
|
|
|
void clear(Promise<Unit> promise);
|
|
|
|
|
|
|
|
void query(const string &prefix, int32 limit, Promise<vector<string>> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
string mode_;
|
|
|
|
Hints hints_;
|
|
|
|
bool sync_with_db_ = false;
|
|
|
|
int64 counter_ = 0;
|
|
|
|
|
|
|
|
ActorShared<> parent_;
|
|
|
|
|
|
|
|
string get_key() const;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void start_up() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void hashtag_used_impl(const string &hashtag);
|
|
|
|
void from_db(Result<string> data, bool dummy);
|
2024-05-25 19:35:21 +02:00
|
|
|
vector<string> keys_to_strings(const vector<int64> &keys);
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
2019-04-26 20:26:48 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|