2018-12-31 20:04:05 +01:00
|
|
|
//
|
2021-01-01 13:57:46 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
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/telegram/files/FileId.h"
|
2019-02-02 11:30:49 +01:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2020-04-19 23:41:26 +02:00
|
|
|
#include "td/telegram/FullMessageId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/Photo.h"
|
|
|
|
#include "td/telegram/SecretInputMedia.h"
|
2020-04-19 15:30:04 +02:00
|
|
|
#include "td/telegram/SpecialStickerSetType.h"
|
2019-09-18 05:55:43 +02:00
|
|
|
#include "td/telegram/StickerSetId.h"
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
#include "td/actor/MultiPromise.h"
|
|
|
|
#include "td/actor/PromiseFuture.h"
|
|
|
|
#include "td/actor/Timeout.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#include "td/utils/buffer.h"
|
|
|
|
#include "td/utils/common.h"
|
2018-03-05 23:44:11 +01:00
|
|
|
#include "td/utils/Hints.h"
|
2020-04-22 14:02:56 +02:00
|
|
|
#include "td/utils/Slice.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <tuple>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2019-02-21 18:54:20 +01:00
|
|
|
class Td;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class StickersManager final : public Actor {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2019-04-19 01:36:48 +02:00
|
|
|
static constexpr int64 GREAT_MINDS_SET_ID = 1842540969984001;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
static vector<StickerSetId> convert_sticker_set_ids(const vector<int64> &sticker_set_ids);
|
|
|
|
static vector<int64> convert_sticker_set_ids(const vector<StickerSetId> &sticker_set_ids);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
StickersManager(Td *td, ActorShared<> parent);
|
|
|
|
|
2020-04-17 15:12:12 +02:00
|
|
|
void init();
|
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
tl_object_ptr<td_api::sticker> get_sticker_object(FileId file_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
tl_object_ptr<td_api::stickers> get_stickers_object(const vector<FileId> &sticker_ids) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-10-15 14:59:51 +02:00
|
|
|
tl_object_ptr<td_api::DiceStickers> get_dice_stickers_object(const string &emoji, int32 value) const;
|
2020-04-19 23:41:26 +02:00
|
|
|
|
2020-04-21 18:08:01 +02:00
|
|
|
int32 get_dice_success_animation_frame_number(const string &emoji, int32 value) const;
|
2020-04-21 13:51:46 +02:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
tl_object_ptr<td_api::stickerSet> get_sticker_set_object(StickerSetId sticker_set_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
tl_object_ptr<td_api::stickerSets> get_sticker_sets_object(int32 total_count,
|
|
|
|
const vector<StickerSetId> &sticker_set_ids,
|
2018-09-20 21:25:09 +02:00
|
|
|
size_t covers_limit) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
tl_object_ptr<telegram_api::InputStickerSet> get_input_sticker_set(StickerSetId sticker_set_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-19 23:41:26 +02:00
|
|
|
void register_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source);
|
|
|
|
|
|
|
|
void unregister_dice(const string &emoji, int32 value, FullMessageId full_message_id, const char *source);
|
|
|
|
|
2021-09-15 23:41:40 +02:00
|
|
|
void get_animated_emoji_click_sticker(const string &message_text, FullMessageId full_message_id,
|
|
|
|
Promise<td_api::object_ptr<td_api::sticker>> &&promise);
|
|
|
|
|
2021-09-19 00:52:56 +02:00
|
|
|
void on_send_animated_emoji_clicks(DialogId dialog_id, const string &emoji);
|
|
|
|
|
2021-09-23 16:16:59 +02:00
|
|
|
bool is_sent_animated_emoji_click(DialogId dialog_id, Slice emoji);
|
2021-09-19 00:52:56 +02:00
|
|
|
|
2021-09-23 16:16:59 +02:00
|
|
|
Status on_animated_emoji_message_clicked(Slice emoji, FullMessageId full_message_id, string data);
|
2021-09-17 14:51:42 +02:00
|
|
|
|
2020-11-09 21:41:23 +01:00
|
|
|
void create_sticker(FileId file_id, string minithumbnail, PhotoSize thumbnail, Dimensions dimensions,
|
2019-07-15 02:43:05 +02:00
|
|
|
tl_object_ptr<telegram_api::documentAttributeSticker> sticker, bool is_animated,
|
2018-12-31 20:04:05 +01:00
|
|
|
MultiPromiseActor *load_data_multipromise_ptr);
|
|
|
|
|
|
|
|
bool has_input_media(FileId sticker_file_id, bool is_secret) const;
|
|
|
|
|
|
|
|
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
|
|
|
tl_object_ptr<telegram_api::InputFile> input_file,
|
2020-12-19 12:31:42 +01:00
|
|
|
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
|
|
|
const string &emoji) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
SecretInputMedia get_secret_input_media(FileId sticker_file_id,
|
|
|
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
|
|
|
BufferSlice thumbnail) const;
|
|
|
|
|
|
|
|
vector<FileId> get_stickers(string emoji, int32 limit, bool force, Promise<Unit> &&promise);
|
|
|
|
|
2018-03-09 18:04:44 +01:00
|
|
|
vector<FileId> search_stickers(string emoji, int32 limit, Promise<Unit> &&promise);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> get_installed_sticker_sets(bool is_masks, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-03-01 21:48:48 +01:00
|
|
|
static bool has_webp_thumbnail(const vector<tl_object_ptr<telegram_api::PhotoSize>> &thumbnails);
|
2018-06-01 00:23:07 +02:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId get_sticker_set_id(const tl_object_ptr<telegram_api::InputStickerSet> &set_ptr);
|
2018-06-01 00:23:07 +02:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId add_sticker_set(tl_object_ptr<telegram_api::InputStickerSet> &&set_ptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId get_sticker_set(StickerSetId set_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId search_sticker_set(const string &short_name_to_search, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::pair<int32, vector<StickerSetId>> search_installed_sticker_sets(bool is_masks, const string &query, int32 limit,
|
|
|
|
Promise<Unit> &&promise);
|
2018-03-05 23:44:11 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> search_sticker_sets(const string &query, Promise<Unit> &&promise);
|
2018-03-05 23:44:11 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void change_sticker_set(StickerSetId set_id, bool is_installed, bool is_archived, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void view_featured_sticker_sets(const vector<StickerSetId> &sticker_set_ids);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_get_installed_sticker_sets(bool is_masks, tl_object_ptr<telegram_api::messages_AllStickers> &&stickers_ptr);
|
|
|
|
|
|
|
|
void on_get_installed_sticker_sets_failed(bool is_masks, Status error);
|
|
|
|
|
2019-11-21 20:18:29 +01:00
|
|
|
StickerSetId on_get_messages_sticker_set(StickerSetId sticker_set_id,
|
2019-12-29 02:59:34 +01:00
|
|
|
tl_object_ptr<telegram_api::messages_stickerSet> &&set, bool is_changed,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-12-29 02:59:34 +01:00
|
|
|
StickerSetId on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet> &&set, bool is_changed, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-12-29 02:59:34 +01:00
|
|
|
StickerSetId on_get_sticker_set_covered(tl_object_ptr<telegram_api::StickerSetCovered> &&set_ptr, bool is_changed,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-19 23:41:26 +02:00
|
|
|
void on_get_special_sticker_set(const SpecialStickerSetType &type, StickerSetId sticker_set_id);
|
|
|
|
|
|
|
|
void on_load_special_sticker_set(const SpecialStickerSetType &type, Status result);
|
2019-11-21 20:18:29 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_load_sticker_set_fail(StickerSetId sticker_set_id, const Status &error);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_install_sticker_set(StickerSetId set_id, bool is_archived,
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<telegram_api::messages_StickerSetInstallResult> &&result);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_uninstall_sticker_set(StickerSetId set_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-19 10:17:51 +02:00
|
|
|
void on_update_dice_emojis();
|
|
|
|
|
2020-04-21 13:51:46 +02:00
|
|
|
void on_update_dice_success_values();
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_update_sticker_sets();
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_update_sticker_sets_order(bool is_masks, const vector<StickerSetId> &sticker_set_ids);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::pair<int32, vector<StickerSetId>> get_archived_sticker_sets(bool is_masks, StickerSetId offset_sticker_set_id,
|
|
|
|
int32 limit, bool force, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_get_archived_sticker_sets(bool is_masks, StickerSetId offset_sticker_set_id,
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<tl_object_ptr<telegram_api::StickerSetCovered>> &&sticker_sets,
|
|
|
|
int32 total_count);
|
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
std::pair<int32, vector<StickerSetId>> get_featured_sticker_sets(int32 offset, int32 limit, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
void on_get_featured_sticker_sets(int32 offset, int32 limit, uint32 generation,
|
|
|
|
tl_object_ptr<telegram_api::messages_FeaturedStickers> &&sticker_sets_ptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
void on_get_featured_sticker_sets_failed(int32 offset, int32 limit, uint32 generation, Status error);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> get_attached_sticker_sets(FileId file_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_get_attached_sticker_sets(FileId file_id,
|
|
|
|
vector<tl_object_ptr<telegram_api::StickerSetCovered>> &&sticker_sets);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void reorder_installed_sticker_sets(bool is_masks, const vector<StickerSetId> &sticker_set_ids,
|
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-06-21 21:25:26 +02:00
|
|
|
FileId upload_sticker_file(UserId user_id, tl_object_ptr<td_api::InputSticker> &&sticker, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-06-17 19:38:03 +02:00
|
|
|
void get_suggested_sticker_set_name(string short_name, Promise<string> &&promise);
|
|
|
|
|
2021-06-18 02:06:20 +02:00
|
|
|
enum class CheckStickerSetNameResult : uint8 { Ok, Invalid, Occupied };
|
2021-06-17 20:29:07 +02:00
|
|
|
void check_sticker_set_name(const string &name, Promise<CheckStickerSetNameResult> &&promise);
|
|
|
|
|
|
|
|
static td_api::object_ptr<td_api::CheckStickerSetNameResult> get_check_sticker_set_name_result_object(
|
|
|
|
CheckStickerSetNameResult result);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void create_new_sticker_set(UserId user_id, string &title, string &short_name, bool is_masks,
|
2021-06-18 17:45:57 +02:00
|
|
|
vector<tl_object_ptr<td_api::InputSticker>> &&stickers, string software,
|
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-23 16:03:13 +01:00
|
|
|
void add_sticker_to_set(UserId user_id, string &short_name, tl_object_ptr<td_api::InputSticker> &&sticker,
|
2018-12-31 20:04:05 +01:00
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2020-03-20 14:36:07 +01:00
|
|
|
void set_sticker_set_thumbnail(UserId user_id, string &short_name, tl_object_ptr<td_api::InputFile> &&thumbnail,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void set_sticker_position_in_set(const tl_object_ptr<td_api::InputFile> &sticker, int32 position,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void remove_sticker_from_set(const tl_object_ptr<td_api::InputFile> &sticker, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
vector<FileId> get_recent_stickers(bool is_attached, Promise<Unit> &&promise);
|
|
|
|
|
2019-02-02 11:54:40 +01:00
|
|
|
void on_get_recent_stickers(bool is_repair, bool is_attached,
|
2019-02-02 11:30:49 +01:00
|
|
|
tl_object_ptr<telegram_api::messages_RecentStickers> &&stickers_ptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-02-02 11:54:40 +01:00
|
|
|
void on_get_recent_stickers_failed(bool is_repair, bool is_attached, Status error);
|
2019-02-02 11:30:49 +01:00
|
|
|
|
2019-04-26 04:49:48 +02:00
|
|
|
FileSourceId get_recent_stickers_file_source_id(int is_attached);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void add_recent_sticker(bool is_attached, const tl_object_ptr<td_api::InputFile> &input_file,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void add_recent_sticker_by_id(bool is_attached, FileId sticker_id);
|
|
|
|
|
|
|
|
void remove_recent_sticker(bool is_attached, const tl_object_ptr<td_api::InputFile> &input_file,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2019-02-02 12:41:30 +01:00
|
|
|
void send_save_recent_sticker_query(bool is_attached, FileId sticker_id, bool unsave, Promise<Unit> &&promise);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void clear_recent_stickers(bool is_attached, Promise<Unit> &&promise);
|
|
|
|
|
2018-03-08 14:49:45 +01:00
|
|
|
void on_update_recent_stickers_limit(int32 recent_stickers_limit);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_update_favorite_stickers_limit(int32 favorite_stickers_limit);
|
|
|
|
|
|
|
|
void reload_favorite_stickers(bool force);
|
|
|
|
|
2019-02-02 11:54:40 +01:00
|
|
|
void repair_favorite_stickers(Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-02-02 11:54:40 +01:00
|
|
|
void on_get_favorite_stickers(bool is_repair,
|
|
|
|
tl_object_ptr<telegram_api::messages_FavedStickers> &&favorite_stickers_ptr);
|
|
|
|
|
|
|
|
void on_get_favorite_stickers_failed(bool is_repair, Status error);
|
|
|
|
|
|
|
|
FileSourceId get_favorite_stickers_file_source_id();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
vector<FileId> get_favorite_stickers(Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void add_favorite_sticker(const tl_object_ptr<td_api::InputFile> &input_file, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void add_favorite_sticker_by_id(FileId sticker_id);
|
|
|
|
|
|
|
|
void remove_favorite_sticker(const tl_object_ptr<td_api::InputFile> &input_file, Promise<Unit> &&promise);
|
|
|
|
|
2019-02-02 12:14:20 +01:00
|
|
|
void send_fave_sticker_query(FileId sticker_id, bool unsave, Promise<Unit> &&promise);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FileId> get_attached_sticker_file_ids(const vector<int32> &int_file_ids);
|
|
|
|
|
|
|
|
vector<string> get_sticker_emojis(const tl_object_ptr<td_api::InputFile> &input_file, Promise<Unit> &&promise);
|
|
|
|
|
2020-04-22 14:17:53 +02:00
|
|
|
vector<string> search_emojis(const string &text, bool exact_match, const vector<string> &input_language_codes,
|
|
|
|
bool force, Promise<Unit> &&promise);
|
2019-05-21 17:48:35 +02:00
|
|
|
|
2019-05-21 21:44:13 +02:00
|
|
|
int64 get_emoji_suggestions_url(const string &language_code, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::httpUrl> get_emoji_suggestions_url_result(int64 random_id);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void reload_sticker_set(StickerSetId sticker_set_id, int64 access_hash, Promise<Unit> &&promise);
|
2019-07-30 17:43:29 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void reload_installed_sticker_sets(bool is_masks, bool force);
|
|
|
|
|
|
|
|
void reload_featured_sticker_sets(bool force);
|
|
|
|
|
|
|
|
void reload_recent_stickers(bool is_attached, bool force);
|
|
|
|
|
2019-02-02 11:54:40 +01:00
|
|
|
void repair_recent_stickers(bool is_attached, Promise<Unit> &&promise);
|
2019-02-02 11:30:49 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId get_sticker_thumbnail_file_id(FileId file_id) const;
|
|
|
|
|
2019-02-02 11:30:49 +01:00
|
|
|
vector<FileId> get_sticker_file_ids(FileId file_id) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void delete_sticker_thumbnail(FileId file_id);
|
|
|
|
|
|
|
|
FileId dup_sticker(FileId new_id, FileId old_id);
|
|
|
|
|
2021-08-26 17:50:28 +02:00
|
|
|
void merge_stickers(FileId new_id, FileId old_id, bool can_delete_old);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-02-21 18:54:20 +01:00
|
|
|
template <class StorerT>
|
2021-09-13 15:03:21 +02:00
|
|
|
void store_sticker(FileId file_id, bool in_sticker_set, StorerT &storer, const char *source) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-02-21 18:54:20 +01:00
|
|
|
template <class ParserT>
|
|
|
|
FileId parse_sticker(bool in_sticker_set, ParserT &parser);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_uploaded_sticker_file(FileId file_id, tl_object_ptr<telegram_api::MessageMedia> media,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2018-03-09 18:04:44 +01:00
|
|
|
void on_find_stickers_success(const string &emoji, tl_object_ptr<telegram_api::messages_Stickers> &&sticker_sets);
|
|
|
|
|
|
|
|
void on_find_stickers_fail(const string &emoji, Status &&error);
|
|
|
|
|
2018-03-05 23:44:11 +01:00
|
|
|
void on_find_sticker_sets_success(const string &query,
|
|
|
|
tl_object_ptr<telegram_api::messages_FoundStickerSets> &&sticker_sets);
|
|
|
|
|
|
|
|
void on_find_sticker_sets_fail(const string &query, Status &&error);
|
|
|
|
|
2019-01-24 20:41:05 +01:00
|
|
|
void send_get_attached_stickers_query(FileId file_id, Promise<Unit> &&promise);
|
|
|
|
|
2018-12-12 03:55:08 +01:00
|
|
|
void after_get_difference();
|
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
|
|
|
|
2019-09-18 01:14:24 +02:00
|
|
|
template <class StorerT>
|
2019-09-18 05:55:43 +02:00
|
|
|
void store_sticker_set_id(StickerSetId sticker_set_id, StorerT &storer) const;
|
2019-09-18 01:14:24 +02:00
|
|
|
|
|
|
|
template <class ParserT>
|
2019-09-18 05:55:43 +02:00
|
|
|
void parse_sticker_set_id(StickerSetId &sticker_set_id, ParserT &parser);
|
2019-09-18 01:14:24 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
private:
|
|
|
|
static constexpr int32 MAX_FEATURED_STICKER_SET_VIEW_DELAY = 5;
|
2020-04-18 00:55:54 +02:00
|
|
|
static constexpr int32 OLD_FEATURED_STICKER_SET_SLICE_SIZE = 20;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-23 16:03:13 +01:00
|
|
|
static constexpr int32 MAX_FOUND_STICKERS = 100; // server side limit
|
|
|
|
static constexpr int64 MAX_STICKER_FILE_SIZE = 1 << 19; // server side limit
|
|
|
|
static constexpr int64 MAX_THUMBNAIL_FILE_SIZE = 1 << 17; // server side limit
|
|
|
|
static constexpr int64 MAX_ANIMATED_STICKER_FILE_SIZE = 1 << 16; // server side limit
|
|
|
|
static constexpr int64 MAX_ANIMATED_THUMBNAIL_FILE_SIZE = 1 << 15; // server side limit
|
|
|
|
static constexpr size_t MAX_STICKER_SET_TITLE_LENGTH = 64; // server side limit
|
|
|
|
static constexpr size_t MAX_STICKER_SET_SHORT_NAME_LENGTH = 64; // server side limit
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-05-21 19:42:41 +02:00
|
|
|
static constexpr int32 EMOJI_KEYWORDS_UPDATE_DELAY = 3600;
|
2021-09-17 18:59:31 +02:00
|
|
|
static constexpr double MIN_ANIMATED_EMOJI_CLICK_DELAY = 0.2;
|
2019-05-21 19:42:41 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
class Sticker {
|
|
|
|
public:
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId set_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string alt;
|
|
|
|
Dimensions dimensions;
|
2020-11-09 21:41:23 +01:00
|
|
|
string minithumbnail;
|
2019-07-15 03:01:26 +02:00
|
|
|
PhotoSize s_thumbnail;
|
|
|
|
PhotoSize m_thumbnail;
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId file_id;
|
2019-07-15 02:43:05 +02:00
|
|
|
bool is_animated = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_mask = false;
|
|
|
|
int32 point = -1;
|
|
|
|
double x_shift = 0;
|
|
|
|
double y_shift = 0;
|
|
|
|
double scale = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StickerSet {
|
|
|
|
public:
|
2020-04-17 14:06:08 +02:00
|
|
|
bool is_inited = false; // basic information about the set
|
2018-12-31 20:04:05 +01:00
|
|
|
bool was_loaded = false;
|
|
|
|
bool is_loaded = false;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId id;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 access_hash = 0;
|
|
|
|
string title;
|
|
|
|
string short_name;
|
|
|
|
int32 sticker_count = 0;
|
|
|
|
int32 hash = 0;
|
|
|
|
int32 expires_at = 0;
|
|
|
|
|
2020-11-09 21:41:23 +01:00
|
|
|
string minithumbnail;
|
2019-05-17 16:35:45 +02:00
|
|
|
PhotoSize thumbnail;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FileId> sticker_ids;
|
|
|
|
std::unordered_map<string, vector<FileId>> emoji_stickers_map_; // emoji -> stickers
|
|
|
|
std::unordered_map<FileId, vector<string>, FileIdHash> sticker_emojis_map_; // sticker -> emojis
|
|
|
|
|
|
|
|
bool is_installed = false;
|
|
|
|
bool is_archived = false;
|
|
|
|
bool is_official = false;
|
2019-07-15 02:43:05 +02:00
|
|
|
bool is_animated = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_masks = false;
|
|
|
|
bool is_viewed = true;
|
2019-05-17 17:08:17 +02:00
|
|
|
bool is_thumbnail_reloaded = false;
|
2020-11-09 21:41:23 +01:00
|
|
|
bool are_legacy_sticker_thumbnails_reloaded = false;
|
2020-04-17 14:56:57 +02:00
|
|
|
mutable bool was_update_sent = false; // does the sticker set is known to the client
|
|
|
|
bool is_changed = true; // have new changes that need to be sent to the client and database
|
|
|
|
bool need_save_to_database = true; // have new changes that need only to be saved to the database
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
vector<uint32> load_requests;
|
|
|
|
vector<uint32> load_without_stickers_requests;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PendingNewStickerSet {
|
2018-12-12 00:48:56 +01:00
|
|
|
MultiPromiseActor upload_files_multipromise{"UploadNewStickerSetFilesMultiPromiseActor"};
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id;
|
|
|
|
string title;
|
|
|
|
string short_name;
|
|
|
|
bool is_masks;
|
2020-03-23 16:03:13 +01:00
|
|
|
bool is_animated;
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FileId> file_ids;
|
2020-03-23 16:03:13 +01:00
|
|
|
vector<tl_object_ptr<td_api::InputSticker>> stickers;
|
2021-06-18 17:45:57 +02:00
|
|
|
string software;
|
2018-12-31 20:04:05 +01:00
|
|
|
Promise<> promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PendingAddStickerToSet {
|
|
|
|
string short_name;
|
|
|
|
FileId file_id;
|
2020-03-23 16:03:13 +01:00
|
|
|
tl_object_ptr<td_api::InputSticker> sticker;
|
2018-12-31 20:04:05 +01:00
|
|
|
Promise<> promise;
|
|
|
|
};
|
|
|
|
|
2020-03-20 14:36:07 +01:00
|
|
|
struct PendingSetStickerSetThumbnail {
|
|
|
|
string short_name;
|
|
|
|
FileId file_id;
|
|
|
|
Promise<> promise;
|
|
|
|
};
|
|
|
|
|
2021-09-15 23:41:40 +02:00
|
|
|
struct PendingGetAnimatedEmojiClickSticker {
|
|
|
|
string message_text_;
|
|
|
|
FullMessageId full_message_id_;
|
|
|
|
double start_time_ = 0;
|
|
|
|
Promise<td_api::object_ptr<td_api::sticker>> promise_;
|
|
|
|
};
|
|
|
|
|
2021-09-17 14:51:42 +02:00
|
|
|
struct PendingOnAnimatedEmojiClicked {
|
|
|
|
string emoji_;
|
|
|
|
FullMessageId full_message_id_;
|
|
|
|
vector<std::pair<int, double>> clicks_;
|
|
|
|
};
|
|
|
|
|
2020-03-14 01:47:19 +01:00
|
|
|
struct SpecialStickerSet {
|
|
|
|
StickerSetId id_;
|
|
|
|
int64 access_hash_ = 0;
|
2020-04-19 15:30:04 +02:00
|
|
|
string short_name_;
|
|
|
|
SpecialStickerSetType type_;
|
2020-04-19 23:41:26 +02:00
|
|
|
bool is_being_loaded_ = false;
|
2020-03-14 01:47:19 +01:00
|
|
|
};
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
class StickerListLogEvent;
|
|
|
|
class StickerSetListLogEvent;
|
|
|
|
|
|
|
|
class UploadStickerFileCallback;
|
|
|
|
|
2021-03-01 02:19:50 +01:00
|
|
|
static vector<td_api::object_ptr<td_api::closedVectorPath>> get_sticker_minithumbnail(CSlice path,
|
2021-03-02 02:48:02 +01:00
|
|
|
StickerSetId sticker_set_id,
|
|
|
|
int64 document_id);
|
2020-11-20 14:22:07 +01:00
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
static tl_object_ptr<td_api::MaskPoint> get_mask_point_object(int32 point);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
tl_object_ptr<td_api::stickerSetInfo> get_sticker_set_info_object(StickerSetId sticker_set_id,
|
|
|
|
size_t covers_limit) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
Sticker *get_sticker(FileId file_id);
|
|
|
|
const Sticker *get_sticker(FileId file_id) const;
|
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
FileId on_get_sticker(unique_ptr<Sticker> new_sticker, bool replace);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSet *get_sticker_set(StickerSetId sticker_set_id);
|
|
|
|
const StickerSet *get_sticker_set(StickerSetId sticker_set_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSet *add_sticker_set(StickerSetId sticker_set_id, int64 access_hash);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-07-15 03:01:26 +02:00
|
|
|
std::pair<int64, FileId> on_get_sticker_document(tl_object_ptr<telegram_api::Document> &&document_ptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
static tl_object_ptr<telegram_api::InputStickerSet> get_input_sticker_set(const StickerSet *set);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId on_get_input_sticker_set(FileId sticker_file_id, tl_object_ptr<telegram_api::InputStickerSet> &&set_ptr,
|
|
|
|
MultiPromiseActor *load_data_multipromise_ptr = nullptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_resolve_sticker_set_short_name(FileId sticker_file_id, const string &short_name);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
int apply_installed_sticker_sets_order(bool is_masks, const vector<StickerSetId> &sticker_set_ids);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_update_sticker_set(StickerSet *sticker_set, bool is_installed, bool is_archived, bool is_changed,
|
|
|
|
bool from_database = false);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
static string get_sticker_set_database_key(StickerSetId set_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
static string get_full_sticker_set_database_key(StickerSetId set_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
string get_sticker_set_database_value(const StickerSet *s, bool with_stickers);
|
|
|
|
|
|
|
|
void update_sticker_set(StickerSet *sticker_set);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void load_sticker_sets(vector<StickerSetId> &&sticker_set_ids, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void load_sticker_sets_without_stickers(vector<StickerSetId> &&sticker_set_ids, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_load_sticker_set_from_database(StickerSetId sticker_set_id, bool with_stickers, string value);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void update_load_requests(StickerSet *sticker_set, bool with_stickers, const Status &status);
|
|
|
|
|
|
|
|
void update_load_request(uint32 load_request_id, const Status &status);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void do_reload_sticker_set(StickerSetId sticker_set_id,
|
|
|
|
tl_object_ptr<telegram_api::InputStickerSet> &&input_sticker_set,
|
2019-07-30 17:43:29 +02:00
|
|
|
Promise<Unit> &&promise) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
static void read_featured_sticker_sets(void *td_void);
|
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 get_sticker_sets_hash(const vector<StickerSetId> &sticker_set_ids) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 get_featured_sticker_sets_hash() const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 get_recent_stickers_hash(const vector<FileId> &sticker_ids) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void load_installed_sticker_sets(bool is_masks, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void load_featured_sticker_sets(Promise<Unit> &&promise);
|
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
void load_old_featured_sticker_sets(Promise<Unit> &&promise);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void load_recent_stickers(bool is_attached, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_load_installed_sticker_sets_from_database(bool is_masks, string value);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_load_installed_sticker_sets_finished(bool is_masks, vector<StickerSetId> &&installed_sticker_set_ids,
|
2018-12-31 20:04:05 +01:00
|
|
|
bool from_database = false);
|
|
|
|
|
|
|
|
void on_load_featured_sticker_sets_from_database(string value);
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
void on_load_featured_sticker_sets_finished(vector<StickerSetId> &&featured_sticker_set_ids);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
void on_load_old_featured_sticker_sets_from_database(uint32 generation, string value);
|
|
|
|
|
|
|
|
void on_load_old_featured_sticker_sets_finished(uint32 generation,
|
|
|
|
vector<StickerSetId> &&old_featured_sticker_set_ids);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_load_recent_stickers_from_database(bool is_attached, string value);
|
|
|
|
|
|
|
|
void on_load_recent_stickers_finished(bool is_attached, vector<FileId> &&recent_sticker_ids,
|
|
|
|
bool from_database = false);
|
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
td_api::object_ptr<td_api::updateInstalledStickerSets> get_update_installed_sticker_sets_object(int is_mask) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_installed_sticker_sets(bool from_database = false);
|
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
void reload_old_featured_sticker_sets(uint32 generation = 0);
|
|
|
|
|
|
|
|
void on_old_featured_sticker_sets_invalidated();
|
|
|
|
|
|
|
|
void invalidate_old_featured_sticker_sets();
|
|
|
|
|
|
|
|
void set_old_featured_sticker_set_count(int32 count);
|
|
|
|
|
|
|
|
// must be called after every call to set_old_featured_sticker_set_count or
|
|
|
|
// any change of old_featured_sticker_set_ids_ size
|
|
|
|
void fix_old_featured_sticker_set_count();
|
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
td_api::object_ptr<td_api::updateTrendingStickerSets> get_update_trending_sticker_sets_object() const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_featured_sticker_sets();
|
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
td_api::object_ptr<td_api::updateRecentStickers> get_update_recent_stickers_object(int is_attached) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_recent_stickers(bool from_database = false);
|
|
|
|
|
2018-03-08 19:04:28 +01:00
|
|
|
void save_recent_stickers_to_database(bool is_attached);
|
|
|
|
|
2019-11-30 19:22:40 +01:00
|
|
|
void add_recent_sticker_impl(bool is_attached, FileId sticker_id, bool add_on_server, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 get_favorite_stickers_hash() const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-11-30 19:22:40 +01:00
|
|
|
void add_favorite_sticker_impl(FileId sticker_id, bool add_on_server, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void load_favorite_stickers(Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_load_favorite_stickers_from_database(const string &value);
|
|
|
|
|
|
|
|
void on_load_favorite_stickers_finished(vector<FileId> &&favorite_sticker_ids, bool from_database = false);
|
|
|
|
|
2018-09-20 21:25:09 +02:00
|
|
|
td_api::object_ptr<td_api::updateFavoriteStickers> get_update_favorite_stickers_object() const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_favorite_stickers(bool from_database = false);
|
|
|
|
|
2018-03-08 19:04:28 +01:00
|
|
|
void save_favorite_stickers_to_database();
|
|
|
|
|
2019-02-21 18:54:20 +01:00
|
|
|
template <class StorerT>
|
|
|
|
void store_sticker_set(const StickerSet *sticker_set, bool with_stickers, StorerT &storer) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-02-21 18:54:20 +01:00
|
|
|
template <class ParserT>
|
|
|
|
void parse_sticker_set(StickerSet *sticker_set, ParserT &parser);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-23 16:03:13 +01:00
|
|
|
static string &get_input_sticker_emojis(td_api::InputSticker *sticker);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-23 16:03:13 +01:00
|
|
|
Result<std::tuple<FileId, bool, bool, bool>> prepare_input_file(const tl_object_ptr<td_api::InputFile> &input_file,
|
|
|
|
bool is_animated, bool for_thumbnail);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-23 16:03:13 +01:00
|
|
|
Result<std::tuple<FileId, bool, bool, bool>> prepare_input_sticker(td_api::InputSticker *sticker);
|
|
|
|
|
|
|
|
tl_object_ptr<telegram_api::inputStickerSetItem> get_input_sticker(td_api::InputSticker *sticker,
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId file_id) const;
|
|
|
|
|
|
|
|
void upload_sticker_file(UserId user_id, FileId file_id, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_upload_sticker_file(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file);
|
|
|
|
|
|
|
|
void on_upload_sticker_file_error(FileId file_id, Status status);
|
|
|
|
|
|
|
|
void do_upload_sticker_file(UserId user_id, FileId file_id, tl_object_ptr<telegram_api::InputFile> &&input_file,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_new_stickers_uploaded(int64 random_id, Result<Unit> result);
|
|
|
|
|
|
|
|
void on_added_sticker_uploaded(int64 random_id, Result<Unit> result);
|
|
|
|
|
2020-03-20 14:36:07 +01:00
|
|
|
void on_sticker_set_thumbnail_uploaded(int64 random_id, Result<Unit> result);
|
|
|
|
|
2020-03-23 16:03:13 +01:00
|
|
|
void do_set_sticker_set_thumbnail(UserId user_id, string short_name, tl_object_ptr<td_api::InputFile> &&thumbnail,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool update_sticker_set_cache(const StickerSet *sticker_set, Promise<Unit> &promise);
|
|
|
|
|
2021-09-15 23:41:40 +02:00
|
|
|
static int get_emoji_number(Slice emoji);
|
|
|
|
|
2021-09-20 12:45:49 +02:00
|
|
|
vector<FileId> get_animated_emoji_stickers(const StickerSet *sticker_set, Slice emoji) const;
|
2021-09-17 15:58:20 +02:00
|
|
|
|
2021-09-20 12:45:49 +02:00
|
|
|
void choose_animated_emoji_click_sticker(const StickerSet *sticker_set, Slice message_text,
|
2021-09-15 23:41:40 +02:00
|
|
|
FullMessageId full_message_id, double start_time,
|
|
|
|
Promise<td_api::object_ptr<td_api::sticker>> &&promise);
|
|
|
|
|
2021-09-19 19:43:47 +02:00
|
|
|
void send_click_animated_emoji_message_response(FileId sticker_id,
|
|
|
|
Promise<td_api::object_ptr<td_api::sticker>> &&promise);
|
|
|
|
|
2021-09-19 00:52:56 +02:00
|
|
|
void flush_sent_animated_emoji_clicks();
|
|
|
|
|
2021-09-16 22:22:34 +02:00
|
|
|
void flush_pending_animated_emoji_clicks();
|
|
|
|
|
2021-09-20 12:45:49 +02:00
|
|
|
void schedule_update_animated_emoji_clicked(const StickerSet *sticker_set, Slice emoji, FullMessageId full_message_id,
|
|
|
|
vector<std::pair<int, double>> clicks);
|
2021-09-17 18:59:31 +02:00
|
|
|
|
2021-09-17 22:36:25 +02:00
|
|
|
void send_update_animated_emoji_clicked(FullMessageId full_message_id, FileId sticker_id);
|
2021-09-17 14:51:42 +02:00
|
|
|
|
2020-04-19 10:17:51 +02:00
|
|
|
td_api::object_ptr<td_api::updateDiceEmojis> get_update_dice_emojis_object() const;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void start_up() final;
|
2019-11-21 20:18:29 +01:00
|
|
|
|
2021-09-16 22:22:34 +02:00
|
|
|
void timeout_expired() final;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void tear_down() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-19 23:41:26 +02:00
|
|
|
SpecialStickerSet &add_special_sticker_set(const string &type);
|
|
|
|
|
2020-03-14 01:47:19 +01:00
|
|
|
static void init_special_sticker_set(SpecialStickerSet &sticker_set, int64 sticker_set_id, int64 access_hash,
|
|
|
|
string name);
|
|
|
|
|
2020-04-19 23:41:26 +02:00
|
|
|
void load_special_sticker_set_info_from_binlog(SpecialStickerSet &sticker_set);
|
|
|
|
|
|
|
|
void load_special_sticker_set_by_type(const SpecialStickerSetType &type);
|
|
|
|
|
2020-03-14 01:47:19 +01:00
|
|
|
void load_special_sticker_set(SpecialStickerSet &sticker_set);
|
|
|
|
|
2020-04-19 23:41:26 +02:00
|
|
|
void reload_special_sticker_set(SpecialStickerSet &sticker_set);
|
|
|
|
|
2019-07-15 03:01:26 +02:00
|
|
|
static void add_sticker_thumbnail(Sticker *s, PhotoSize thumbnail);
|
|
|
|
|
2019-07-15 02:43:05 +02:00
|
|
|
static string get_sticker_mime_type(const Sticker *s);
|
|
|
|
|
2019-05-21 17:48:35 +02:00
|
|
|
static string get_emoji_language_code_version_database_key(const string &language_code);
|
|
|
|
|
2019-05-21 19:42:41 +02:00
|
|
|
static string get_emoji_language_code_last_difference_time_database_key(const string &language_code);
|
|
|
|
|
2019-05-21 17:48:35 +02:00
|
|
|
static string get_language_emojis_database_key(const string &language_code, const string &text);
|
|
|
|
|
|
|
|
static string get_emoji_language_codes_database_key(const vector<string> &language_codes);
|
|
|
|
|
|
|
|
int32 get_emoji_language_code_version(const string &language_code);
|
|
|
|
|
2019-05-21 19:42:41 +02:00
|
|
|
double get_emoji_language_code_last_difference_time(const string &language_code);
|
|
|
|
|
2020-04-22 14:17:53 +02:00
|
|
|
vector<string> get_emoji_language_codes(const vector<string> &input_language_codes, Slice text,
|
|
|
|
Promise<Unit> &promise);
|
2019-05-21 17:48:35 +02:00
|
|
|
|
|
|
|
void load_language_codes(vector<string> language_codes, string key, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_get_language_codes(const string &key, Result<vector<string>> &&result);
|
|
|
|
|
|
|
|
vector<string> search_language_emojis(const string &language_code, const string &text, bool exact_match) const;
|
|
|
|
|
|
|
|
void load_emoji_keywords(const string &language_code, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_get_emoji_keywords(const string &language_code,
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::emojiKeywordsDifference>> &&result);
|
|
|
|
|
2019-05-21 19:42:41 +02:00
|
|
|
void load_emoji_keywords_difference(const string &language_code);
|
|
|
|
|
|
|
|
void on_get_emoji_keywords_difference(
|
|
|
|
const string &language_code, int32 from_version,
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::emojiKeywordsDifference>> &&result);
|
|
|
|
|
2019-05-21 21:44:13 +02:00
|
|
|
void on_get_emoji_suggestions_url(int64 random_id, Promise<Unit> &&promise,
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::emojiURL>> &&r_emoji_url);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Td *td_;
|
|
|
|
ActorShared<> parent_;
|
2020-06-04 00:19:37 +02:00
|
|
|
|
|
|
|
bool is_inited_ = false;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::unordered_map<FileId, unique_ptr<Sticker>, FileIdHash> stickers_; // file_id -> Sticker
|
|
|
|
std::unordered_map<StickerSetId, unique_ptr<StickerSet>, StickerSetIdHash> sticker_sets_; // id -> StickerSet
|
|
|
|
std::unordered_map<string, StickerSetId> short_name_to_sticker_set_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> installed_sticker_set_ids_[2];
|
|
|
|
vector<StickerSetId> featured_sticker_set_ids_;
|
2020-04-18 00:55:54 +02:00
|
|
|
vector<StickerSetId> old_featured_sticker_set_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FileId> recent_sticker_ids_[2];
|
|
|
|
vector<FileId> favorite_sticker_ids_;
|
|
|
|
|
2020-11-23 18:33:35 +01:00
|
|
|
double next_installed_sticker_sets_load_time_[2] = {0, 0};
|
|
|
|
double next_featured_sticker_sets_load_time_ = 0;
|
|
|
|
double next_recent_stickers_load_time_[2] = {0, 0};
|
|
|
|
double next_favorite_stickers_load_time_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 installed_sticker_sets_hash_[2] = {0, 0};
|
|
|
|
int64 featured_sticker_sets_hash_ = 0;
|
|
|
|
int64 recent_stickers_hash_[2] = {0, 0};
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
int32 old_featured_sticker_set_count_ = -1;
|
|
|
|
uint32 old_featured_sticker_set_generation_ = 1;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool need_update_installed_sticker_sets_[2] = {false, false};
|
|
|
|
bool need_update_featured_sticker_sets_ = false;
|
|
|
|
bool need_update_recent_stickers_[2] = {false, false};
|
|
|
|
|
|
|
|
bool are_installed_sticker_sets_loaded_[2] = {false, false};
|
|
|
|
bool are_featured_sticker_sets_loaded_ = false;
|
|
|
|
bool are_recent_stickers_loaded_[2] = {false, false};
|
|
|
|
bool are_favorite_stickers_loaded_ = false;
|
|
|
|
|
2020-04-18 00:55:54 +02:00
|
|
|
bool are_old_featured_sticker_sets_invalidated_ = false;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<Promise<Unit>> load_installed_sticker_sets_queries_[2];
|
|
|
|
vector<Promise<Unit>> load_featured_sticker_sets_queries_;
|
2020-04-18 00:55:54 +02:00
|
|
|
vector<Promise<Unit>> load_old_featured_sticker_sets_queries_;
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<Promise<Unit>> load_recent_stickers_queries_[2];
|
2019-02-02 11:54:40 +01:00
|
|
|
vector<Promise<Unit>> repair_recent_stickers_queries_[2];
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<Promise<Unit>> load_favorite_stickers_queries_;
|
2019-02-02 11:54:40 +01:00
|
|
|
vector<Promise<Unit>> repair_favorite_stickers_queries_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-02-02 11:54:40 +01:00
|
|
|
vector<FileId> recent_sticker_file_ids_[2];
|
|
|
|
FileSourceId recent_stickers_file_source_id_[2];
|
|
|
|
vector<FileId> favorite_sticker_file_ids_;
|
|
|
|
FileSourceId favorite_stickers_file_source_id_;
|
2019-02-02 11:30:49 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> archived_sticker_set_ids_[2];
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 total_archived_sticker_set_count_[2] = {-1, -1};
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::unordered_map<FileId, vector<StickerSetId>, FileIdHash> attached_sticker_sets_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-03-05 23:44:11 +01:00
|
|
|
Hints installed_sticker_sets_hints_[2]; // search installed sticker sets by their title and name
|
|
|
|
|
2021-01-15 11:57:45 +01:00
|
|
|
struct FoundStickers {
|
2021-01-15 12:53:00 +01:00
|
|
|
vector<FileId> sticker_ids_;
|
|
|
|
int32 cache_time_ = 300;
|
|
|
|
double next_reload_time_ = 0;
|
2021-01-15 11:57:45 +01:00
|
|
|
};
|
|
|
|
std::unordered_map<string, FoundStickers> found_stickers_;
|
2018-03-09 18:04:44 +01:00
|
|
|
std::unordered_map<string, vector<Promise<Unit>>> search_stickers_queries_;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::unordered_map<string, vector<StickerSetId>> found_sticker_sets_;
|
2018-03-05 23:44:11 +01:00
|
|
|
std::unordered_map<string, vector<Promise<Unit>>> search_sticker_sets_queries_;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::unordered_set<StickerSetId, StickerSetIdHash> pending_viewed_featured_sticker_set_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
Timeout pending_featured_sticker_set_views_timeout_;
|
|
|
|
|
2018-03-08 14:49:45 +01:00
|
|
|
int32 recent_stickers_limit_ = 200;
|
|
|
|
int32 favorite_stickers_limit_ = 5;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-19 15:30:04 +02:00
|
|
|
std::unordered_map<string, SpecialStickerSet> special_sticker_sets_;
|
2019-11-21 20:18:29 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct StickerSetLoadRequest {
|
|
|
|
Promise<Unit> promise;
|
|
|
|
Status error;
|
|
|
|
size_t left_queries;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unordered_map<uint32, StickerSetLoadRequest> sticker_set_load_requests_;
|
|
|
|
uint32 current_sticker_set_load_request_ = 0;
|
|
|
|
|
|
|
|
std::unordered_map<int64, unique_ptr<PendingNewStickerSet>> pending_new_sticker_sets_;
|
|
|
|
|
|
|
|
std::unordered_map<int64, unique_ptr<PendingAddStickerToSet>> pending_add_sticker_to_sets_;
|
|
|
|
|
2020-03-20 14:36:07 +01:00
|
|
|
std::unordered_map<int64, unique_ptr<PendingSetStickerSetThumbnail>> pending_set_sticker_set_thumbnails_;
|
|
|
|
|
2021-09-24 15:53:42 +02:00
|
|
|
double next_click_animated_emoji_message_time_ = 0;
|
|
|
|
double next_update_animated_emoji_clicked_time_ = 0;
|
2021-09-15 23:41:40 +02:00
|
|
|
vector<PendingGetAnimatedEmojiClickSticker> pending_get_animated_emoji_click_stickers_;
|
2021-09-17 14:51:42 +02:00
|
|
|
vector<PendingOnAnimatedEmojiClicked> pending_on_animated_emoji_message_clicked_;
|
2021-09-15 23:41:40 +02:00
|
|
|
|
2021-09-16 22:22:34 +02:00
|
|
|
string last_clicked_animated_emoji_;
|
|
|
|
FullMessageId last_clicked_animated_emoji_full_message_id_;
|
|
|
|
std::vector<std::pair<int, double>> pending_animated_emoji_clicks_;
|
|
|
|
|
2021-09-19 00:52:56 +02:00
|
|
|
struct SentAnimatedEmojiClicks {
|
|
|
|
double send_time = 0.0;
|
|
|
|
DialogId dialog_id;
|
|
|
|
string emoji;
|
|
|
|
};
|
|
|
|
std::vector<SentAnimatedEmojiClicks> sent_animated_emoji_clicks_;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
std::shared_ptr<UploadStickerFileCallback> upload_sticker_file_callback_;
|
|
|
|
|
|
|
|
std::unordered_map<FileId, std::pair<UserId, Promise<Unit>>, FileIdHash> being_uploaded_files_;
|
2019-05-21 17:48:35 +02:00
|
|
|
|
|
|
|
std::unordered_map<string, vector<string>> emoji_language_codes_;
|
|
|
|
std::unordered_map<string, int32> emoji_language_code_versions_;
|
2019-05-21 19:42:41 +02:00
|
|
|
std::unordered_map<string, double> emoji_language_code_last_difference_times_;
|
2020-01-08 17:25:36 +01:00
|
|
|
std::unordered_set<string> reloaded_emoji_keywords_;
|
2019-05-21 17:48:35 +02:00
|
|
|
std::unordered_map<string, vector<Promise<Unit>>> load_emoji_keywords_queries_;
|
|
|
|
std::unordered_map<string, vector<Promise<Unit>>> load_language_codes_queries_;
|
2019-05-21 21:44:13 +02:00
|
|
|
std::unordered_map<int64, string> emoji_suggestions_urls_;
|
2020-04-19 10:17:51 +02:00
|
|
|
|
2020-04-19 23:41:26 +02:00
|
|
|
std::unordered_map<string, std::unordered_set<FullMessageId, FullMessageIdHash>> dice_messages_;
|
|
|
|
|
2020-04-19 15:30:04 +02:00
|
|
|
string dice_emojis_str_;
|
|
|
|
vector<string> dice_emojis_;
|
2020-04-21 13:51:46 +02:00
|
|
|
|
|
|
|
string dice_success_values_str_;
|
2020-04-21 18:08:01 +02:00
|
|
|
vector<std::pair<int32, int32>> dice_success_values_;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|