2024-02-21 18:43:55 +01:00
|
|
|
//
|
2024-05-29 11:17:15 +02:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2024-02-21 18:43:55 +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
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
#include "td/telegram/DialogId.h"
|
2024-02-29 17:01:40 +01:00
|
|
|
#include "td/telegram/files/FileId.h"
|
2024-02-29 15:41:05 +01:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2024-02-21 20:06:07 +01:00
|
|
|
#include "td/telegram/MessageId.h"
|
2024-02-29 15:11:39 +01:00
|
|
|
#include "td/telegram/QuickReplyMessageFullId.h"
|
2024-02-24 01:16:56 +01:00
|
|
|
#include "td/telegram/QuickReplyShortcutId.h"
|
2024-02-21 20:06:07 +01:00
|
|
|
#include "td/telegram/td_api.h"
|
2024-03-07 11:56:57 +01:00
|
|
|
#include "td/telegram/telegram_api.h"
|
2024-02-21 20:06:07 +01:00
|
|
|
#include "td/telegram/UserId.h"
|
|
|
|
|
2024-02-21 18:43:55 +01:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2024-02-28 15:19:28 +01:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2024-02-24 01:06:20 +01:00
|
|
|
#include "td/utils/FlatHashSet.h"
|
|
|
|
#include "td/utils/Promise.h"
|
2024-03-04 13:00:00 +01:00
|
|
|
#include "td/utils/Slice.h"
|
2024-03-04 12:34:47 +01:00
|
|
|
#include "td/utils/Status.h"
|
2024-02-21 18:43:55 +01:00
|
|
|
|
2024-04-17 20:29:58 +02:00
|
|
|
#include <memory>
|
2024-04-20 17:57:32 +02:00
|
|
|
#include <tuple>
|
2024-02-22 19:44:13 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2024-02-21 18:43:55 +01:00
|
|
|
namespace td {
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
class Dependencies;
|
2024-04-15 22:12:22 +02:00
|
|
|
struct InputMessageContent;
|
2024-02-21 20:06:07 +01:00
|
|
|
class MessageContent;
|
2024-03-06 13:56:50 +01:00
|
|
|
struct ReplyMarkup;
|
2024-02-21 18:43:55 +01:00
|
|
|
class Td;
|
|
|
|
|
|
|
|
class QuickReplyManager final : public Actor {
|
|
|
|
public:
|
|
|
|
QuickReplyManager(Td *td, ActorShared<> parent);
|
|
|
|
|
2024-03-04 12:34:47 +01:00
|
|
|
static Status check_shortcut_name(CSlice name);
|
|
|
|
|
2024-02-22 21:04:36 +01:00
|
|
|
void get_quick_reply_shortcuts(Promise<Unit> &&promise);
|
2024-02-22 15:32:12 +01:00
|
|
|
|
2024-03-04 13:00:00 +01:00
|
|
|
void set_quick_reply_shortcut_name(QuickReplyShortcutId shortcut_id, const string &name, Promise<Unit> &&promise);
|
|
|
|
|
2024-02-27 16:10:11 +01:00
|
|
|
void delete_quick_reply_shortcut(QuickReplyShortcutId shortcut_id, Promise<Unit> &&promise);
|
2024-02-24 01:02:42 +01:00
|
|
|
|
2024-02-27 16:10:11 +01:00
|
|
|
void reorder_quick_reply_shortcuts(const vector<QuickReplyShortcutId> &shortcut_ids, Promise<Unit> &&promise);
|
2024-02-24 12:40:25 +01:00
|
|
|
|
2024-02-29 14:39:38 +01:00
|
|
|
void update_quick_reply_message(telegram_api::object_ptr<telegram_api::Message> &&message_ptr);
|
|
|
|
|
2024-02-29 19:59:53 +01:00
|
|
|
void delete_quick_reply_messages_from_updates(QuickReplyShortcutId shortcut_id, const vector<MessageId> &message_ids);
|
2024-02-29 12:43:32 +01:00
|
|
|
|
2024-02-29 14:05:16 +01:00
|
|
|
void get_quick_reply_shortcut_messages(QuickReplyShortcutId shortcut_id, Promise<Unit> &&promise);
|
2024-02-28 15:19:28 +01:00
|
|
|
|
2024-02-29 19:34:45 +01:00
|
|
|
void delete_quick_reply_shortcut_messages(QuickReplyShortcutId shortcut_id, const vector<MessageId> &message_ids,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-04-17 17:39:25 +02:00
|
|
|
Result<td_api::object_ptr<td_api::quickReplyMessage>> send_message(
|
|
|
|
const string &shortcut_name, MessageId reply_to_message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content);
|
|
|
|
|
2024-04-18 21:13:39 +02:00
|
|
|
Result<td_api::object_ptr<td_api::quickReplyMessage>> send_inline_query_result_message(const string &shortcut_name,
|
|
|
|
MessageId reply_to_message_id,
|
|
|
|
int64 query_id,
|
|
|
|
const string &result_id,
|
|
|
|
bool hide_via_bot);
|
|
|
|
|
2024-04-29 20:48:12 +02:00
|
|
|
Result<td_api::object_ptr<td_api::quickReplyMessages>> send_message_group(
|
|
|
|
const string &shortcut_name, MessageId reply_to_message_id,
|
|
|
|
vector<td_api::object_ptr<td_api::InputMessageContent>> &&input_message_contents);
|
|
|
|
|
2024-04-18 22:45:53 +02:00
|
|
|
Result<td_api::object_ptr<td_api::quickReplyMessages>> resend_messages(const string &shortcut_name,
|
|
|
|
vector<MessageId> message_ids);
|
|
|
|
|
2024-04-19 15:42:58 +02:00
|
|
|
void edit_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-02-22 15:32:12 +01:00
|
|
|
void reload_quick_reply_shortcuts();
|
|
|
|
|
2024-02-29 19:34:45 +01:00
|
|
|
void reload_quick_reply_messages(QuickReplyShortcutId shortcut_id, Promise<Unit> &&promise);
|
|
|
|
|
2024-02-29 15:05:00 +01:00
|
|
|
void reload_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id, Promise<Unit> &&promise);
|
|
|
|
|
2024-03-04 18:06:32 +01:00
|
|
|
struct QuickReplyMessageContent {
|
|
|
|
unique_ptr<MessageContent> content_;
|
|
|
|
MessageId original_message_id_;
|
|
|
|
MessageId original_reply_to_message_id_;
|
2024-03-06 13:56:50 +01:00
|
|
|
unique_ptr<ReplyMarkup> reply_markup_;
|
2024-03-18 20:38:30 +01:00
|
|
|
UserId via_bot_user_id_;
|
2024-03-04 18:06:32 +01:00
|
|
|
int64 media_album_id_;
|
|
|
|
bool invert_media_;
|
|
|
|
bool disable_web_page_preview_;
|
|
|
|
};
|
|
|
|
Result<vector<QuickReplyMessageContent>> get_quick_reply_message_contents(DialogId dialog_id,
|
|
|
|
QuickReplyShortcutId shortcut_id) const;
|
|
|
|
|
2024-02-29 15:41:05 +01:00
|
|
|
FileSourceId get_quick_reply_message_file_source_id(QuickReplyMessageFullId message_full_id);
|
|
|
|
|
2024-02-22 19:26:17 +01:00
|
|
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
|
|
|
|
2024-02-21 18:43:55 +01:00
|
|
|
private:
|
2024-04-18 22:45:53 +02:00
|
|
|
static constexpr size_t MAX_GROUPED_MESSAGES = 10; // server side limit
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
struct QuickReplyMessage {
|
2024-02-22 15:32:12 +01:00
|
|
|
QuickReplyMessage() = default;
|
|
|
|
QuickReplyMessage(const QuickReplyMessage &) = delete;
|
|
|
|
QuickReplyMessage &operator=(const QuickReplyMessage &) = delete;
|
|
|
|
QuickReplyMessage(QuickReplyMessage &&) = delete;
|
|
|
|
QuickReplyMessage &operator=(QuickReplyMessage &&) = delete;
|
|
|
|
~QuickReplyMessage();
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
MessageId message_id;
|
2024-02-24 01:16:56 +01:00
|
|
|
QuickReplyShortcutId shortcut_id;
|
2024-02-22 19:40:07 +01:00
|
|
|
int32 edit_date = 0;
|
2024-02-21 20:06:07 +01:00
|
|
|
|
|
|
|
int64 random_id = 0; // for send_message
|
|
|
|
|
2024-02-21 20:27:46 +01:00
|
|
|
MessageId reply_to_message_id;
|
2024-02-21 20:06:07 +01:00
|
|
|
|
2024-02-21 20:27:46 +01:00
|
|
|
string send_emoji; // for send_message
|
2024-02-21 20:06:07 +01:00
|
|
|
|
2024-04-18 21:13:39 +02:00
|
|
|
int64 inline_query_id = 0; // for send_message
|
|
|
|
string inline_result_id; // for send_message
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
UserId via_bot_user_id;
|
|
|
|
|
|
|
|
bool is_failed_to_send = false;
|
|
|
|
bool disable_notification = false;
|
|
|
|
bool invert_media = false;
|
2024-03-04 16:55:03 +01:00
|
|
|
bool disable_web_page_preview = false;
|
2024-02-21 20:06:07 +01:00
|
|
|
|
2024-03-04 16:55:03 +01:00
|
|
|
bool from_background = false; // for send_message
|
|
|
|
bool hide_via_bot = false; // for resend_message
|
2024-02-21 20:06:07 +01:00
|
|
|
|
2024-04-19 15:42:58 +02:00
|
|
|
bool edited_invert_media = false;
|
|
|
|
bool edited_disable_web_page_preview = false;
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
int32 legacy_layer = 0;
|
|
|
|
|
|
|
|
int32 send_error_code = 0;
|
|
|
|
string send_error_message;
|
|
|
|
double try_resend_at = 0;
|
|
|
|
|
|
|
|
int64 media_album_id = 0;
|
|
|
|
|
|
|
|
unique_ptr<MessageContent> content;
|
2024-03-06 13:56:50 +01:00
|
|
|
unique_ptr<ReplyMarkup> reply_markup;
|
2024-02-21 20:06:07 +01:00
|
|
|
|
2024-04-19 15:42:58 +02:00
|
|
|
unique_ptr<MessageContent> edited_content;
|
|
|
|
int64 edit_generation = 0;
|
|
|
|
|
2024-02-23 14:17:37 +01:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2024-02-22 15:32:12 +01:00
|
|
|
};
|
2024-02-21 20:06:07 +01:00
|
|
|
|
2024-02-22 15:32:12 +01:00
|
|
|
struct Shortcut {
|
|
|
|
Shortcut() = default;
|
|
|
|
Shortcut(const Shortcut &) = delete;
|
|
|
|
Shortcut &operator=(const Shortcut &) = delete;
|
|
|
|
Shortcut(Shortcut &&) = delete;
|
|
|
|
Shortcut &operator=(Shortcut &&) = delete;
|
|
|
|
~Shortcut();
|
|
|
|
|
|
|
|
string name_;
|
2024-02-24 01:16:56 +01:00
|
|
|
QuickReplyShortcutId shortcut_id_;
|
2024-02-22 21:08:38 +01:00
|
|
|
int32 server_total_count_ = 0;
|
|
|
|
int32 local_total_count_ = 0;
|
2024-02-22 15:32:12 +01:00
|
|
|
vector<unique_ptr<QuickReplyMessage>> messages_;
|
2024-04-15 23:53:48 +02:00
|
|
|
MessageId last_assigned_message_id_;
|
2024-02-23 14:17:37 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2024-02-22 15:32:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Shortcuts {
|
|
|
|
vector<unique_ptr<Shortcut>> shortcuts_;
|
|
|
|
bool are_inited_ = false;
|
2024-03-05 13:30:57 +01:00
|
|
|
bool are_loaded_from_database_ = false;
|
2024-02-22 15:32:12 +01:00
|
|
|
|
2024-02-22 21:04:36 +01:00
|
|
|
vector<Promise<Unit>> load_queries_;
|
2024-02-23 14:17:37 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2024-02-21 20:06:07 +01:00
|
|
|
};
|
|
|
|
|
2024-04-19 15:42:58 +02:00
|
|
|
class EditQuickReplyMessageQuery;
|
2024-04-29 20:48:12 +02:00
|
|
|
class SendQuickReplyInlineMessageQuery;
|
|
|
|
class SendQuickReplyMediaQuery;
|
|
|
|
class SendQuickReplyMessageQuery;
|
|
|
|
class SendQuickReplyMultiMediaQuery;
|
|
|
|
class UploadQuickReplyMediaQuery;
|
2024-04-17 17:39:25 +02:00
|
|
|
|
2024-04-17 20:29:58 +02:00
|
|
|
class UploadMediaCallback;
|
|
|
|
class UploadThumbnailCallback;
|
|
|
|
|
|
|
|
std::shared_ptr<UploadMediaCallback> upload_media_callback_;
|
|
|
|
std::shared_ptr<UploadThumbnailCallback> upload_thumbnail_callback_;
|
|
|
|
|
2024-02-21 18:43:55 +01:00
|
|
|
void tear_down() final;
|
|
|
|
|
2024-03-04 12:34:47 +01:00
|
|
|
static bool is_shortcut_name_letter(uint32 code);
|
|
|
|
|
2024-02-21 20:06:07 +01:00
|
|
|
void add_quick_reply_message_dependencies(Dependencies &dependencies, const QuickReplyMessage *m) const;
|
|
|
|
|
|
|
|
unique_ptr<QuickReplyMessage> create_message(telegram_api::object_ptr<telegram_api::Message> message_ptr,
|
|
|
|
const char *source) const;
|
|
|
|
|
2024-02-23 18:22:33 +01:00
|
|
|
bool can_edit_quick_reply_message(const QuickReplyMessage *m) const;
|
|
|
|
|
|
|
|
bool can_resend_quick_reply_message(const QuickReplyMessage *m) const;
|
2024-02-21 20:43:29 +01:00
|
|
|
|
|
|
|
td_api::object_ptr<td_api::MessageSendingState> get_message_sending_state_object(const QuickReplyMessage *m) const;
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::MessageContent> get_quick_reply_message_message_content_object(
|
|
|
|
const QuickReplyMessage *m) const;
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::quickReplyMessage> get_quick_reply_message_object(const QuickReplyMessage *m,
|
|
|
|
const char *source) const;
|
|
|
|
|
2024-02-22 15:32:12 +01:00
|
|
|
td_api::object_ptr<td_api::quickReplyShortcut> get_quick_reply_shortcut_object(const Shortcut *s,
|
|
|
|
const char *source) const;
|
|
|
|
|
2024-02-22 17:45:49 +01:00
|
|
|
static int32 get_shortcut_message_count(const Shortcut *s);
|
|
|
|
|
2024-02-29 13:55:38 +01:00
|
|
|
static bool have_all_shortcut_messages(const Shortcut *s);
|
|
|
|
|
2024-02-22 15:32:12 +01:00
|
|
|
void on_reload_quick_reply_shortcuts(
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::messages_QuickReplies>> r_shortcuts);
|
|
|
|
|
|
|
|
void on_load_quick_reply_success();
|
|
|
|
|
|
|
|
void on_load_quick_reply_fail(Status error);
|
|
|
|
|
2024-03-04 13:00:00 +01:00
|
|
|
void on_set_quick_reply_shortcut_name(QuickReplyShortcutId shortcut_id, const string &name, Promise<Unit> &&promise);
|
|
|
|
|
2024-02-23 12:49:29 +01:00
|
|
|
int64 get_shortcuts_hash() const;
|
|
|
|
|
2024-02-28 15:19:28 +01:00
|
|
|
void on_reload_quick_reply_messages(QuickReplyShortcutId shortcut_id,
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::messages_Messages>> r_messages);
|
|
|
|
|
2024-02-28 15:38:17 +01:00
|
|
|
static int64 get_quick_reply_messages_hash(const Shortcut *s);
|
|
|
|
|
2024-02-29 15:05:00 +01:00
|
|
|
void on_reload_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id,
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::messages_Messages>> r_messages,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void on_get_quick_reply_message(Shortcut *s, unique_ptr<QuickReplyMessage> message);
|
|
|
|
|
2024-02-29 18:58:30 +01:00
|
|
|
void update_quick_reply_message(QuickReplyShortcutId shortcut_id, unique_ptr<QuickReplyMessage> &old_message,
|
|
|
|
unique_ptr<QuickReplyMessage> &&new_message);
|
|
|
|
|
2024-02-29 19:59:53 +01:00
|
|
|
void delete_quick_reply_messages(Shortcut *s, const vector<MessageId> &message_ids, const char *source);
|
2024-02-29 15:21:55 +01:00
|
|
|
|
2024-02-24 01:16:56 +01:00
|
|
|
Shortcut *get_shortcut(QuickReplyShortcutId shortcut_id);
|
2024-02-22 17:45:49 +01:00
|
|
|
|
2024-03-04 18:06:32 +01:00
|
|
|
const Shortcut *get_shortcut(QuickReplyShortcutId shortcut_id) const;
|
|
|
|
|
2024-02-24 01:02:42 +01:00
|
|
|
Shortcut *get_shortcut(const string &name);
|
|
|
|
|
2024-02-27 16:10:11 +01:00
|
|
|
vector<unique_ptr<Shortcut>>::iterator get_shortcut_it(QuickReplyShortcutId shortcut_id);
|
|
|
|
|
2024-02-29 12:43:32 +01:00
|
|
|
vector<unique_ptr<QuickReplyMessage>>::iterator get_message_it(Shortcut *s, MessageId message_id);
|
|
|
|
|
2024-04-17 20:29:58 +02:00
|
|
|
QuickReplyMessage *get_message(QuickReplyMessageFullId message_full_id);
|
|
|
|
|
|
|
|
QuickReplyMessage *get_message(Shortcut *s, MessageId message_id);
|
|
|
|
|
2024-04-15 22:36:27 +02:00
|
|
|
Result<Shortcut *> create_new_local_shortcut(const string &name, int32 new_message_count);
|
2024-04-15 21:41:36 +02:00
|
|
|
|
2024-04-15 21:55:26 +02:00
|
|
|
static MessageId get_input_reply_to_message_id(const Shortcut *s, MessageId reply_to_message_id);
|
|
|
|
|
2024-04-15 22:12:22 +02:00
|
|
|
Result<InputMessageContent> process_input_message_content(
|
|
|
|
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content);
|
|
|
|
|
2024-04-15 23:53:48 +02:00
|
|
|
MessageId get_next_message_id(Shortcut *s, MessageType type) const;
|
|
|
|
|
|
|
|
MessageId get_next_yet_unsent_message_id(Shortcut *s) const;
|
|
|
|
|
|
|
|
MessageId get_next_local_message_id(Shortcut *s) const;
|
|
|
|
|
|
|
|
QuickReplyMessage *add_local_message(Shortcut *s, MessageId reply_to_message_id, unique_ptr<MessageContent> &&content,
|
|
|
|
bool invert_media, UserId via_bot_user_id, bool hide_via_bot,
|
|
|
|
bool disable_web_page_preview, string &&send_emoji);
|
|
|
|
|
2024-02-24 12:22:01 +01:00
|
|
|
bool is_shortcut_list_changed(const vector<unique_ptr<Shortcut>> &new_shortcuts) const;
|
|
|
|
|
2024-02-27 16:10:11 +01:00
|
|
|
vector<QuickReplyShortcutId> get_shortcut_ids() const;
|
|
|
|
|
2024-02-24 12:40:25 +01:00
|
|
|
vector<QuickReplyShortcutId> get_server_shortcut_ids() const;
|
|
|
|
|
2024-02-22 17:45:49 +01:00
|
|
|
static void sort_quick_reply_messages(vector<unique_ptr<QuickReplyMessage>> &messages);
|
|
|
|
|
2024-02-22 19:44:13 +01:00
|
|
|
using QuickReplyMessageUniqueId = std::pair<MessageId, int32>;
|
|
|
|
|
2024-02-22 19:47:34 +01:00
|
|
|
static QuickReplyMessageUniqueId get_quick_reply_unique_id(const QuickReplyMessage *m);
|
|
|
|
|
2024-02-22 19:44:13 +01:00
|
|
|
static vector<QuickReplyMessageUniqueId> get_quick_reply_unique_ids(
|
2024-02-22 19:40:07 +01:00
|
|
|
const vector<unique_ptr<QuickReplyMessage>> &messages);
|
2024-02-22 17:45:49 +01:00
|
|
|
|
2024-02-22 19:44:13 +01:00
|
|
|
static vector<QuickReplyMessageUniqueId> get_server_quick_reply_unique_ids(
|
2024-02-22 19:40:07 +01:00
|
|
|
const vector<unique_ptr<QuickReplyMessage>> &messages);
|
2024-02-22 17:45:49 +01:00
|
|
|
|
2024-03-05 16:12:05 +01:00
|
|
|
void update_shortcut_from(Shortcut *new_shortcut, Shortcut *old_shortcut, bool is_partial, bool *is_shortcut_changed,
|
|
|
|
bool *are_messages_changed);
|
2024-02-22 17:45:49 +01:00
|
|
|
|
2024-02-22 19:23:19 +01:00
|
|
|
td_api::object_ptr<td_api::updateQuickReplyShortcut> get_update_quick_reply_shortcut_object(const Shortcut *s,
|
|
|
|
const char *source) const;
|
|
|
|
|
|
|
|
void send_update_quick_reply_shortcut(const Shortcut *s, const char *source);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::updateQuickReplyShortcutDeleted> get_update_quick_reply_shortcut_deleted_object(
|
|
|
|
const Shortcut *s) const;
|
|
|
|
|
|
|
|
void send_update_quick_reply_shortcut_deleted(const Shortcut *s);
|
|
|
|
|
2024-02-22 20:55:09 +01:00
|
|
|
td_api::object_ptr<td_api::updateQuickReplyShortcuts> get_update_quick_reply_shortcuts_object() const;
|
|
|
|
|
|
|
|
void send_update_quick_reply_shortcuts();
|
|
|
|
|
2024-02-29 13:55:38 +01:00
|
|
|
td_api::object_ptr<td_api::updateQuickReplyShortcutMessages> get_update_quick_reply_shortcut_messages_object(
|
2024-02-29 14:10:15 +01:00
|
|
|
const Shortcut *s, const char *source) const;
|
2024-02-29 13:55:38 +01:00
|
|
|
|
2024-02-29 14:10:15 +01:00
|
|
|
void send_update_quick_reply_shortcut_messages(const Shortcut *s, const char *source);
|
2024-02-29 13:55:38 +01:00
|
|
|
|
2024-03-04 13:00:00 +01:00
|
|
|
void set_quick_reply_shortcut_name_on_server(QuickReplyShortcutId shortcut_id, const string &name,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-02-24 01:28:55 +01:00
|
|
|
void delete_quick_reply_shortcut_from_server(QuickReplyShortcutId shortcut_id, Promise<Unit> &&promise);
|
|
|
|
|
2024-02-24 12:40:25 +01:00
|
|
|
void reorder_quick_reply_shortcuts_on_server(vector<QuickReplyShortcutId> shortcut_ids, Promise<Unit> &&promise);
|
|
|
|
|
2024-02-29 19:34:45 +01:00
|
|
|
void delete_quick_reply_messages_on_server(QuickReplyShortcutId shortcut_id, const vector<MessageId> &message_ids,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-04-17 17:39:25 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::InputQuickReplyShortcut> get_input_quick_reply_shortcut(
|
|
|
|
QuickReplyShortcutId shortcut_id) const;
|
|
|
|
|
2024-04-18 15:05:43 +02:00
|
|
|
Status check_send_quick_reply_messages_response(QuickReplyShortcutId shortcut_id,
|
|
|
|
const telegram_api::object_ptr<telegram_api::Updates> &updates_ptr,
|
|
|
|
const vector<int64> &random_ids);
|
2024-04-17 17:39:25 +02:00
|
|
|
|
|
|
|
void process_send_quick_reply_updates(QuickReplyShortcutId shortcut_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::Updates> updates_ptr,
|
|
|
|
vector<int64> random_ids);
|
|
|
|
|
|
|
|
void on_failed_send_quick_reply_messages(QuickReplyShortcutId shortcut_id, vector<int64> random_ids, Status error);
|
|
|
|
|
2024-04-29 20:48:12 +02:00
|
|
|
void update_message_content(const QuickReplyMessage *old_message, QuickReplyMessage *new_message, bool is_edit);
|
|
|
|
|
|
|
|
void update_message_content(const unique_ptr<MessageContent> &old_content, unique_ptr<MessageContent> &new_content,
|
|
|
|
bool need_merge_files);
|
2024-04-18 13:33:07 +02:00
|
|
|
|
2024-04-17 17:39:25 +02:00
|
|
|
void do_send_message(const QuickReplyMessage *m, vector<int> bad_parts = {});
|
|
|
|
|
2024-04-18 14:13:16 +02:00
|
|
|
void on_send_message_file_parts_missing(QuickReplyShortcutId shortcut_id, int64 random_id, vector<int> &&bad_parts);
|
|
|
|
|
2024-04-18 14:01:58 +02:00
|
|
|
void on_send_message_file_reference_error(QuickReplyShortcutId shortcut_id, int64 random_id);
|
|
|
|
|
2024-04-17 20:29:58 +02:00
|
|
|
void on_upload_media(FileId file_id, telegram_api::object_ptr<telegram_api::InputFile> input_file);
|
|
|
|
|
|
|
|
void do_send_media(QuickReplyMessage *m, FileId file_id, FileId thumbnail_file_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> input_file,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> input_thumbnail);
|
|
|
|
|
|
|
|
void on_upload_media_error(FileId file_id, Status status);
|
|
|
|
|
|
|
|
void on_upload_thumbnail(FileId thumbnail_file_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> thumbnail_input_file);
|
|
|
|
|
2024-04-29 20:48:12 +02:00
|
|
|
void on_upload_message_media_success(QuickReplyShortcutId shortcut_id, MessageId message_id, FileId file_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::MessageMedia> &&media);
|
|
|
|
|
|
|
|
void on_upload_message_media_fail(QuickReplyShortcutId shortcut_id, MessageId message_id, Status error);
|
|
|
|
|
|
|
|
void on_upload_message_media_finished(int64 media_album_id, QuickReplyShortcutId shortcut_id, MessageId message_id,
|
|
|
|
Status result);
|
|
|
|
|
|
|
|
void do_send_message_group(QuickReplyShortcutId shortcut_id, int64 media_album_id);
|
|
|
|
|
2024-04-17 18:08:42 +02:00
|
|
|
void on_message_media_uploaded(const QuickReplyMessage *m,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputMedia> &&input_media, FileId file_id,
|
|
|
|
FileId thumbnail_file_id);
|
|
|
|
|
2024-04-29 20:48:12 +02:00
|
|
|
void on_send_media_group_file_reference_error(QuickReplyShortcutId shortcut_id, vector<int64> random_ids);
|
|
|
|
|
|
|
|
int64 generate_new_media_album_id() const;
|
2024-04-18 22:45:53 +02:00
|
|
|
|
2024-04-19 15:42:58 +02:00
|
|
|
void on_edit_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id, int64 edit_generation,
|
2024-04-20 17:57:32 +02:00
|
|
|
FileId file_id, bool was_uploaded,
|
2024-04-19 15:42:58 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::Updates> updates_ptr);
|
|
|
|
|
2024-04-20 17:57:32 +02:00
|
|
|
void fail_edit_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id, int64 edit_generation,
|
|
|
|
FileId file_id, FileId thumbnail_file_id, string file_reference, bool was_uploaded,
|
|
|
|
bool was_thumbnail_uploaded, Status status);
|
2024-04-19 15:42:58 +02:00
|
|
|
|
2024-02-27 21:47:29 +01:00
|
|
|
string get_quick_reply_shortcuts_database_key();
|
|
|
|
|
|
|
|
void save_quick_reply_shortcuts();
|
|
|
|
|
2024-03-05 13:30:57 +01:00
|
|
|
void load_quick_reply_shortcuts();
|
|
|
|
|
2024-02-29 17:01:40 +01:00
|
|
|
vector<FileId> get_message_file_ids(const QuickReplyMessage *m) const;
|
|
|
|
|
|
|
|
void delete_message_files(QuickReplyShortcutId shortcut_id, const QuickReplyMessage *m) const;
|
|
|
|
|
2024-02-29 19:05:56 +01:00
|
|
|
void change_message_files(QuickReplyMessageFullId message_full_id, const QuickReplyMessage *m,
|
|
|
|
const vector<FileId> &old_file_ids);
|
|
|
|
|
2024-02-22 15:32:12 +01:00
|
|
|
Shortcuts shortcuts_;
|
|
|
|
|
2024-04-15 22:36:27 +02:00
|
|
|
int32 next_local_shortcut_id_ = QuickReplyShortcutId::MAX_SERVER_SHORTCUT_ID + 1;
|
|
|
|
|
2024-02-24 01:16:56 +01:00
|
|
|
FlatHashSet<QuickReplyShortcutId, QuickReplyShortcutIdHash> deleted_shortcut_ids_;
|
2024-02-24 01:06:20 +01:00
|
|
|
|
2024-04-29 23:03:17 +02:00
|
|
|
FlatHashMap<QuickReplyShortcutId, QuickReplyShortcutId, QuickReplyShortcutIdHash> persistent_shortcut_ids_;
|
|
|
|
|
2024-02-29 14:05:16 +01:00
|
|
|
FlatHashMap<QuickReplyShortcutId, vector<Promise<Unit>>, QuickReplyShortcutIdHash> get_shortcut_messages_queries_;
|
2024-02-28 15:19:28 +01:00
|
|
|
|
2024-02-29 15:27:12 +01:00
|
|
|
FlatHashSet<QuickReplyMessageFullId, QuickReplyMessageFullIdHash> deleted_message_full_ids_;
|
|
|
|
|
2024-02-29 15:41:05 +01:00
|
|
|
FlatHashMap<QuickReplyMessageFullId, FileSourceId, QuickReplyMessageFullIdHash> message_full_id_to_file_source_id_;
|
|
|
|
|
2024-04-20 17:57:32 +02:00
|
|
|
FlatHashMap<FileId, std::tuple<QuickReplyMessageFullId, FileId, int64>, FileIdHash>
|
2024-04-17 20:29:58 +02:00
|
|
|
being_uploaded_files_; // file_id -> message, thumbnail_file_id
|
|
|
|
|
|
|
|
struct UploadedThumbnailInfo {
|
|
|
|
QuickReplyMessageFullId quick_reply_message_full_id;
|
2024-04-20 17:57:32 +02:00
|
|
|
FileId file_id; // original file file_id
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> input_file; // original file InputFile
|
|
|
|
int64 edit_generation;
|
2024-04-17 20:29:58 +02:00
|
|
|
};
|
|
|
|
FlatHashMap<FileId, UploadedThumbnailInfo, FileIdHash> being_uploaded_thumbnails_; // thumbnail_file_id -> ...
|
|
|
|
|
2024-04-29 20:48:12 +02:00
|
|
|
struct PendingMessageGroupSend {
|
|
|
|
size_t finished_count = 0;
|
|
|
|
vector<MessageId> message_ids;
|
|
|
|
vector<bool> is_finished;
|
|
|
|
vector<Status> results;
|
|
|
|
};
|
|
|
|
FlatHashMap<int64, PendingMessageGroupSend> pending_message_group_sends_; // media_album_id -> ...
|
|
|
|
|
2024-04-19 15:42:58 +02:00
|
|
|
int64 current_message_edit_generation_ = 0;
|
|
|
|
|
2024-02-21 18:43:55 +01:00
|
|
|
Td *td_;
|
|
|
|
ActorShared<> parent_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|