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
|
|
|
|
|
2024-04-15 16:28:13 +02:00
|
|
|
#include "td/telegram/AccessRights.h"
|
2021-11-11 19:13:03 +01:00
|
|
|
#include "td/telegram/AffectedHistory.h"
|
2023-04-10 16:23:21 +02:00
|
|
|
#include "td/telegram/BackgroundInfo.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/ChannelId.h"
|
2022-08-30 10:45:27 +02:00
|
|
|
#include "td/telegram/ChatReactions.h"
|
2018-09-29 02:39:27 +02:00
|
|
|
#include "td/telegram/DialogDate.h"
|
2019-09-15 03:15:46 +02:00
|
|
|
#include "td/telegram/DialogDb.h"
|
2023-03-27 17:34:25 +02:00
|
|
|
#include "td/telegram/DialogFilterDialogInfo.h"
|
2020-05-12 02:14:20 +02:00
|
|
|
#include "td/telegram/DialogFilterId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/DialogId.h"
|
2020-05-21 18:39:34 +02:00
|
|
|
#include "td/telegram/DialogListId.h"
|
2022-10-25 00:22:04 +02:00
|
|
|
#include "td/telegram/DialogNotificationSettings.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/DialogParticipant.h"
|
2020-04-28 15:25:56 +02:00
|
|
|
#include "td/telegram/DialogSource.h"
|
2021-08-01 05:17:51 +02:00
|
|
|
#include "td/telegram/EncryptedFile.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/files/FileId.h"
|
2019-01-19 03:44:31 +01:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2019-08-19 03:51:03 +02:00
|
|
|
#include "td/telegram/FolderId.h"
|
2020-12-13 22:36:44 +01:00
|
|
|
#include "td/telegram/InputGroupCallId.h"
|
2020-09-21 14:21:41 +02:00
|
|
|
#include "td/telegram/logevent/LogEventHelper.h"
|
2020-01-27 14:06:00 +01:00
|
|
|
#include "td/telegram/MessageContentType.h"
|
2020-08-09 13:18:08 +02:00
|
|
|
#include "td/telegram/MessageCopyOptions.h"
|
2022-11-09 18:35:22 +01:00
|
|
|
#include "td/telegram/MessageDb.h"
|
2024-06-05 16:01:11 +02:00
|
|
|
#include "td/telegram/MessageEffectId.h"
|
2023-09-21 18:11:17 +02:00
|
|
|
#include "td/telegram/MessageFullId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/MessageId.h"
|
2023-06-08 16:27:24 +02:00
|
|
|
#include "td/telegram/MessageInputReplyTo.h"
|
2021-05-27 19:47:04 +02:00
|
|
|
#include "td/telegram/MessageLinkInfo.h"
|
2023-10-09 17:48:01 +02:00
|
|
|
#include "td/telegram/MessageOrigin.h"
|
2022-11-02 04:28:35 +01:00
|
|
|
#include "td/telegram/MessageReplyHeader.h"
|
2020-09-07 13:07:40 +02:00
|
|
|
#include "td/telegram/MessageReplyInfo.h"
|
2020-08-22 09:27:13 +02:00
|
|
|
#include "td/telegram/MessageSearchFilter.h"
|
2024-01-30 13:07:21 +01:00
|
|
|
#include "td/telegram/MessageSelfDestructType.h"
|
2022-12-07 17:28:27 +01:00
|
|
|
#include "td/telegram/MessagesInfo.h"
|
2023-02-07 19:08:54 +01:00
|
|
|
#include "td/telegram/MessageSource.h"
|
2021-09-01 19:31:39 +02:00
|
|
|
#include "td/telegram/MessageThreadInfo.h"
|
2021-12-21 12:06:15 +01:00
|
|
|
#include "td/telegram/MessageTtl.h"
|
2023-02-23 13:15:10 +01:00
|
|
|
#include "td/telegram/MessageViewer.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/net/NetQuery.h"
|
2018-11-26 18:05:06 +01:00
|
|
|
#include "td/telegram/Notification.h"
|
2023-08-23 18:38:06 +02:00
|
|
|
#include "td/telegram/NotificationGroupFromDatabase.h"
|
2018-11-11 13:58:52 +01:00
|
|
|
#include "td/telegram/NotificationGroupId.h"
|
2023-08-21 17:52:56 +02:00
|
|
|
#include "td/telegram/NotificationGroupInfo.h"
|
2018-11-28 22:51:25 +01:00
|
|
|
#include "td/telegram/NotificationGroupKey.h"
|
2018-12-23 22:34:40 +01:00
|
|
|
#include "td/telegram/NotificationGroupType.h"
|
2018-11-11 13:58:52 +01:00
|
|
|
#include "td/telegram/NotificationId.h"
|
2022-10-25 00:22:04 +02:00
|
|
|
#include "td/telegram/NotificationSettingsScope.h"
|
2023-05-02 16:38:55 +02:00
|
|
|
#include "td/telegram/OrderedMessage.h"
|
2024-03-05 11:08:26 +01:00
|
|
|
#include "td/telegram/QuickReplyShortcutId.h"
|
2023-08-04 17:39:07 +02:00
|
|
|
#include "td/telegram/ReactionType.h"
|
2024-01-24 15:11:41 +01:00
|
|
|
#include "td/telegram/ReactionUnavailabilityReason.h"
|
2021-09-13 19:34:57 +02:00
|
|
|
#include "td/telegram/RecentDialogList.h"
|
2023-10-26 13:51:32 +02:00
|
|
|
#include "td/telegram/RepliedMessageInfo.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/ReplyMarkup.h"
|
2019-11-24 00:28:48 +01:00
|
|
|
#include "td/telegram/RestrictionReason.h"
|
2024-01-13 10:06:31 +01:00
|
|
|
#include "td/telegram/SavedMessagesTopicId.h"
|
2019-12-02 17:20:54 +01:00
|
|
|
#include "td/telegram/ScheduledServerMessageId.h"
|
2021-10-27 16:32:09 +02:00
|
|
|
#include "td/telegram/secret_api.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/SecretChatId.h"
|
|
|
|
#include "td/telegram/SecretInputMedia.h"
|
2022-01-28 17:57:50 +01:00
|
|
|
#include "td/telegram/ServerMessageId.h"
|
2023-06-07 14:10:46 +02:00
|
|
|
#include "td/telegram/StoryFullId.h"
|
2023-08-22 17:55:59 +02:00
|
|
|
#include "td/telegram/StoryNotificationSettings.h"
|
2020-08-22 09:27:13 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
2021-10-27 16:32:09 +02:00
|
|
|
#include "td/telegram/UserId.h"
|
2020-08-22 09:27:13 +02:00
|
|
|
|
2018-11-11 13:58:52 +01:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
#include "td/actor/MultiPromise.h"
|
2022-07-02 22:32:18 +02:00
|
|
|
#include "td/actor/MultiTimeout.h"
|
2018-11-11 13:58:52 +01:00
|
|
|
#include "td/actor/SignalSlot.h"
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/buffer.h"
|
|
|
|
#include "td/utils/ChangesProcessor.h"
|
|
|
|
#include "td/utils/common.h"
|
2022-02-07 22:04:34 +01:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2022-03-11 19:38:48 +01:00
|
|
|
#include "td/utils/FlatHashSet.h"
|
2022-11-23 17:37:32 +01:00
|
|
|
#include "td/utils/HashTableUtils.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Heap.h"
|
|
|
|
#include "td/utils/Hints.h"
|
2023-05-18 13:33:00 +02:00
|
|
|
#include "td/utils/List.h"
|
2022-06-27 12:30:18 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2019-01-31 03:05:40 +01:00
|
|
|
#include "td/utils/Slice.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
2022-05-19 18:34:48 +02:00
|
|
|
#include "td/utils/WaitFreeHashMap.h"
|
2022-08-20 23:20:57 +02:00
|
|
|
#include "td/utils/WaitFreeHashSet.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <functional>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2023-05-23 13:57:04 +02:00
|
|
|
#include <queue>
|
2018-12-31 20:04:05 +01:00
|
|
|
#include <set>
|
2022-02-10 16:03:03 +01:00
|
|
|
#include <unordered_map>
|
2018-12-31 20:04:05 +01:00
|
|
|
#include <unordered_set>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2019-01-06 20:11:02 +01:00
|
|
|
struct BinlogEvent;
|
2024-04-08 01:37:52 +02:00
|
|
|
class BusinessBotManageBar;
|
2022-03-11 13:10:24 +01:00
|
|
|
class Dependencies;
|
2021-11-23 10:05:32 +01:00
|
|
|
class DialogActionBar;
|
2020-06-02 12:58:53 +02:00
|
|
|
class DialogFilter;
|
2020-01-27 14:10:59 +01:00
|
|
|
class DraftMessage;
|
2024-05-18 22:59:26 +02:00
|
|
|
class FactCheck;
|
2020-01-27 14:10:59 +01:00
|
|
|
struct InputMessageContent;
|
|
|
|
class MessageContent;
|
2024-01-11 18:13:43 +01:00
|
|
|
class MessageForwardInfo;
|
2022-01-20 20:54:34 +01:00
|
|
|
struct MessageReactions;
|
2024-05-10 15:24:32 +02:00
|
|
|
struct MessageSearchOffset;
|
2024-04-09 15:19:33 +02:00
|
|
|
class MissingInvitees;
|
2020-01-27 14:10:59 +01:00
|
|
|
class Td;
|
2024-01-07 21:45:33 +01:00
|
|
|
class Usernames;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class MessagesManager final : public Actor {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW = 1 << 1;
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_HAS_REPLY_MARKUP = 1 << 2;
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_HAS_ENTITIES = 1 << 3;
|
|
|
|
// static constexpr int32 SEND_MESSAGE_FLAG_IS_POST = 1 << 4;
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_DISABLE_NOTIFICATION = 1 << 5;
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_FROM_BACKGROUND = 1 << 6;
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_CLEAR_DRAFT = 1 << 7;
|
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_WITH_MY_SCORE = 1 << 8;
|
2022-10-18 13:23:46 +02:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_IS_FROM_THREAD = 1 << 9;
|
2019-12-05 18:34:19 +01:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_HAS_SCHEDULE_DATE = 1 << 10;
|
2018-12-31 20:04:05 +01:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_HAS_MESSAGE = 1 << 11;
|
2021-11-25 13:49:51 +01:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_HAS_SEND_AS = 1 << 13;
|
2021-12-28 16:19:19 +01:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_NOFORWARDS = 1 << 14;
|
2022-08-08 22:00:06 +02:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_UPDATE_STICKER_SETS_ORDER = 1 << 15;
|
2023-10-17 11:27:26 +02:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_INVERT_MEDIA = 1 << 16;
|
2024-05-09 18:02:17 +02:00
|
|
|
static constexpr int32 SEND_MESSAGE_FLAG_EFFECT = 1 << 18;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
MessagesManager(Td *td, ActorShared<> parent);
|
|
|
|
MessagesManager(const MessagesManager &) = delete;
|
|
|
|
MessagesManager &operator=(const MessagesManager &) = delete;
|
|
|
|
MessagesManager(MessagesManager &&) = delete;
|
|
|
|
MessagesManager &operator=(MessagesManager &&) = delete;
|
2021-07-03 22:51:36 +02:00
|
|
|
~MessagesManager() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-07-24 18:42:09 +02:00
|
|
|
static bool is_invalid_poll_message(const telegram_api::Message *message);
|
|
|
|
|
2023-09-25 20:39:02 +02:00
|
|
|
static int32 get_message_date(const tl_object_ptr<telegram_api::Message> &message_ptr);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
void on_get_empty_messages(DialogId dialog_id, const vector<MessageId> &empty_message_ids);
|
2020-09-14 01:23:02 +02:00
|
|
|
|
2024-03-28 16:58:45 +01:00
|
|
|
void get_channel_difference_if_needed(DialogId dialog_id, MessageId message_id, const char *source);
|
|
|
|
|
2020-11-07 20:28:45 +01:00
|
|
|
void get_channel_difference_if_needed(DialogId dialog_id, MessagesInfo &&messages_info,
|
2023-12-13 17:48:11 +01:00
|
|
|
Promise<MessagesInfo> &&promise, const char *source);
|
2020-11-07 20:28:45 +01:00
|
|
|
|
2023-12-13 17:48:11 +01:00
|
|
|
void get_channel_differences_if_needed(MessagesInfo &&messages_info, Promise<MessagesInfo> &&promise,
|
|
|
|
const char *source);
|
2021-09-23 22:34:55 +02:00
|
|
|
|
2023-11-30 15:21:56 +01:00
|
|
|
void get_channel_differences_if_needed(
|
2023-12-26 10:02:53 +01:00
|
|
|
const vector<const telegram_api::object_ptr<telegram_api::Message> *> &messages, Promise<Unit> &&promise,
|
|
|
|
const char *source);
|
2023-11-30 15:21:56 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_get_messages(vector<tl_object_ptr<telegram_api::Message>> &&messages, bool is_channel_message,
|
2021-10-06 22:10:27 +02:00
|
|
|
bool is_scheduled, Promise<Unit> &&promise, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-29 05:07:11 +02:00
|
|
|
void on_get_history(DialogId dialog_id, MessageId from_message_id, MessageId old_last_new_message_id, int32 offset,
|
|
|
|
int32 limit, bool from_the_end, vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-01-16 19:56:59 +01:00
|
|
|
void on_get_public_dialogs_search_result(const string &query, vector<tl_object_ptr<telegram_api::Peer>> &&my_peers,
|
|
|
|
vector<tl_object_ptr<telegram_api::Peer>> &&peers);
|
2018-01-16 17:04:36 +01:00
|
|
|
void on_failed_public_dialogs_search(const string &query, Status &&error);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-01-16 12:00:14 +01:00
|
|
|
void on_get_message_search_result_calendar(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
2024-06-08 20:20:11 +02:00
|
|
|
MessageId from_message_id, MessageSearchFilter filter, int32 total_count,
|
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
2021-10-30 02:34:49 +02:00
|
|
|
vector<tl_object_ptr<telegram_api::searchResultsCalendarPeriod>> &&periods,
|
2024-06-08 20:20:11 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::messageCalendar>> &&promise);
|
2021-10-30 02:34:49 +02:00
|
|
|
|
2024-06-13 14:09:20 +02:00
|
|
|
void on_get_call_messages(MessageId from_message_id, int32 limit, MessageSearchFilter filter, int32 total_count,
|
|
|
|
vector<telegram_api::object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
|
|
|
|
2024-01-15 17:43:03 +01:00
|
|
|
void on_get_dialog_messages_search_result(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
const string &query, DialogId sender_dialog_id, MessageId from_message_id,
|
|
|
|
int32 offset, int32 limit, MessageSearchFilter filter,
|
2024-01-22 19:14:02 +01:00
|
|
|
MessageId top_thread_message_id, const ReactionType &tag, int64 random_id,
|
|
|
|
int32 total_count, vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
2021-10-06 22:10:27 +02:00
|
|
|
Promise<Unit> &&promise);
|
2018-01-31 12:59:14 +01:00
|
|
|
void on_failed_dialog_messages_search(DialogId dialog_id, int64 random_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-01-15 22:30:37 +01:00
|
|
|
void on_get_dialog_message_count(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
MessageSearchFilter filter, int32 total_count, Promise<int32> &&promise);
|
2021-10-03 12:47:50 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_get_messages_search_result(const string &query, int32 offset_date, DialogId offset_dialog_id,
|
2020-08-22 09:05:51 +02:00
|
|
|
MessageId offset_message_id, int32 limit, MessageSearchFilter filter,
|
2024-05-10 13:08:10 +02:00
|
|
|
int32 min_date, int32 max_date, int32 total_count,
|
2022-12-25 20:43:37 +01:00
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&messages, int32 next_rate,
|
2024-05-10 13:08:10 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-10 15:24:32 +02:00
|
|
|
void on_get_hashtag_search_result(const string &hashtag, const MessageSearchOffset &old_offset, int32 limit,
|
|
|
|
int32 total_count, vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
int32 next_rate, Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
|
|
|
|
2022-02-22 13:58:16 +01:00
|
|
|
void on_get_outgoing_document_messages(vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
|
|
|
|
2019-12-04 22:24:48 +01:00
|
|
|
void on_get_scheduled_server_messages(DialogId dialog_id, uint32 generation,
|
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&messages, bool is_not_modified);
|
|
|
|
|
2021-10-06 13:22:42 +02:00
|
|
|
void on_get_recent_locations(DialogId dialog_id, int32 limit, int32 total_count,
|
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
Promise<td_api::object_ptr<td_api::messages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId on_get_message(tl_object_ptr<telegram_api::Message> message_ptr, bool from_update,
|
2023-05-11 19:27:00 +02:00
|
|
|
bool is_channel_message, bool is_scheduled, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-07 00:28:18 +02:00
|
|
|
void open_secret_message(SecretChatId secret_chat_id, int64 random_id, Promise<Unit>);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-08-01 05:17:51 +02:00
|
|
|
void on_send_secret_message_success(int64 random_id, MessageId message_id, int32 date, unique_ptr<EncryptedFile> file,
|
2022-10-07 00:28:18 +02:00
|
|
|
Promise<Unit> promise);
|
|
|
|
void on_send_secret_message_error(int64 random_id, Status error, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-07 00:28:18 +02:00
|
|
|
void delete_secret_messages(SecretChatId secret_chat_id, std::vector<int64> random_ids, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-01-20 12:49:18 +01:00
|
|
|
void delete_secret_chat_history(SecretChatId secret_chat_id, bool remove_from_dialog_list, MessageId last_message_id,
|
2022-10-07 00:28:18 +02:00
|
|
|
Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void read_secret_chat_outbox(SecretChatId secret_chat_id, int32 up_to_date, int32 read_date);
|
|
|
|
|
2018-12-04 17:40:12 +01:00
|
|
|
void on_update_secret_chat_state(SecretChatId secret_chat_id, SecretChatState state);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_get_secret_message(SecretChatId secret_chat_id, UserId user_id, MessageId message_id, int32 date,
|
2021-08-01 05:17:51 +02:00
|
|
|
unique_ptr<EncryptedFile> file, tl_object_ptr<secret_api::decryptedMessage> message,
|
2022-10-07 00:28:18 +02:00
|
|
|
Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_secret_chat_screenshot_taken(SecretChatId secret_chat_id, UserId user_id, MessageId message_id, int32 date,
|
2022-10-07 00:28:18 +02:00
|
|
|
int64 random_id, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_secret_chat_ttl_changed(SecretChatId secret_chat_id, UserId user_id, MessageId message_id, int32 date,
|
2022-10-07 00:28:18 +02:00
|
|
|
int32 ttl, int64 random_id, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_update_sent_text_message(int64 random_id, tl_object_ptr<telegram_api::MessageMedia> message_media,
|
|
|
|
vector<tl_object_ptr<telegram_api::MessageEntity>> &&entities);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void delete_pending_message_web_page(MessageFullId message_full_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-22 17:24:02 +02:00
|
|
|
void on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<telegram_api::Dialog>> &&dialog_folders,
|
|
|
|
int32 total_count, vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-10 22:47:28 +02:00
|
|
|
bool on_update_message_id(int64 random_id, MessageId new_message_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-17 14:44:30 +02:00
|
|
|
void on_update_dialog_draft_message(DialogId dialog_id, MessageId top_thread_message_id,
|
2023-11-01 19:32:09 +01:00
|
|
|
tl_object_ptr<telegram_api::DraftMessage> &&draft_message, bool force = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-22 17:24:02 +02:00
|
|
|
void on_update_dialog_is_pinned(FolderId folder_id, DialogId dialog_id, bool is_pinned);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-22 17:24:02 +02:00
|
|
|
void on_update_pinned_dialogs(FolderId folder_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-11-16 13:04:57 +01:00
|
|
|
void on_update_dialog_is_forum(DialogId dialog_id, bool is_forum);
|
|
|
|
|
2023-11-16 11:59:32 +01:00
|
|
|
void on_update_dialog_view_as_messages(DialogId dialog_id, bool view_as_messages);
|
|
|
|
|
2018-06-25 23:10:53 +02:00
|
|
|
void on_update_dialog_is_marked_as_unread(DialogId dialog_id, bool is_marked_as_unread);
|
|
|
|
|
2023-01-20 10:38:25 +01:00
|
|
|
void on_update_dialog_is_translatable(DialogId dialog_id, bool is_translatable);
|
|
|
|
|
2023-01-20 10:57:06 +01:00
|
|
|
void update_is_translatable(bool new_is_premium);
|
|
|
|
|
2023-07-28 15:19:05 +02:00
|
|
|
void on_update_dialog_is_blocked(DialogId dialog_id, bool is_blocked, bool is_blocked_for_stories);
|
2020-09-20 00:54:40 +02:00
|
|
|
|
2024-04-07 21:45:55 +02:00
|
|
|
void on_update_dialog_business_bot_is_paused(DialogId dialog_id, bool is_paused);
|
|
|
|
|
2024-04-08 02:10:33 +02:00
|
|
|
void on_update_dialog_business_bot_removed(DialogId dialog_id);
|
|
|
|
|
2020-10-20 19:28:37 +02:00
|
|
|
void on_update_dialog_last_pinned_message_id(DialogId dialog_id, MessageId last_pinned_message_id);
|
2019-02-01 13:19:32 +01:00
|
|
|
|
2023-04-10 16:23:21 +02:00
|
|
|
void on_update_dialog_background(DialogId dialog_id, telegram_api::object_ptr<telegram_api::WallPaper> &&wallpaper);
|
|
|
|
|
2021-08-23 17:47:32 +02:00
|
|
|
void on_update_dialog_theme_name(DialogId dialog_id, string theme_name);
|
|
|
|
|
2021-10-26 19:51:06 +02:00
|
|
|
void on_update_dialog_pending_join_requests(DialogId dialog_id, int32 pending_join_request_count,
|
|
|
|
vector<int64> pending_requesters);
|
2021-10-12 17:11:17 +02:00
|
|
|
|
2019-12-04 18:51:52 +01:00
|
|
|
void on_update_dialog_has_scheduled_server_messages(DialogId dialog_id, bool has_scheduled_server_messages);
|
2019-11-25 17:11:24 +01:00
|
|
|
|
2019-08-19 03:51:03 +02:00
|
|
|
void on_update_dialog_folder_id(DialogId dialog_id, FolderId folder_id);
|
|
|
|
|
2020-12-15 17:25:07 +01:00
|
|
|
void on_update_dialog_group_call(DialogId dialog_id, bool has_active_group_call, bool is_group_call_empty,
|
2021-03-06 23:06:51 +01:00
|
|
|
const char *source, bool force = false);
|
2020-12-13 22:36:44 +01:00
|
|
|
|
|
|
|
void on_update_dialog_group_call_id(DialogId dialog_id, InputGroupCallId input_group_call_id);
|
|
|
|
|
2021-03-08 13:27:47 +01:00
|
|
|
void on_update_dialog_default_join_group_call_as_dialog_id(DialogId dialog_id, DialogId default_join_as_dialog_id,
|
|
|
|
bool force);
|
2021-03-08 13:13:36 +01:00
|
|
|
|
2021-11-12 14:15:19 +01:00
|
|
|
void on_update_dialog_default_send_message_as_dialog_id(DialogId dialog_id, DialogId default_send_as_dialog_id,
|
|
|
|
bool force);
|
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
void on_update_dialog_message_ttl(DialogId dialog_id, MessageTtl message_ttl);
|
2021-02-09 15:35:48 +01:00
|
|
|
|
2019-03-25 23:24:23 +01:00
|
|
|
void on_update_service_notification(tl_object_ptr<telegram_api::updateServiceNotification> &&update,
|
2019-04-02 21:24:54 +02:00
|
|
|
bool skip_new_entities, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_update_read_channel_inbox(tl_object_ptr<telegram_api::updateReadChannelInbox> &&update);
|
|
|
|
|
|
|
|
void on_update_read_channel_outbox(tl_object_ptr<telegram_api::updateReadChannelOutbox> &&update);
|
|
|
|
|
|
|
|
void on_update_read_channel_messages_contents(
|
|
|
|
tl_object_ptr<telegram_api::updateChannelReadMessagesContents> &&update);
|
|
|
|
|
2020-09-16 15:41:08 +02:00
|
|
|
void on_update_read_message_comments(DialogId dialog_id, MessageId message_id, MessageId max_message_id,
|
2022-12-14 12:25:04 +01:00
|
|
|
MessageId last_read_inbox_message_id, MessageId last_read_outbox_message_id,
|
|
|
|
int32 unread_count);
|
2020-09-16 15:41:08 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_update_channel_too_long(tl_object_ptr<telegram_api::updateChannelTooLong> &&update, bool force_apply);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_message_view_count(MessageFullId message_full_id, int32 view_count);
|
2020-07-31 04:50:11 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_message_forward_count(MessageFullId message_full_id, int32 forward_count);
|
2020-07-31 04:50:11 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_message_reactions(MessageFullId message_full_id,
|
2022-02-08 16:48:09 +01:00
|
|
|
tl_object_ptr<telegram_api::messageReactions> &&reactions, Promise<Unit> &&promise);
|
2022-01-21 09:53:18 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void update_message_reactions(MessageFullId message_full_id, unique_ptr<MessageReactions> &&reactions);
|
2022-02-12 12:15:14 +01:00
|
|
|
|
2022-03-07 12:27:42 +01:00
|
|
|
void try_reload_message_reactions(DialogId dialog_id, bool is_finished);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_get_message_reaction_list(MessageFullId message_full_id, const ReactionType &reaction_type,
|
2023-08-04 17:39:07 +02:00
|
|
|
FlatHashMap<ReactionType, vector<DialogId>, ReactionTypeHash> reaction_types,
|
|
|
|
int32 total_count);
|
2022-02-14 09:34:12 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_message_interaction_info(MessageFullId message_full_id, int32 view_count, int32 forward_count,
|
2022-02-12 12:15:14 +01:00
|
|
|
bool has_reply_info,
|
|
|
|
tl_object_ptr<telegram_api::messageReplies> &&reply_info);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_live_location_viewed(MessageFullId message_full_id);
|
2019-12-13 19:05:10 +01:00
|
|
|
|
2019-12-13 23:57:17 +01:00
|
|
|
void on_update_some_live_location_viewed(Promise<Unit> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_message_extended_media(MessageFullId message_full_id,
|
2022-09-23 11:07:07 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::MessageExtendedMedia> extended_media);
|
|
|
|
|
2024-06-10 19:10:05 +02:00
|
|
|
void on_external_update_message_content(MessageFullId message_full_id, const char *source,
|
|
|
|
bool expect_no_message = false);
|
2019-02-20 23:54:31 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_update_message_content(MessageFullId message_full_id);
|
2022-09-19 10:15:13 +02:00
|
|
|
|
2019-08-27 17:32:39 +02:00
|
|
|
void on_read_channel_inbox(ChannelId channel_id, MessageId max_message_id, int32 server_unread_count, int32 pts,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_read_channel_outbox(ChannelId channel_id, MessageId max_message_id);
|
|
|
|
|
2023-07-22 21:40:26 +02:00
|
|
|
void on_update_channel_max_unavailable_message_id(ChannelId channel_id, MessageId max_unavailable_message_id,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-12-02 17:20:54 +01:00
|
|
|
void on_update_delete_scheduled_messages(DialogId dialog_id, vector<ScheduledServerMessageId> &&server_message_ids);
|
|
|
|
|
2024-01-06 22:46:36 +01:00
|
|
|
void on_dialog_speaking_action(DialogId dialog_id, DialogId speaking_dialog_id, int32 date);
|
|
|
|
|
|
|
|
void on_message_animated_emoji_clicked(MessageFullId message_full_id, string &&emoji, string &&data);
|
2018-03-13 09:57:58 +01:00
|
|
|
|
2019-03-25 17:01:33 +01:00
|
|
|
void read_history_inbox(DialogId dialog_id, MessageId max_message_id, int32 unread_count, const char *source);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void delete_messages(DialogId dialog_id, const vector<MessageId> &message_ids, bool revoke, Promise<Unit> &&promise);
|
|
|
|
|
2022-04-12 16:34:08 +02:00
|
|
|
void on_failed_message_deletion(DialogId dialog_id, const vector<int32> &server_message_ids);
|
|
|
|
|
|
|
|
void on_failed_scheduled_message_deletion(DialogId dialog_id, const vector<MessageId> &message_ids);
|
|
|
|
|
2019-03-27 21:17:41 +01:00
|
|
|
void delete_dialog_history(DialogId dialog_id, bool remove_from_dialog_list, bool revoke, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-29 23:35:37 +02:00
|
|
|
void delete_topic_history(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
|
|
|
|
2021-01-19 11:21:50 +01:00
|
|
|
void delete_all_call_messages(bool revoke, Promise<Unit> &&promise);
|
|
|
|
|
2021-11-19 13:48:05 +01:00
|
|
|
void delete_dialog_messages_by_sender(DialogId dialog_id, DialogId sender_dialog_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-02-04 21:06:48 +01:00
|
|
|
static Status fix_delete_message_min_max_dates(int32 &min_date, int32 &max_date);
|
|
|
|
|
2021-10-25 19:39:22 +02:00
|
|
|
void delete_dialog_messages_by_date(DialogId dialog_id, int32 min_date, int32 max_date, bool revoke,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2021-02-04 14:01:04 +01:00
|
|
|
void on_dialog_deleted(DialogId dialog_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-12-18 13:20:05 +01:00
|
|
|
void on_update_dialog_group_call_rights(DialogId dialog_id);
|
2020-12-16 14:38:06 +01:00
|
|
|
|
2022-10-24 15:57:26 +02:00
|
|
|
void read_all_dialog_mentions(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-24 16:04:05 +02:00
|
|
|
void read_all_dialog_reactions(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
2022-01-30 10:37:24 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Status add_recently_found_dialog(DialogId dialog_id) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
Status remove_recently_found_dialog(DialogId dialog_id) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
void clear_recently_found_dialogs();
|
|
|
|
|
2023-05-16 20:41:19 +02:00
|
|
|
std::pair<int32, vector<DialogId>> search_recently_found_dialogs(const string &query, int32 limit,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2021-09-14 13:18:37 +02:00
|
|
|
std::pair<int32, vector<DialogId>> get_recently_opened_dialogs(int32 limit, Promise<Unit> &&promise);
|
|
|
|
|
2021-11-15 15:08:37 +01:00
|
|
|
void get_dialog_send_message_as_dialog_ids(DialogId dialog_id,
|
2022-10-04 16:53:56 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::chatMessageSenders>> &&promise,
|
2021-12-03 18:10:30 +01:00
|
|
|
bool is_recursive = false);
|
2021-11-15 15:08:37 +01:00
|
|
|
|
|
|
|
void set_dialog_default_send_message_as_dialog_id(DialogId dialog_id, DialogId message_sender_dialog_id,
|
|
|
|
Promise<Unit> &&promise);
|
2021-11-12 15:11:01 +01:00
|
|
|
|
2022-03-31 14:05:08 +02:00
|
|
|
bool get_dialog_silent_send_message(DialogId dialog_id) const;
|
|
|
|
|
2023-03-11 21:18:24 +01:00
|
|
|
bool get_dialog_has_last_message(DialogId dialog_id) const;
|
|
|
|
|
2022-04-26 16:13:31 +02:00
|
|
|
DialogId get_dialog_default_send_message_as_dialog_id(DialogId dialog_id) const;
|
|
|
|
|
2023-10-29 20:14:41 +01:00
|
|
|
struct ForwardedMessageInfo {
|
|
|
|
int32 origin_date_ = 0;
|
|
|
|
MessageOrigin origin_;
|
|
|
|
unique_ptr<MessageContent> content_;
|
|
|
|
};
|
|
|
|
ForwardedMessageInfo get_forwarded_message_info(MessageFullId message_full_id);
|
|
|
|
|
2024-03-11 12:19:08 +01:00
|
|
|
MessageInputReplyTo create_message_input_reply_to(DialogId dialog_id, MessageId top_thread_message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
|
|
|
|
bool for_draft);
|
2023-05-31 16:19:31 +02:00
|
|
|
|
2021-08-31 21:34:46 +02:00
|
|
|
Result<td_api::object_ptr<td_api::message>> send_message(
|
2024-01-30 23:52:02 +01:00
|
|
|
DialogId dialog_id, const MessageId top_thread_message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2019-12-06 00:32:23 +01:00
|
|
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-02-22 19:51:35 +01:00
|
|
|
Result<td_api::object_ptr<td_api::messages>> send_message_group(
|
2024-01-30 23:52:02 +01:00
|
|
|
DialogId dialog_id, const MessageId top_thread_message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
|
2023-10-23 17:40:55 +02:00
|
|
|
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
Result<MessageId> send_bot_start_message(UserId bot_user_id, DialogId dialog_id,
|
|
|
|
const string ¶meter) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2023-10-23 17:58:53 +02:00
|
|
|
Result<td_api::object_ptr<td_api::message>> send_inline_query_result_message(
|
2024-01-30 23:52:02 +01:00
|
|
|
DialogId dialog_id, const MessageId top_thread_message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
|
|
|
|
int64 query_id, const string &result_id, bool hide_via_bot) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-23 17:40:55 +02:00
|
|
|
Result<td_api::object_ptr<td_api::messages>> forward_messages(
|
|
|
|
DialogId to_dialog_id, MessageId top_thread_message_id, DialogId from_dialog_id, vector<MessageId> message_ids,
|
|
|
|
tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share,
|
|
|
|
vector<MessageCopyOptions> &©_options) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-03-05 11:08:26 +01:00
|
|
|
Result<td_api::object_ptr<td_api::messages>> send_quick_reply_shortcut_messages(
|
|
|
|
DialogId dialog_id, QuickReplyShortcutId shortcut_id, int32 sending_id) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2023-11-06 11:20:16 +01:00
|
|
|
Result<vector<MessageId>> resend_messages(DialogId dialog_id, vector<MessageId> message_ids,
|
2023-11-28 16:16:04 +01:00
|
|
|
td_api::object_ptr<td_api::inputTextQuote> &"e) TD_WARN_UNUSED_RESULT;
|
2019-08-11 03:05:00 +02:00
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
void set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-12-22 16:47:23 +01:00
|
|
|
void share_dialogs_with_bot(MessageFullId message_full_id, int32 button_id, vector<DialogId> shared_dialog_ids,
|
|
|
|
bool expect_user, bool only_check, Promise<Unit> &&promise);
|
2023-01-13 15:03:35 +01:00
|
|
|
|
2023-10-06 10:58:05 +02:00
|
|
|
Result<MessageId> add_local_message(
|
|
|
|
DialogId dialog_id, td_api::object_ptr<td_api::MessageSender> &&sender,
|
|
|
|
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, bool disable_notification,
|
|
|
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;
|
2018-03-26 22:20:56 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void edit_message_text(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Promise<Unit> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void edit_message_live_location(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2024-05-02 15:24:35 +02:00
|
|
|
tl_object_ptr<td_api::location> &&input_location, int32 live_period, int32 heading,
|
2020-10-30 13:51:20 +01:00
|
|
|
int32 proximity_alert_radius, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void edit_message_media(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2018-06-19 01:31:34 +02:00
|
|
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Promise<Unit> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void edit_message_caption(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2024-05-16 11:42:36 +02:00
|
|
|
tl_object_ptr<td_api::formattedText> &&input_caption, bool invert_media,
|
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void edit_message_reply_markup(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2018-12-31 20:04:05 +01:00
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void edit_message_scheduling_state(MessageFullId message_full_id,
|
2019-12-03 02:36:23 +01:00
|
|
|
td_api::object_ptr<td_api::MessageSchedulingState> &&scheduling_state,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-05-20 11:30:05 +02:00
|
|
|
void set_message_fact_check(MessageFullId message_full_id, td_api::object_ptr<td_api::formattedText> &&text,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2023-05-01 13:57:16 +02:00
|
|
|
void get_dialog_filter_dialog_count(td_api::object_ptr<td_api::chatFolder> filter, Promise<int32> &&promise);
|
|
|
|
|
2023-03-27 16:44:13 +02:00
|
|
|
void add_dialog_list_for_dialog_filter(DialogFilterId dialog_filter_id);
|
|
|
|
|
|
|
|
void edit_dialog_list_for_dialog_filter(unique_ptr<DialogFilter> &old_dialog_filter,
|
|
|
|
unique_ptr<DialogFilter> new_dialog_filter, bool &disable_get_dialog_filter,
|
|
|
|
const char *source);
|
|
|
|
|
|
|
|
void delete_dialog_list_for_dialog_filter(DialogFilterId dialog_filter_id, const char *source);
|
|
|
|
|
2020-05-31 02:50:52 +02:00
|
|
|
vector<DialogListId> get_dialog_lists_to_add_dialog(DialogId dialog_id);
|
|
|
|
|
2020-05-30 23:48:33 +02:00
|
|
|
void add_dialog_to_list(DialogId dialog_id, DialogListId dialog_list_id, Promise<Unit> &&promise);
|
2019-08-27 16:23:01 +02:00
|
|
|
|
2023-08-04 17:39:07 +02:00
|
|
|
void set_active_reactions(vector<ReactionType> active_reaction_types);
|
2022-01-19 16:59:48 +01:00
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
void set_dialog_available_reactions(DialogId dialog_id,
|
|
|
|
td_api::object_ptr<td_api::ChatAvailableReactions> &&available_reactions_ptr,
|
|
|
|
Promise<Unit> &&promise);
|
2022-01-05 14:23:35 +01:00
|
|
|
|
2021-08-27 18:23:22 +02:00
|
|
|
void set_dialog_theme(DialogId dialog_id, const string &theme_name, Promise<Unit> &&promise);
|
|
|
|
|
2020-10-23 01:12:32 +02:00
|
|
|
void pin_dialog_message(DialogId dialog_id, MessageId message_id, bool disable_notification, bool only_for_self,
|
|
|
|
bool is_unpin, Promise<Unit> &&promise);
|
2019-02-01 13:19:32 +01:00
|
|
|
|
2022-10-31 17:44:01 +01:00
|
|
|
void unpin_all_dialog_messages(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
2020-10-23 00:56:06 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool have_dialog(DialogId dialog_id) const;
|
2021-09-01 18:41:00 +02:00
|
|
|
bool have_dialog_force(DialogId dialog_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-08-24 16:29:22 +02:00
|
|
|
void reload_dialog_notification_settings(DialogId dialog_id, Promise<Unit> &&promise, const char *source);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool load_dialog(DialogId dialog_id, int left_tries, Promise<Unit> &&promise);
|
|
|
|
|
2021-09-26 18:38:27 +02:00
|
|
|
void load_dialogs(vector<DialogId> dialog_ids, Promise<vector<DialogId>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-08-10 16:52:31 +02:00
|
|
|
Result<DialogDate> get_dialog_list_last_date(DialogListId dialog_list_id);
|
|
|
|
|
2021-08-11 14:59:09 +02:00
|
|
|
vector<DialogId> get_dialogs(DialogListId dialog_list_id, DialogDate offset, int32 limit, bool exact_limit,
|
|
|
|
bool force, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void get_dialogs_from_list(DialogListId dialog_list_id, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::chats>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-04-14 14:17:25 +02:00
|
|
|
void read_all_dialogs_from_list(DialogListId dialog_list_id, Promise<Unit> &&promise, bool is_recursive = false);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<DialogId> search_public_dialogs(const string &query, Promise<Unit> &&promise);
|
|
|
|
|
2020-09-19 23:28:26 +02:00
|
|
|
std::pair<int32, vector<DialogId>> search_dialogs(const string &query, int32 limit, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-01-16 19:56:59 +01:00
|
|
|
vector<DialogId> search_dialogs_on_server(const string &query, int32 limit, Promise<Unit> &&promise);
|
|
|
|
|
2021-10-23 20:17:00 +02:00
|
|
|
void block_message_sender_from_replies(MessageId message_id, bool need_delete_message, bool need_delete_all_messages,
|
2020-10-18 00:26:36 +02:00
|
|
|
bool report_spam, Promise<Unit> &&promise);
|
2020-09-24 14:29:34 +02:00
|
|
|
|
2023-04-24 15:03:08 +02:00
|
|
|
bool is_dialog_blocked(DialogId dialog_id) const;
|
|
|
|
|
2023-07-28 16:52:44 +02:00
|
|
|
void get_blocked_dialogs(const td_api::object_ptr<td_api::BlockList> &block_list, int32 offset, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
2020-09-20 02:29:00 +02:00
|
|
|
|
2021-10-09 21:05:23 +02:00
|
|
|
void on_get_blocked_dialogs(int32 offset, int32 limit, int32 total_count,
|
|
|
|
vector<tl_object_ptr<telegram_api::peerBlocked>> &&blocked_peers,
|
|
|
|
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
2020-09-20 02:29:00 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool can_get_message_statistics(MessageFullId message_full_id);
|
2020-08-01 04:19:54 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
DialogId get_dialog_message_sender(MessageFullId message_full_id);
|
2021-11-19 15:12:22 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool have_message_force(MessageFullId message_full_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_message(MessageFullId message_full_id, Promise<Unit> &&promise);
|
2018-02-07 00:31:38 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId get_replied_message(DialogId dialog_id, MessageId message_id, bool force, Promise<Unit> &&promise);
|
2018-02-07 00:31:38 +01:00
|
|
|
|
2020-10-28 23:06:07 +01:00
|
|
|
MessageId get_dialog_pinned_message(DialogId dialog_id, Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
void get_callback_query_message(DialogId dialog_id, MessageId message_id, int64 callback_query_id,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
|
|
|
bool get_messages(DialogId dialog_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_message_from_server(MessageFullId message_full_id, Promise<Unit> &&promise, const char *source,
|
2020-10-28 23:06:07 +01:00
|
|
|
tl_object_ptr<telegram_api::InputMessage> input_message = nullptr);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_messages_from_server(vector<MessageFullId> &&message_ids, Promise<Unit> &&promise, const char *source,
|
2020-10-28 23:06:07 +01:00
|
|
|
tl_object_ptr<telegram_api::InputMessage> input_message = nullptr);
|
|
|
|
|
2020-09-22 16:27:35 +02:00
|
|
|
void get_message_thread(DialogId dialog_id, MessageId message_id, Promise<MessageThreadInfo> &&promise);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::messageThreadInfo> get_message_thread_info_object(const MessageThreadInfo &info);
|
2020-09-15 16:07:34 +02:00
|
|
|
|
2020-11-07 12:35:33 +01:00
|
|
|
void process_discussion_message(telegram_api::object_ptr<telegram_api::messages_discussionMessage> &&result,
|
|
|
|
DialogId dialog_id, MessageId message_id, DialogId expected_dialog_id,
|
2021-08-13 11:26:47 +02:00
|
|
|
MessageId expected_message_id, Promise<MessageThreadInfo> promise);
|
2020-09-15 16:07:34 +02:00
|
|
|
|
2024-01-09 11:37:29 +01:00
|
|
|
void get_message_read_date(MessageFullId message_full_id,
|
2024-01-09 12:47:04 +01:00
|
|
|
Promise<td_api::object_ptr<td_api::MessageReadDate>> &&promise);
|
2024-01-09 11:37:29 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_message_viewers(MessageFullId message_full_id,
|
2023-02-23 13:15:10 +01:00
|
|
|
Promise<td_api::object_ptr<td_api::messageViewers>> &&promise);
|
2021-09-03 15:14:03 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void translate_message_text(MessageFullId message_full_id, const string &to_language_code,
|
2023-01-23 13:46:26 +01:00
|
|
|
Promise<td_api::object_ptr<td_api::formattedText>> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool is_message_edited_recently(MessageFullId message_full_id, int32 seconds);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-01-04 20:46:13 +01:00
|
|
|
struct ReportDialogFromActionBar {
|
|
|
|
bool know_action_bar_ = false;
|
|
|
|
bool is_reported_ = false;
|
|
|
|
};
|
|
|
|
ReportDialogFromActionBar report_dialog_from_action_bar(DialogId dialog_id, Promise<Unit> &promise);
|
|
|
|
|
2021-09-13 19:34:57 +02:00
|
|
|
bool is_deleted_secret_chat(DialogId dialog_id) const;
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Result<std::pair<string, bool>> get_message_link(MessageFullId message_full_id, int32 media_timestamp, bool for_group,
|
2022-11-04 13:56:16 +01:00
|
|
|
bool in_message_thread);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
string get_message_embedding_code(MessageFullId message_full_id, bool for_group, Promise<Unit> &&promise);
|
2020-09-20 17:17:47 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_get_public_message_link(MessageFullId message_full_id, bool for_group, string url, string html);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-05 11:12:59 +02:00
|
|
|
void get_message_link_info(Slice url, Promise<MessageLinkInfo> &&promise);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::messageLinkInfo> get_message_link_info_object(const MessageLinkInfo &info) const;
|
|
|
|
|
2023-03-27 13:09:55 +02:00
|
|
|
bool is_dialog_in_dialog_list(DialogId dialog_id) const;
|
|
|
|
|
2023-03-27 16:44:13 +02:00
|
|
|
Status can_add_dialog_to_filter(DialogId dialog_id);
|
2020-05-19 01:41:07 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Status delete_dialog_reply_markup(DialogId dialog_id, MessageId message_id) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2020-09-22 18:45:27 +02:00
|
|
|
Status set_dialog_draft_message(DialogId dialog_id, MessageId top_thread_message_id,
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::draftMessage> &&draft_message) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2018-07-19 16:23:18 +02:00
|
|
|
void clear_all_draft_messages(bool exclude_secret_chats, Promise<Unit> &&promise);
|
2018-07-17 05:46:27 +02:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
Status toggle_dialog_is_pinned(DialogListId dialog_list_id, DialogId dialog_id, bool is_pinned) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-11-16 14:57:18 +01:00
|
|
|
Status toggle_dialog_view_as_messages(DialogId dialog_id, bool view_as_messages) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2018-06-27 23:08:44 +02:00
|
|
|
Status toggle_dialog_is_marked_as_unread(DialogId dialog_id, bool is_marked_as_unread) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2023-01-20 10:38:25 +01:00
|
|
|
Status toggle_dialog_is_translatable(DialogId dialog_id, bool is_translatable) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2023-07-28 16:33:47 +02:00
|
|
|
Status set_message_sender_block_list(const td_api::object_ptr<td_api::MessageSender> &sender,
|
|
|
|
const td_api::object_ptr<td_api::BlockList> &block_list) TD_WARN_UNUSED_RESULT;
|
2020-09-20 02:00:01 +02:00
|
|
|
|
2018-04-28 20:05:04 +02:00
|
|
|
Status toggle_dialog_silent_send_message(DialogId dialog_id, bool silent_send_message) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
Status set_pinned_dialogs(DialogListId dialog_list_id, vector<DialogId> dialog_ids) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
Status set_dialog_client_data(DialogId dialog_id, string &&client_data) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2018-01-23 22:45:26 +01:00
|
|
|
void create_dialog(DialogId dialog_id, bool force, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-12-07 10:32:23 +01:00
|
|
|
bool is_dialog_opened(DialogId dialog_id) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Status open_dialog(DialogId dialog_id) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
|
|
|
Status close_dialog(DialogId dialog_id) TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2023-02-07 19:08:54 +01:00
|
|
|
Status view_messages(DialogId dialog_id, vector<MessageId> message_ids, MessageSource source,
|
2020-09-22 00:13:06 +02:00
|
|
|
bool force_read) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-03-07 18:17:00 +01:00
|
|
|
void finish_get_message_views(DialogId dialog_id, const vector<MessageId> &message_ids);
|
|
|
|
|
2022-09-24 21:17:17 +02:00
|
|
|
void finish_get_message_extended_media(DialogId dialog_id, const vector<MessageId> &message_ids);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Status open_message_content(MessageFullId message_full_id) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void click_animated_emoji_message(MessageFullId message_full_id,
|
2021-09-15 23:41:40 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::sticker>> &&promise);
|
|
|
|
|
2023-08-22 17:55:59 +02:00
|
|
|
StoryNotificationSettings get_story_notification_settings(DialogId dialog_id);
|
|
|
|
|
2019-03-05 15:15:17 +01:00
|
|
|
vector<DialogId> get_dialog_notification_settings_exceptions(NotificationSettingsScope scope, bool filter_scope,
|
|
|
|
bool compare_sound, bool force, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
Status set_dialog_notification_settings(DialogId dialog_id,
|
|
|
|
tl_object_ptr<td_api::chatNotificationSettings> &¬ification_settings)
|
|
|
|
TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void reset_all_notification_settings();
|
|
|
|
|
2023-06-09 13:08:16 +02:00
|
|
|
void update_story_max_reply_media_timestamp_in_replied_messages(StoryFullId story_full_id);
|
|
|
|
|
2023-04-13 21:41:22 +02:00
|
|
|
int64 get_chat_id_object(DialogId dialog_id, const char *source) const;
|
|
|
|
|
2024-03-29 09:19:50 +01:00
|
|
|
td_api::object_ptr<td_api::chat> get_chat_object(DialogId dialog_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-02-07 14:10:56 +01:00
|
|
|
td_api::object_ptr<td_api::draftMessage> get_my_dialog_draft_message_object() const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::messages> get_dialog_history(DialogId dialog_id, MessageId from_message_id, int32 offset,
|
|
|
|
int32 limit, int left_tries, bool only_local,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2020-09-30 03:26:39 +02:00
|
|
|
std::pair<DialogId, vector<MessageId>> get_message_thread_history(DialogId dialog_id, MessageId message_id,
|
|
|
|
MessageId from_message_id, int32 offset,
|
|
|
|
int32 limit, int64 &random_id,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-06-08 20:20:11 +02:00
|
|
|
void get_dialog_message_calendar(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
MessageId from_message_id, MessageSearchFilter filter,
|
|
|
|
Promise<td_api::object_ptr<td_api::messageCalendar>> &&promise);
|
2021-10-30 02:34:49 +02:00
|
|
|
|
2022-12-28 16:42:11 +01:00
|
|
|
struct FoundDialogMessages {
|
|
|
|
vector<MessageId> message_ids;
|
|
|
|
MessageId next_from_message_id;
|
|
|
|
int32 total_count = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::foundChatMessages> get_found_chat_messages_object(
|
|
|
|
DialogId dialog_id, const FoundDialogMessages &found_dialog_messages, const char *source);
|
|
|
|
|
|
|
|
FoundDialogMessages search_dialog_messages(DialogId dialog_id, const string &query,
|
|
|
|
const td_api::object_ptr<td_api::MessageSender> &sender,
|
|
|
|
MessageId from_message_id, int32 offset, int32 limit,
|
|
|
|
MessageSearchFilter filter, MessageId top_thread_message_id,
|
2024-01-22 19:14:02 +01:00
|
|
|
SavedMessagesTopicId saved_messages_topic_id, const ReactionType &tag,
|
|
|
|
int64 &random_id, bool use_db, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-08-21 13:47:43 +02:00
|
|
|
struct FoundMessages {
|
2023-09-21 18:11:17 +02:00
|
|
|
vector<MessageFullId> message_full_ids;
|
2020-08-21 13:47:43 +02:00
|
|
|
string next_offset;
|
2020-08-21 14:08:47 +02:00
|
|
|
int32 total_count = 0;
|
2020-08-21 13:47:43 +02:00
|
|
|
};
|
|
|
|
|
2021-10-03 13:54:40 +02:00
|
|
|
td_api::object_ptr<td_api::foundMessages> get_found_messages_object(const FoundMessages &found_messages,
|
|
|
|
const char *source);
|
2020-08-21 13:47:43 +02:00
|
|
|
|
2024-05-11 20:54:21 +02:00
|
|
|
void offline_search_messages(DialogId dialog_id, const string &query, string offset, int32 limit,
|
|
|
|
MessageSearchFilter filter,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-10 13:15:02 +02:00
|
|
|
void search_messages(DialogListId dialog_list_id, bool ignore_folder_id, bool broadcasts_only, const string &query,
|
2024-05-10 14:28:37 +02:00
|
|
|
const string &offset_str, int32 limit, MessageSearchFilter filter, int32 min_date,
|
|
|
|
int32 max_date, Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-06-13 14:09:20 +02:00
|
|
|
void search_call_messages(const string &offset, int32 limit, bool only_missed,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-02-22 13:58:16 +01:00
|
|
|
void search_outgoing_document_messages(const string &query, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
|
|
|
|
2024-05-10 15:24:32 +02:00
|
|
|
void search_hashtag_posts(string hashtag, string offset_str, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
|
|
|
|
2021-10-06 13:22:42 +02:00
|
|
|
void search_dialog_recent_location_messages(DialogId dialog_id, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::messages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
vector<MessageFullId> get_active_live_location_messages(Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-11 23:48:28 +02:00
|
|
|
void get_dialog_message_by_date(DialogId dialog_id, int32 date,
|
|
|
|
Promise<td_api::object_ptr<td_api::message>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-11 23:48:28 +02:00
|
|
|
void on_get_dialog_message_by_date(DialogId dialog_id, int32 date,
|
|
|
|
vector<telegram_api::object_ptr<telegram_api::Message>> &&messages,
|
|
|
|
Promise<td_api::object_ptr<td_api::message>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-01-16 12:12:57 +01:00
|
|
|
void get_dialog_sparse_message_positions(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
MessageSearchFilter filter, MessageId from_message_id, int32 limit,
|
2021-10-15 16:40:30 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::messagePositions>> &&promise);
|
|
|
|
|
2024-01-16 12:12:57 +01:00
|
|
|
static void on_get_dialog_sparse_message_positions(
|
|
|
|
DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id, MessageSearchFilter filter,
|
2021-10-15 16:40:30 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::messages_searchResultsPositions> positions,
|
|
|
|
Promise<td_api::object_ptr<td_api::messagePositions>> &&promise);
|
|
|
|
|
2024-01-15 22:30:37 +01:00
|
|
|
void get_dialog_message_count(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
MessageSearchFilter filter, bool return_local, Promise<int32> &&promise);
|
2018-07-19 15:58:09 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_dialog_message_position(MessageFullId message_full_id, MessageSearchFilter filter,
|
2024-01-15 18:39:47 +01:00
|
|
|
MessageId top_thread_message_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
Promise<int32> &&promise);
|
2022-09-30 19:04:21 +02:00
|
|
|
|
2020-02-28 21:01:30 +01:00
|
|
|
vector<MessageId> get_dialog_scheduled_messages(DialogId dialog_id, bool force, bool ignore_result,
|
|
|
|
Promise<Unit> &&promise);
|
2019-12-04 18:06:39 +01:00
|
|
|
|
2024-02-04 21:06:48 +01:00
|
|
|
using AffectedHistoryQuery = std::function<void(DialogId, Promise<AffectedHistory>)>;
|
|
|
|
|
|
|
|
void run_affected_history_query_until_complete(DialogId dialog_id, AffectedHistoryQuery query,
|
|
|
|
bool get_affected_messages, Promise<Unit> &&promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Result<td_api::object_ptr<td_api::availableReactions>> get_message_available_reactions(MessageFullId message_full_id,
|
2022-09-13 18:19:35 +02:00
|
|
|
int32 row_size);
|
2022-01-26 13:25:03 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void add_message_reaction(MessageFullId message_full_id, ReactionType reaction_type, bool is_big, bool add_to_recent,
|
2022-09-05 21:04:50 +02:00
|
|
|
Promise<Unit> &&promise);
|
2022-01-21 18:39:55 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void remove_message_reaction(MessageFullId message_full_id, ReactionType reaction_type, Promise<Unit> &&promise);
|
2022-09-09 14:56:45 +02:00
|
|
|
|
2021-11-09 14:54:49 +01:00
|
|
|
td_api::object_ptr<td_api::message> get_dialog_event_log_message_object(
|
2021-12-21 12:53:22 +01:00
|
|
|
DialogId dialog_id, tl_object_ptr<telegram_api::Message> &&message, DialogId &sender_dialog_id);
|
2021-11-09 14:54:49 +01:00
|
|
|
|
2024-03-16 22:19:24 +01:00
|
|
|
td_api::object_ptr<td_api::businessMessage> get_business_message_object(
|
|
|
|
telegram_api::object_ptr<telegram_api::Message> &&message,
|
|
|
|
telegram_api::object_ptr<telegram_api::Message> &&reply_to_message);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-03-09 00:14:02 +01:00
|
|
|
td_api::object_ptr<td_api::message> get_message_object(MessageFullId message_full_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-03-09 00:14:02 +01:00
|
|
|
td_api::object_ptr<td_api::messages> get_messages_object(int32 total_count, DialogId dialog_id,
|
|
|
|
const vector<MessageId> &message_ids, bool skip_not_found,
|
|
|
|
const char *source);
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::messages> get_messages_object(int32 total_count,
|
|
|
|
const vector<MessageFullId> &message_full_ids,
|
|
|
|
bool skip_not_found, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-04-28 17:39:05 +02:00
|
|
|
void process_pts_update(tl_object_ptr<telegram_api::Update> &&update_ptr);
|
2021-01-11 23:46:13 +01:00
|
|
|
|
2021-01-15 23:17:35 +01:00
|
|
|
void skip_old_pending_pts_update(tl_object_ptr<telegram_api::Update> &&update, int32 new_pts, int32 old_pts,
|
|
|
|
int32 pts_count, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void add_pending_channel_update(DialogId dialog_id, tl_object_ptr<telegram_api::Update> &&update, int32 new_pts,
|
2020-12-24 22:14:18 +01:00
|
|
|
int32 pts_count, Promise<Unit> &&promise, const char *source,
|
|
|
|
bool is_postponed_update = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-02-04 02:06:20 +01:00
|
|
|
bool is_old_channel_update(DialogId dialog_id, int32 new_pts);
|
|
|
|
|
2021-01-25 15:58:19 +01:00
|
|
|
void on_dialog_bots_updated(DialogId dialog_id, vector<UserId> bot_user_ids, bool from_database);
|
2019-01-07 17:30:09 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_dialog_photo_updated(DialogId dialog_id);
|
2023-12-16 09:49:26 +01:00
|
|
|
void on_dialog_accent_colors_updated(DialogId dialog_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_dialog_title_updated(DialogId dialog_id);
|
2023-12-21 18:01:26 +01:00
|
|
|
void on_dialog_emoji_status_updated(DialogId dialog_id);
|
2022-10-12 20:04:18 +02:00
|
|
|
void on_dialog_usernames_updated(DialogId dialog_id, const Usernames &old_usernames, const Usernames &new_usernames);
|
2021-11-24 18:03:38 +01:00
|
|
|
void on_dialog_default_permissions_updated(DialogId dialog_id);
|
2021-12-06 19:43:55 +01:00
|
|
|
void on_dialog_has_protected_content_updated(DialogId dialog_id);
|
2019-10-11 01:59:40 +02:00
|
|
|
|
|
|
|
void on_dialog_user_is_contact_updated(DialogId dialog_id, bool is_contact);
|
2019-10-11 02:11:22 +02:00
|
|
|
void on_dialog_user_is_deleted_updated(DialogId dialog_id, bool is_deleted);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-09-13 16:52:39 +02:00
|
|
|
void on_dialog_linked_channel_updated(DialogId dialog_id, ChannelId old_linked_channel_id,
|
|
|
|
ChannelId new_linked_channel_id) const;
|
|
|
|
|
2021-10-26 19:51:06 +02:00
|
|
|
void drop_dialog_pending_join_requests(DialogId dialog_id);
|
2021-10-13 23:34:28 +02:00
|
|
|
|
2022-04-11 11:45:52 +02:00
|
|
|
void on_update_notification_scope_is_muted(NotificationSettingsScope scope, bool is_muted);
|
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
void on_update_dialog_notify_settings(DialogId dialog_id,
|
2019-02-20 02:30:22 +01:00
|
|
|
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-04-22 02:19:40 +02:00
|
|
|
void on_update_dialog_available_reactions(DialogId dialog_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::ChatReactions> &&available_reactions,
|
|
|
|
int32 reactions_limit);
|
2022-01-04 14:33:57 +01:00
|
|
|
|
2019-10-11 16:59:04 +02:00
|
|
|
void hide_dialog_action_bar(DialogId dialog_id);
|
|
|
|
|
2019-10-11 02:28:41 +02:00
|
|
|
void remove_dialog_action_bar(DialogId dialog_id, Promise<Unit> &&promise);
|
|
|
|
|
2021-11-22 18:13:55 +01:00
|
|
|
void reget_dialog_action_bar(DialogId dialog_id, const char *source, bool is_repair = true);
|
2019-10-11 16:59:04 +02:00
|
|
|
|
2024-04-08 01:45:54 +02:00
|
|
|
void hide_all_business_bot_manager_bars();
|
|
|
|
|
2019-10-17 19:55:55 +02:00
|
|
|
void on_get_peer_settings(DialogId dialog_id, tl_object_ptr<telegram_api::peerSettings> &&peer_settings,
|
|
|
|
bool ignore_privacy_exception = false);
|
2019-09-07 01:07:56 +02:00
|
|
|
|
2020-06-04 01:02:17 +02:00
|
|
|
void on_authorization_success();
|
2020-06-03 18:21:59 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void before_get_difference();
|
|
|
|
|
|
|
|
void after_get_difference();
|
|
|
|
|
2023-11-12 20:55:48 +01:00
|
|
|
bool on_get_message_error(DialogId dialog_id, MessageId message_id, const Status &status, const char *source);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_send_message_get_quick_ack(int64 random_id);
|
|
|
|
|
|
|
|
void check_send_message_result(int64 random_id, DialogId dialog_id, const telegram_api::Updates *updates_ptr,
|
|
|
|
const char *source);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId on_send_message_success(int64 random_id, MessageId new_message_id, int32 date, int32 ttl_period,
|
2021-02-02 00:00:28 +01:00
|
|
|
FileId new_file_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-07-05 09:55:16 +02:00
|
|
|
void on_send_message_file_parts_missing(int64 random_id, vector<int> &&bad_parts);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-01-28 16:21:48 +01:00
|
|
|
void on_send_message_file_reference_error(int64 random_id);
|
|
|
|
|
2019-02-08 15:54:23 +01:00
|
|
|
void on_send_media_group_file_reference_error(DialogId dialog_id, vector<int64> random_ids);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_send_message_fail(int64 random_id, Status error);
|
|
|
|
|
|
|
|
void on_upload_message_media_success(DialogId dialog_id, MessageId message_id,
|
|
|
|
tl_object_ptr<telegram_api::MessageMedia> &&media);
|
|
|
|
|
2023-07-05 09:55:16 +02:00
|
|
|
void on_upload_message_media_file_parts_missing(DialogId dialog_id, MessageId message_id, vector<int> &&bad_parts);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_upload_message_media_fail(DialogId dialog_id, MessageId message_id, Status error);
|
|
|
|
|
2024-04-09 15:19:33 +02:00
|
|
|
void on_create_new_dialog(telegram_api::object_ptr<telegram_api::Updates> &&updates,
|
|
|
|
MissingInvitees &&missing_invitees,
|
|
|
|
Promise<td_api::object_ptr<td_api::createdBasicGroupChat>> &&chat_promise,
|
|
|
|
Promise<td_api::object_ptr<td_api::chat>> &&channel_promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_get_channel_difference(DialogId dialog_id, int32 request_pts, int32 request_limit,
|
2023-07-25 13:12:58 +02:00
|
|
|
tl_object_ptr<telegram_api::updates_ChannelDifference> &&difference_ptr,
|
|
|
|
Status &&status);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-08 16:29:50 +02:00
|
|
|
void try_update_dialog_pos(DialogId dialog_id);
|
|
|
|
|
2019-12-25 20:57:12 +01:00
|
|
|
void force_create_dialog(DialogId dialog_id, const char *source, bool expect_no_access = false,
|
|
|
|
bool force_update_dialog_pos = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-05-03 16:16:04 +02:00
|
|
|
void on_get_dialog_query_finished(DialogId dialog_id, Status &&status);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-04-28 11:03:00 +02:00
|
|
|
void remove_sponsored_dialog();
|
|
|
|
|
2020-04-28 15:25:56 +02:00
|
|
|
void on_get_sponsored_dialog(tl_object_ptr<telegram_api::Peer> peer, DialogSource source,
|
|
|
|
vector<tl_object_ptr<telegram_api::User>> users,
|
|
|
|
vector<tl_object_ptr<telegram_api::Chat>> chats);
|
2018-05-08 22:02:15 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FileSourceId get_message_file_source_id(MessageFullId message_full_id, bool force = false);
|
2019-01-30 22:37:38 +01:00
|
|
|
|
2019-03-28 22:08:57 +01:00
|
|
|
struct MessagePushNotificationInfo {
|
|
|
|
NotificationGroupId group_id;
|
|
|
|
NotificationGroupType group_type = NotificationGroupType::Calls;
|
|
|
|
DialogId settings_dialog_id;
|
|
|
|
};
|
2019-03-29 13:26:08 +01:00
|
|
|
Result<MessagePushNotificationInfo> get_message_push_notification_info(DialogId dialog_id, MessageId message_id,
|
|
|
|
int64 random_id, UserId sender_user_id,
|
2020-09-08 21:08:10 +02:00
|
|
|
DialogId sender_dialog_id, int32 date,
|
|
|
|
bool is_from_scheduled, bool contains_mention,
|
|
|
|
bool is_pinned, bool is_from_binlog);
|
2019-03-26 16:05:53 +01:00
|
|
|
|
2023-08-23 18:38:06 +02:00
|
|
|
NotificationGroupFromDatabase get_message_notification_group_force(NotificationGroupId group_id);
|
2018-11-26 18:05:06 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
vector<NotificationGroupKey> get_message_notification_group_keys_from_database(NotificationGroupKey from_group_key,
|
|
|
|
int32 limit);
|
2018-11-28 22:51:25 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void get_message_notifications_from_database(DialogId dialog_id, NotificationGroupId group_id,
|
|
|
|
NotificationId from_notification_id, MessageId from_message_id,
|
|
|
|
int32 limit, Promise<vector<Notification>> promise);
|
2018-12-03 16:38:29 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void remove_message_notification(DialogId dialog_id, NotificationGroupId group_id, NotificationId notification_id);
|
2018-11-29 00:48:47 +01:00
|
|
|
|
2019-04-07 17:48:09 +02:00
|
|
|
void remove_message_notifications_by_message_ids(DialogId dialog_id, const vector<MessageId> &message_ids);
|
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void remove_message_notifications(DialogId dialog_id, NotificationGroupId group_id,
|
2019-04-02 00:05:31 +02:00
|
|
|
NotificationId max_notification_id, MessageId max_message_id);
|
2018-11-29 22:02:33 +01:00
|
|
|
|
2022-04-11 11:45:52 +02:00
|
|
|
void remove_scope_pinned_message_notifications(NotificationSettingsScope scope);
|
|
|
|
|
|
|
|
void on_update_scope_mention_notifications(NotificationSettingsScope scope, bool disable_mention_notifications);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_binlog_events(vector<BinlogEvent> &&events);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void set_poll_answer(MessageFullId message_full_id, vector<int32> &&option_ids, Promise<Unit> &&promise);
|
2019-02-21 13:23:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_poll_voters(MessageFullId message_full_id, int32 option_id, int32 offset, int32 limit,
|
2023-04-25 15:41:04 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
|
2020-01-13 19:21:58 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void stop_poll(MessageFullId message_full_id, td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
2019-04-12 01:10:33 +02:00
|
|
|
Promise<Unit> &&promise);
|
2019-02-22 16:09:55 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Result<string> get_login_button_url(MessageFullId message_full_id, int64 button_id);
|
2021-05-25 01:39:29 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Result<ServerMessageId> get_invoice_message_id(MessageFullId message_full_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Result<ServerMessageId> get_payment_successful_message_id(MessageFullId message_full_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-06 17:28:02 +02:00
|
|
|
Result<ServerMessageId> get_giveaway_message_id(MessageFullId message_full_id);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool can_set_game_score(MessageFullId message_full_id) const;
|
2021-09-07 09:45:01 +02:00
|
|
|
|
2018-09-21 09:15:07 +02:00
|
|
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void add_message_file_to_downloads(MessageFullId message_full_id, FileId file_id, int32 priority,
|
2022-02-23 20:56:03 +01:00
|
|
|
Promise<td_api::object_ptr<td_api::file>> promise);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void get_message_file_search_text(MessageFullId message_full_id, string unique_file_id, Promise<string> promise);
|
2022-02-26 19:52:14 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
private:
|
|
|
|
class PendingPtsUpdate {
|
|
|
|
public:
|
|
|
|
tl_object_ptr<telegram_api::Update> update;
|
|
|
|
int32 pts;
|
|
|
|
int32 pts_count;
|
2020-12-24 19:56:15 +01:00
|
|
|
Promise<Unit> promise;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-12-24 19:56:15 +01:00
|
|
|
PendingPtsUpdate(tl_object_ptr<telegram_api::Update> &&update, int32 pts, int32 pts_count, Promise<Unit> &&promise)
|
|
|
|
: update(std::move(update)), pts(pts), pts_count(pts_count), promise(std::move(promise)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MessageInfo {
|
|
|
|
DialogId dialog_id;
|
|
|
|
MessageId message_id;
|
|
|
|
UserId sender_user_id;
|
2020-09-08 21:08:10 +02:00
|
|
|
DialogId sender_dialog_id;
|
2024-01-13 10:06:31 +01:00
|
|
|
SavedMessagesTopicId saved_messages_topic_id;
|
2018-09-19 18:18:10 +02:00
|
|
|
int32 date = 0;
|
2021-02-08 21:41:17 +01:00
|
|
|
int32 ttl_period = 0;
|
2024-01-30 13:07:21 +01:00
|
|
|
MessageSelfDestructType ttl;
|
2021-11-03 22:21:27 +01:00
|
|
|
bool disable_web_page_preview = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 random_id = 0;
|
|
|
|
tl_object_ptr<telegram_api::messageFwdHeader> forward_header;
|
2022-11-02 04:28:35 +01:00
|
|
|
MessageReplyHeader reply_header;
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId via_bot_user_id;
|
2024-03-09 01:08:19 +01:00
|
|
|
UserId via_business_bot_user_id;
|
2020-07-31 04:50:11 +02:00
|
|
|
int32 view_count = 0;
|
|
|
|
int32 forward_count = 0;
|
2020-08-31 12:42:27 +02:00
|
|
|
tl_object_ptr<telegram_api::messageReplies> reply_info;
|
2022-01-20 20:54:34 +01:00
|
|
|
tl_object_ptr<telegram_api::messageReactions> reactions;
|
2024-05-18 22:59:26 +02:00
|
|
|
tl_object_ptr<telegram_api::factCheck> fact_check;
|
2024-02-11 00:45:18 +01:00
|
|
|
int32 sender_boost_count = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 edit_date = 0;
|
2019-11-24 00:28:48 +01:00
|
|
|
vector<RestrictionReason> restriction_reasons;
|
2018-12-31 20:04:05 +01:00
|
|
|
string author_signature;
|
|
|
|
int64 media_album_id = 0;
|
2024-06-05 16:01:11 +02:00
|
|
|
MessageEffectId effect_id;
|
2023-09-25 21:48:35 +02:00
|
|
|
bool is_outgoing = false;
|
|
|
|
bool is_silent = false;
|
|
|
|
bool is_channel_post = false;
|
|
|
|
bool is_legacy = false;
|
|
|
|
bool hide_edit_date = false;
|
|
|
|
bool is_from_scheduled = false;
|
2024-03-20 16:54:04 +01:00
|
|
|
bool is_from_offline = false;
|
2023-09-25 21:48:35 +02:00
|
|
|
bool is_pinned = false;
|
|
|
|
bool noforwards = false;
|
|
|
|
bool has_mention = false;
|
|
|
|
bool has_unread_content = false;
|
2023-10-17 11:27:26 +02:00
|
|
|
bool invert_media = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
unique_ptr<MessageContent> content;
|
|
|
|
tl_object_ptr<telegram_api::ReplyMarkup> reply_markup;
|
|
|
|
};
|
|
|
|
|
2023-05-02 15:07:01 +02:00
|
|
|
// Do not forget to update MessagesManager::update_message and all make_unique<Message> when this class is changed
|
2023-05-06 01:37:53 +02:00
|
|
|
struct Message final : public ListNode {
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId message_id;
|
|
|
|
UserId sender_user_id;
|
2020-09-08 21:08:10 +02:00
|
|
|
DialogId sender_dialog_id;
|
2024-01-13 10:06:31 +01:00
|
|
|
SavedMessagesTopicId saved_messages_topic_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 date = 0;
|
|
|
|
int32 edit_date = 0;
|
2018-09-19 18:18:10 +02:00
|
|
|
int32 send_date = 0;
|
2024-02-11 00:45:18 +01:00
|
|
|
int32 sending_id = 0; // for yet unsent messages
|
|
|
|
int32 sender_boost_count = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
int64 random_id = 0;
|
|
|
|
|
|
|
|
unique_ptr<MessageForwardInfo> forward_info;
|
|
|
|
|
2023-10-26 13:51:32 +02:00
|
|
|
RepliedMessageInfo replied_message_info;
|
2023-06-07 14:10:46 +02:00
|
|
|
StoryFullId reply_to_story_full_id;
|
2023-10-26 13:51:32 +02:00
|
|
|
|
2023-10-25 12:07:25 +02:00
|
|
|
MessageId top_thread_message_id;
|
2020-09-29 14:06:08 +02:00
|
|
|
MessageId linked_top_thread_message_id;
|
2020-09-28 23:22:35 +02:00
|
|
|
vector<MessageId> local_thread_message_ids;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-01-30 23:45:20 +01:00
|
|
|
MessageId initial_top_thread_message_id; // for send_message
|
|
|
|
MessageInputReplyTo input_reply_to; // for send_message
|
|
|
|
int64 reply_to_random_id = 0; // for send_message
|
|
|
|
string send_emoji; // for send_message
|
2023-10-25 12:07:25 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId via_bot_user_id;
|
2024-03-09 01:08:19 +01:00
|
|
|
UserId via_business_bot_user_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-11-24 00:28:48 +01:00
|
|
|
vector<RestrictionReason> restriction_reasons;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
string author_signature;
|
|
|
|
|
|
|
|
bool is_channel_post = false;
|
2022-10-28 11:43:51 +02:00
|
|
|
bool is_topic_message = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_outgoing = false;
|
2019-08-10 23:14:35 +02:00
|
|
|
bool is_failed_to_send = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool disable_notification = false;
|
|
|
|
bool contains_mention = false;
|
|
|
|
bool contains_unread_mention = false;
|
2019-11-21 22:02:09 +01:00
|
|
|
bool hide_edit_date = false;
|
2019-03-14 20:00:31 +01:00
|
|
|
bool had_reply_markup = false; // had non-inline reply markup?
|
|
|
|
bool had_forward_info = false;
|
2020-10-20 01:08:56 +02:00
|
|
|
bool is_content_secret = false; // must be shown only while tapped
|
2019-01-10 18:54:46 +01:00
|
|
|
bool is_mention_notification_disabled = false;
|
2019-11-25 01:36:49 +01:00
|
|
|
bool is_from_scheduled = false;
|
2024-03-20 16:54:04 +01:00
|
|
|
bool is_from_offline = false;
|
2020-10-20 01:08:56 +02:00
|
|
|
bool is_pinned = false;
|
2021-08-09 18:37:47 +02:00
|
|
|
bool are_media_timestamp_entities_found = false;
|
2021-11-25 11:47:54 +01:00
|
|
|
bool noforwards = false;
|
2023-10-17 11:27:26 +02:00
|
|
|
bool invert_media = false;
|
2024-03-04 16:55:03 +01:00
|
|
|
bool disable_web_page_preview = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-11-25 13:49:51 +01:00
|
|
|
bool has_explicit_sender = false; // for send_message
|
2019-12-12 22:46:38 +01:00
|
|
|
bool is_copy = false; // for send_message
|
2018-12-31 20:04:05 +01:00
|
|
|
bool from_background = false; // for send_message
|
2022-09-04 00:14:25 +02:00
|
|
|
bool update_stickersets_order = false; // for send_message
|
2018-12-31 20:04:05 +01:00
|
|
|
bool clear_draft = false; // for send_message
|
|
|
|
bool in_game_share = false; // for send_message
|
2019-08-11 00:10:01 +02:00
|
|
|
bool hide_via_bot = false; // for resend_message
|
2019-08-11 00:23:34 +02:00
|
|
|
bool is_bot_start_message = false; // for resend_message
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-03-07 18:17:00 +01:00
|
|
|
bool has_get_message_views_query = false;
|
|
|
|
bool need_view_counter_increment = false;
|
|
|
|
|
2022-09-24 21:17:17 +02:00
|
|
|
bool has_get_extended_media_query = false;
|
|
|
|
|
2019-08-16 01:50:22 +02:00
|
|
|
DialogId real_forward_from_dialog_id; // for resend_message
|
|
|
|
MessageId real_forward_from_message_id; // for resend_message
|
2019-08-11 02:20:16 +02:00
|
|
|
|
2018-11-11 13:58:52 +01:00
|
|
|
NotificationId notification_id;
|
2019-04-07 17:48:09 +02:00
|
|
|
NotificationId removed_notification_id;
|
2018-11-11 13:58:52 +01:00
|
|
|
|
2021-08-05 08:59:43 +02:00
|
|
|
int32 max_reply_media_timestamp = -1;
|
2021-08-06 04:55:43 +02:00
|
|
|
int32 max_own_media_timestamp = -2; // to update replied messages on the first load
|
2021-08-05 08:59:43 +02:00
|
|
|
|
2020-07-31 04:50:11 +02:00
|
|
|
int32 view_count = 0;
|
|
|
|
int32 forward_count = 0;
|
2020-08-31 12:42:27 +02:00
|
|
|
MessageReplyInfo reply_info;
|
2022-01-20 20:54:34 +01:00
|
|
|
unique_ptr<MessageReactions> reactions;
|
2024-05-18 22:59:26 +02:00
|
|
|
unique_ptr<FactCheck> fact_check;
|
2020-09-22 18:45:27 +02:00
|
|
|
unique_ptr<DraftMessage> thread_draft_message;
|
2022-02-15 15:11:29 +01:00
|
|
|
uint32 available_reactions_generation = 0;
|
2020-12-05 14:23:22 +01:00
|
|
|
int32 interaction_info_update_date = 0;
|
2022-11-14 18:12:23 +01:00
|
|
|
uint32 history_generation = 0;
|
2020-08-31 12:42:27 +02:00
|
|
|
|
2019-08-15 17:16:09 +02:00
|
|
|
int32 legacy_layer = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-10 23:14:35 +02:00
|
|
|
int32 send_error_code = 0;
|
|
|
|
string send_error_message;
|
|
|
|
double try_resend_at = 0;
|
|
|
|
|
2024-01-30 13:07:21 +01:00
|
|
|
int32 ttl_period = 0; // counted from message send date
|
|
|
|
MessageSelfDestructType ttl; // counted from message content view date
|
|
|
|
double ttl_expires_at = 0; // only for TTL
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
int64 media_album_id = 0;
|
2024-06-05 16:01:11 +02:00
|
|
|
MessageEffectId effect_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
unique_ptr<MessageContent> content;
|
|
|
|
|
|
|
|
unique_ptr<ReplyMarkup> reply_markup;
|
|
|
|
|
2019-12-03 18:26:09 +01:00
|
|
|
int32 edited_schedule_date = 0;
|
2023-10-21 23:50:19 +02:00
|
|
|
bool edited_invert_media = false;
|
2018-06-19 01:31:34 +02:00
|
|
|
unique_ptr<MessageContent> edited_content;
|
|
|
|
unique_ptr<ReplyMarkup> edited_reply_markup;
|
|
|
|
uint64 edit_generation = 0;
|
|
|
|
Promise<Unit> edit_promise;
|
|
|
|
|
2020-12-25 01:30:52 +01:00
|
|
|
int32 last_edit_pts = 0;
|
|
|
|
|
2021-05-09 17:43:11 +02:00
|
|
|
const char *debug_source = "null";
|
2021-04-06 11:33:08 +02:00
|
|
|
|
2018-09-27 18:51:45 +02:00
|
|
|
mutable int32 last_access_date = 0;
|
2021-08-10 15:18:08 +02:00
|
|
|
mutable bool is_update_sent = false; // whether the message is known to the app
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
mutable uint64 send_message_log_event_id = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-11 03:05:00 +02:00
|
|
|
mutable NetQueryRef send_query_ref;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2023-05-06 01:37:53 +02:00
|
|
|
|
|
|
|
Message() = default;
|
|
|
|
Message(const Message &) = delete;
|
|
|
|
Message &operator=(const Message &) = delete;
|
|
|
|
Message(Message &&) = delete;
|
|
|
|
Message &operator=(Message &&) = delete;
|
|
|
|
~Message() = default;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
2023-03-16 18:10:54 +01:00
|
|
|
struct DialogScheduledMessages {
|
|
|
|
FlatHashMap<ScheduledServerMessageId, int32, ScheduledServerMessageIdHash> scheduled_message_date_;
|
|
|
|
|
|
|
|
FlatHashMap<int32, MessageId> last_assigned_scheduled_message_id_; // date -> message_id
|
|
|
|
|
|
|
|
FlatHashSet<ScheduledServerMessageId, ScheduledServerMessageIdHash> deleted_scheduled_server_message_ids_;
|
|
|
|
|
2023-05-01 23:52:23 +02:00
|
|
|
FlatHashMap<MessageId, unique_ptr<Message>, MessageIdHash> scheduled_messages_;
|
2023-03-16 18:10:54 +01:00
|
|
|
};
|
|
|
|
|
2023-03-16 20:38:29 +01:00
|
|
|
struct NotificationInfo {
|
2023-03-16 20:57:14 +01:00
|
|
|
NotificationGroupInfo message_notification_group_;
|
|
|
|
NotificationGroupInfo mention_notification_group_;
|
|
|
|
NotificationId new_secret_chat_notification_id_; // secret chats only
|
|
|
|
MessageId pinned_message_notification_message_id_;
|
2023-08-27 01:48:18 +02:00
|
|
|
MessageId max_push_notification_message_id_;
|
2023-03-16 20:38:29 +01:00
|
|
|
|
2023-03-16 20:57:14 +01:00
|
|
|
vector<std::pair<DialogId, MessageId>> pending_new_message_notifications_;
|
|
|
|
vector<std::pair<DialogId, MessageId>> pending_new_mention_notifications_;
|
2023-03-16 20:38:29 +01:00
|
|
|
|
2023-03-16 20:57:14 +01:00
|
|
|
FlatHashMap<NotificationId, MessageId, NotificationIdHash> notification_id_to_message_id_;
|
2023-03-16 20:38:29 +01:00
|
|
|
};
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct Dialog {
|
|
|
|
DialogId dialog_id;
|
|
|
|
MessageId last_new_message_id; // identifier of the last known server message received from update, there should be
|
|
|
|
// no server messages after it
|
2021-09-06 12:58:40 +02:00
|
|
|
MessageId last_message_id; // identifier of the message after which currently there are no messages, i.e. a
|
2018-12-31 20:04:05 +01:00
|
|
|
// message without a gap after it, memory only
|
|
|
|
MessageId first_database_message_id; // identifier of the first message in the database, needed
|
2021-09-06 12:58:40 +02:00
|
|
|
// until there are no gaps in the database
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId last_database_message_id; // identifier of the last local or server message, if last_database_message_id
|
2019-10-19 20:20:16 +02:00
|
|
|
// is known and last_message_id is known, then last_database_message_id <=
|
2018-12-31 20:04:05 +01:00
|
|
|
// last_message_id
|
|
|
|
|
2020-08-22 09:05:51 +02:00
|
|
|
std::array<MessageId, message_search_filter_count()> first_database_message_id_by_index;
|
2018-12-31 20:04:05 +01:00
|
|
|
// use struct Count?
|
2020-08-22 09:05:51 +02:00
|
|
|
std::array<int32, message_search_filter_count()> message_count_by_index{{0}};
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
int32 server_unread_count = 0;
|
|
|
|
int32 local_unread_count = 0;
|
|
|
|
int32 unread_mention_count = 0;
|
2022-01-28 16:39:13 +01:00
|
|
|
int32 unread_reaction_count = 0;
|
2018-06-20 03:02:02 +02:00
|
|
|
int32 last_read_inbox_message_date = 0; // secret chats only
|
2021-10-19 17:11:16 +02:00
|
|
|
MessageId last_read_inbox_message_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId last_read_outbox_message_id;
|
2020-10-20 19:28:37 +02:00
|
|
|
MessageId last_pinned_message_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId reply_markup_message_id;
|
2018-04-09 18:30:27 +02:00
|
|
|
DialogNotificationSettings notification_settings;
|
2022-08-30 10:45:27 +02:00
|
|
|
ChatReactions available_reactions;
|
2022-02-15 15:11:29 +01:00
|
|
|
uint32 available_reactions_generation = 0;
|
2021-12-21 12:06:15 +01:00
|
|
|
MessageTtl message_ttl;
|
2018-12-31 20:04:05 +01:00
|
|
|
unique_ptr<DraftMessage> draft_message;
|
2021-11-22 20:39:59 +01:00
|
|
|
unique_ptr<DialogActionBar> action_bar;
|
2024-04-08 01:37:52 +02:00
|
|
|
unique_ptr<BusinessBotManageBar> business_bot_manage_bar;
|
2020-09-24 18:15:42 +02:00
|
|
|
LogEventIdWithGeneration save_draft_message_log_event_id;
|
|
|
|
LogEventIdWithGeneration save_notification_settings_log_event_id;
|
|
|
|
LogEventIdWithGeneration set_folder_id_log_event_id;
|
2020-12-13 22:36:44 +01:00
|
|
|
InputGroupCallId active_group_call_id;
|
2021-04-12 01:49:28 +02:00
|
|
|
InputGroupCallId expected_active_group_call_id;
|
2021-03-08 13:13:36 +01:00
|
|
|
DialogId default_join_group_call_as_dialog_id;
|
2021-11-12 14:15:19 +01:00
|
|
|
DialogId default_send_message_as_dialog_id;
|
2023-04-10 16:23:21 +02:00
|
|
|
BackgroundInfo background_info;
|
2021-08-23 17:47:32 +02:00
|
|
|
string theme_name;
|
2021-10-12 17:11:17 +02:00
|
|
|
int32 pending_join_request_count = 0;
|
2021-10-26 19:51:06 +02:00
|
|
|
vector<UserId> pending_join_request_user_ids;
|
2022-07-15 16:03:40 +02:00
|
|
|
int32 have_full_history_source = 0;
|
2022-08-27 10:19:00 +02:00
|
|
|
int32 unload_dialog_delay_seed = 0;
|
2022-09-21 16:44:25 +02:00
|
|
|
int64 last_media_album_id = 0;
|
2022-11-14 18:12:23 +01:00
|
|
|
uint32 history_generation = 0;
|
2023-02-07 19:45:03 +01:00
|
|
|
uint32 open_count = 0;
|
2020-05-09 22:39:11 +02:00
|
|
|
|
2023-03-16 20:38:29 +01:00
|
|
|
unique_ptr<NotificationInfo> notification_info;
|
|
|
|
|
2019-08-19 03:51:03 +02:00
|
|
|
FolderId folder_id;
|
2020-05-21 18:39:34 +02:00
|
|
|
vector<DialogListId> dialog_list_ids; // TODO replace with mask
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
MessageId
|
2019-11-29 17:24:45 +01:00
|
|
|
last_read_all_mentions_message_id; // all mentions with a message identifier not greater than it are implicitly read
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId
|
2019-11-29 17:24:45 +01:00
|
|
|
max_unavailable_message_id; // maximum unavailable message identifier for dialogs with cleared/unavailable history
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
int64 order = DEFAULT_ORDER;
|
2023-11-01 13:02:32 +01:00
|
|
|
int64 pending_order = DEFAULT_ORDER;
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId deleted_last_message_id;
|
2021-10-19 17:11:16 +02:00
|
|
|
int32 delete_last_message_date = 0;
|
2023-11-01 13:02:32 +01:00
|
|
|
int32 last_clear_history_date = 0;
|
|
|
|
MessageId last_clear_history_message_id;
|
2020-01-08 02:34:15 +01:00
|
|
|
MessageId last_edited_message_id;
|
2019-12-04 18:06:39 +01:00
|
|
|
uint32 scheduled_messages_sync_generation = 0;
|
2020-02-28 19:40:31 +01:00
|
|
|
uint32 last_repair_scheduled_messages_generation = 0;
|
2018-01-26 16:07:21 +01:00
|
|
|
|
2018-08-04 23:05:29 +02:00
|
|
|
MessageId max_added_message_id;
|
2019-02-07 12:12:22 +01:00
|
|
|
MessageId being_added_message_id;
|
2019-04-13 15:50:06 +02:00
|
|
|
MessageId being_updated_last_new_message_id;
|
|
|
|
MessageId being_updated_last_database_message_id;
|
2019-04-28 16:07:27 +02:00
|
|
|
MessageId being_deleted_message_id;
|
2018-08-04 23:05:29 +02:00
|
|
|
|
2018-01-26 16:07:21 +01:00
|
|
|
bool has_contact_registered_message = false;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_last_message_deleted_locally = false;
|
|
|
|
|
2021-11-22 18:13:55 +01:00
|
|
|
bool need_repair_action_bar = false;
|
2019-10-10 22:19:26 +02:00
|
|
|
bool know_action_bar = false;
|
2021-11-23 10:10:49 +01:00
|
|
|
bool has_outgoing_messages = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-14 21:49:09 +02:00
|
|
|
bool was_opened = false;
|
2023-07-24 14:42:38 +02:00
|
|
|
bool need_unload_on_close = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
bool need_restore_reply_markup = true;
|
2021-12-20 18:23:26 +01:00
|
|
|
bool need_drop_default_send_message_as_dialog_id = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
bool have_full_history = false;
|
|
|
|
bool is_empty = false;
|
|
|
|
|
|
|
|
bool is_last_read_inbox_message_id_inited = false;
|
|
|
|
bool is_last_read_outbox_message_id_inited = false;
|
2020-10-20 19:28:37 +02:00
|
|
|
bool is_last_pinned_message_id_inited = false;
|
2019-08-19 03:51:03 +02:00
|
|
|
bool is_folder_id_inited = false;
|
2018-05-02 12:30:52 +02:00
|
|
|
bool need_repair_server_unread_count = false;
|
2020-02-19 02:14:58 +01:00
|
|
|
bool need_repair_channel_server_unread_count = false;
|
2023-11-16 13:04:57 +01:00
|
|
|
bool is_forum = false;
|
2023-11-16 11:59:32 +01:00
|
|
|
bool view_as_messages = false;
|
2018-06-27 23:08:44 +02:00
|
|
|
bool is_marked_as_unread = false;
|
2020-09-20 00:54:40 +02:00
|
|
|
bool is_blocked = false;
|
|
|
|
bool is_is_blocked_inited = false;
|
2023-07-28 15:19:05 +02:00
|
|
|
bool is_blocked_for_stories = false;
|
|
|
|
bool is_is_blocked_for_stories_inited = false;
|
2019-12-04 19:44:40 +01:00
|
|
|
bool last_sent_has_scheduled_messages = false;
|
2019-12-04 18:51:52 +01:00
|
|
|
bool has_scheduled_server_messages = false;
|
2019-12-04 20:43:14 +01:00
|
|
|
bool has_scheduled_database_messages = false;
|
|
|
|
bool is_has_scheduled_database_messages_checked = false;
|
2019-12-04 18:06:39 +01:00
|
|
|
bool has_loaded_scheduled_messages_from_database = false;
|
2020-02-28 21:01:30 +01:00
|
|
|
bool sent_scheduled_messages = false;
|
2020-08-08 22:00:51 +02:00
|
|
|
bool had_last_yet_unsent_message = false; // whether the dialog was stored to database without last message
|
2020-12-13 22:36:44 +01:00
|
|
|
bool has_active_group_call = false;
|
|
|
|
bool is_group_call_empty = false;
|
2021-12-21 12:06:15 +01:00
|
|
|
bool is_message_ttl_inited = false;
|
2021-04-12 01:49:28 +02:00
|
|
|
bool has_expected_active_group_call_id = false;
|
2021-07-22 03:10:40 +02:00
|
|
|
bool has_bots = false;
|
2023-11-16 11:59:32 +01:00
|
|
|
bool is_view_as_messages_inited = false;
|
2024-02-07 13:32:50 +01:00
|
|
|
bool is_saved_messages_view_as_messages_inited = false;
|
2021-07-22 03:10:40 +02:00
|
|
|
bool is_has_bots_inited = false;
|
2023-04-10 16:23:21 +02:00
|
|
|
bool is_background_inited = false;
|
2021-08-23 17:47:32 +02:00
|
|
|
bool is_theme_name_inited = false;
|
2022-01-04 14:33:57 +01:00
|
|
|
bool is_available_reactions_inited = false;
|
2022-08-08 12:19:11 +02:00
|
|
|
bool had_yet_unsent_message_id_overflow = false;
|
2023-01-16 18:30:52 +01:00
|
|
|
bool need_repair_unread_reaction_count = false;
|
2023-02-22 11:09:24 +01:00
|
|
|
bool need_repair_unread_mention_count = false;
|
2023-01-20 10:38:25 +01:00
|
|
|
bool is_translatable = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-06-08 18:42:21 +02:00
|
|
|
bool is_update_new_chat_sent = false;
|
2022-08-08 18:52:29 +02:00
|
|
|
bool is_update_new_chat_being_sent = false;
|
2021-02-13 23:25:17 +01:00
|
|
|
bool has_unload_timeout = false;
|
2021-07-29 02:32:08 +02:00
|
|
|
bool is_channel_difference_finished = false;
|
2018-06-08 18:42:21 +02:00
|
|
|
|
2022-11-23 17:37:32 +01:00
|
|
|
int32 pts = 0; // for channels only
|
|
|
|
int32 pending_read_channel_inbox_pts = 0; // for channels only
|
|
|
|
int32 pending_read_channel_inbox_server_unread_count = 0; // for channels only
|
|
|
|
MessageId pending_read_channel_inbox_max_message_id; // for channels only
|
2023-07-26 12:38:10 +02:00
|
|
|
FlatHashMap<int64, MessageId> random_id_to_message_id; // for secret chats and yet unsent messages only
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
MessageId last_assigned_message_id; // identifier of the last local or yet unsent message, assigned after
|
|
|
|
// application start, used to guarantee that all assigned message identifiers
|
|
|
|
// are different
|
|
|
|
|
2022-08-20 23:20:57 +02:00
|
|
|
WaitFreeHashSet<MessageId, MessageIdHash> deleted_message_ids;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
string client_data;
|
|
|
|
|
2023-05-02 15:07:01 +02:00
|
|
|
WaitFreeHashMap<MessageId, unique_ptr<Message>, MessageIdHash> messages;
|
2023-05-02 17:04:54 +02:00
|
|
|
|
2023-05-06 01:37:53 +02:00
|
|
|
mutable ListNode message_lru_list;
|
|
|
|
|
2023-05-02 17:04:54 +02:00
|
|
|
OrderedMessages ordered_messages;
|
2023-03-16 18:10:54 +01:00
|
|
|
|
|
|
|
unique_ptr<DialogScheduledMessages> scheduled_messages;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-04-01 23:01:09 +02:00
|
|
|
const char *debug_set_dialog_last_database_message_id = "Unknown"; // to be removed soon
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-12 16:37:25 +01:00
|
|
|
// message identifiers loaded from database
|
2018-07-15 11:29:28 +02:00
|
|
|
MessageId debug_last_new_message_id;
|
|
|
|
MessageId debug_first_database_message_id;
|
|
|
|
MessageId debug_last_database_message_id;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Dialog() = default;
|
|
|
|
Dialog(const Dialog &) = delete;
|
|
|
|
Dialog &operator=(const Dialog &) = delete;
|
2023-05-05 12:51:19 +02:00
|
|
|
Dialog(Dialog &&) = delete;
|
|
|
|
Dialog &operator=(Dialog &&) = delete;
|
2022-07-20 12:40:14 +02:00
|
|
|
~Dialog() = default;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
2019-08-22 17:24:02 +02:00
|
|
|
struct DialogList {
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogListId dialog_list_id;
|
2019-08-22 17:24:02 +02:00
|
|
|
bool is_message_unread_count_inited_ = false;
|
|
|
|
bool is_dialog_unread_count_inited_ = false;
|
|
|
|
bool need_unread_count_recalc_ = true;
|
|
|
|
int32 unread_message_total_count_ = 0;
|
|
|
|
int32 unread_message_muted_count_ = 0;
|
|
|
|
int32 unread_dialog_total_count_ = 0;
|
|
|
|
int32 unread_dialog_muted_count_ = 0;
|
|
|
|
int32 unread_dialog_marked_count_ = 0;
|
|
|
|
int32 unread_dialog_muted_marked_count_ = 0;
|
2019-12-26 19:44:35 +01:00
|
|
|
int32 in_memory_dialog_total_count_ = 0;
|
|
|
|
int32 server_dialog_total_count_ = -1;
|
|
|
|
int32 secret_chat_total_count_ = -1;
|
2024-05-14 20:00:59 +02:00
|
|
|
int64 unique_id_ = 0;
|
2019-08-22 17:24:02 +02:00
|
|
|
|
2020-05-21 02:39:45 +02:00
|
|
|
vector<Promise<Unit>> load_list_queries_;
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, int64, DialogIdHash> pinned_dialog_id_orders_;
|
2020-05-21 02:39:45 +02:00
|
|
|
vector<DialogDate> pinned_dialogs_;
|
2020-06-04 14:31:29 +02:00
|
|
|
bool are_pinned_dialogs_inited_ = false;
|
2020-05-03 00:10:54 +02:00
|
|
|
|
2020-05-20 02:04:52 +02:00
|
|
|
DialogDate last_pinned_dialog_date_ = MIN_DIALOG_DATE; // in memory
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
// date of the last loaded dialog
|
2020-05-20 02:04:52 +02:00
|
|
|
// min(folder1_last_dialog_date_, folder2_last_dialog_date, last_pinned_dialog_date_)
|
|
|
|
DialogDate list_last_dialog_date_ = MIN_DIALOG_DATE; // in memory
|
2020-05-21 03:40:04 +02:00
|
|
|
};
|
2020-05-20 02:04:52 +02:00
|
|
|
|
2020-05-21 03:40:04 +02:00
|
|
|
struct DialogFolder {
|
|
|
|
FolderId folder_id;
|
2020-05-03 21:59:28 +02:00
|
|
|
// date of the last loaded dialog in the folder
|
2020-05-20 02:04:52 +02:00
|
|
|
DialogDate folder_last_dialog_date_{MAX_ORDINARY_DIALOG_ORDER, DialogId()}; // in memory
|
2020-03-18 21:19:23 +01:00
|
|
|
|
2020-05-03 21:59:28 +02:00
|
|
|
std::set<DialogDate> ordered_dialogs_; // all known dialogs, including with default order
|
2019-08-22 17:24:02 +02:00
|
|
|
|
|
|
|
// date of last known user/group/channel dialog in the right order
|
2020-05-22 17:26:30 +02:00
|
|
|
DialogDate last_server_dialog_date_{MAX_ORDINARY_DIALOG_ORDER, DialogId()};
|
|
|
|
DialogDate last_loaded_database_dialog_date_{MAX_ORDINARY_DIALOG_ORDER, DialogId()};
|
|
|
|
DialogDate last_database_server_dialog_date_{MAX_ORDINARY_DIALOG_ORDER, DialogId()};
|
2019-08-22 17:24:02 +02:00
|
|
|
|
2020-05-21 02:39:45 +02:00
|
|
|
MultiPromiseActor load_folder_dialog_list_multipromise_{
|
2020-05-03 21:59:28 +02:00
|
|
|
"LoadDialogListMultiPromiseActor"}; // must be defined before pending_on_get_dialogs_
|
2019-08-22 17:24:02 +02:00
|
|
|
int32 load_dialog_list_limit_max_ = 0;
|
|
|
|
};
|
|
|
|
|
2020-05-04 00:47:26 +02:00
|
|
|
class DialogListViewIterator {
|
|
|
|
MessagesManager *messages_manager_;
|
2020-05-21 18:39:34 +02:00
|
|
|
const DialogListId *dialog_list_id_;
|
2020-05-04 00:47:26 +02:00
|
|
|
|
|
|
|
public:
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogListViewIterator(MessagesManager *messages_manager, const DialogListId *dialog_list_id)
|
2020-05-04 00:47:26 +02:00
|
|
|
: messages_manager_(messages_manager), dialog_list_id_(dialog_list_id) {
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogList &operator*() const {
|
2020-05-15 15:32:07 +02:00
|
|
|
auto dialog_list_ptr = messages_manager_->get_dialog_list(*dialog_list_id_);
|
|
|
|
CHECK(dialog_list_ptr != nullptr);
|
|
|
|
return *dialog_list_ptr;
|
2020-05-04 00:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const DialogListViewIterator &other) const {
|
|
|
|
return dialog_list_id_ != other.dialog_list_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator++() {
|
|
|
|
dialog_list_id_++;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DialogListView {
|
|
|
|
MessagesManager *messages_manager_;
|
|
|
|
// TODO can be optimized to store only mask of dialog lists
|
2020-05-21 18:39:34 +02:00
|
|
|
vector<DialogListId> dialog_list_ids_;
|
2020-05-04 00:47:26 +02:00
|
|
|
|
|
|
|
public:
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogListView(MessagesManager *messages_manager, vector<DialogListId> dialog_list_ids)
|
2020-05-04 00:47:26 +02:00
|
|
|
: messages_manager_(messages_manager), dialog_list_ids_(std::move(dialog_list_ids)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogListViewIterator begin() {
|
2020-06-04 14:31:29 +02:00
|
|
|
return DialogListViewIterator(messages_manager_, dialog_list_ids_.empty() ? nullptr : &dialog_list_ids_[0]);
|
2020-05-04 00:47:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DialogListViewIterator end() {
|
2020-06-04 14:31:29 +02:00
|
|
|
return DialogListViewIterator(
|
|
|
|
messages_manager_, dialog_list_ids_.empty() ? nullptr : &dialog_list_ids_[0] + dialog_list_ids_.size());
|
2020-05-04 00:47:26 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-01 22:09:35 +02:00
|
|
|
struct DialogPositionInList {
|
2020-05-09 22:39:11 +02:00
|
|
|
int64 order = DEFAULT_ORDER;
|
|
|
|
int64 private_order = 0;
|
|
|
|
int64 public_order = 0;
|
|
|
|
bool is_pinned = false;
|
|
|
|
bool is_sponsored = false;
|
2020-05-10 21:06:13 +02:00
|
|
|
|
|
|
|
int32 total_dialog_count = 0;
|
2020-05-29 05:07:51 +02:00
|
|
|
|
2020-06-01 22:09:35 +02:00
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogPositionInList &order) {
|
2020-05-29 05:07:51 +02:00
|
|
|
return string_builder << "order = " << order.order << ", private_order = " << order.private_order
|
|
|
|
<< ", public_order = " << order.public_order << ", is_pinned = " << order.is_pinned
|
|
|
|
<< ", is_sponsored = " << order.is_sponsored
|
|
|
|
<< ", total_dialog_count = " << order.total_dialog_count;
|
|
|
|
}
|
2020-05-09 22:39:11 +02:00
|
|
|
};
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct PendingSecretMessage {
|
2019-09-08 02:49:16 +02:00
|
|
|
enum class Type : int32 { NewMessage, DeleteMessages, DeleteHistory };
|
2019-09-04 20:29:27 +02:00
|
|
|
Type type = Type::NewMessage;
|
|
|
|
|
|
|
|
// for NewMessage
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageInfo message_info;
|
2018-12-12 00:48:56 +01:00
|
|
|
MultiPromiseActor load_data_multipromise{"LoadPendingSecretMessageDataMultiPromiseActor"};
|
2019-09-04 20:29:27 +02:00
|
|
|
|
|
|
|
// for DeleteMessages/DeleteHistory
|
|
|
|
DialogId dialog_id;
|
|
|
|
vector<int64> random_ids;
|
|
|
|
MessageId last_message_id;
|
2021-01-20 12:49:18 +01:00
|
|
|
bool remove_from_dialog_list = false;
|
2019-09-04 20:29:27 +02:00
|
|
|
|
2022-10-07 00:28:18 +02:00
|
|
|
Promise<Unit> success_promise;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
2020-08-09 14:14:30 +02:00
|
|
|
struct MessageSendOptions {
|
2019-12-06 00:32:23 +01:00
|
|
|
bool disable_notification = false;
|
|
|
|
bool from_background = false;
|
2022-09-04 00:14:25 +02:00
|
|
|
bool update_stickersets_order = false;
|
2021-12-28 16:19:19 +01:00
|
|
|
bool protect_content = false;
|
2023-10-23 17:40:55 +02:00
|
|
|
bool only_preview = false;
|
2019-12-06 01:08:11 +01:00
|
|
|
int32 schedule_date = 0;
|
2023-02-23 15:05:43 +01:00
|
|
|
int32 sending_id = 0;
|
2024-06-05 16:01:11 +02:00
|
|
|
MessageEffectId effect_id;
|
2019-12-06 00:32:23 +01:00
|
|
|
|
2020-08-09 14:14:30 +02:00
|
|
|
MessageSendOptions() = default;
|
2022-09-04 00:14:25 +02:00
|
|
|
MessageSendOptions(bool disable_notification, bool from_background, bool update_stickersets_order,
|
2024-06-05 16:01:11 +02:00
|
|
|
bool protect_content, bool only_preview, int32 schedule_date, int32 sending_id,
|
|
|
|
MessageEffectId effect_id)
|
2021-12-28 16:19:19 +01:00
|
|
|
: disable_notification(disable_notification)
|
|
|
|
, from_background(from_background)
|
2022-09-04 00:14:25 +02:00
|
|
|
, update_stickersets_order(update_stickersets_order)
|
2021-12-28 16:19:19 +01:00
|
|
|
, protect_content(protect_content)
|
2023-10-23 17:40:55 +02:00
|
|
|
, only_preview(only_preview)
|
2023-02-23 15:05:43 +01:00
|
|
|
, schedule_date(schedule_date)
|
2024-05-09 18:02:17 +02:00
|
|
|
, sending_id(sending_id)
|
|
|
|
, effect_id(effect_id) {
|
2019-12-06 00:32:23 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-03-16 15:54:33 +01:00
|
|
|
struct SuffixLoadQueries {
|
|
|
|
bool suffix_load_done_ = false;
|
|
|
|
bool suffix_load_has_query_ = false;
|
|
|
|
|
|
|
|
MessageId suffix_load_first_message_id_; // identifier of some message such all suffix messages in range
|
|
|
|
// [suffix_load_first_message_id_, last_message_id] are loaded
|
|
|
|
MessageId suffix_load_query_message_id_;
|
|
|
|
vector<std::pair<Promise<Unit>, std::function<bool(const Message *)>>> suffix_load_queries_;
|
|
|
|
};
|
|
|
|
|
2023-07-28 02:36:21 +02:00
|
|
|
struct PendingGetHistoryQuery {
|
2023-07-27 19:40:56 +02:00
|
|
|
DialogId dialog_id_;
|
2023-07-28 02:36:21 +02:00
|
|
|
MessageId from_message_id_;
|
2023-07-27 19:40:56 +02:00
|
|
|
MessageId old_last_message_id_;
|
2023-07-28 02:36:21 +02:00
|
|
|
int32 offset_ = 0;
|
2023-07-27 19:40:56 +02:00
|
|
|
int32 limit_ = 0;
|
|
|
|
bool from_database_ = false;
|
|
|
|
bool only_local_ = false;
|
|
|
|
|
2023-07-28 02:36:21 +02:00
|
|
|
bool operator==(const PendingGetHistoryQuery &other) const {
|
|
|
|
return dialog_id_ == other.dialog_id_ && from_message_id_ == other.from_message_id_ &&
|
|
|
|
old_last_message_id_ == other.old_last_message_id_ && offset_ == other.offset_ && limit_ == other.limit_ &&
|
|
|
|
from_database_ == other.from_database_ && only_local_ == other.only_local_;
|
2023-07-27 19:40:56 +02:00
|
|
|
}
|
|
|
|
};
|
2023-07-28 02:36:21 +02:00
|
|
|
struct PendingGetHistoryQueryHash {
|
|
|
|
uint32 operator()(const PendingGetHistoryQuery &query) const {
|
2023-07-27 19:40:56 +02:00
|
|
|
uint32 hash = DialogIdHash()(query.dialog_id_);
|
2023-07-28 02:36:21 +02:00
|
|
|
hash = combine_hashes(hash, MessageIdHash()(query.from_message_id_));
|
2023-07-27 19:40:56 +02:00
|
|
|
hash = combine_hashes(hash, MessageIdHash()(query.old_last_message_id_));
|
2023-07-28 02:36:21 +02:00
|
|
|
hash = combine_hashes(hash, Hash<int32>()(query.offset_));
|
2023-07-27 19:40:56 +02:00
|
|
|
hash = combine_hashes(hash, Hash<int32>()(query.limit_));
|
|
|
|
hash = combine_hashes(hash, static_cast<uint32>(query.from_database_));
|
|
|
|
hash = combine_hashes(hash, static_cast<uint32>(query.only_local_));
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-18 00:26:36 +02:00
|
|
|
class BlockMessageSenderFromRepliesOnServerLogEvent;
|
2021-10-27 14:38:09 +02:00
|
|
|
class DeleteAllCallMessagesOnServerLogEvent;
|
2021-11-19 14:00:21 +01:00
|
|
|
class DeleteAllChannelMessagesFromSenderOnServerLogEvent;
|
2021-10-27 14:38:09 +02:00
|
|
|
class DeleteDialogHistoryOnServerLogEvent;
|
2021-10-25 19:39:22 +02:00
|
|
|
class DeleteDialogMessagesByDateOnServerLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
class DeleteMessageLogEvent;
|
2021-10-27 14:38:09 +02:00
|
|
|
class DeleteMessagesOnServerLogEvent;
|
|
|
|
class DeleteScheduledMessagesOnServerLogEvent;
|
2022-10-29 23:35:37 +02:00
|
|
|
class DeleteTopicHistoryOnServerLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
class ForwardMessagesLogEvent;
|
|
|
|
class GetChannelDifferenceLogEvent;
|
|
|
|
class ReadAllDialogMentionsOnServerLogEvent;
|
2022-01-30 10:37:24 +01:00
|
|
|
class ReadAllDialogReactionsOnServerLogEvent;
|
2018-06-20 03:02:02 +02:00
|
|
|
class ReadHistoryInSecretChatLogEvent;
|
2020-09-22 00:13:06 +02:00
|
|
|
class ReadHistoryOnServerLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
class ReadMessageContentsOnServerLogEvent;
|
2020-09-22 00:13:06 +02:00
|
|
|
class ReadMessageThreadHistoryOnServerLogEvent;
|
2021-10-27 14:27:09 +02:00
|
|
|
class RegetDialogLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
class ReorderPinnedDialogsOnServerLogEvent;
|
2018-04-28 21:50:12 +02:00
|
|
|
class ResetAllNotificationSettingsOnServerLogEvent;
|
2019-11-29 13:03:03 +01:00
|
|
|
class SaveDialogDraftMessageOnServerLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
class SendBotStartMessageLogEvent;
|
|
|
|
class SendInlineQueryResultMessageLogEvent;
|
|
|
|
class SendMessageLogEvent;
|
2024-04-12 01:10:55 +02:00
|
|
|
class SendQuickReplyShortcutMessagesLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
class SendScreenshotTakenNotificationMessageLogEvent;
|
2019-11-29 13:03:03 +01:00
|
|
|
class SetDialogFolderIdOnServerLogEvent;
|
2020-09-20 02:00:01 +02:00
|
|
|
class ToggleDialogIsBlockedOnServerLogEvent;
|
2023-11-16 14:57:18 +01:00
|
|
|
class ToggleDialogViewAsMessagesOnServerLogEvent;
|
2020-09-22 00:13:06 +02:00
|
|
|
class ToggleDialogIsMarkedAsUnreadOnServerLogEvent;
|
2023-01-20 10:38:25 +01:00
|
|
|
class ToggleDialogIsTranslatableOnServerLogEvent;
|
2020-09-22 00:13:06 +02:00
|
|
|
class ToggleDialogIsPinnedOnServerLogEvent;
|
2021-10-25 19:39:22 +02:00
|
|
|
class ToggleDialogReportSpamStateOnServerLogEvent;
|
2020-10-23 00:56:06 +02:00
|
|
|
class UnpinAllDialogMessagesOnServerLogEvent;
|
2019-11-29 13:03:03 +01:00
|
|
|
class UpdateDialogNotificationSettingsOnServerLogEvent;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
static constexpr size_t MAX_GROUPED_MESSAGES = 10; // server side limit
|
|
|
|
static constexpr int32 MAX_GET_DIALOGS = 100; // server side limit
|
|
|
|
static constexpr int32 MAX_GET_HISTORY = 100; // server side limit
|
|
|
|
static constexpr int32 MAX_SEARCH_MESSAGES = 100; // server side limit
|
2020-12-17 16:20:28 +01:00
|
|
|
static constexpr int32 MIN_SEARCH_PUBLIC_DIALOG_PREFIX_LEN = 4; // server side limit
|
2021-06-16 04:25:44 +02:00
|
|
|
static constexpr int32 MIN_CHANNEL_DIFFERENCE = 1;
|
2018-12-31 20:04:05 +01:00
|
|
|
static constexpr int32 MAX_CHANNEL_DIFFERENCE = 100;
|
2023-03-21 14:55:07 +01:00
|
|
|
static constexpr int32 MAX_BOT_CHANNEL_DIFFERENCE = 100000; // server side limit
|
|
|
|
static constexpr int32 MAX_RECENT_DIALOGS = 50; // some reasonable value
|
2023-10-02 19:38:59 +02:00
|
|
|
static constexpr size_t MIN_DELETED_ASYNCHRONOUSLY_MESSAGES = 2;
|
2022-11-11 14:06:05 +01:00
|
|
|
static constexpr size_t MAX_UNLOADED_MESSAGES = 5000;
|
2020-05-20 02:04:52 +02:00
|
|
|
|
2020-03-26 17:04:48 +01:00
|
|
|
static constexpr int64 SPONSORED_DIALOG_ORDER = static_cast<int64>(2147483647) << 32;
|
2018-12-31 20:04:05 +01:00
|
|
|
static constexpr int32 MIN_PINNED_DIALOG_DATE = 2147000000; // some big date
|
2020-05-20 02:04:52 +02:00
|
|
|
static constexpr int64 MAX_ORDINARY_DIALOG_ORDER =
|
|
|
|
9221294780217032704; // == get_dialog_order(MessageId(), MIN_PINNED_DIALOG_DATE - 1)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
static constexpr int32 CHANNEL_DIFFERENCE_FLAG_IS_FINAL = 1 << 0;
|
|
|
|
static constexpr int32 CHANNEL_DIFFERENCE_FLAG_HAS_TIMEOUT = 1 << 1;
|
|
|
|
|
|
|
|
static constexpr int32 DIALOG_FLAG_HAS_PTS = 1 << 0;
|
|
|
|
static constexpr int32 DIALOG_FLAG_HAS_DRAFT = 1 << 1;
|
|
|
|
static constexpr int32 DIALOG_FLAG_IS_PINNED = 1 << 2;
|
2019-08-19 03:51:03 +02:00
|
|
|
static constexpr int32 DIALOG_FLAG_HAS_FOLDER_ID = 1 << 4;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
static constexpr int32 MAX_MESSAGE_VIEW_DELAY = 1; // seconds
|
|
|
|
static constexpr int32 MIN_SAVE_DRAFT_DELAY = 1; // seconds
|
2018-05-03 14:36:05 +02:00
|
|
|
static constexpr int32 MIN_READ_HISTORY_DELAY = 3; // seconds
|
2018-12-31 20:04:05 +01:00
|
|
|
static constexpr int32 MAX_SAVE_DIALOG_DELAY = 0; // seconds
|
|
|
|
|
2023-05-15 12:28:23 +02:00
|
|
|
static constexpr int32 DEFAULT_LOADED_EXPIRED_MESSAGES = 50;
|
|
|
|
|
2022-03-07 13:20:22 +01:00
|
|
|
static constexpr int32 LIVE_LOCATION_VIEW_PERIOD = 60; // seconds, server-side limit
|
|
|
|
static constexpr int32 UPDATE_VIEWED_MESSAGES_PERIOD = 15; // seconds
|
2019-12-16 16:39:40 +01:00
|
|
|
|
2020-02-13 01:03:50 +01:00
|
|
|
static constexpr int32 AUTH_NOTIFICATION_ID_CACHE_TIME = 7 * 86400;
|
2022-08-01 00:39:09 +02:00
|
|
|
static constexpr size_t MAX_SAVED_AUTH_NOTIFICATION_IDS = 100;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-09-19 18:43:01 +02:00
|
|
|
static constexpr int32 MAX_RESEND_DELAY = 86400; // seconds, some resonable limit
|
|
|
|
|
2019-12-03 01:12:41 +01:00
|
|
|
static constexpr int32 SCHEDULE_WHEN_ONLINE_DATE = 2147483646;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static constexpr const char *DELETE_MESSAGE_USER_REQUEST_SOURCE = "user request";
|
|
|
|
|
2021-01-15 23:17:35 +01:00
|
|
|
static constexpr bool DROP_SEND_MESSAGE_UPDATES = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-06-13 16:14:19 +02:00
|
|
|
vector<UserId> get_message_user_ids(const Message *m) const;
|
2023-03-17 16:51:04 +01:00
|
|
|
|
2023-10-26 23:34:33 +02:00
|
|
|
vector<ChannelId> get_message_channel_ids(const Message *m) const;
|
2023-03-17 16:51:04 +01:00
|
|
|
|
2018-05-07 19:20:20 +02:00
|
|
|
static bool is_dialog_inited(const Dialog *d);
|
2018-05-03 15:29:33 +02:00
|
|
|
|
2018-07-02 03:21:18 +02:00
|
|
|
int32 get_dialog_mute_until(const Dialog *d) const;
|
|
|
|
|
|
|
|
bool is_dialog_muted(const Dialog *d) const;
|
|
|
|
|
2019-01-10 18:54:46 +01:00
|
|
|
bool is_dialog_pinned_message_notifications_disabled(const Dialog *d) const;
|
|
|
|
|
|
|
|
bool is_dialog_mention_notifications_disabled(const Dialog *d) const;
|
2019-01-10 01:47:33 +01:00
|
|
|
|
2021-05-08 23:31:43 +02:00
|
|
|
bool is_dialog_pinned(DialogListId dialog_list_id, DialogId dialog_id) const;
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
int64 get_dialog_pinned_order(DialogListId dialog_list_id, DialogId dialog_id) const;
|
2020-05-03 00:10:54 +02:00
|
|
|
|
2020-05-27 22:35:35 +02:00
|
|
|
static int64 get_dialog_pinned_order(const DialogList *list, DialogId dialog_id);
|
2020-05-03 00:10:54 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void open_dialog(Dialog *d);
|
|
|
|
|
|
|
|
void close_dialog(Dialog *d);
|
|
|
|
|
2021-01-23 21:19:37 +01:00
|
|
|
void on_resolve_secret_chat_message_via_bot_username(const string &via_bot_username, MessageInfo *message_info_ptr,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2022-04-18 17:21:41 +02:00
|
|
|
void add_secret_message(unique_ptr<PendingSecretMessage> pending_secret_message, Promise<Unit> lock_promise = {});
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-07 14:28:52 +02:00
|
|
|
void on_add_secret_message_ready(int64 token);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void finish_add_secret_message(unique_ptr<PendingSecretMessage> pending_secret_message);
|
|
|
|
|
2022-10-07 00:28:18 +02:00
|
|
|
void finish_delete_secret_messages(DialogId dialog_id, std::vector<int64> random_ids, Promise<Unit> promise);
|
2019-09-04 20:29:27 +02:00
|
|
|
|
2021-01-20 12:49:18 +01:00
|
|
|
void finish_delete_secret_chat_history(DialogId dialog_id, bool remove_from_dialog_list, MessageId last_message_id,
|
2022-10-07 00:28:18 +02:00
|
|
|
Promise<Unit> promise);
|
2019-09-04 20:29:27 +02:00
|
|
|
|
2024-03-08 20:11:50 +01:00
|
|
|
static MessageInfo parse_telegram_api_message(Td *td, tl_object_ptr<telegram_api::Message> message_ptr,
|
|
|
|
bool is_scheduled, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-03-08 20:19:22 +01:00
|
|
|
static std::pair<DialogId, unique_ptr<Message>> create_message(Td *td, MessageInfo &&message_info,
|
2024-03-09 00:14:02 +01:00
|
|
|
bool is_channel_message, bool is_business_message,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-12-05 18:34:19 +01:00
|
|
|
MessageId find_old_message_id(DialogId dialog_id, MessageId message_id) const;
|
|
|
|
|
2021-01-24 00:14:51 +01:00
|
|
|
void delete_update_message_id(DialogId dialog_id, MessageId message_id);
|
|
|
|
|
2024-01-15 22:30:37 +01:00
|
|
|
void get_dialog_message_count_from_server(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
MessageSearchFilter filter, Promise<int32> &&promise);
|
2022-04-28 16:43:29 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId on_get_message(MessageInfo &&message_info, const bool from_update, const bool is_channel_message,
|
2023-05-11 19:27:00 +02:00
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
Result<InputMessageContent> process_input_message_content(
|
2023-11-29 12:17:49 +01:00
|
|
|
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
|
|
|
bool check_permissions = true);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-08-09 13:18:08 +02:00
|
|
|
Result<MessageCopyOptions> process_message_copy_options(DialogId dialog_id,
|
|
|
|
tl_object_ptr<td_api::messageCopyOptions> &&options) const;
|
|
|
|
|
2020-08-09 14:14:30 +02:00
|
|
|
Result<MessageSendOptions> process_message_send_options(DialogId dialog_id,
|
2022-09-04 00:14:25 +02:00
|
|
|
tl_object_ptr<td_api::messageSendOptions> &&options,
|
2024-05-09 18:02:17 +02:00
|
|
|
bool allow_update_stickersets_order, bool allow_effect) const;
|
2019-12-06 00:32:23 +01:00
|
|
|
|
2020-08-09 14:14:30 +02:00
|
|
|
static Status can_use_message_send_options(const MessageSendOptions &options,
|
2024-01-30 13:07:21 +01:00
|
|
|
const unique_ptr<MessageContent> &content, MessageSelfDestructType ttl);
|
2023-02-23 15:05:43 +01:00
|
|
|
|
2020-08-09 14:14:30 +02:00
|
|
|
static Status can_use_message_send_options(const MessageSendOptions &options, const InputMessageContent &content);
|
2019-12-06 02:25:44 +01:00
|
|
|
|
2023-06-08 16:27:24 +02:00
|
|
|
Status can_use_top_thread_message_id(Dialog *d, MessageId top_thread_message_id,
|
|
|
|
const MessageInputReplyTo &input_reply_to);
|
2020-09-23 00:52:16 +02:00
|
|
|
|
2022-05-16 18:47:06 +02:00
|
|
|
int64 generate_new_random_id(const Dialog *d);
|
2021-10-20 00:36:00 +02:00
|
|
|
|
2023-06-08 16:27:24 +02:00
|
|
|
unique_ptr<Message> create_message_to_send(Dialog *d, MessageId top_thread_message_id,
|
2023-10-27 02:37:26 +02:00
|
|
|
MessageInputReplyTo &&input_reply_to, const MessageSendOptions &options,
|
2023-10-21 23:50:19 +02:00
|
|
|
unique_ptr<MessageContent> &&content, bool invert_media,
|
|
|
|
bool suppress_reply_info, unique_ptr<MessageForwardInfo> forward_info,
|
2024-01-25 14:45:24 +01:00
|
|
|
DialogId real_forward_from_dialog_id, bool is_copy,
|
|
|
|
DialogId send_as_dialog_id) const;
|
2021-08-31 16:26:51 +02:00
|
|
|
|
2023-10-27 02:37:26 +02:00
|
|
|
Message *get_message_to_send(Dialog *d, MessageId top_thread_message_id, MessageInputReplyTo &&input_reply_to,
|
2020-09-24 14:29:34 +02:00
|
|
|
const MessageSendOptions &options, unique_ptr<MessageContent> &&content,
|
2023-10-21 23:50:19 +02:00
|
|
|
bool invert_media, bool *need_update_dialog_pos, bool suppress_reply_info = false,
|
2024-01-25 14:45:24 +01:00
|
|
|
unique_ptr<MessageForwardInfo> forward_info = nullptr,
|
|
|
|
DialogId real_forward_from_dialog_id = DialogId(), bool is_copy = false,
|
2021-11-25 15:01:54 +01:00
|
|
|
DialogId sender_dialog_id = DialogId());
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
int64 begin_send_message(DialogId dialog_id, const Message *m);
|
|
|
|
|
|
|
|
Status can_send_message(DialogId dialog_id) const TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2020-01-16 04:10:08 +01:00
|
|
|
bool can_resend_message(const Message *m) const;
|
2019-08-11 03:05:00 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool can_edit_message(DialogId dialog_id, const Message *m, bool is_editing, bool only_reply_markup = false) const;
|
|
|
|
|
2021-08-04 06:57:27 +02:00
|
|
|
static Status can_get_media_timestamp_link(DialogId dialog_id, const Message *m);
|
|
|
|
|
2022-08-23 15:44:20 +02:00
|
|
|
bool can_report_message_reactions(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2024-01-09 11:37:29 +01:00
|
|
|
Status can_get_message_read_date(DialogId dialog_id, const Message *m) const TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Status can_get_message_viewers(MessageFullId message_full_id) TD_WARN_UNUSED_RESULT;
|
2021-09-03 15:14:03 +02:00
|
|
|
|
|
|
|
Status can_get_message_viewers(DialogId dialog_id, const Message *m) const TD_WARN_UNUSED_RESULT;
|
|
|
|
|
2019-01-31 01:06:21 +01:00
|
|
|
void cancel_edit_message_media(DialogId dialog_id, Message *m, Slice error_message);
|
2018-06-19 01:31:34 +02:00
|
|
|
|
|
|
|
void on_message_media_edited(DialogId dialog_id, MessageId message_id, FileId file_id, FileId thumbnail_file_id,
|
2019-12-03 18:26:09 +01:00
|
|
|
bool was_uploaded, bool was_thumbnail_uploaded, string file_reference,
|
2021-10-21 11:51:16 +02:00
|
|
|
int32 schedule_date, uint64 generation, Result<int32> &&result);
|
2018-06-19 01:31:34 +02:00
|
|
|
|
2023-03-15 14:50:56 +01:00
|
|
|
MessageId get_persistent_message_id(const Dialog *d, MessageId message_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
static MessageFullId get_replied_message_id(DialogId dialog_id, const Message *m);
|
2018-02-07 00:31:38 +01:00
|
|
|
|
2024-03-11 12:19:08 +01:00
|
|
|
MessageInputReplyTo create_message_input_reply_to(Dialog *d, MessageId top_thread_message_id,
|
|
|
|
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
|
|
|
|
bool for_draft);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-27 02:27:03 +02:00
|
|
|
static const MessageInputReplyTo *get_message_input_reply_to(const Message *m);
|
2023-10-06 12:05:50 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool can_set_game_score(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2021-07-29 20:43:03 +02:00
|
|
|
void add_postponed_channel_update(DialogId dialog_id, tl_object_ptr<telegram_api::Update> &&update, int32 new_pts,
|
|
|
|
int32 pts_count, Promise<Unit> &&promise);
|
|
|
|
|
2022-10-26 13:52:51 +02:00
|
|
|
bool process_channel_update(tl_object_ptr<telegram_api::Update> &&update_ptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_message_edited(MessageFullId message_full_id, int32 pts, bool had_message);
|
2018-04-23 00:50:07 +02:00
|
|
|
|
2023-07-11 16:14:02 +02:00
|
|
|
void delete_messages_from_updates(const vector<MessageId> &message_ids, bool is_permanent);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-11-03 17:26:22 +01:00
|
|
|
void delete_dialog_messages(DialogId dialog_id, const vector<MessageId> &message_ids,
|
2022-11-03 17:37:07 +01:00
|
|
|
bool force_update_for_not_found_messages, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-11-03 17:37:07 +01:00
|
|
|
void delete_dialog_messages(Dialog *d, const vector<MessageId> &message_ids, bool force_update_for_not_found_messages,
|
2022-11-03 17:26:22 +01:00
|
|
|
const char *source);
|
2022-11-03 17:14:35 +01:00
|
|
|
|
2020-10-20 14:08:36 +02:00
|
|
|
void update_dialog_pinned_messages_from_updates(DialogId dialog_id, const vector<MessageId> &message_ids,
|
|
|
|
bool is_pin);
|
|
|
|
|
|
|
|
bool update_message_is_pinned(Dialog *d, Message *m, bool is_pin, const char *source);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void do_forward_messages(DialogId to_dialog_id, DialogId from_dialog_id, const vector<Message *> &messages,
|
2022-05-08 22:54:04 +02:00
|
|
|
const vector<MessageId> &message_ids, bool drop_author, bool drop_media_captions,
|
|
|
|
uint64 log_event_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-04-12 01:10:55 +02:00
|
|
|
uint64 save_send_quick_reply_shortcut_messages_log_event(DialogId dialog_id, QuickReplyShortcutId shortcut_id,
|
|
|
|
const vector<Message *> &messages,
|
|
|
|
const vector<MessageId> &message_ids);
|
|
|
|
|
2024-03-05 11:08:26 +01:00
|
|
|
void do_send_quick_reply_shortcut_messages(DialogId dialog_id, QuickReplyShortcutId shortcut_id,
|
|
|
|
const vector<Message *> &messages, const vector<MessageId> &message_ids,
|
|
|
|
uint64 log_event_id);
|
|
|
|
|
|
|
|
void send_send_quick_reply_messages_query(DialogId dialog_id, QuickReplyShortcutId shortcut_id,
|
|
|
|
vector<MessageId> message_ids, vector<int64> random_ids,
|
|
|
|
Promise<Unit> promise);
|
|
|
|
|
2024-01-30 23:52:02 +01:00
|
|
|
void send_forward_message_query(int32 flags, DialogId to_dialog_id, const MessageId top_thread_message_id,
|
2022-10-21 17:02:39 +02:00
|
|
|
DialogId from_dialog_id, tl_object_ptr<telegram_api::InputPeer> as_input_peer,
|
|
|
|
vector<MessageId> message_ids, vector<int64> random_ids, int32 schedule_date,
|
|
|
|
Promise<Unit> promise);
|
2022-08-10 15:25:17 +02:00
|
|
|
|
2022-10-21 17:02:39 +02:00
|
|
|
Result<td_api::object_ptr<td_api::message>> forward_message(DialogId to_dialog_id, MessageId top_thread_message_id,
|
|
|
|
DialogId from_dialog_id, MessageId message_id,
|
2023-02-23 15:05:43 +01:00
|
|
|
td_api::object_ptr<td_api::messageSendOptions> &&options,
|
2021-08-31 21:34:46 +02:00
|
|
|
bool in_game_share,
|
|
|
|
MessageCopyOptions &©_options) TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-29 20:05:23 +01:00
|
|
|
MessageOrigin get_forwarded_message_origin(DialogId dialog_id, const Message *m) const;
|
2023-10-29 18:40:36 +01:00
|
|
|
|
2021-08-31 18:12:24 +02:00
|
|
|
unique_ptr<MessageForwardInfo> create_message_forward_info(DialogId from_dialog_id, DialogId to_dialog_id,
|
2023-10-29 20:05:23 +01:00
|
|
|
const Message *m) const;
|
2021-08-31 18:12:24 +02:00
|
|
|
|
2022-05-08 22:54:04 +02:00
|
|
|
void fix_forwarded_message(Message *m, DialogId to_dialog_id, const Message *forwarded_message, int64 media_album_id,
|
|
|
|
bool drop_author) const;
|
2021-08-31 18:42:37 +02:00
|
|
|
|
2021-08-31 19:39:32 +02:00
|
|
|
struct ForwardedMessages {
|
|
|
|
struct CopiedMessage {
|
|
|
|
unique_ptr<MessageContent> content;
|
2023-06-08 16:27:24 +02:00
|
|
|
MessageInputReplyTo input_reply_to;
|
2022-05-16 20:10:18 +02:00
|
|
|
MessageId original_message_id;
|
|
|
|
MessageId original_reply_to_message_id;
|
2021-08-31 19:39:32 +02:00
|
|
|
unique_ptr<ReplyMarkup> reply_markup;
|
|
|
|
int64 media_album_id;
|
|
|
|
bool disable_web_page_preview;
|
2023-10-21 23:50:19 +02:00
|
|
|
bool invert_media;
|
2021-08-31 19:39:32 +02:00
|
|
|
size_t index;
|
|
|
|
};
|
|
|
|
vector<CopiedMessage> copied_messages;
|
|
|
|
|
|
|
|
struct ForwardedMessageContent {
|
|
|
|
unique_ptr<MessageContent> content;
|
2023-10-21 23:50:19 +02:00
|
|
|
bool invert_media;
|
2021-08-31 19:39:32 +02:00
|
|
|
int64 media_album_id;
|
|
|
|
size_t index;
|
|
|
|
};
|
|
|
|
vector<ForwardedMessageContent> forwarded_message_contents;
|
2022-05-08 22:54:04 +02:00
|
|
|
bool drop_author = false;
|
|
|
|
bool drop_media_captions = false;
|
2021-08-31 19:39:32 +02:00
|
|
|
|
|
|
|
Dialog *from_dialog;
|
2022-10-21 17:02:39 +02:00
|
|
|
MessageId top_thread_message_id;
|
2021-08-31 19:39:32 +02:00
|
|
|
Dialog *to_dialog;
|
|
|
|
MessageSendOptions message_send_options;
|
|
|
|
};
|
|
|
|
|
2022-10-21 17:02:39 +02:00
|
|
|
Result<ForwardedMessages> get_forwarded_messages(DialogId to_dialog_id, MessageId top_thread_message_id,
|
|
|
|
DialogId from_dialog_id, const vector<MessageId> &message_ids,
|
2023-02-23 15:05:43 +01:00
|
|
|
td_api::object_ptr<td_api::messageSendOptions> &&options,
|
2021-08-31 19:39:32 +02:00
|
|
|
bool in_game_share, vector<MessageCopyOptions> &©_options);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void do_send_media(DialogId dialog_id, Message *m, FileId file_id, FileId thumbnail_file_id,
|
|
|
|
tl_object_ptr<telegram_api::InputFile> input_file,
|
|
|
|
tl_object_ptr<telegram_api::InputFile> input_thumbnail);
|
|
|
|
|
|
|
|
void do_send_secret_media(DialogId dialog_id, Message *m, FileId file_id, FileId thumbnail_file_id,
|
|
|
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_encrypted_file,
|
|
|
|
BufferSlice thumbnail);
|
|
|
|
|
2019-08-11 03:05:00 +02:00
|
|
|
void do_send_message(DialogId dialog_id, const Message *m, vector<int> bad_parts = {});
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-11 03:05:00 +02:00
|
|
|
void on_message_media_uploaded(DialogId dialog_id, const Message *m,
|
|
|
|
tl_object_ptr<telegram_api::InputMedia> &&input_media, FileId file_id,
|
|
|
|
FileId thumbnail_file_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-11 03:05:00 +02:00
|
|
|
void on_secret_message_media_uploaded(DialogId dialog_id, const Message *m, SecretInputMedia &&secret_input_media,
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId file_id, FileId thumbnail_file_id);
|
|
|
|
|
|
|
|
void on_upload_message_media_finished(int64 media_album_id, DialogId dialog_id, MessageId message_id, Status result);
|
|
|
|
|
|
|
|
void do_send_message_group(int64 media_album_id);
|
|
|
|
|
2020-09-12 23:51:24 +02:00
|
|
|
void on_text_message_ready_to_send(DialogId dialog_id, MessageId message_id);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_media_message_ready_to_send(DialogId dialog_id, MessageId message_id, Promise<Message *> &&promise);
|
|
|
|
|
2022-02-04 14:25:37 +01:00
|
|
|
void send_secret_message(DialogId dialog_id, const Message *m, SecretInputMedia media);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_yet_unsent_media_queue_updated(DialogId dialog_id);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static void save_send_bot_start_message_log_event(UserId bot_user_id, DialogId dialog_id, const string ¶meter,
|
|
|
|
const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-08-10 15:25:17 +02:00
|
|
|
void do_send_bot_start_message(UserId bot_user_id, DialogId dialog_id, MessageId message_id, const string ¶meter);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static void save_send_inline_query_result_message_log_event(DialogId dialog_id, const Message *m, int64 query_id,
|
|
|
|
const string &result_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-08-10 15:25:17 +02:00
|
|
|
void do_send_inline_query_result_message(DialogId dialog_id, MessageId message_id, int64 query_id,
|
2019-08-11 03:05:00 +02:00
|
|
|
const string &result_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-04-30 15:00:20 +02:00
|
|
|
void send_screenshot_taken_notification_message(Dialog *d);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_send_screenshot_taken_notification_message_log_event(DialogId dialog_id, const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void do_send_screenshot_taken_notification_message(DialogId dialog_id, const Message *m, uint64 log_event_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-27 12:33:00 +02:00
|
|
|
void set_message_reply(const Dialog *d, Message *m, MessageInputReplyTo input_reply_to, bool is_message_in_dialog);
|
|
|
|
|
|
|
|
void update_message_reply_to_message_id(const Dialog *d, Message *m, MessageId reply_to_message_id,
|
|
|
|
bool is_message_in_dialog);
|
2023-06-06 23:57:27 +02:00
|
|
|
|
2022-05-16 17:11:49 +02:00
|
|
|
void restore_message_reply_to_message_id(Dialog *d, Message *m);
|
|
|
|
|
2023-05-11 12:26:41 +02:00
|
|
|
Message *continue_send_message(DialogId dialog_id, unique_ptr<Message> &&message, bool *need_update_dialog_pos,
|
2023-01-25 11:03:57 +01:00
|
|
|
uint64 log_event_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
bool is_message_unload_enabled() const;
|
|
|
|
|
2019-08-11 01:10:21 +02:00
|
|
|
int64 generate_new_media_album_id();
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static bool can_forward_message(DialogId from_dialog_id, const Message *m);
|
|
|
|
|
2021-11-26 15:21:21 +01:00
|
|
|
bool can_save_message(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2020-08-01 04:19:54 +02:00
|
|
|
bool can_get_message_statistics(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2022-04-29 13:33:35 +02:00
|
|
|
struct CanDeleteDialog {
|
|
|
|
bool for_self_;
|
|
|
|
bool for_all_users_;
|
|
|
|
|
|
|
|
CanDeleteDialog(bool for_self, bool for_all_users) : for_self_(for_self), for_all_users_(for_all_users) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
CanDeleteDialog can_delete_dialog(const Dialog *d) const;
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static bool can_delete_channel_message(const DialogParticipantStatus &status, const Message *m, bool is_bot);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-03-20 01:59:09 +01:00
|
|
|
bool can_delete_message(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool can_revoke_message(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
|
|
|
bool can_unload_message(const Dialog *d, const Message *m) const;
|
|
|
|
|
2022-11-03 16:10:51 +01:00
|
|
|
unique_ptr<Message> unload_message(Dialog *d, MessageId message_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
unique_ptr<Message> delete_message(Dialog *d, MessageId message_id, bool is_permanently_deleted,
|
|
|
|
bool *need_update_dialog_pos, const char *source);
|
|
|
|
|
|
|
|
unique_ptr<Message> do_delete_message(Dialog *d, MessageId message_id, bool is_permanently_deleted,
|
|
|
|
bool only_from_memory, bool *need_update_dialog_pos, const char *source);
|
|
|
|
|
2019-12-02 16:22:05 +01:00
|
|
|
unique_ptr<Message> do_delete_scheduled_message(Dialog *d, MessageId message_id, bool is_permanently_deleted,
|
|
|
|
const char *source);
|
2019-11-29 13:03:03 +01:00
|
|
|
|
2023-05-01 14:48:35 +02:00
|
|
|
void on_message_deleted_from_database(Dialog *d, const Message *m, const char *source);
|
|
|
|
|
2019-12-06 18:47:22 +01:00
|
|
|
void on_message_deleted(Dialog *d, Message *m, bool is_permanently_deleted, const char *source);
|
2019-02-19 15:33:15 +01:00
|
|
|
|
2022-05-18 11:16:32 +02:00
|
|
|
static bool is_deleted_message(const Dialog *d, MessageId message_id);
|
|
|
|
|
2019-03-01 02:04:02 +01:00
|
|
|
int32 get_unload_dialog_delay() const;
|
|
|
|
|
2022-08-27 10:19:00 +02:00
|
|
|
double get_next_unload_dialog_delay(Dialog *d) const;
|
2021-12-13 13:32:46 +01:00
|
|
|
|
2023-07-24 14:42:38 +02:00
|
|
|
void unload_dialog(DialogId dialog_id, int32 delay);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-13 02:37:35 +02:00
|
|
|
void clear_dialog_message_list(Dialog *d, bool remove_from_dialog_list, int32 last_message_date);
|
|
|
|
|
2019-12-06 18:47:22 +01:00
|
|
|
void delete_all_dialog_messages(Dialog *d, bool remove_from_dialog_list, bool is_permanently_deleted);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-11-09 08:19:04 +01:00
|
|
|
void erase_delete_messages_log_event(uint64 log_event_id);
|
|
|
|
|
2022-05-18 18:10:48 +02:00
|
|
|
void delete_sent_message_on_server(DialogId dialog_id, MessageId message_id, MessageId old_message_id);
|
2019-11-29 13:03:03 +01:00
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
void delete_messages_on_server(DialogId dialog_id, vector<MessageId> message_ids, bool revoke, uint64 log_event_id,
|
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
void delete_scheduled_messages_on_server(DialogId dialog_id, vector<MessageId> message_ids, uint64 log_event_id,
|
|
|
|
Promise<Unit> &&promise);
|
2019-11-29 13:03:03 +01:00
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
void delete_dialog_history_on_server(DialogId dialog_id, MessageId max_message_id, bool remove_from_dialog_list,
|
|
|
|
bool revoke, bool allow_error, uint64 log_event_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-29 23:35:37 +02:00
|
|
|
void delete_topic_history_on_server(DialogId dialog_id, MessageId top_thread_message_id, uint64 log_event_id,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
void delete_all_call_messages_on_server(bool revoke, uint64 log_event_id, Promise<Unit> &&promise);
|
2021-01-19 11:21:50 +01:00
|
|
|
|
2021-10-23 20:17:00 +02:00
|
|
|
void block_message_sender_from_replies_on_server(MessageId message_id, bool need_delete_message,
|
|
|
|
bool need_delete_all_messages, bool report_spam, uint64 log_event_id,
|
|
|
|
Promise<Unit> &&promise);
|
2020-09-24 14:29:34 +02:00
|
|
|
|
2021-11-19 13:48:05 +01:00
|
|
|
void delete_all_channel_messages_by_sender_on_server(ChannelId channel_id, DialogId sender_dialog_id,
|
|
|
|
uint64 log_event_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-25 19:39:22 +02:00
|
|
|
void delete_dialog_messages_by_date_on_server(DialogId dialog_id, int32 min_date, int32 max_date, bool revoke,
|
|
|
|
uint64 log_event_id, Promise<Unit> &&promise);
|
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void read_all_dialog_mentions_on_server(DialogId dialog_id, uint64 log_event_id, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-01-30 10:37:24 +01:00
|
|
|
void read_all_dialog_reactions_on_server(DialogId dialog_id, uint64 log_event_id, Promise<Unit> &&promise);
|
|
|
|
|
2020-10-23 00:56:06 +02:00
|
|
|
void unpin_all_dialog_messages_on_server(DialogId dialog_id, uint64 log_event_id, Promise<Unit> &&promise);
|
|
|
|
|
2021-11-11 18:55:49 +01:00
|
|
|
void on_get_affected_history(DialogId dialog_id, AffectedHistoryQuery query, bool get_affected_messages,
|
|
|
|
AffectedHistory affected_history, Promise<Unit> &&promise);
|
|
|
|
|
2023-05-02 15:54:52 +02:00
|
|
|
static vector<MessageId> find_dialog_messages(const Dialog *d, const std::function<bool(const Message *)> &condition);
|
|
|
|
|
2023-05-02 17:40:22 +02:00
|
|
|
std::function<int32(MessageId)> get_get_message_date(const Dialog *d) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-02 20:54:11 +02:00
|
|
|
vector<MessageId> find_unloadable_messages(const Dialog *d, int32 unload_before_date,
|
|
|
|
bool &has_left_to_unload_messages) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-08-29 02:16:49 +02:00
|
|
|
void on_pending_message_views_timeout(DialogId dialog_id);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void update_message_interaction_info(MessageFullId message_full_id, int32 view_count, int32 forward_count,
|
2022-01-20 20:54:34 +01:00
|
|
|
bool has_reply_info, tl_object_ptr<telegram_api::messageReplies> &&reply_info,
|
2022-02-12 12:15:14 +01:00
|
|
|
bool has_reactions, unique_ptr<MessageReactions> &&reactions);
|
2020-07-31 04:50:11 +02:00
|
|
|
|
2022-10-29 01:05:31 +02:00
|
|
|
bool is_thread_message(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2022-10-29 19:18:49 +02:00
|
|
|
bool is_thread_message(DialogId dialog_id, MessageId message_id, const MessageReplyInfo &reply_info,
|
2022-10-29 01:05:31 +02:00
|
|
|
MessageContentType content_type) const;
|
|
|
|
|
2022-10-29 19:18:49 +02:00
|
|
|
bool is_active_message_reply_info(DialogId dialog_id, const MessageReplyInfo &reply_info) const;
|
2020-09-11 13:51:13 +02:00
|
|
|
|
2020-09-25 15:37:24 +02:00
|
|
|
bool is_visible_message_reply_info(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2022-01-20 20:54:34 +01:00
|
|
|
bool is_visible_message_reactions(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2022-01-28 17:57:50 +01:00
|
|
|
bool has_unread_message_reactions(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2020-10-01 21:43:13 +02:00
|
|
|
void on_message_reply_info_changed(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Result<MessageFullId> get_top_thread_message_full_id(DialogId dialog_id, const Message *m, bool allow_non_root) const;
|
2020-10-01 14:25:54 +02:00
|
|
|
|
2020-07-31 04:50:11 +02:00
|
|
|
td_api::object_ptr<td_api::messageInteractionInfo> get_message_interaction_info_object(DialogId dialog_id,
|
|
|
|
const Message *m) const;
|
|
|
|
|
2024-05-18 22:59:26 +02:00
|
|
|
td_api::object_ptr<td_api::factCheck> get_message_fact_check_object(const Message *m) const;
|
|
|
|
|
2022-01-28 15:10:17 +01:00
|
|
|
vector<td_api::object_ptr<td_api::unreadReaction>> get_unread_reactions_object(DialogId dialog_id,
|
|
|
|
const Message *m) const;
|
|
|
|
|
2022-02-15 21:25:00 +01:00
|
|
|
bool update_message_interaction_info(Dialog *d, Message *m, int32 view_count, int32 forward_count,
|
2022-01-20 20:54:34 +01:00
|
|
|
bool has_reply_info, MessageReplyInfo &&reply_info, bool has_reactions,
|
|
|
|
unique_ptr<MessageReactions> &&reactions, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-19 20:22:51 +02:00
|
|
|
bool update_message_fact_check(const Dialog *d, Message *m, unique_ptr<FactCheck> &&fact_check, bool need_save);
|
|
|
|
|
2018-01-31 12:52:44 +01:00
|
|
|
bool update_message_contains_unread_mention(Dialog *d, Message *m, bool contains_unread_mention, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-01-28 18:27:39 +01:00
|
|
|
bool remove_message_unread_reactions(Dialog *d, Message *m, const char *source);
|
|
|
|
|
2023-09-06 23:31:05 +02:00
|
|
|
void read_message_content_from_updates(MessageId message_id, int32 read_date);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void read_channel_message_content_from_updates(Dialog *d, MessageId message_id);
|
|
|
|
|
2023-09-06 23:31:05 +02:00
|
|
|
bool read_message_content(Dialog *d, Message *m, bool is_local_read, int32 read_date, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void read_message_contents_on_server(DialogId dialog_id, vector<MessageId> message_ids, uint64 log_event_id,
|
|
|
|
Promise<Unit> &&promise, bool skip_log_event = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-12-30 01:31:33 +01:00
|
|
|
bool has_incoming_notification(DialogId dialog_id, const Message *m) const;
|
2018-05-01 20:12:00 +02:00
|
|
|
|
2023-05-13 02:51:27 +02:00
|
|
|
void read_history_outbox(Dialog *d, MessageId max_message_id, int32 read_date = -1);
|
|
|
|
|
2023-05-13 02:46:43 +02:00
|
|
|
void read_history_inbox(Dialog *d, MessageId max_message_id, int32 unread_count, const char *source);
|
|
|
|
|
2023-04-14 13:55:59 +02:00
|
|
|
void read_dialog_inbox(Dialog *d, MessageId max_message_id);
|
|
|
|
|
2023-04-14 14:17:25 +02:00
|
|
|
void mark_dialog_as_read(Dialog *d);
|
|
|
|
|
2019-12-30 01:31:33 +01:00
|
|
|
int32 calc_new_unread_count_from_last_unread(Dialog *d, MessageId max_message_id, MessageType type) const;
|
2018-05-01 20:12:00 +02:00
|
|
|
|
2019-12-30 01:31:33 +01:00
|
|
|
int32 calc_new_unread_count_from_the_end(Dialog *d, MessageId max_message_id, MessageType type,
|
|
|
|
int32 hint_unread_count) const;
|
|
|
|
|
|
|
|
int32 calc_new_unread_count(Dialog *d, MessageId max_message_id, MessageType type, int32 hint_unread_count) const;
|
2018-05-01 19:13:36 +02:00
|
|
|
|
2022-04-04 18:29:03 +02:00
|
|
|
void repair_server_unread_count(DialogId dialog_id, int32 unread_count, const char *source);
|
2018-05-03 10:57:19 +02:00
|
|
|
|
2018-05-10 19:06:48 +02:00
|
|
|
void repair_channel_server_unread_count(Dialog *d);
|
|
|
|
|
2023-01-16 18:30:52 +01:00
|
|
|
void repair_dialog_unread_reaction_count(Dialog *d, Promise<Unit> &&promise, const char *source);
|
|
|
|
|
2023-02-22 11:09:24 +01:00
|
|
|
void repair_dialog_unread_mention_count(Dialog *d, const char *source);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void read_history_outbox(DialogId dialog_id, MessageId max_message_id, int32 read_date = -1);
|
|
|
|
|
2018-05-03 14:36:05 +02:00
|
|
|
void read_history_on_server(Dialog *d, MessageId max_message_id);
|
|
|
|
|
2020-09-22 00:13:06 +02:00
|
|
|
void do_read_history_on_server(DialogId dialog_id);
|
|
|
|
|
|
|
|
void read_history_on_server_impl(Dialog *d, MessageId max_message_id);
|
|
|
|
|
|
|
|
void read_message_thread_history_on_server_impl(Dialog *d, MessageId top_thread_message_id, MessageId max_message_id);
|
|
|
|
|
|
|
|
void on_read_history_finished(DialogId dialog_id, MessageId top_thread_message_id, uint64 generation);
|
2018-05-03 14:36:05 +02:00
|
|
|
|
2020-09-22 00:13:06 +02:00
|
|
|
void read_message_thread_history_on_server(Dialog *d, MessageId top_thread_message_id, MessageId max_message_id,
|
|
|
|
MessageId last_message_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void read_secret_chat_outbox_inner(DialogId dialog_id, int32 up_to_date, int32 read_date);
|
|
|
|
|
2018-01-25 16:36:40 +01:00
|
|
|
void set_dialog_max_unavailable_message_id(DialogId dialog_id, MessageId max_unavailable_message_id, bool from_update,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-03-07 13:20:22 +01:00
|
|
|
void on_update_viewed_messages_timeout(DialogId dialog_id);
|
|
|
|
|
2023-05-01 14:33:51 +02:00
|
|
|
void on_send_update_chat_read_inbox_timeout(DialogId dialog_id);
|
|
|
|
|
2021-12-04 22:12:59 +01:00
|
|
|
bool delete_newer_server_messages_at_the_end(Dialog *d, MessageId max_message_id);
|
|
|
|
|
2020-09-30 03:26:39 +02:00
|
|
|
template <class T, class It>
|
|
|
|
vector<MessageId> get_message_history_slice(const T &begin, It it, const T &end, MessageId from_message_id,
|
|
|
|
int32 offset, int32 limit);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void preload_newer_messages(const Dialog *d, MessageId max_message_id);
|
|
|
|
|
|
|
|
void preload_older_messages(const Dialog *d, MessageId min_message_id);
|
|
|
|
|
2023-07-28 13:33:54 +02:00
|
|
|
void load_last_dialog_message_later(DialogId dialog_id);
|
|
|
|
|
|
|
|
void load_last_dialog_message(const Dialog *d, const char *source);
|
|
|
|
|
2021-07-19 20:38:04 +02:00
|
|
|
void on_get_history_from_database(DialogId dialog_id, MessageId from_message_id,
|
2023-07-28 13:12:22 +02:00
|
|
|
MessageId old_last_database_message_id, int32 offset, int32 limit, bool only_local,
|
|
|
|
vector<MessageDbDialogMessage> &&messages, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-19 19:56:30 +02:00
|
|
|
void get_history_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit, bool from_database,
|
2023-07-28 12:32:07 +02:00
|
|
|
bool only_local, Promise<Unit> &&promise, const char *source);
|
2021-07-19 19:56:30 +02:00
|
|
|
|
2023-07-28 13:33:54 +02:00
|
|
|
void on_get_history_finished(const PendingGetHistoryQuery &query, Result<Unit> &&result);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void load_messages(DialogId dialog_id, MessageId from_message_id, int32 offset, int32 limit, int left_tries,
|
|
|
|
bool only_local, Promise<Unit> &&promise);
|
|
|
|
|
2021-07-19 19:56:30 +02:00
|
|
|
void load_messages_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit, int left_tries,
|
|
|
|
bool only_local, Promise<Unit> &&promise);
|
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
void load_dialog_scheduled_messages(DialogId dialog_id, bool from_database, int64 hash, Promise<Unit> &&promise);
|
2019-12-04 18:06:39 +01:00
|
|
|
|
2022-11-09 18:35:22 +01:00
|
|
|
void on_get_scheduled_messages_from_database(DialogId dialog_id, vector<MessageDbDialogMessage> &&messages);
|
2019-12-04 18:06:39 +01:00
|
|
|
|
2023-05-01 22:15:54 +02:00
|
|
|
static bool have_dialog_scheduled_messages_in_memory(const Dialog *d);
|
|
|
|
|
2021-01-15 23:17:35 +01:00
|
|
|
static bool is_allowed_useless_update(const tl_object_ptr<telegram_api::Update> &update);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-04-27 18:51:11 +02:00
|
|
|
bool is_message_auto_read(DialogId dialog_id, bool is_outgoing) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void fail_send_message(MessageFullId message_full_id, int32 error_code, const string &error_message);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void fail_send_message(MessageFullId message_full_id, Status error);
|
2018-09-19 18:59:23 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void fail_edit_message_media(MessageFullId message_full_id, Status &&error);
|
2018-06-19 01:31:34 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_dialog_updated(DialogId dialog_id, const char *source);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static BufferSlice get_dialog_database_value(const Dialog *d);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void save_dialog_to_database(DialogId dialog_id);
|
|
|
|
|
2019-05-04 00:03:10 +02:00
|
|
|
void on_save_dialog_to_database(DialogId dialog_id, bool can_reuse_notification_group, bool success);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void try_reuse_notification_group(NotificationGroupInfo &group_info);
|
|
|
|
|
2020-05-21 02:39:45 +02:00
|
|
|
void load_dialog_list(DialogList &list, int32 limit, Promise<Unit> &&promise);
|
|
|
|
|
2021-08-11 15:32:00 +02:00
|
|
|
void load_folder_dialog_list(FolderId folder_id, int32 limit, bool only_local);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-11 00:23:17 +02:00
|
|
|
void on_load_folder_dialog_list(FolderId folder_id, Result<Unit> &&result);
|
2020-06-05 06:21:02 +02:00
|
|
|
|
2020-05-21 02:39:45 +02:00
|
|
|
void load_folder_dialog_list_from_database(FolderId folder_id, int32 limit, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-11-07 20:28:45 +01:00
|
|
|
void preload_folder_dialog_list(FolderId folder_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-08-11 14:59:09 +02:00
|
|
|
void get_dialogs_from_list_impl(int64 task_id);
|
|
|
|
|
|
|
|
void on_get_dialogs_from_list(int64 task_id, Result<Unit> &&result);
|
|
|
|
|
2020-05-01 21:43:05 +02:00
|
|
|
static void invalidate_message_indexes(Dialog *d);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void update_message_count_by_index(Dialog *d, int diff, const Message *m);
|
|
|
|
|
2018-05-23 17:28:46 +02:00
|
|
|
void update_message_count_by_index(Dialog *d, int diff, int32 index_mask);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 get_message_index_mask(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2020-10-31 11:55:53 +01:00
|
|
|
void update_reply_count_by_message(Dialog *d, int diff, const Message *m);
|
|
|
|
|
|
|
|
void update_message_reply_count(Dialog *d, MessageId message_id, DialogId replier_dialog_id,
|
2020-12-05 14:23:22 +01:00
|
|
|
MessageId reply_message_id, int32 update_date, int diff, bool is_recursive = false);
|
2020-10-31 11:55:53 +01:00
|
|
|
|
2023-05-11 12:12:04 +02:00
|
|
|
void fix_new_message(const Dialog *d, Message *m, bool from_database) const;
|
|
|
|
|
2023-05-12 13:25:00 +02:00
|
|
|
void remove_message_remove_keyboard_reply_markup(Message *m) const;
|
|
|
|
|
2023-12-21 15:10:09 +01:00
|
|
|
void update_replied_by_message_count(DialogId dialog_id, const Message *m, bool is_add);
|
|
|
|
|
2023-05-12 15:29:21 +02:00
|
|
|
void add_message_to_dialog_message_list(const Message *m, Dialog *d, const bool from_database, const bool from_update,
|
|
|
|
const bool need_update, bool *need_update_dialog_pos, const char *source);
|
|
|
|
|
2023-05-11 19:27:00 +02:00
|
|
|
Message *add_message_to_dialog(Dialog *d, unique_ptr<Message> message, const bool from_database,
|
|
|
|
const bool from_update, bool *need_update, bool *need_update_dialog_pos,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-10 19:41:02 +02:00
|
|
|
Message *add_scheduled_message_to_dialog(Dialog *d, unique_ptr<Message> message, bool from_database, bool from_update,
|
|
|
|
bool *need_update, const char *source);
|
2019-11-29 13:03:03 +01:00
|
|
|
|
2020-09-28 23:22:35 +02:00
|
|
|
void register_new_local_message_id(Dialog *d, const Message *m);
|
|
|
|
|
2018-11-28 18:18:50 +01:00
|
|
|
void on_message_changed(const Dialog *d, const Message *m, bool need_send_update, const char *source);
|
2018-01-25 13:00:23 +01:00
|
|
|
|
2022-09-19 15:19:59 +02:00
|
|
|
void on_message_notification_changed(Dialog *d, const Message *m, const char *source);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool need_delete_file(MessageFullId message_full_id, FileId file_id) const;
|
2019-04-28 19:21:44 +02:00
|
|
|
|
2019-11-30 16:05:30 +01:00
|
|
|
bool need_delete_message_files(DialogId dialog_id, const Message *m) const;
|
2019-04-20 15:41:32 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void add_message_to_database(const Dialog *d, const Message *m, const char *source);
|
|
|
|
|
2023-09-13 15:29:37 +02:00
|
|
|
void delete_all_dialog_notifications(Dialog *d, MessageId max_message_id, const char *source);
|
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void delete_all_dialog_messages_from_database(Dialog *d, MessageId max_message_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-10 22:26:50 +02:00
|
|
|
void delete_message_from_database(Dialog *d, MessageId message_id, const Message *m, bool is_permanently_deleted,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-05-18 18:10:48 +02:00
|
|
|
void update_reply_to_message_id(DialogId dialog_id, MessageId old_message_id, MessageId new_message_id,
|
|
|
|
bool have_new_message, const char *source);
|
2022-05-17 14:06:40 +02:00
|
|
|
|
2019-04-28 19:21:44 +02:00
|
|
|
void delete_message_files(DialogId dialog_id, const Message *m) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-10-24 21:49:50 +02:00
|
|
|
static void add_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id);
|
|
|
|
|
|
|
|
static void delete_random_id_to_message_id_correspondence(Dialog *d, int64 random_id, MessageId message_id);
|
|
|
|
|
2023-03-16 21:07:12 +01:00
|
|
|
static void add_notification_id_to_message_id_correspondence(NotificationInfo *notification_info,
|
|
|
|
NotificationId notification_id, MessageId message_id);
|
2018-11-29 00:48:47 +01:00
|
|
|
|
2023-03-16 21:07:12 +01:00
|
|
|
static void delete_notification_id_to_message_id_correspondence(NotificationInfo *notification_info,
|
|
|
|
NotificationId notification_id, MessageId message_id);
|
2018-11-29 00:48:47 +01:00
|
|
|
|
2023-08-22 01:31:47 +02:00
|
|
|
static bool is_notification_info_group_id(const NotificationInfo *notification_info, NotificationGroupId group_id);
|
|
|
|
|
|
|
|
static bool is_dialog_notification_group_id(const Dialog *d, NotificationGroupId group_id);
|
|
|
|
|
2019-10-23 20:53:26 +02:00
|
|
|
void remove_message_notification_id(Dialog *d, Message *m, bool is_permanent, bool force_update,
|
|
|
|
bool ignore_pinned_message_notification_removal = false);
|
2018-11-29 00:48:47 +01:00
|
|
|
|
2018-12-04 17:40:12 +01:00
|
|
|
void remove_new_secret_chat_notification(Dialog *d, bool is_permanent);
|
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void fix_dialog_last_notification_id(Dialog *d, bool from_mentions, MessageId message_id);
|
2018-11-29 16:36:31 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void do_fix_dialog_last_notification_id(DialogId dialog_id, bool from_mentions,
|
|
|
|
NotificationId prev_last_notification_id,
|
|
|
|
Result<vector<Notification>> result);
|
2018-11-29 16:36:31 +01:00
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void do_delete_message_log_event(const DeleteMessageLogEvent &log_event) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-12-20 21:25:54 +01:00
|
|
|
int64 get_message_reply_to_random_id(const Dialog *d, const Message *m) const;
|
|
|
|
|
2023-05-28 22:07:39 +02:00
|
|
|
bool update_message(Dialog *d, Message *old_message, unique_ptr<Message> new_message, bool is_message_in_dialog);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-09-28 22:57:34 +02:00
|
|
|
static bool need_message_changed_warning(const Message *old_message);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-05-23 17:28:46 +02:00
|
|
|
bool update_message_content(DialogId dialog_id, Message *old_message, unique_ptr<MessageContent> new_content,
|
2022-09-19 00:12:20 +02:00
|
|
|
bool need_merge_files, bool is_message_in_dialog, bool &is_content_changed);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-06-08 19:14:38 +02:00
|
|
|
void update_message_max_reply_media_timestamp(const Dialog *d, Message *m,
|
|
|
|
bool need_send_update_message_content) const;
|
2021-08-05 08:59:43 +02:00
|
|
|
|
|
|
|
void update_message_max_own_media_timestamp(const Dialog *d, Message *m);
|
|
|
|
|
2021-08-06 04:55:43 +02:00
|
|
|
void update_message_max_reply_media_timestamp_in_replied_messages(DialogId dialog_id, MessageId reply_to_message_id);
|
|
|
|
|
2023-06-09 13:08:16 +02:00
|
|
|
bool can_register_message_reply(const Message *m) const;
|
|
|
|
|
2022-03-23 16:27:17 +01:00
|
|
|
void register_message_reply(DialogId dialog_id, const Message *m);
|
2021-08-06 04:55:43 +02:00
|
|
|
|
2022-03-23 16:27:17 +01:00
|
|
|
void reregister_message_reply(DialogId dialog_id, const Message *m);
|
2021-08-06 04:55:43 +02:00
|
|
|
|
2022-03-23 16:27:17 +01:00
|
|
|
void unregister_message_reply(DialogId dialog_id, const Message *m);
|
2021-08-06 04:55:43 +02:00
|
|
|
|
2018-11-11 13:58:52 +01:00
|
|
|
void send_update_new_message(const Dialog *d, const Message *m);
|
|
|
|
|
2022-06-16 17:54:50 +02:00
|
|
|
bool get_dialog_show_preview(const Dialog *d) const;
|
|
|
|
|
|
|
|
bool is_message_preview_enabled(const Dialog *d, const Message *m, bool from_mentions);
|
|
|
|
|
2022-05-05 22:07:42 +02:00
|
|
|
static bool is_from_mention_notification_group(const Message *m);
|
2018-11-29 16:36:31 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
static bool is_message_notification_active(const Dialog *d, const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-03-16 18:39:00 +01:00
|
|
|
static NotificationGroupInfo &get_notification_group_info(Dialog *d, bool from_mentions);
|
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
static NotificationGroupInfo &get_notification_group_info(Dialog *d, const Message *m);
|
2018-12-04 17:40:12 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
NotificationGroupId get_dialog_notification_group_id(DialogId dialog_id, NotificationGroupInfo &group_info);
|
2018-12-05 23:34:22 +01:00
|
|
|
|
2023-03-16 21:11:08 +01:00
|
|
|
NotificationId get_next_notification_id(NotificationInfo *notification_info,
|
|
|
|
NotificationGroupId notification_group_id, MessageId message_id);
|
2018-12-22 21:24:18 +01:00
|
|
|
|
2018-12-25 03:45:36 +01:00
|
|
|
void try_add_pinned_message_notification(Dialog *d, vector<Notification> &res, NotificationId max_notification_id,
|
|
|
|
int32 limit);
|
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
vector<Notification> get_message_notifications_from_database_force(Dialog *d, bool from_mentions, int32 limit);
|
|
|
|
|
2022-11-09 18:35:22 +01:00
|
|
|
static vector<MessageDbDialogMessage> do_get_message_notifications_from_database_force(
|
2021-10-01 11:55:12 +02:00
|
|
|
Dialog *d, bool from_mentions, NotificationId from_notification_id, MessageId from_message_id, int32 limit);
|
2018-12-03 16:38:29 +01:00
|
|
|
|
2018-12-25 03:45:36 +01:00
|
|
|
void do_get_message_notifications_from_database(Dialog *d, bool from_mentions,
|
|
|
|
NotificationId initial_from_notification_id,
|
|
|
|
NotificationId from_notification_id, MessageId from_message_id,
|
|
|
|
int32 limit, Promise<vector<Notification>> promise);
|
2018-12-05 23:59:33 +01:00
|
|
|
|
2018-12-25 03:45:36 +01:00
|
|
|
void on_get_message_notifications_from_database(DialogId dialog_id, bool from_mentions,
|
|
|
|
NotificationId initial_from_notification_id, int32 limit,
|
2022-11-09 18:35:22 +01:00
|
|
|
Result<vector<MessageDbDialogMessage>> result,
|
2018-12-03 16:38:29 +01:00
|
|
|
Promise<vector<Notification>> promise);
|
2018-11-28 21:19:30 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void do_remove_message_notification(DialogId dialog_id, bool from_mentions, NotificationId notification_id,
|
2022-11-09 18:35:22 +01:00
|
|
|
vector<MessageDbDialogMessage> result);
|
2018-11-29 00:48:47 +01:00
|
|
|
|
2018-12-25 16:04:29 +01:00
|
|
|
int32 get_dialog_pending_notification_count(const Dialog *d, bool from_mentions) const;
|
|
|
|
|
|
|
|
void update_dialog_mention_notification_count(const Dialog *d);
|
2018-11-20 16:03:49 +01:00
|
|
|
|
2019-02-05 15:10:06 +01:00
|
|
|
bool is_message_notification_disabled(const Dialog *d, const Message *m) const;
|
|
|
|
|
2019-03-26 16:05:53 +01:00
|
|
|
bool is_dialog_message_notification_disabled(DialogId dialog_id, int32 message_date) const;
|
|
|
|
|
2019-02-05 15:10:06 +01:00
|
|
|
bool may_need_message_notification(const Dialog *d, const Message *m) const;
|
|
|
|
|
2018-11-28 18:18:50 +01:00
|
|
|
bool add_new_message_notification(Dialog *d, Message *m, bool force);
|
2018-11-08 19:00:03 +01:00
|
|
|
|
2018-12-22 21:24:18 +01:00
|
|
|
void flush_pending_new_message_notifications(DialogId dialog_id, bool from_mentions, DialogId settings_dialog_id);
|
|
|
|
|
2019-10-18 16:02:34 +02:00
|
|
|
void remove_all_dialog_notifications(Dialog *d, bool from_mentions, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-10-18 16:21:00 +02:00
|
|
|
void remove_message_dialog_notifications(Dialog *d, MessageId max_message_id, bool from_mentions, const char *source);
|
2018-11-20 18:17:15 +01:00
|
|
|
|
2021-07-22 04:39:16 +02:00
|
|
|
bool need_skip_bot_commands(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2023-11-10 16:43:04 +01:00
|
|
|
void send_update_message_send_succeeded(Dialog *d, MessageId old_message_id, const Message *m,
|
|
|
|
bool *need_update_dialog_pos);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-08-13 12:19:58 +02:00
|
|
|
void send_update_message_content(const Dialog *d, Message *m, bool is_message_in_dialog, const char *source);
|
2021-07-22 05:54:43 +02:00
|
|
|
|
|
|
|
void send_update_message_content_impl(DialogId dialog_id, const Message *m, const char *source) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-03-13 18:48:08 +01:00
|
|
|
void send_update_message_edited(DialogId dialog_id, const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-09-11 19:20:46 +02:00
|
|
|
void send_update_message_interaction_info(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2024-05-18 22:59:26 +02:00
|
|
|
void send_update_message_fact_check(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2022-01-28 16:39:13 +01:00
|
|
|
void send_update_message_unread_reactions(DialogId dialog_id, const Message *m, int32 unread_reaction_count) const;
|
2022-01-28 15:10:17 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void send_update_message_live_location_viewed(MessageFullId message_full_id);
|
2019-12-13 19:05:10 +01:00
|
|
|
|
2022-11-08 11:43:46 +01:00
|
|
|
void send_update_delete_messages(DialogId dialog_id, vector<int64> &&message_ids, bool is_permanent) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-07 19:03:04 +02:00
|
|
|
void send_update_new_chat(Dialog *d, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-11-16 13:04:57 +01:00
|
|
|
bool need_hide_dialog_draft_message(const Dialog *d) const;
|
2023-04-29 20:58:39 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_chat_draft_message(const Dialog *d);
|
|
|
|
|
2024-02-06 14:03:11 +01:00
|
|
|
void send_update_last_message_if_needed(const Dialog *d, const Message *m, const char *source) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_chat_last_message(Dialog *d, const char *source);
|
|
|
|
|
2018-01-25 13:26:25 +01:00
|
|
|
void send_update_chat_last_message_impl(const Dialog *d, const char *source) const;
|
|
|
|
|
2020-05-26 00:58:06 +02:00
|
|
|
void send_update_unread_message_count(DialogList &list, DialogId dialog_id, bool force, const char *source,
|
2020-05-22 18:20:50 +02:00
|
|
|
bool from_database = false);
|
2018-02-25 01:00:17 +01:00
|
|
|
|
2020-05-26 00:58:06 +02:00
|
|
|
void send_update_unread_chat_count(DialogList &list, DialogId dialog_id, bool force, const char *source,
|
2020-05-22 18:20:50 +02:00
|
|
|
bool from_database = false);
|
2018-07-02 03:02:30 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void send_update_chat_read_inbox(const Dialog *d, bool force, const char *source);
|
|
|
|
|
|
|
|
void send_update_chat_read_outbox(const Dialog *d);
|
|
|
|
|
|
|
|
void send_update_chat_unread_mention_count(const Dialog *d);
|
|
|
|
|
2022-04-23 00:14:51 +02:00
|
|
|
void send_update_chat_unread_reaction_count(const Dialog *d, const char *source);
|
2022-01-28 16:39:13 +01:00
|
|
|
|
2020-05-29 00:58:24 +02:00
|
|
|
void send_update_chat_position(DialogListId dialog_list_id, const Dialog *d, const char *source) const;
|
2018-05-08 22:02:15 +02:00
|
|
|
|
2020-01-06 18:40:58 +01:00
|
|
|
void send_update_secret_chats_with_user_action_bar(const Dialog *d) const;
|
|
|
|
|
2021-11-23 07:35:38 +01:00
|
|
|
void send_update_chat_action_bar(Dialog *d);
|
2019-10-11 00:23:28 +02:00
|
|
|
|
2024-04-08 01:37:52 +02:00
|
|
|
void send_update_chat_business_bot_manage_bar(Dialog *d);
|
|
|
|
|
2022-01-04 14:33:57 +01:00
|
|
|
void send_update_chat_available_reactions(const Dialog *d);
|
|
|
|
|
2023-04-10 16:23:21 +02:00
|
|
|
void send_update_secret_chats_with_user_background(const Dialog *d) const;
|
|
|
|
|
|
|
|
void send_update_chat_background(const Dialog *d);
|
|
|
|
|
2021-08-27 19:36:40 +02:00
|
|
|
void send_update_secret_chats_with_user_theme(const Dialog *d) const;
|
|
|
|
|
|
|
|
void send_update_chat_theme(const Dialog *d);
|
|
|
|
|
2021-10-26 19:51:06 +02:00
|
|
|
void send_update_chat_pending_join_requests(const Dialog *d);
|
2021-10-12 17:11:17 +02:00
|
|
|
|
2021-10-14 14:44:21 +02:00
|
|
|
void send_update_chat_video_chat(const Dialog *d);
|
2020-12-13 22:36:44 +01:00
|
|
|
|
2021-12-21 11:49:26 +01:00
|
|
|
void send_update_chat_message_sender(const Dialog *d);
|
2021-11-12 14:15:19 +01:00
|
|
|
|
2022-12-28 19:46:16 +01:00
|
|
|
void send_update_chat_message_auto_delete_time(const Dialog *d);
|
2021-02-09 15:35:48 +01:00
|
|
|
|
2020-02-28 19:40:31 +01:00
|
|
|
void send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion);
|
2019-12-04 19:01:00 +01:00
|
|
|
|
2020-03-24 01:47:33 +01:00
|
|
|
void repair_dialog_action_bar(Dialog *d, const char *source);
|
|
|
|
|
2019-10-11 03:17:46 +02:00
|
|
|
void hide_dialog_action_bar(Dialog *d);
|
|
|
|
|
2020-12-13 22:36:44 +01:00
|
|
|
void repair_dialog_active_group_call_id(DialogId dialog_id);
|
|
|
|
|
|
|
|
void do_repair_dialog_active_group_call_id(DialogId dialog_id);
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static Result<int32> get_message_schedule_date(td_api::object_ptr<td_api::MessageSchedulingState> &&scheduling_state);
|
|
|
|
|
2020-01-16 04:10:08 +01:00
|
|
|
tl_object_ptr<td_api::MessageSendingState> get_message_sending_state_object(const Message *m) const;
|
2019-12-03 01:20:38 +01:00
|
|
|
|
2019-12-03 01:12:41 +01:00
|
|
|
static tl_object_ptr<td_api::MessageSchedulingState> get_message_scheduling_state_object(int32 send_date);
|
|
|
|
|
2023-10-19 12:59:18 +02:00
|
|
|
td_api::object_ptr<td_api::MessageContent> get_message_message_content_object(DialogId dialog_id,
|
|
|
|
const Message *m) const;
|
|
|
|
|
2024-03-09 00:14:02 +01:00
|
|
|
td_api::object_ptr<td_api::message> get_message_object(DialogId dialog_id, const Message *m,
|
|
|
|
const char *source) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-03-09 00:14:02 +01:00
|
|
|
static td_api::object_ptr<td_api::messages> get_messages_object(int32 total_count,
|
|
|
|
vector<tl_object_ptr<td_api::message>> &&messages,
|
|
|
|
bool skip_not_found);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-03-16 22:19:24 +01:00
|
|
|
td_api::object_ptr<td_api::message> get_business_message_message_object(
|
|
|
|
telegram_api::object_ptr<telegram_api::Message> &&message);
|
|
|
|
|
2018-01-16 19:56:59 +01:00
|
|
|
vector<DialogId> sort_dialogs_by_order(const vector<DialogId> &dialog_ids, int32 limit) const;
|
|
|
|
|
2018-10-07 23:28:03 +02:00
|
|
|
static bool need_unread_counter(int64 dialog_order);
|
|
|
|
|
2020-03-19 23:15:15 +01:00
|
|
|
int32 get_dialog_total_count(const DialogList &list) const;
|
2019-12-26 19:44:35 +01:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
void repair_server_dialog_total_count(DialogListId dialog_list_id);
|
2019-12-26 20:19:25 +01:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
void repair_secret_chat_total_count(DialogListId dialog_list_id);
|
2019-12-26 20:33:18 +01:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
void on_get_secret_chat_total_count(DialogListId dialog_list_id, int32 total_count);
|
2019-12-26 20:33:18 +01:00
|
|
|
|
2021-10-11 09:03:34 +02:00
|
|
|
void recalc_unread_count(DialogListId dialog_list_id, int32 old_dialog_total_count, bool force);
|
2018-02-25 01:00:17 +01:00
|
|
|
|
2019-08-22 17:24:02 +02:00
|
|
|
td_api::object_ptr<td_api::updateUnreadMessageCount> get_update_unread_message_count_object(
|
2020-03-17 02:29:24 +01:00
|
|
|
const DialogList &list) const;
|
2018-10-09 16:12:10 +02:00
|
|
|
|
2020-03-17 02:29:24 +01:00
|
|
|
td_api::object_ptr<td_api::updateUnreadChatCount> get_update_unread_chat_count_object(const DialogList &list) const;
|
2018-10-09 16:12:10 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static void save_unread_chat_count(const DialogList &list);
|
2020-05-29 08:08:01 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void set_dialog_last_read_inbox_message_id(Dialog *d, MessageId message_id, int32 server_unread_count,
|
|
|
|
int32 local_unread_count, bool force_update, const char *source);
|
|
|
|
|
|
|
|
void set_dialog_last_read_outbox_message_id(Dialog *d, MessageId message_id);
|
|
|
|
|
2022-09-21 16:44:25 +02:00
|
|
|
void set_dialog_last_message_id(Dialog *d, MessageId last_message_id, const char *source, const Message *m = nullptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void set_dialog_first_database_message_id(Dialog *d, MessageId first_database_message_id, const char *source);
|
|
|
|
|
2018-12-15 18:43:20 +01:00
|
|
|
void set_dialog_last_database_message_id(Dialog *d, MessageId last_database_message_id, const char *source,
|
|
|
|
bool is_loaded_from_database = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void set_dialog_last_new_message_id(Dialog *d, MessageId last_new_message_id, const char *source);
|
|
|
|
|
|
|
|
void set_dialog_last_clear_history_date(Dialog *d, int32 date, MessageId last_clear_history_message_id,
|
2018-12-15 18:43:20 +01:00
|
|
|
const char *source, bool is_loaded_from_database = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-08-10 08:19:08 +02:00
|
|
|
static void set_dialog_unread_mention_count(Dialog *d, int32 unread_mention_count);
|
|
|
|
|
2022-01-28 16:39:13 +01:00
|
|
|
static void set_dialog_unread_reaction_count(Dialog *d, int32 unread_reaction_count);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void set_dialog_is_empty(Dialog *d, const char *source);
|
|
|
|
|
2020-10-23 13:50:05 +02:00
|
|
|
void remove_dialog_newer_messages(Dialog *d, MessageId from_message_id, const char *source);
|
|
|
|
|
2022-08-18 16:00:18 +02:00
|
|
|
int32 get_pinned_dialogs_limit(DialogListId dialog_list_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-08-02 02:56:45 +02:00
|
|
|
bool set_dialog_is_pinned(DialogId dialog_id, bool is_pinned);
|
2020-05-29 05:57:55 +02:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
bool set_dialog_is_pinned(DialogListId dialog_list_id, Dialog *d, bool is_pinned,
|
|
|
|
bool need_update_dialog_lists = true);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-08-27 22:12:50 +02:00
|
|
|
void save_pinned_folder_dialog_ids(const DialogList &list) const;
|
|
|
|
|
2023-11-16 13:04:57 +01:00
|
|
|
void on_update_dialog_view_as_topics(const Dialog *d, bool old_view_as_topics);
|
|
|
|
|
|
|
|
void set_dialog_is_forum(Dialog *d, bool is_forum);
|
|
|
|
|
2024-02-07 23:33:08 +01:00
|
|
|
void set_dialog_view_as_messages(Dialog *d, bool view_as_messages, const char *source);
|
2023-11-16 11:59:32 +01:00
|
|
|
|
2018-06-27 23:08:44 +02:00
|
|
|
void set_dialog_is_marked_as_unread(Dialog *d, bool is_marked_as_unread);
|
|
|
|
|
2023-01-20 10:38:25 +01:00
|
|
|
void set_dialog_is_translatable(Dialog *d, bool is_translatable);
|
|
|
|
|
2023-07-28 15:19:05 +02:00
|
|
|
void set_dialog_is_blocked(Dialog *d, bool is_blocked, bool is_blocked_for_stories);
|
2020-09-20 00:54:40 +02:00
|
|
|
|
2021-07-22 03:10:40 +02:00
|
|
|
void set_dialog_has_bots(Dialog *d, bool has_bots);
|
|
|
|
|
2020-10-20 19:28:37 +02:00
|
|
|
void set_dialog_last_pinned_message_id(Dialog *d, MessageId last_pinned_message_id);
|
2019-02-01 13:19:32 +01:00
|
|
|
|
2020-10-20 19:28:37 +02:00
|
|
|
void drop_dialog_last_pinned_message_id(Dialog *d);
|
2020-10-20 18:07:11 +02:00
|
|
|
|
2023-04-10 16:23:21 +02:00
|
|
|
void set_dialog_background(Dialog *d, BackgroundInfo &&background_info);
|
|
|
|
|
2021-08-23 17:47:32 +02:00
|
|
|
void set_dialog_theme_name(Dialog *d, string theme_name);
|
|
|
|
|
2021-10-26 19:51:06 +02:00
|
|
|
void fix_pending_join_requests(DialogId dialog_id, int32 &pending_join_request_count,
|
|
|
|
vector<UserId> &pending_join_request_user_ids) const;
|
2021-10-13 23:34:28 +02:00
|
|
|
|
2021-10-26 19:51:06 +02:00
|
|
|
void set_dialog_pending_join_requests(Dialog *d, int32 pending_join_request_count,
|
|
|
|
vector<UserId> pending_join_request_user_ids);
|
2021-10-12 17:11:17 +02:00
|
|
|
|
2020-02-28 19:40:31 +01:00
|
|
|
void repair_dialog_scheduled_messages(Dialog *d);
|
2019-12-04 22:58:59 +01:00
|
|
|
|
2019-12-04 18:51:52 +01:00
|
|
|
void set_dialog_has_scheduled_server_messages(Dialog *d, bool has_scheduled_server_messages);
|
2019-11-25 17:11:24 +01:00
|
|
|
|
2019-12-04 20:43:14 +01:00
|
|
|
void set_dialog_has_scheduled_database_messages(DialogId dialog_id, bool has_scheduled_database_messages);
|
|
|
|
|
|
|
|
void set_dialog_has_scheduled_database_messages_impl(Dialog *d, bool has_scheduled_database_messages);
|
|
|
|
|
2019-08-19 03:51:03 +02:00
|
|
|
void set_dialog_folder_id(Dialog *d, FolderId folder_id);
|
|
|
|
|
2020-07-09 22:14:41 +02:00
|
|
|
void do_set_dialog_folder_id(Dialog *d, FolderId folder_id);
|
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void toggle_dialog_is_pinned_on_server(DialogId dialog_id, bool is_pinned, uint64 log_event_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-11-16 14:57:18 +01:00
|
|
|
void toggle_dialog_view_as_messages_on_server(DialogId dialog_id, bool view_as_messages, uint64 log_event_id);
|
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void toggle_dialog_is_marked_as_unread_on_server(DialogId dialog_id, bool is_marked_as_unread, uint64 log_event_id);
|
2018-06-27 23:08:44 +02:00
|
|
|
|
2023-01-20 10:38:25 +01:00
|
|
|
void toggle_dialog_is_translatable_on_server(DialogId dialog_id, bool is_translatable, uint64 log_event_id);
|
|
|
|
|
2023-07-28 16:33:47 +02:00
|
|
|
void toggle_dialog_is_blocked_on_server(DialogId dialog_id, bool is_blocked, bool is_blocked_for_stories,
|
|
|
|
uint64 log_event_id);
|
2020-09-20 02:00:01 +02:00
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void reorder_pinned_dialogs_on_server(FolderId folder_id, const vector<DialogId> &dialog_ids, uint64 log_event_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void set_dialog_reply_markup(Dialog *d, MessageId message_id);
|
|
|
|
|
|
|
|
void try_restore_dialog_reply_markup(Dialog *d, const Message *m);
|
|
|
|
|
2020-02-18 18:28:16 +01:00
|
|
|
void set_dialog_pinned_message_notification(Dialog *d, MessageId message_id, const char *source);
|
2018-12-25 03:45:36 +01:00
|
|
|
|
2020-02-18 18:28:16 +01:00
|
|
|
void remove_dialog_pinned_message_notification(Dialog *d, const char *source);
|
2019-01-10 20:16:05 +01:00
|
|
|
|
2019-01-10 18:54:46 +01:00
|
|
|
void remove_dialog_mention_notifications(Dialog *d);
|
|
|
|
|
2023-08-21 18:50:24 +02:00
|
|
|
void set_dialog_last_notification(DialogId dialog_id, NotificationGroupInfo &group_info, int32 last_notification_date,
|
2018-12-22 21:24:18 +01:00
|
|
|
NotificationId last_notification_id, const char *source);
|
2018-11-12 15:44:42 +01:00
|
|
|
|
2023-08-21 18:50:24 +02:00
|
|
|
void set_dialog_last_notification_checked(DialogId dialog_id, NotificationGroupInfo &group_info,
|
|
|
|
int32 last_notification_date, NotificationId last_notification_id,
|
|
|
|
const char *source);
|
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
bool update_dialog_notification_settings(DialogId dialog_id, DialogNotificationSettings *current_settings,
|
2022-04-11 19:01:44 +02:00
|
|
|
DialogNotificationSettings &&new_settings);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-10-04 11:24:58 +02:00
|
|
|
void schedule_dialog_unmute(DialogId dialog_id, bool use_default, int32 mute_until, int32 unix_time);
|
2020-06-02 19:02:25 +02:00
|
|
|
|
2020-06-05 03:05:43 +02:00
|
|
|
void update_dialog_unmute_timeout(Dialog *d, bool &old_use_default, int32 &old_mute_until, bool new_use_default,
|
2018-04-09 18:30:27 +02:00
|
|
|
int32 new_mute_until);
|
|
|
|
|
2018-02-23 16:35:36 +01:00
|
|
|
void on_dialog_unmute(DialogId dialog_id);
|
|
|
|
|
2018-04-28 20:05:04 +02:00
|
|
|
bool update_dialog_silent_send_message(Dialog *d, bool silent_send_message);
|
|
|
|
|
2022-11-29 11:08:06 +01:00
|
|
|
void set_dialog_message_ttl(Dialog *d, MessageTtl message_ttl);
|
|
|
|
|
2024-01-22 18:03:05 +01:00
|
|
|
bool can_add_message_tag(DialogId dialog_id, const MessageReactions *reactions) const;
|
|
|
|
|
2024-01-24 15:11:41 +01:00
|
|
|
ChatReactions get_message_available_reactions(const Dialog *d, const Message *m, bool disallow_custom_for_non_premium,
|
|
|
|
ReactionUnavailabilityReason *unavailability_reason);
|
2022-01-26 14:51:47 +01:00
|
|
|
|
2023-10-16 09:35:47 +02:00
|
|
|
DialogId get_my_reaction_dialog_id(const Dialog *d) const;
|
|
|
|
|
2022-09-09 15:21:00 +02:00
|
|
|
void set_message_reactions(Dialog *d, Message *m, bool is_big, bool add_to_recent, Promise<Unit> &&promise);
|
2022-09-09 14:56:45 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_set_message_reactions(MessageFullId message_full_id, Result<Unit> result, Promise<Unit> promise);
|
2022-01-26 16:48:46 +01:00
|
|
|
|
2023-06-01 14:31:05 +02:00
|
|
|
void on_read_message_reactions(DialogId dialog_id, vector<MessageId> &&message_ids, Result<Unit> &&result);
|
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
void set_dialog_available_reactions(Dialog *d, ChatReactions &&available_reactions);
|
2022-01-04 14:33:57 +01:00
|
|
|
|
2022-04-11 15:01:30 +02:00
|
|
|
void set_dialog_next_available_reactions_generation(Dialog *d, uint32 generation);
|
2022-02-15 21:25:00 +01:00
|
|
|
|
2022-02-15 15:11:29 +01:00
|
|
|
void hide_dialog_message_reactions(Dialog *d);
|
2022-01-26 11:49:17 +01:00
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
ChatReactions get_active_reactions(const ChatReactions &available_reactions) const;
|
2022-01-19 16:59:48 +01:00
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
ChatReactions get_dialog_active_reactions(const Dialog *d) const;
|
2022-01-19 16:10:16 +01:00
|
|
|
|
2022-09-02 17:59:15 +02:00
|
|
|
ChatReactions get_message_active_reactions(const Dialog *d, const Message *m) const;
|
2022-01-27 16:17:29 +01:00
|
|
|
|
2022-03-07 13:20:22 +01:00
|
|
|
static bool need_poll_dialog_message_reactions(const Dialog *d);
|
|
|
|
|
|
|
|
static bool need_poll_message_reactions(const Dialog *d, const Message *m);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void queue_message_reactions_reload(MessageFullId message_full_id);
|
2022-02-16 15:09:26 +01:00
|
|
|
|
2022-03-07 12:27:42 +01:00
|
|
|
void queue_message_reactions_reload(DialogId dialog_id, const vector<MessageId> &message_ids);
|
2022-02-16 15:09:26 +01:00
|
|
|
|
2024-05-19 20:22:51 +02:00
|
|
|
void on_get_message_fact_checks(DialogId dialog_id, const vector<MessageId> &message_ids,
|
|
|
|
Result<vector<telegram_api::object_ptr<telegram_api::factCheck>>> r_fact_checks);
|
|
|
|
|
2018-03-12 21:33:56 +01:00
|
|
|
void on_send_dialog_action_timeout(DialogId dialog_id);
|
|
|
|
|
2021-11-23 12:29:49 +01:00
|
|
|
void cancel_dialog_action(DialogId dialog_id, const Message *m);
|
2018-03-14 19:36:28 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Dialog *get_dialog_by_message_id(MessageId message_id);
|
|
|
|
|
2018-08-05 00:29:53 +02:00
|
|
|
MessageId get_message_id_by_random_id(Dialog *d, int64 random_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-11 11:12:43 +02:00
|
|
|
Dialog *add_dialog_for_new_message(DialogId dialog_id, bool have_last_message, bool *need_update_dialog_pos,
|
|
|
|
const char *source);
|
|
|
|
|
2021-04-07 22:35:09 +02:00
|
|
|
Dialog *add_dialog(DialogId dialog_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-08-04 15:30:14 +02:00
|
|
|
Dialog *add_new_dialog(unique_ptr<Dialog> &&dialog, bool is_loaded_from_database, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-11-01 13:19:03 +01:00
|
|
|
void fix_new_dialog(Dialog *d, unique_ptr<DraftMessage> &&draft_message, unique_ptr<Message> &&last_database_message,
|
|
|
|
MessageId last_database_message_id, int64 order, int32 last_clear_history_date,
|
|
|
|
MessageId last_clear_history_message_id, DialogId default_join_group_call_as_dialog_id,
|
|
|
|
DialogId default_send_message_as_dialog_id, bool need_drop_default_send_message_as_dialog_id,
|
|
|
|
bool is_loaded_from_database, const char *source);
|
2018-02-13 22:17:00 +01:00
|
|
|
|
2023-11-01 13:19:03 +01:00
|
|
|
bool add_pending_dialog_data(Dialog *d, unique_ptr<Message> &&last_database_message,
|
|
|
|
unique_ptr<DraftMessage> &&draft_message);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-11-23 05:45:32 +01:00
|
|
|
void fix_dialog_action_bar(const Dialog *d, DialogActionBar *action_bar);
|
2019-10-10 22:19:26 +02:00
|
|
|
|
2024-04-08 01:37:52 +02:00
|
|
|
void fix_dialog_business_bot_manage_bar(DialogId dialog_id, BusinessBotManageBar *business_bot_manage_bar);
|
|
|
|
|
2021-11-22 22:24:18 +01:00
|
|
|
td_api::object_ptr<td_api::ChatActionBar> get_chat_action_bar_object(const Dialog *d) const;
|
2019-10-10 22:19:26 +02:00
|
|
|
|
2024-04-08 01:37:52 +02:00
|
|
|
td_api::object_ptr<td_api::businessBotManageBar> get_business_bot_manage_bar_object(const Dialog *d) const;
|
|
|
|
|
2023-04-10 17:45:26 +02:00
|
|
|
td_api::object_ptr<td_api::chatBackground> get_chat_background_object(const Dialog *d) const;
|
2023-04-10 16:23:21 +02:00
|
|
|
|
2021-08-27 19:36:40 +02:00
|
|
|
string get_dialog_theme_name(const Dialog *d) const;
|
|
|
|
|
2021-10-26 19:51:06 +02:00
|
|
|
td_api::object_ptr<td_api::chatJoinRequestsInfo> get_chat_join_requests_info_object(const Dialog *d) const;
|
|
|
|
|
2021-10-14 14:44:21 +02:00
|
|
|
td_api::object_ptr<td_api::videoChat> get_video_chat_object(const Dialog *d) const;
|
2021-03-08 15:00:39 +01:00
|
|
|
|
2021-12-21 11:49:26 +01:00
|
|
|
td_api::object_ptr<td_api::MessageSender> get_default_message_sender_object(const Dialog *d) const;
|
2021-11-12 14:15:19 +01:00
|
|
|
|
2024-03-29 09:19:50 +01:00
|
|
|
td_api::object_ptr<td_api::chat> get_chat_object(const Dialog *d, const char *source) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
Dialog *get_dialog(DialogId dialog_id);
|
|
|
|
const Dialog *get_dialog(DialogId dialog_id) const;
|
|
|
|
|
2021-04-07 23:39:41 +02:00
|
|
|
Dialog *get_dialog_force(DialogId dialog_id, const char *source = "get_dialog_force");
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
Dialog *on_load_dialog_from_database(DialogId dialog_id, BufferSlice &&value, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-15 03:15:46 +02:00
|
|
|
void on_get_dialogs_from_database(FolderId folder_id, int32 limit, DialogDbGetDialogsResult &&dialogs,
|
2019-08-22 17:24:02 +02:00
|
|
|
Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-04-15 16:28:13 +02:00
|
|
|
Result<Dialog *> check_dialog_access(DialogId dialog_id, bool allow_secret_chats, AccessRights access_rights,
|
|
|
|
const char *source);
|
|
|
|
|
2021-01-20 13:02:45 +01:00
|
|
|
void send_get_dialog_query(DialogId dialog_id, Promise<Unit> &&promise, uint64 log_event_id, const char *source);
|
2018-01-16 17:04:36 +01:00
|
|
|
|
|
|
|
void send_search_public_dialogs_query(const string &query, Promise<Unit> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
vector<DialogId> get_pinned_dialog_ids(DialogListId dialog_list_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-02-09 21:23:18 +01:00
|
|
|
bool set_folder_pinned_dialogs(FolderId folder_id, vector<DialogId> old_dialog_ids, vector<DialogId> new_dialog_ids);
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
void reload_pinned_dialogs(DialogListId dialog_list_id, Promise<Unit> &&promise);
|
2019-08-06 00:02:09 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void update_dialogs_hints(const Dialog *d);
|
|
|
|
void update_dialogs_hints_rating(const Dialog *d);
|
|
|
|
|
2020-05-21 02:48:54 +02:00
|
|
|
vector<FolderId> get_dialog_list_folder_ids(const DialogList &list) const;
|
|
|
|
|
2020-05-21 03:40:04 +02:00
|
|
|
bool has_dialogs_from_folder(const DialogList &list, const DialogFolder &folder) const;
|
2020-05-20 02:04:52 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static bool is_dialog_in_list(const Dialog *d, DialogListId dialog_list_id);
|
2020-05-28 00:15:34 +02:00
|
|
|
|
2024-02-23 11:38:51 +01:00
|
|
|
void add_dialog_to_list(Dialog *d, DialogListId dialog_list_id);
|
2020-05-28 00:15:34 +02:00
|
|
|
|
2024-02-23 11:38:51 +01:00
|
|
|
void remove_dialog_from_list(Dialog *d, DialogListId dialog_list_id);
|
2020-05-20 02:10:30 +02:00
|
|
|
|
2023-03-27 17:34:25 +02:00
|
|
|
DialogFilterDialogInfo get_dialog_info_for_dialog_filter(const Dialog *d) const;
|
2020-05-26 15:21:26 +02:00
|
|
|
|
2020-05-20 02:10:30 +02:00
|
|
|
bool need_dialog_in_list(const Dialog *d, const DialogList &list) const;
|
2020-05-12 00:57:17 +02:00
|
|
|
|
2020-06-01 22:09:35 +02:00
|
|
|
static bool need_send_update_chat_position(const DialogPositionInList &old_position,
|
|
|
|
const DialogPositionInList &new_position);
|
2020-05-29 02:16:56 +02:00
|
|
|
|
2020-06-01 22:09:35 +02:00
|
|
|
DialogPositionInList get_dialog_position_in_list(const DialogList *list, const Dialog *d, bool actual = false) const;
|
2020-05-09 22:39:11 +02:00
|
|
|
|
2022-02-10 16:03:03 +01:00
|
|
|
std::unordered_map<DialogListId, DialogPositionInList, DialogListIdHash> get_dialog_positions(const Dialog *d) const;
|
2020-05-09 22:39:11 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static vector<DialogListId> get_dialog_list_ids(const Dialog *d);
|
|
|
|
|
2020-05-04 00:47:26 +02:00
|
|
|
DialogListView get_dialog_lists(const Dialog *d);
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogList &add_dialog_list(DialogListId dialog_list_id);
|
2020-05-15 15:32:07 +02:00
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogList *get_dialog_list(DialogListId dialog_list_id);
|
|
|
|
const DialogList *get_dialog_list(DialogListId dialog_list_id) const;
|
2019-08-22 17:24:02 +02:00
|
|
|
|
2020-05-21 03:40:04 +02:00
|
|
|
DialogFolder *get_dialog_folder(FolderId folder_id);
|
|
|
|
const DialogFolder *get_dialog_folder(FolderId folder_id) const;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static Message *get_message(Dialog *d, MessageId message_id);
|
|
|
|
static const Message *get_message(const Dialog *d, MessageId message_id);
|
2023-07-06 19:55:02 +02:00
|
|
|
static const Message *get_message_static(const Dialog *d, MessageId message_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Message *get_message(MessageFullId message_full_id);
|
|
|
|
const Message *get_message(MessageFullId message_full_id) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-16 16:28:33 +02:00
|
|
|
bool have_message_force(Dialog *d, MessageId message_id, const char *source);
|
|
|
|
|
2019-03-11 14:06:21 +01:00
|
|
|
Message *get_message_force(Dialog *d, MessageId message_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
Message *get_message_force(MessageFullId message_full_id, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-02-08 13:54:25 +01:00
|
|
|
void get_message_force_from_server(Dialog *d, MessageId message_id, Promise<Unit> &&promise,
|
|
|
|
tl_object_ptr<telegram_api::InputMessage> input_message = nullptr);
|
2018-02-07 00:31:38 +01:00
|
|
|
|
2022-11-09 18:35:22 +01:00
|
|
|
Message *on_get_message_from_database(const MessageDbMessage &message, bool is_scheduled, const char *source);
|
2021-10-01 10:36:32 +02:00
|
|
|
|
2022-11-09 18:35:22 +01:00
|
|
|
Message *on_get_message_from_database(Dialog *d, const MessageDbDialogMessage &message, bool is_scheduled,
|
2021-10-01 11:55:12 +02:00
|
|
|
const char *source);
|
|
|
|
|
2022-02-15 23:39:20 +01:00
|
|
|
Message *on_get_message_from_database(Dialog *d, MessageId message_id, const BufferSlice &value, bool is_scheduled,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-28 21:44:27 +02:00
|
|
|
vector<MessageId> on_get_messages_from_database(Dialog *d, vector<MessageDbDialogMessage> &&messages,
|
|
|
|
MessageId first_message_id, bool &have_error, const char *source);
|
|
|
|
|
2024-05-11 23:48:28 +02:00
|
|
|
void get_dialog_message_by_date_from_server(const Dialog *d, int32 date, bool after_database_search,
|
|
|
|
Promise<td_api::object_ptr<td_api::message>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-11 23:48:28 +02:00
|
|
|
void on_get_dialog_message_by_date_from_database(DialogId dialog_id, int32 date,
|
|
|
|
Result<MessageDbDialogMessage> result,
|
|
|
|
Promise<td_api::object_ptr<td_api::message>> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
std::pair<bool, int32> get_dialog_mute_until(DialogId dialog_id, const Dialog *d) const;
|
2022-04-15 17:36:24 +02:00
|
|
|
|
|
|
|
int64 get_dialog_notification_ringtone_id(DialogId dialog_id, const Dialog *d) const;
|
2018-04-09 18:30:27 +02:00
|
|
|
|
|
|
|
DialogNotificationSettings *get_dialog_notification_settings(DialogId dialog_id, bool force);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-04-07 23:28:45 +02:00
|
|
|
vector<FileId> get_message_file_ids(const Message *m) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-06-05 18:54:33 +02:00
|
|
|
void cancel_upload_message_content_files(const MessageContent *content);
|
|
|
|
|
2022-11-21 12:33:19 +01:00
|
|
|
static void cancel_upload_file(FileId file_id, const char *source);
|
2019-02-15 17:54:18 +01:00
|
|
|
|
2019-11-29 13:30:48 +01:00
|
|
|
void cancel_send_message_query(DialogId dialog_id, Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-12-06 18:47:22 +01:00
|
|
|
void cancel_send_deleted_message(DialogId dialog_id, Message *m, bool is_permanently_deleted);
|
2019-11-29 13:52:18 +01:00
|
|
|
|
2020-09-21 00:08:49 +02:00
|
|
|
bool is_discussion_message(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2020-09-12 16:31:20 +02:00
|
|
|
bool has_message_sender_user_id(DialogId dialog_id, const Message *m) const;
|
|
|
|
|
2021-08-05 08:59:43 +02:00
|
|
|
int32 get_message_own_max_media_timestamp(const Message *m) const;
|
|
|
|
|
|
|
|
static int32 get_message_max_media_timestamp(const Message *m);
|
|
|
|
|
2020-03-28 00:35:07 +01:00
|
|
|
static bool get_message_disable_web_page_preview(const Message *m);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static int32 get_message_flags(const Message *m);
|
|
|
|
|
2021-11-25 13:49:51 +01:00
|
|
|
tl_object_ptr<telegram_api::InputPeer> get_send_message_as_input_peer(const Message *m) const;
|
|
|
|
|
2018-06-20 21:18:53 +02:00
|
|
|
void ttl_read_history(Dialog *d, bool is_outgoing, MessageId from_message_id, MessageId till_message_id,
|
|
|
|
double view_date);
|
|
|
|
void ttl_read_history_impl(DialogId dialog_id, bool is_outgoing, MessageId from_message_id, MessageId till_message_id,
|
|
|
|
double view_date);
|
2019-06-11 01:55:07 +02:00
|
|
|
void ttl_on_view(const Dialog *d, Message *m, double view_date, double now);
|
2023-09-06 23:31:05 +02:00
|
|
|
bool ttl_on_open(Dialog *d, Message *m, double now, bool is_local_read, int32 read_date);
|
2019-06-11 01:55:07 +02:00
|
|
|
void ttl_register_message(DialogId dialog_id, const Message *m, double now);
|
2021-02-08 21:41:17 +01:00
|
|
|
void ttl_unregister_message(DialogId dialog_id, const Message *m, const char *source);
|
2021-02-09 15:51:20 +01:00
|
|
|
void ttl_period_register_message(DialogId dialog_id, const Message *m, double server_time);
|
2021-02-08 21:41:17 +01:00
|
|
|
void ttl_period_unregister_message(DialogId dialog_id, const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
void ttl_loop(double now);
|
|
|
|
void ttl_update_timeout(double now);
|
2018-01-05 19:37:07 +01:00
|
|
|
|
2019-01-10 18:54:46 +01:00
|
|
|
void on_message_ttl_expired(Dialog *d, Message *m);
|
2023-06-06 23:57:27 +02:00
|
|
|
|
|
|
|
void on_message_ttl_expired_impl(Dialog *d, Message *m, bool is_message_in_dialog);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void start_up() final;
|
2021-11-07 13:20:15 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void loop() final;
|
2021-11-07 13:20:15 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void tear_down() final;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-11-07 13:20:15 +01:00
|
|
|
void hangup() final;
|
|
|
|
|
2024-01-25 15:33:11 +01:00
|
|
|
void create_folders(int source);
|
2023-05-15 12:28:23 +02:00
|
|
|
|
2019-01-05 23:25:09 +01:00
|
|
|
void init();
|
|
|
|
|
2023-05-15 12:04:03 +02:00
|
|
|
void ttl_db_loop();
|
2023-05-15 12:28:23 +02:00
|
|
|
|
|
|
|
void ttl_db_on_result(Result<std::vector<MessageDbMessage>> r_result, bool dummy);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_restore_missing_message_after_get_difference(MessageFullId message_full_id, MessageId old_message_id,
|
2022-08-21 09:08:09 +02:00
|
|
|
Result<Unit> result);
|
2022-08-21 06:24:53 +02:00
|
|
|
|
2023-09-15 17:20:21 +02:00
|
|
|
void on_get_message_link_dialog(MessageLinkInfo &&info, DialogId dialog_id, Promise<MessageLinkInfo> &&promise);
|
2019-08-05 11:12:59 +02:00
|
|
|
|
2020-09-18 03:14:59 +02:00
|
|
|
void on_get_message_link_message(MessageLinkInfo &&info, DialogId dialog_id, Promise<MessageLinkInfo> &&promise);
|
|
|
|
|
|
|
|
void on_get_message_link_discussion_message(MessageLinkInfo &&info, DialogId comment_dialog_id,
|
|
|
|
Promise<MessageLinkInfo> &&promise);
|
|
|
|
|
2020-11-07 19:08:45 +01:00
|
|
|
void process_discussion_message_impl(telegram_api::object_ptr<telegram_api::messages_discussionMessage> &&result,
|
|
|
|
DialogId dialog_id, MessageId message_id, DialogId expected_dialog_id,
|
2021-08-13 11:26:47 +02:00
|
|
|
MessageId expected_message_id, Promise<MessageThreadInfo> promise);
|
2020-11-07 19:08:45 +01:00
|
|
|
|
2021-08-13 11:26:47 +02:00
|
|
|
void on_get_discussion_message(DialogId dialog_id, MessageId message_id, MessageThreadInfo &&message_thread_info,
|
2020-11-07 12:35:33 +01:00
|
|
|
Promise<MessageThreadInfo> &&promise);
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
void on_get_message_viewers(DialogId dialog_id, MessageViewers message_viewers, bool is_recursive,
|
|
|
|
Promise<td_api::object_ptr<td_api::messageViewers>> &&promise);
|
2021-09-03 15:14:03 +02:00
|
|
|
|
2020-08-22 09:05:51 +02:00
|
|
|
static MessageId get_first_database_message_id_by_index(const Dialog *d, MessageSearchFilter filter);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-06-08 20:20:11 +02:00
|
|
|
void get_message_calendar_from_server(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
|
|
|
|
MessageId from_message_id, MessageSearchFilter filter,
|
|
|
|
Promise<td_api::object_ptr<td_api::messageCalendar>> &&promise);
|
|
|
|
|
|
|
|
void on_get_message_calendar_from_database(DialogId dialog_id, MessageId from_message_id,
|
2021-11-01 11:50:45 +01:00
|
|
|
MessageId first_db_message_id, MessageSearchFilter filter,
|
2024-06-08 20:20:11 +02:00
|
|
|
Result<MessageDbCalendar> r_calendar,
|
|
|
|
Promise<td_api::object_ptr<td_api::messageCalendar>> promise);
|
2021-11-01 11:50:45 +01:00
|
|
|
|
2022-11-09 18:35:22 +01:00
|
|
|
void on_search_dialog_message_db_result(int64 random_id, DialogId dialog_id, MessageId from_message_id,
|
|
|
|
MessageId first_db_message_id, MessageSearchFilter filter, int32 offset,
|
|
|
|
int32 limit, Result<vector<MessageDbDialogMessage>> r_messages,
|
|
|
|
Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-11 20:54:21 +02:00
|
|
|
void on_message_db_fts_result(Result<MessageDbFtsResult> result, string offset, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-06-13 14:09:20 +02:00
|
|
|
void on_message_db_calls_result(Result<MessageDbCallsResult> result, MessageId first_db_message_id,
|
|
|
|
MessageId offset_message_id, int32 limit, MessageSearchFilter filter,
|
|
|
|
Promise<td_api::object_ptr<td_api::foundMessages>> &&promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void on_load_active_live_location_message_full_ids_from_database(string value);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_load_active_live_location_messages_finished();
|
|
|
|
|
|
|
|
void try_add_active_live_location(DialogId dialog_id, const Message *m);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void add_active_live_location(MessageFullId message_full_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
bool delete_active_live_location(DialogId dialog_id, const Message *m);
|
|
|
|
|
|
|
|
void save_active_live_locations();
|
|
|
|
|
2019-12-16 02:07:14 +01:00
|
|
|
void on_message_live_location_viewed(Dialog *d, const Message *m);
|
|
|
|
|
|
|
|
void view_message_live_location_on_server(int64 task_id);
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
void view_message_live_location_on_server_impl(int64 task_id, MessageFullId message_full_id);
|
2019-12-16 16:39:40 +01:00
|
|
|
|
2019-12-16 02:07:14 +01:00
|
|
|
void on_message_live_location_viewed_on_server(int64 task_id);
|
|
|
|
|
2021-07-22 05:54:43 +02:00
|
|
|
void try_add_bot_command_message_id(DialogId dialog_id, const Message *m);
|
|
|
|
|
|
|
|
void delete_bot_command_message_id(DialogId dialog_id, MessageId message_id);
|
|
|
|
|
2019-01-03 16:26:44 +01:00
|
|
|
void add_message_file_sources(DialogId dialog_id, const Message *m);
|
|
|
|
|
|
|
|
void remove_message_file_sources(DialogId dialog_id, const Message *m);
|
|
|
|
|
2019-11-30 16:17:34 +01:00
|
|
|
void change_message_files(DialogId dialog_id, const Message *m, const vector<FileId> &old_file_ids);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Result<unique_ptr<ReplyMarkup>> get_dialog_reply_markup(
|
2024-01-11 18:35:02 +01:00
|
|
|
DialogId dialog_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup) const TD_WARN_UNUSED_RESULT;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-11-16 11:59:32 +01:00
|
|
|
bool get_dialog_view_as_topics(const Dialog *d) const;
|
|
|
|
|
2020-02-27 20:39:06 +01:00
|
|
|
bool get_dialog_has_scheduled_messages(const Dialog *d) const;
|
2019-03-20 13:28:06 +01:00
|
|
|
|
2023-03-16 18:10:54 +01:00
|
|
|
static DialogScheduledMessages *add_dialog_scheduled_messages(Dialog *d);
|
|
|
|
|
2023-03-16 20:38:29 +01:00
|
|
|
static NotificationInfo *add_dialog_notification_info(Dialog *d);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static int64 get_dialog_order(MessageId message_id, int32 message_date);
|
|
|
|
|
2020-03-19 23:15:15 +01:00
|
|
|
bool is_dialog_sponsored(const Dialog *d) const;
|
|
|
|
|
2020-05-09 22:51:14 +02:00
|
|
|
int64 get_dialog_base_order(const Dialog *d) const;
|
2020-05-04 15:33:42 +02:00
|
|
|
|
|
|
|
int64 get_dialog_private_order(const DialogList *list, const Dialog *d) const;
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
td_api::object_ptr<td_api::chatPosition> get_chat_position_object(DialogListId dialog_list_id, const Dialog *d) const;
|
2020-05-08 14:48:25 +02:00
|
|
|
|
|
|
|
vector<td_api::object_ptr<td_api::chatPosition>> get_chat_positions_object(const Dialog *d) const;
|
2019-08-20 19:25:38 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool update_dialog_draft_message(Dialog *d, unique_ptr<DraftMessage> &&draft_message, bool from_update,
|
|
|
|
bool need_update_dialog_pos);
|
|
|
|
|
2024-01-31 00:47:43 +01:00
|
|
|
void clear_dialog_draft_by_sent_message(Dialog *d, const Message *m, bool need_update_dialog_pos);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void save_dialog_draft_message_on_server(DialogId dialog_id);
|
|
|
|
|
|
|
|
void on_saved_dialog_draft_message(DialogId dialog_id, uint64 generation);
|
|
|
|
|
2018-04-28 21:31:42 +02:00
|
|
|
void update_dialog_notification_settings_on_server(DialogId dialog_id, bool from_binlog);
|
2018-04-28 20:05:04 +02:00
|
|
|
|
2020-02-12 23:22:25 +01:00
|
|
|
void send_update_dialog_notification_settings_query(const Dialog *d, Promise<Unit> &&promise);
|
2018-10-02 01:40:34 +02:00
|
|
|
|
2018-04-28 21:50:12 +02:00
|
|
|
void on_updated_dialog_notification_settings(DialogId dialog_id, uint64 generation);
|
|
|
|
|
2020-09-22 01:15:09 +02:00
|
|
|
void reset_all_notification_settings_on_server(uint64 log_event_id);
|
2018-04-28 20:05:04 +02:00
|
|
|
|
2021-09-24 09:42:39 +02:00
|
|
|
void toggle_dialog_report_spam_state_on_server(DialogId dialog_id, bool is_spam_dialog, uint64 log_event_id,
|
2018-04-29 07:58:45 +02:00
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2019-08-27 16:23:01 +02:00
|
|
|
void set_dialog_folder_id_on_server(DialogId dialog_id, bool from_binlog);
|
|
|
|
|
|
|
|
void on_updated_dialog_folder_id(DialogId dialog_id, uint64 generation);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 get_next_pinned_dialog_order();
|
|
|
|
|
2020-05-09 22:39:11 +02:00
|
|
|
void update_dialog_pos(Dialog *d, const char *source, bool need_send_update = true,
|
2020-03-18 17:41:18 +01:00
|
|
|
bool is_loaded_from_database = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-05-09 22:39:11 +02:00
|
|
|
bool set_dialog_order(Dialog *d, int64 new_order, bool need_send_update, bool is_loaded_from_database,
|
2018-11-17 23:42:15 +01:00
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-02-10 16:03:03 +01:00
|
|
|
void update_dialog_lists(Dialog *d,
|
|
|
|
std::unordered_map<DialogListId, DialogPositionInList, DialogListIdHash> &&old_positions,
|
2020-05-09 22:39:11 +02:00
|
|
|
bool need_send_update, bool is_loaded_from_database, const char *source);
|
|
|
|
|
2019-08-22 17:24:02 +02:00
|
|
|
void update_last_dialog_date(FolderId folder_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-06-07 22:07:46 +02:00
|
|
|
bool do_update_list_last_pinned_dialog_date(DialogList &list) const;
|
|
|
|
|
2020-06-07 22:59:16 +02:00
|
|
|
void update_list_last_pinned_dialog_date(DialogList &list);
|
2020-05-25 23:47:26 +02:00
|
|
|
|
2020-06-07 22:22:33 +02:00
|
|
|
bool do_update_list_last_dialog_date(DialogList &list, const vector<FolderId> &folder_ids) const;
|
|
|
|
|
2020-06-07 22:59:16 +02:00
|
|
|
void update_list_last_dialog_date(DialogList &list);
|
2020-05-20 02:04:52 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static string get_channel_pts_key(DialogId dialog_id);
|
|
|
|
|
|
|
|
int32 load_channel_pts(DialogId dialog_id) const;
|
|
|
|
|
2019-08-27 23:27:12 +02:00
|
|
|
void set_channel_pts(Dialog *d, int32 new_pts, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-11-07 19:08:45 +01:00
|
|
|
bool need_channel_difference_to_add_message(DialogId dialog_id,
|
|
|
|
const tl_object_ptr<telegram_api::Message> &message_ptr);
|
|
|
|
|
2024-03-28 16:58:45 +01:00
|
|
|
bool need_channel_difference_to_add_message(DialogId dialog_id, MessageId message_id);
|
|
|
|
|
2023-11-17 15:42:28 +01:00
|
|
|
void run_after_channel_difference(DialogId dialog_id, MessageId expected_max_message_id, Promise<Unit> &&promise,
|
|
|
|
const char *source);
|
2020-11-07 19:08:45 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool running_get_channel_difference(DialogId dialog_id) const;
|
|
|
|
|
2023-07-23 19:42:30 +02:00
|
|
|
void retry_get_channel_difference_later(DialogId dialog_id);
|
|
|
|
|
2019-08-29 02:16:49 +02:00
|
|
|
void on_channel_get_difference_timeout(DialogId dialog_id);
|
|
|
|
|
2023-05-22 18:19:36 +02:00
|
|
|
void update_expected_channel_pts(DialogId dialog_id, int32 expected_pts);
|
2023-05-22 17:23:40 +02:00
|
|
|
|
2023-05-22 18:19:36 +02:00
|
|
|
void update_expected_channel_max_message_id(DialogId dialog_id, MessageId expected_max_message_id);
|
|
|
|
|
|
|
|
void schedule_get_channel_difference(DialogId dialog_id, int32 expected_pts, MessageId expected_max_message_id,
|
2023-07-04 14:23:39 +02:00
|
|
|
double delay, const char *source);
|
2023-05-22 18:19:36 +02:00
|
|
|
|
|
|
|
void get_channel_difference(DialogId dialog_id, int32 pts, int32 expected_pts, MessageId expected_max_message_id,
|
|
|
|
bool force, const char *source, bool is_old = false);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void do_get_channel_difference(DialogId dialog_id, int32 pts, bool force,
|
2022-11-23 11:21:46 +01:00
|
|
|
tl_object_ptr<telegram_api::InputChannel> &&input_channel, bool is_old,
|
|
|
|
const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-23 13:57:04 +02:00
|
|
|
void process_pending_get_channel_differences();
|
|
|
|
|
2021-07-31 03:55:05 +02:00
|
|
|
void process_get_channel_difference_updates(DialogId dialog_id, int32 new_pts,
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&new_messages,
|
|
|
|
vector<tl_object_ptr<telegram_api::Update>> &&other_updates);
|
|
|
|
|
|
|
|
void on_get_channel_dialog(DialogId dialog_id, MessageId last_message_id, MessageId read_inbox_max_message_id,
|
2022-01-28 16:39:13 +01:00
|
|
|
int32 server_unread_count, int32 unread_mention_count, int32 unread_reaction_count,
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId read_outbox_max_message_id,
|
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&messages);
|
|
|
|
|
|
|
|
void after_get_channel_difference(DialogId dialog_id, bool success);
|
|
|
|
|
|
|
|
static void on_channel_get_difference_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
|
|
|
static void on_pending_message_views_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2019-12-16 16:39:40 +01:00
|
|
|
static void on_pending_message_live_location_view_timeout_callback(void *messages_manager_ptr, int64 task_id);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static void on_pending_draft_message_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2018-05-03 14:36:05 +02:00
|
|
|
static void on_pending_read_history_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static void on_pending_updated_dialog_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
|
|
|
static void on_pending_unload_dialog_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2018-02-23 16:35:36 +01:00
|
|
|
static void on_dialog_unmute_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2018-03-12 21:33:56 +01:00
|
|
|
static void on_pending_send_dialog_action_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2020-05-21 02:39:45 +02:00
|
|
|
static void on_preload_folder_dialog_list_timeout_callback(void *messages_manager_ptr, int64 folder_id_int);
|
2019-08-22 17:24:02 +02:00
|
|
|
|
2022-03-07 13:20:22 +01:00
|
|
|
static void on_update_viewed_messages_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2023-05-01 14:33:51 +02:00
|
|
|
static void on_send_update_chat_read_inbox_timeout_callback(void *messages_manager_ptr, int64 dialog_id_int);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void load_secret_thumbnail(FileId thumbnail_file_id);
|
|
|
|
|
|
|
|
void on_upload_media(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
|
|
|
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_encrypted_file);
|
|
|
|
void on_upload_media_error(FileId file_id, Status status);
|
|
|
|
|
|
|
|
void on_load_secret_thumbnail(FileId thumbnail_file_id, BufferSlice thumbnail);
|
|
|
|
void on_upload_thumbnail(FileId thumbnail_file_id, tl_object_ptr<telegram_api::InputFile> thumbnail_input_file);
|
|
|
|
|
2020-04-28 15:25:56 +02:00
|
|
|
void add_sponsored_dialog(const Dialog *d, DialogSource source);
|
2020-04-02 02:03:17 +02:00
|
|
|
|
2020-04-28 15:25:56 +02:00
|
|
|
void save_sponsored_dialog();
|
|
|
|
|
|
|
|
void set_sponsored_dialog(DialogId dialog_id, DialogSource source);
|
2018-05-08 22:02:15 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Dialog *get_service_notifications_dialog();
|
|
|
|
|
2023-04-28 13:44:35 +02:00
|
|
|
static void extract_authentication_codes(DialogId dialog_id, const Message *m, vector<string> &authentication_codes);
|
|
|
|
|
2020-02-13 01:03:50 +01:00
|
|
|
void save_auth_notification_ids();
|
|
|
|
|
2023-05-03 13:34:06 +02:00
|
|
|
MessageId get_next_message_id(Dialog *d, MessageType type) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-03 13:34:06 +02:00
|
|
|
MessageId get_next_local_message_id(Dialog *d) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-03 13:34:06 +02:00
|
|
|
MessageId get_next_yet_unsent_message_id(Dialog *d) const;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-02-29 18:36:49 +01:00
|
|
|
static MessageId get_next_yet_unsent_scheduled_message_id(Dialog *d, int32 date);
|
2019-12-02 21:29:08 +01:00
|
|
|
|
2019-11-30 18:22:44 +01:00
|
|
|
void reget_message_from_server_if_needed(DialogId dialog_id, const Message *m);
|
|
|
|
|
2021-04-11 04:37:53 +02:00
|
|
|
void speculatively_update_active_group_call_id(Dialog *d, const Message *m);
|
|
|
|
|
2019-11-30 17:41:23 +01:00
|
|
|
void speculatively_update_channel_participants(DialogId dialog_id, const Message *m);
|
|
|
|
|
2019-11-30 18:04:49 +01:00
|
|
|
void update_sent_message_contents(DialogId dialog_id, const Message *m);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void update_used_hashtags(DialogId dialog_id, const Message *m);
|
|
|
|
|
2019-11-30 17:29:52 +01:00
|
|
|
void update_top_dialogs(DialogId dialog_id, const Message *m);
|
|
|
|
|
2020-12-28 14:21:39 +01:00
|
|
|
void update_forward_count(DialogId dialog_id, const Message *m);
|
|
|
|
|
2023-10-09 19:44:44 +02:00
|
|
|
void update_forward_count(MessageFullId message_full_id, int32 update_date);
|
2020-08-01 04:54:39 +02:00
|
|
|
|
2021-11-23 10:10:49 +01:00
|
|
|
void update_has_outgoing_messages(DialogId dialog_id, const Message *m);
|
2020-07-10 11:44:02 +02:00
|
|
|
|
2020-08-19 23:00:42 +02:00
|
|
|
string get_message_search_text(const Message *m) const;
|
2018-09-27 21:44:40 +02:00
|
|
|
|
2022-02-15 23:39:20 +01:00
|
|
|
unique_ptr<Message> parse_message(Dialog *d, MessageId expected_message_id, const BufferSlice &value,
|
|
|
|
bool is_scheduled);
|
2018-10-25 17:00:49 +02:00
|
|
|
|
2021-04-12 05:04:43 +02:00
|
|
|
unique_ptr<Dialog> parse_dialog(DialogId dialog_id, const BufferSlice &value, const char *source);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void load_calls_db_state();
|
|
|
|
void save_calls_db_state();
|
|
|
|
|
2021-12-22 18:15:18 +01:00
|
|
|
void add_message_dependencies(Dependencies &dependencies, const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static void save_send_message_log_event(DialogId dialog_id, const Message *m);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_toggle_dialog_report_spam_state_on_server_log_event(DialogId dialog_id, bool is_spam_dialog);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
static uint64 save_delete_messages_on_server_log_event(DialogId dialog_id, const vector<MessageId> &message_ids,
|
|
|
|
bool revoke);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
static uint64 save_delete_scheduled_messages_on_server_log_event(DialogId dialog_id,
|
|
|
|
const vector<MessageId> &message_ids);
|
2019-11-29 13:03:03 +01:00
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
static uint64 save_delete_dialog_history_on_server_log_event(DialogId dialog_id, MessageId max_message_id,
|
|
|
|
bool remove_from_dialog_list, bool revoke);
|
2021-01-19 11:21:50 +01:00
|
|
|
|
2022-10-29 23:35:37 +02:00
|
|
|
static uint64 save_delete_topic_history_on_server_log_event(DialogId dialog_id, MessageId top_thread_message_id);
|
|
|
|
|
2021-10-27 14:38:09 +02:00
|
|
|
static uint64 save_delete_all_call_messages_on_server_log_event(bool revoke);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-23 20:17:00 +02:00
|
|
|
static uint64 save_block_message_sender_from_replies_on_server_log_event(MessageId message_id,
|
|
|
|
bool need_delete_message,
|
|
|
|
bool need_delete_all_messages,
|
|
|
|
bool report_spam);
|
2020-09-24 14:29:34 +02:00
|
|
|
|
2021-11-19 13:48:05 +01:00
|
|
|
static uint64 save_delete_all_channel_messages_by_sender_on_server_log_event(ChannelId channel_id,
|
|
|
|
DialogId sender_dialog_id);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-25 19:39:22 +02:00
|
|
|
static uint64 save_delete_dialog_messages_by_date_on_server_log_event(DialogId dialog_id, int32 min_date,
|
|
|
|
int32 max_date, bool revoke);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_read_all_dialog_mentions_on_server_log_event(DialogId dialog_id);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2022-01-30 10:37:24 +01:00
|
|
|
static uint64 save_read_all_dialog_reactions_on_server_log_event(DialogId dialog_id);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_toggle_dialog_is_pinned_on_server_log_event(DialogId dialog_id, bool is_pinned);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_reorder_pinned_dialogs_on_server_log_event(FolderId folder_id, const vector<DialogId> &dialog_ids);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2023-11-16 14:57:18 +01:00
|
|
|
static uint64 save_toggle_dialog_view_as_messages_on_server_log_event(DialogId dialog_id, bool view_as_messages);
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_toggle_dialog_is_marked_as_unread_on_server_log_event(DialogId dialog_id,
|
|
|
|
bool is_marked_as_unread);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2023-01-20 10:38:25 +01:00
|
|
|
static uint64 save_toggle_dialog_is_translatable_on_server_log_event(DialogId dialog_id, bool is_translatable);
|
|
|
|
|
2023-07-28 16:33:47 +02:00
|
|
|
static uint64 save_toggle_dialog_is_blocked_on_server_log_event(DialogId dialog_id, bool is_blocked,
|
|
|
|
bool is_blocked_for_stories);
|
2020-09-20 02:00:01 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_read_message_contents_on_server_log_event(DialogId dialog_id,
|
|
|
|
const vector<MessageId> &message_ids);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_reset_all_notification_settings_on_server_log_event();
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-27 14:27:09 +02:00
|
|
|
static uint64 save_reget_dialog_log_event(DialogId dialog_id);
|
2018-10-02 01:01:17 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_forward_messages_log_event(DialogId to_dialog_id, DialogId from_dialog_id,
|
2022-05-08 22:54:04 +02:00
|
|
|
const vector<Message *> &messages, const vector<MessageId> &message_ids,
|
|
|
|
bool drop_author, bool drop_media_captions);
|
2018-10-02 01:40:34 +02:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static uint64 save_unpin_all_dialog_messages_on_server_log_event(DialogId dialog_id);
|
2020-10-23 00:56:06 +02:00
|
|
|
|
2023-03-16 15:54:33 +01:00
|
|
|
void suffix_load_loop(const Dialog *d, SuffixLoadQueries *queries);
|
|
|
|
void suffix_load_update_first_message_id(const Dialog *d, SuffixLoadQueries *queries);
|
2018-12-31 20:04:05 +01:00
|
|
|
void suffix_load_query_ready(DialogId dialog_id);
|
2022-10-07 00:28:18 +02:00
|
|
|
void suffix_load_add_query(Dialog *d, std::pair<Promise<Unit>, std::function<bool(const Message *)>> query);
|
|
|
|
void suffix_load_till_date(Dialog *d, int32 date, Promise<Unit> promise);
|
|
|
|
void suffix_load_till_message_id(Dialog *d, MessageId message_id, Promise<Unit> promise);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-10-12 09:56:01 +02:00
|
|
|
bool is_deleted_secret_chat(const Dialog *d) const;
|
|
|
|
|
2019-12-03 18:26:09 +01:00
|
|
|
static int32 get_message_schedule_date(const Message *m);
|
|
|
|
|
2024-01-11 17:36:00 +01:00
|
|
|
static int32 get_message_original_date(const Message *m);
|
|
|
|
|
2020-11-07 22:38:13 +01:00
|
|
|
static DialogId get_message_original_sender(const Message *m);
|
|
|
|
|
2021-11-19 15:12:22 +01:00
|
|
|
static DialogId get_message_sender(const Message *m);
|
|
|
|
|
2021-09-13 19:34:57 +02:00
|
|
|
RecentDialogList recently_found_dialogs_;
|
2021-09-14 13:18:37 +02:00
|
|
|
RecentDialogList recently_opened_dialogs_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
class UploadMediaCallback;
|
|
|
|
class UploadThumbnailCallback;
|
|
|
|
|
|
|
|
std::shared_ptr<UploadMediaCallback> upload_media_callback_;
|
|
|
|
std::shared_ptr<UploadThumbnailCallback> upload_thumbnail_callback_;
|
|
|
|
|
2021-01-15 23:17:35 +01:00
|
|
|
double last_channel_pts_jump_warning_time_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<FileId, std::pair<MessageFullId, FileId>, FileIdHash>
|
2018-12-31 20:04:05 +01:00
|
|
|
being_uploaded_files_; // file_id -> message, thumbnail_file_id
|
|
|
|
struct UploadedThumbnailInfo {
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId message_full_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId file_id; // original file file_id
|
|
|
|
tl_object_ptr<telegram_api::InputFile> input_file; // original file InputFile
|
|
|
|
};
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<FileId, UploadedThumbnailInfo, FileIdHash> being_uploaded_thumbnails_; // thumbnail_file_id -> ...
|
2018-12-31 20:04:05 +01:00
|
|
|
struct UploadedSecretThumbnailInfo {
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId message_full_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId file_id; // original file file_id
|
|
|
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file; // original file InputEncryptedFile
|
|
|
|
};
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<FileId, UploadedSecretThumbnailInfo, FileIdHash>
|
2018-12-31 20:04:05 +01:00
|
|
|
being_loaded_secret_thumbnails_; // thumbnail_file_id -> ...
|
|
|
|
|
|
|
|
// TTL
|
2021-07-04 04:58:54 +02:00
|
|
|
class TtlNode final : private HeapNode {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2021-02-08 21:41:17 +01:00
|
|
|
TtlNode(DialogId dialog_id, MessageId message_id, bool by_ttl_period)
|
2023-09-21 18:11:17 +02:00
|
|
|
: message_full_id_(dialog_id, message_id), by_ttl_period_(by_ttl_period) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId message_full_id_;
|
2021-02-08 21:41:17 +01:00
|
|
|
bool by_ttl_period_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
HeapNode *as_heap_node() const {
|
|
|
|
return const_cast<HeapNode *>(static_cast<const HeapNode *>(this));
|
|
|
|
}
|
|
|
|
static TtlNode *from_heap_node(HeapNode *node) {
|
|
|
|
return static_cast<TtlNode *>(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const TtlNode &other) const {
|
2024-05-14 20:09:58 +02:00
|
|
|
return message_full_id_ == other.message_full_id_ && by_ttl_period_ == other.by_ttl_period_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
struct TtlNodeHash {
|
2022-11-23 17:37:32 +01:00
|
|
|
uint32 operator()(const TtlNode &ttl_node) const {
|
2023-09-21 18:11:17 +02:00
|
|
|
return MessageFullIdHash()(ttl_node.message_full_id_) * 2 + static_cast<uint32>(ttl_node.by_ttl_period_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
std::unordered_set<TtlNode, TtlNodeHash> ttl_nodes_;
|
|
|
|
KHeap<double> ttl_heap_;
|
|
|
|
Slot ttl_slot_;
|
|
|
|
|
2020-08-27 00:52:59 +02:00
|
|
|
enum YieldType : int32 { None, TtlDb }; // None must be first
|
2023-05-15 12:04:03 +02:00
|
|
|
double ttl_db_next_request_time_ = 0;
|
2023-05-15 12:28:23 +02:00
|
|
|
int32 ttl_db_next_limit_ = DEFAULT_LOADED_EXPIRED_MESSAGES;
|
2023-05-15 12:04:03 +02:00
|
|
|
bool ttl_db_has_query_ = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
Slot ttl_db_slot_;
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<int64, MessageFullId> being_sent_messages_; // message_random_id -> message
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<MessageFullId, MessageId, MessageFullIdHash> update_message_ids_; // new_message_id -> temporary_id
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, FlatHashMap<ScheduledServerMessageId, MessageId, ScheduledServerMessageIdHash>,
|
2022-02-07 22:04:34 +01:00
|
|
|
DialogIdHash>
|
2020-04-22 11:48:52 +02:00
|
|
|
update_scheduled_message_ids_; // new_message_id -> temporary_id
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-08-05 00:29:53 +02:00
|
|
|
const char *debug_add_message_to_dialog_fail_reason_ = "";
|
2018-02-02 17:51:24 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct PendingMessageGroupSend {
|
|
|
|
DialogId dialog_id;
|
|
|
|
size_t finished_count = 0;
|
|
|
|
vector<MessageId> message_ids;
|
|
|
|
vector<bool> is_finished;
|
|
|
|
vector<Status> results;
|
|
|
|
};
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<int64, PendingMessageGroupSend> pending_message_group_sends_; // media_album_id -> ...
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-05-19 18:34:48 +02:00
|
|
|
WaitFreeHashMap<MessageId, DialogId, MessageIdHash> message_id_to_dialog_id_;
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<MessageId, DialogId, MessageIdHash> last_clear_history_message_id_to_dialog_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-01-10 15:09:09 +01:00
|
|
|
struct PendingCreatedDialog {
|
2024-04-09 15:19:33 +02:00
|
|
|
td_api::object_ptr<td_api::failedToAddMembers> failed_to_add_members_;
|
|
|
|
Promise<td_api::object_ptr<td_api::createdBasicGroupChat>> chat_promise_;
|
|
|
|
Promise<td_api::object_ptr<td_api::chat>> channel_promise_;
|
2024-01-10 15:09:09 +01:00
|
|
|
};
|
|
|
|
FlatHashMap<DialogId, PendingCreatedDialog, DialogIdHash> pending_created_dialogs_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
bool running_get_difference_ = false; // true after before_get_difference and false after after_get_difference
|
|
|
|
|
2022-08-04 16:38:33 +02:00
|
|
|
WaitFreeHashMap<DialogId, unique_ptr<Dialog>, DialogIdHash> dialogs_;
|
2022-04-25 19:52:44 +02:00
|
|
|
int64 added_message_count_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-03-11 19:38:48 +01:00
|
|
|
FlatHashSet<DialogId, DialogIdHash> loaded_dialogs_; // dialogs loaded from database, but not added to dialogs_
|
2022-12-23 12:28:03 +01:00
|
|
|
FlatHashSet<DialogId, DialogIdHash> failed_to_load_dialogs_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-03-11 19:38:48 +01:00
|
|
|
FlatHashSet<DialogId, DialogIdHash> postponed_chat_read_inbox_updates_;
|
2019-02-27 00:54:15 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<string, vector<Promise<Unit>>> search_public_dialogs_queries_;
|
|
|
|
FlatHashMap<string, vector<DialogId>> found_public_dialogs_; // TODO time bound cache
|
|
|
|
FlatHashMap<string, vector<DialogId>> found_on_server_dialogs_; // TODO time bound cache
|
2018-01-16 17:04:36 +01:00
|
|
|
|
2022-12-28 16:42:11 +01:00
|
|
|
FlatHashMap<int64, FoundDialogMessages> found_dialog_messages_; // random_id -> FoundDialogMessages
|
|
|
|
FlatHashMap<int64, DialogId> found_dialog_messages_dialog_id_; // random_id -> dialog_id
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-08-10 14:58:39 +02:00
|
|
|
struct MessageEmbeddingCodes {
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<MessageId, string, MessageIdHash> embedding_codes_;
|
2020-09-14 00:39:34 +02:00
|
|
|
};
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, MessageEmbeddingCodes, DialogIdHash> message_embedding_codes_[2];
|
2018-01-16 22:27:16 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> get_dialog_queries_;
|
|
|
|
FlatHashMap<DialogId, uint64, DialogIdHash> get_dialog_query_log_event_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<MessageFullId, int32, MessageFullIdHash> replied_by_yet_unsent_messages_;
|
2023-10-25 02:02:26 +02:00
|
|
|
FlatHashMap<MessageFullId, FlatHashSet<MessageFullId, MessageFullIdHash>, MessageFullIdHash>
|
|
|
|
replied_yet_unsent_messages_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
// message_full_id -> replies with media timestamps
|
|
|
|
FlatHashMap<MessageFullId, FlatHashSet<MessageFullId, MessageFullIdHash>, MessageFullIdHash>
|
2023-06-09 13:08:16 +02:00
|
|
|
message_to_replied_media_timestamp_messages_;
|
|
|
|
|
|
|
|
// story_full_id -> replies with media timestamps
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<StoryFullId, FlatHashSet<MessageFullId, MessageFullIdHash>, StoryFullIdHash>
|
2023-06-09 13:08:16 +02:00
|
|
|
story_to_replied_media_timestamp_messages_;
|
2021-08-06 04:55:43 +02:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<NotificationGroupId, DialogId, NotificationGroupIdHash> notification_group_id_to_dialog_id_;
|
2018-11-28 17:21:18 +01:00
|
|
|
|
2018-06-19 01:31:34 +02:00
|
|
|
uint64 current_message_edit_generation_ = 0;
|
|
|
|
|
2020-05-21 18:39:34 +02:00
|
|
|
std::unordered_set<DialogListId, DialogListIdHash> postponed_unread_message_count_updates_;
|
|
|
|
std::unordered_set<DialogListId, DialogListIdHash> postponed_unread_chat_count_updates_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-05-03 00:38:11 +02:00
|
|
|
int64 current_pinned_dialog_order_ = static_cast<int64>(MIN_PINNED_DIALOG_DATE) << 32;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2024-05-14 20:00:59 +02:00
|
|
|
int64 current_dialog_list_unique_id_ = 0;
|
2022-02-10 16:03:03 +01:00
|
|
|
std::unordered_map<DialogListId, DialogList, DialogListIdHash> dialog_lists_;
|
|
|
|
std::unordered_map<FolderId, DialogFolder, FolderIdHash> dialog_folders_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-05-23 13:57:04 +02:00
|
|
|
struct PendingGetChannelDifference {
|
|
|
|
DialogId dialog_id_;
|
|
|
|
int32 pts_ = 0;
|
|
|
|
int32 limit_ = 0;
|
|
|
|
bool force_ = false;
|
|
|
|
telegram_api::object_ptr<telegram_api::InputChannel> input_channel_;
|
|
|
|
const char *source_ = nullptr;
|
|
|
|
|
|
|
|
PendingGetChannelDifference(DialogId dialog_id, int32 pts, int32 limit, bool force,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputChannel> &&input_channel,
|
|
|
|
const char *source)
|
|
|
|
: dialog_id_(dialog_id)
|
|
|
|
, pts_(pts)
|
|
|
|
, limit_(limit)
|
|
|
|
, force_(force)
|
|
|
|
, input_channel_(std::move(input_channel))
|
|
|
|
, source_(source) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
std::queue<unique_ptr<PendingGetChannelDifference>> pending_get_channel_differences_;
|
|
|
|
int32 get_channel_difference_count_ = 0;
|
|
|
|
|
2023-05-22 18:21:42 +02:00
|
|
|
FlatHashMap<DialogId, string, DialogIdHash> active_get_channel_differences_;
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, uint64, DialogIdHash> get_channel_difference_to_log_event_id_;
|
|
|
|
FlatHashMap<DialogId, int32, DialogIdHash> channel_get_difference_retry_timeouts_;
|
|
|
|
FlatHashMap<DialogId, std::multimap<int32, PendingPtsUpdate>, DialogIdHash> postponed_channel_updates_;
|
2022-03-11 19:38:48 +01:00
|
|
|
FlatHashSet<DialogId, DialogIdHash> is_channel_difference_finished_;
|
2023-05-22 18:19:36 +02:00
|
|
|
FlatHashMap<DialogId, int32, DialogIdHash> expected_channel_pts_;
|
|
|
|
FlatHashMap<DialogId, MessageId, DialogIdHash> expected_channel_max_message_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-08-01 19:31:20 +02:00
|
|
|
MultiTimeout channel_get_difference_timeout_{"ChannelGetDifferenceTimeout"};
|
|
|
|
MultiTimeout channel_get_difference_retry_timeout_{"ChannelGetDifferenceRetryTimeout"};
|
|
|
|
MultiTimeout pending_message_views_timeout_{"PendingMessageViewsTimeout"};
|
2019-12-16 16:39:40 +01:00
|
|
|
MultiTimeout pending_message_live_location_view_timeout_{"PendingMessageLiveLocationViewTimeout"};
|
2018-08-01 19:31:20 +02:00
|
|
|
MultiTimeout pending_draft_message_timeout_{"PendingDraftMessageTimeout"};
|
|
|
|
MultiTimeout pending_read_history_timeout_{"PendingReadHistoryTimeout"};
|
|
|
|
MultiTimeout pending_updated_dialog_timeout_{"PendingUpdatedDialogTimeout"};
|
|
|
|
MultiTimeout pending_unload_dialog_timeout_{"PendingUnloadDialogTimeout"};
|
|
|
|
MultiTimeout dialog_unmute_timeout_{"DialogUnmuteTimeout"};
|
|
|
|
MultiTimeout pending_send_dialog_action_timeout_{"PendingSendDialogActionTimeout"};
|
2020-05-21 02:39:45 +02:00
|
|
|
MultiTimeout preload_folder_dialog_list_timeout_{"PreloadFolderDialogListTimeout"};
|
2022-03-07 13:20:22 +01:00
|
|
|
MultiTimeout update_viewed_messages_timeout_{"UpdateViewedMessagesTimeout"};
|
2023-05-01 14:33:51 +02:00
|
|
|
MultiTimeout send_update_chat_read_inbox_timeout_{"SendUpdateChatReadInboxTimeout"};
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-10-12 20:04:18 +02:00
|
|
|
Hints dialogs_hints_; // search dialogs by title and usernames
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashSet<MessageFullId, MessageFullIdHash> active_live_location_message_full_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool are_active_live_location_messages_loaded_ = false;
|
|
|
|
vector<Promise<Unit>> load_active_live_location_messages_queries_;
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> load_scheduled_messages_from_database_queries_;
|
2019-12-04 18:06:39 +01:00
|
|
|
|
2021-08-11 14:59:09 +02:00
|
|
|
struct GetDialogsTask {
|
|
|
|
DialogListId dialog_list_id;
|
2024-05-14 20:00:59 +02:00
|
|
|
int64 dialog_list_unique_id;
|
2021-08-11 14:59:09 +02:00
|
|
|
int32 limit;
|
|
|
|
int32 retry_count;
|
|
|
|
DialogDate last_dialog_date = MIN_DIALOG_DATE;
|
|
|
|
Promise<td_api::object_ptr<td_api::chats>> promise;
|
|
|
|
};
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<int64, GetDialogsTask> get_dialogs_tasks_;
|
2021-08-11 14:59:09 +02:00
|
|
|
int64 current_get_dialogs_task_id_ = 0;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct PendingOnGetDialogs {
|
2019-08-22 17:24:02 +02:00
|
|
|
FolderId folder_id;
|
2019-08-19 03:51:03 +02:00
|
|
|
vector<tl_object_ptr<telegram_api::Dialog>> dialogs;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 total_count;
|
|
|
|
vector<tl_object_ptr<telegram_api::Message>> messages;
|
|
|
|
Promise<Unit> promise;
|
|
|
|
};
|
|
|
|
|
|
|
|
vector<PendingOnGetDialogs> pending_on_get_dialogs_;
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, PendingOnGetDialogs, DialogIdHash> pending_channel_on_get_dialogs_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, vector<Promise<Unit>>, DialogIdHash> run_after_get_channel_difference_;
|
2020-11-07 19:08:45 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
ChangesProcessor<unique_ptr<PendingSecretMessage>> pending_secret_messages_;
|
|
|
|
|
2022-05-17 15:19:39 +02:00
|
|
|
FlatHashMap<DialogId, FlatHashMap<int64, MessageId>, DialogIdHash>
|
|
|
|
pending_secret_message_ids_; // random_id -> message_id
|
|
|
|
|
2023-10-31 21:24:28 +01:00
|
|
|
struct AddDialogData {
|
|
|
|
int32 dependent_dialog_count_ = 0;
|
|
|
|
unique_ptr<Message> last_message_;
|
2023-11-01 13:19:03 +01:00
|
|
|
unique_ptr<DraftMessage> draft_message_;
|
2023-10-31 21:24:28 +01:00
|
|
|
|
|
|
|
AddDialogData() = default;
|
2023-11-01 13:19:03 +01:00
|
|
|
AddDialogData(int32 dependent_dialog_count, unique_ptr<Message> &&last_message,
|
|
|
|
unique_ptr<DraftMessage> &&draft_message);
|
2023-10-31 21:24:28 +01:00
|
|
|
};
|
|
|
|
FlatHashMap<DialogId, vector<DialogId>, DialogIdHash> pending_add_dialog_dependent_dialogs_;
|
|
|
|
FlatHashMap<DialogId, AddDialogData, DialogIdHash> pending_add_dialog_data_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, vector<DialogId>, DialogIdHash>
|
2021-03-08 13:13:36 +01:00
|
|
|
pending_add_default_join_group_call_as_dialog_id_; // dialog_id -> dependent dialogs
|
2021-11-12 14:15:19 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, vector<std::pair<DialogId, bool>>, DialogIdHash>
|
2021-12-20 20:54:20 +01:00
|
|
|
pending_add_default_send_message_as_dialog_id_; // dialog_id -> [dependent dialog, need_drop]
|
2021-03-08 13:13:36 +01:00
|
|
|
|
2021-07-22 05:54:43 +02:00
|
|
|
struct MessageIds {
|
2022-03-11 19:38:48 +01:00
|
|
|
FlatHashSet<MessageId, MessageIdHash> message_ids;
|
2021-07-22 05:54:43 +02:00
|
|
|
};
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, MessageIds, DialogIdHash> dialog_bot_command_message_ids_;
|
2021-07-22 05:54:43 +02:00
|
|
|
|
2018-10-01 00:34:06 +02:00
|
|
|
struct CallsDbState {
|
|
|
|
std::array<MessageId, 2> first_calls_database_message_id_by_index;
|
|
|
|
std::array<int32, 2> message_count_by_index;
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
CallsDbState calls_db_state_;
|
|
|
|
|
2019-12-16 02:07:14 +01:00
|
|
|
int64 viewed_live_location_task_id_ = 0;
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<int64, MessageFullId> viewed_live_location_tasks_; // task_id -> task
|
2023-03-16 14:15:54 +01:00
|
|
|
FlatHashMap<DialogId, FlatHashMap<MessageId, int64, MessageIdHash>, DialogIdHash>
|
|
|
|
pending_viewed_live_locations_; // ... -> task_id
|
2019-12-16 02:07:14 +01:00
|
|
|
|
2023-05-23 16:01:51 +02:00
|
|
|
struct UnsentMediaQueue {
|
|
|
|
DialogId dialog_id_;
|
|
|
|
std::map<MessageId, Promise<Message *>> queue_;
|
|
|
|
};
|
|
|
|
FlatHashMap<uint64, UnsentMediaQueue> yet_unsent_media_queues_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
WaitFreeHashMap<MessageFullId, FileSourceId, MessageFullIdHash> message_full_id_to_file_source_id_;
|
2019-01-18 19:24:03 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, int32, DialogIdHash> last_outgoing_forwarded_message_date_;
|
2019-11-30 17:29:52 +01:00
|
|
|
|
2022-03-07 12:27:42 +01:00
|
|
|
struct ViewedMessagesInfo {
|
|
|
|
FlatHashMap<MessageId, uint64, MessageIdHash> message_id_to_view_id;
|
|
|
|
std::map<uint64, MessageId> recently_viewed_messages;
|
|
|
|
uint64 current_view_id = 0;
|
|
|
|
};
|
2022-03-07 13:20:22 +01:00
|
|
|
FlatHashMap<DialogId, unique_ptr<ViewedMessagesInfo>, DialogIdHash> dialog_viewed_messages_;
|
2022-03-07 12:27:42 +01:00
|
|
|
|
2022-02-16 15:09:26 +01:00
|
|
|
struct ReactionsToReload {
|
2022-03-11 19:38:48 +01:00
|
|
|
FlatHashSet<MessageId, MessageIdHash> message_ids;
|
2022-02-16 15:09:26 +01:00
|
|
|
bool is_request_sent = false;
|
|
|
|
};
|
|
|
|
FlatHashMap<DialogId, ReactionsToReload, DialogIdHash> being_reloaded_reactions_;
|
|
|
|
|
2024-05-19 20:22:51 +02:00
|
|
|
FlatHashSet<MessageFullId, MessageFullIdHash> being_reloaded_fact_checks_;
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, std::pair<bool, bool>, DialogIdHash> pending_dialog_group_call_updates_;
|
2020-12-13 22:36:44 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<string, int32> auth_notification_id_date_;
|
2020-02-13 01:03:50 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<DialogId, MessageId, DialogIdHash> previous_repaired_read_inbox_max_message_id_;
|
2020-02-19 01:09:18 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<MessageFullId, MessageId, MessageFullIdHash> yet_unsent_message_full_id_to_persistent_message_id_;
|
|
|
|
FlatHashMap<MessageFullId, std::set<MessageId>, MessageFullIdHash>
|
2023-03-15 14:59:23 +01:00
|
|
|
yet_unsent_thread_message_ids_; // {dialog_id, top_thread_message_id} -> yet unsent message IDs
|
2023-03-15 14:50:56 +01:00
|
|
|
|
2023-03-16 15:54:33 +01:00
|
|
|
FlatHashMap<DialogId, unique_ptr<SuffixLoadQueries>, DialogIdHash> dialog_suffix_load_queries_;
|
|
|
|
|
2023-03-15 21:45:30 +01:00
|
|
|
struct PendingMessageView {
|
|
|
|
FlatHashSet<MessageId, MessageIdHash> message_ids_;
|
|
|
|
bool increment_view_counter_ = false;
|
|
|
|
};
|
|
|
|
FlatHashMap<DialogId, PendingMessageView, DialogIdHash> pending_message_views_;
|
|
|
|
|
2023-03-16 16:21:51 +01:00
|
|
|
FlatHashMap<DialogId, std::unordered_map<int64, LogEventIdWithGeneration, Hash<int64>>, DialogIdHash>
|
|
|
|
read_history_log_event_ids_;
|
|
|
|
|
2023-03-16 16:05:36 +01:00
|
|
|
FlatHashMap<DialogId, std::unordered_set<MessageId, MessageIdHash>, DialogIdHash> updated_read_history_message_ids_;
|
|
|
|
|
2022-01-30 10:55:27 +01:00
|
|
|
struct PendingReaction {
|
|
|
|
int32 query_count = 0;
|
|
|
|
bool was_updated = false;
|
|
|
|
};
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<MessageFullId, PendingReaction, MessageFullIdHash> pending_reactions_;
|
2022-01-30 10:55:27 +01:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
FlatHashMap<MessageFullId, int32, MessageFullIdHash> pending_read_reactions_;
|
2023-06-01 14:31:05 +02:00
|
|
|
|
2023-08-04 17:39:07 +02:00
|
|
|
vector<ReactionType> active_reaction_types_;
|
|
|
|
FlatHashMap<ReactionType, size_t, ReactionTypeHash> active_reaction_pos_;
|
2022-01-19 16:59:48 +01:00
|
|
|
|
2023-07-28 02:36:21 +02:00
|
|
|
FlatHashMap<PendingGetHistoryQuery, vector<Promise<Unit>>, PendingGetHistoryQueryHash> get_history_queries_;
|
2023-07-27 19:40:56 +02:00
|
|
|
|
2019-12-04 18:06:39 +01:00
|
|
|
uint32 scheduled_messages_sync_generation_ = 1;
|
|
|
|
|
2021-05-29 22:08:08 +02:00
|
|
|
int64 authorization_date_ = 0;
|
|
|
|
|
2020-04-30 13:57:01 +02:00
|
|
|
DialogId removed_sponsored_dialog_id_;
|
2018-06-13 23:07:24 +02:00
|
|
|
DialogId sponsored_dialog_id_;
|
2020-04-28 15:25:56 +02:00
|
|
|
DialogSource sponsored_dialog_source_;
|
2018-05-08 22:02:15 +02:00
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId being_readded_message_id_;
|
2020-03-07 19:00:10 +01:00
|
|
|
|
2018-11-17 23:42:15 +01:00
|
|
|
DialogId being_added_dialog_id_;
|
2021-07-18 05:16:08 +02:00
|
|
|
DialogId being_added_by_new_message_dialog_id_;
|
2022-05-15 09:53:06 +02:00
|
|
|
DialogId being_added_new_dialog_id_;
|
2018-11-17 23:42:15 +01:00
|
|
|
|
2019-03-16 19:30:03 +01:00
|
|
|
DialogId debug_channel_difference_dialog_;
|
2022-08-18 23:00:32 +02:00
|
|
|
DialogId debug_last_get_channel_difference_dialog_id_;
|
|
|
|
const char *debug_last_get_channel_difference_source_ = "unknown";
|
2019-03-16 19:30:03 +01:00
|
|
|
|
2018-11-29 12:37:48 +01:00
|
|
|
double start_time_ = 0;
|
2019-01-05 23:25:09 +01:00
|
|
|
bool is_inited_ = false;
|
2024-01-25 15:33:11 +01:00
|
|
|
int create_folders_source_ = 0;
|
2018-11-29 12:37:48 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
Td *td_;
|
|
|
|
ActorShared<> parent_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|