2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
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)
|
|
|
|
//
|
|
|
|
#include "td/telegram/Td.h"
|
|
|
|
|
2021-11-16 11:02:07 +01:00
|
|
|
#include "td/telegram/Account.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/AnimationsManager.h"
|
2022-05-24 13:56:02 +02:00
|
|
|
#include "td/telegram/Application.h"
|
2022-03-25 12:17:09 +01:00
|
|
|
#include "td/telegram/AttachMenuManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/AudiosManager.h"
|
|
|
|
#include "td/telegram/AuthManager.h"
|
2019-05-14 01:03:05 +02:00
|
|
|
#include "td/telegram/AutoDownloadSettings.h"
|
2019-05-14 16:26:13 +02:00
|
|
|
#include "td/telegram/BackgroundId.h"
|
2019-05-07 04:51:56 +02:00
|
|
|
#include "td/telegram/BackgroundManager.h"
|
2019-05-14 16:26:13 +02:00
|
|
|
#include "td/telegram/BackgroundType.h"
|
2021-06-22 03:25:15 +02:00
|
|
|
#include "td/telegram/BotCommand.h"
|
2022-04-07 16:20:26 +02:00
|
|
|
#include "td/telegram/BotMenuButton.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/CallbackQueriesManager.h"
|
|
|
|
#include "td/telegram/CallId.h"
|
|
|
|
#include "td/telegram/CallManager.h"
|
|
|
|
#include "td/telegram/ChannelId.h"
|
2022-04-04 15:19:41 +02:00
|
|
|
#include "td/telegram/ChannelType.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/ChatId.h"
|
|
|
|
#include "td/telegram/ConfigManager.h"
|
|
|
|
#include "td/telegram/ContactsManager.h"
|
2020-08-23 23:43:31 +02:00
|
|
|
#include "td/telegram/CountryInfoManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/DeviceTokenManager.h"
|
2020-10-01 18:28:10 +02:00
|
|
|
#include "td/telegram/DialogAction.h"
|
2021-11-09 14:54:49 +01:00
|
|
|
#include "td/telegram/DialogEventLog.h"
|
2020-06-05 02:43:13 +02:00
|
|
|
#include "td/telegram/DialogFilter.h"
|
2020-06-07 17:14:52 +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"
|
2019-10-14 16:51:12 +02:00
|
|
|
#include "td/telegram/DialogLocation.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/DialogParticipant.h"
|
2022-03-19 19:37:46 +01:00
|
|
|
#include "td/telegram/DialogParticipantFilter.h"
|
2020-04-30 21:21:42 +02:00
|
|
|
#include "td/telegram/DialogSource.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/DocumentsManager.h"
|
2022-02-23 19:34:09 +01:00
|
|
|
#include "td/telegram/DownloadManager.h"
|
2022-03-02 12:03:41 +01:00
|
|
|
#include "td/telegram/DownloadManagerCallback.h"
|
2022-08-30 15:02:25 +02:00
|
|
|
#include "td/telegram/EmojiStatus.h"
|
2018-12-05 10:32:31 +01:00
|
|
|
#include "td/telegram/FileReferenceManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/files/FileGcParameters.h"
|
|
|
|
#include "td/telegram/files/FileId.h"
|
|
|
|
#include "td/telegram/files/FileManager.h"
|
2019-01-31 03:05:40 +01:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2021-09-26 11:44:18 +02:00
|
|
|
#include "td/telegram/files/FileStats.h"
|
2019-01-19 22:54:29 +01:00
|
|
|
#include "td/telegram/files/FileType.h"
|
2019-08-22 17:24:02 +02:00
|
|
|
#include "td/telegram/FolderId.h"
|
2019-11-26 17:53:10 +01:00
|
|
|
#include "td/telegram/FullMessageId.h"
|
2021-09-07 09:02:44 +02:00
|
|
|
#include "td/telegram/GameManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/Global.h"
|
2020-12-22 13:51:57 +01:00
|
|
|
#include "td/telegram/GroupCallId.h"
|
2020-11-24 16:22:00 +01:00
|
|
|
#include "td/telegram/GroupCallManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/HashtagHints.h"
|
|
|
|
#include "td/telegram/InlineQueriesManager.h"
|
2018-12-10 02:01:02 +01:00
|
|
|
#include "td/telegram/JsonValue.h"
|
2018-07-03 19:28:00 +02:00
|
|
|
#include "td/telegram/LanguagePackManager.h"
|
2021-05-25 01:24:30 +02:00
|
|
|
#include "td/telegram/LinkManager.h"
|
2019-10-13 01:39:44 +02:00
|
|
|
#include "td/telegram/Location.h"
|
2018-10-24 17:42:40 +02:00
|
|
|
#include "td/telegram/Logging.h"
|
2020-08-09 13:18:08 +02:00
|
|
|
#include "td/telegram/MessageCopyOptions.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/MessageEntity.h"
|
|
|
|
#include "td/telegram/MessageId.h"
|
2021-05-27 19:47:04 +02:00
|
|
|
#include "td/telegram/MessageLinkInfo.h"
|
2022-01-21 14:46:16 +01:00
|
|
|
#include "td/telegram/MessageReaction.h"
|
2020-08-22 09:48:36 +02:00
|
|
|
#include "td/telegram/MessageSearchFilter.h"
|
2021-11-15 10:07:52 +01:00
|
|
|
#include "td/telegram/MessageSender.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/MessagesManager.h"
|
2021-08-12 21:00:27 +02:00
|
|
|
#include "td/telegram/MessageThreadInfo.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/misc.h"
|
2019-01-19 22:54:29 +01:00
|
|
|
#include "td/telegram/net/ConnectionCreator.h"
|
|
|
|
#include "td/telegram/net/DcId.h"
|
|
|
|
#include "td/telegram/net/MtprotoHeader.h"
|
|
|
|
#include "td/telegram/net/NetQuery.h"
|
|
|
|
#include "td/telegram/net/NetQueryDelayer.h"
|
|
|
|
#include "td/telegram/net/NetQueryDispatcher.h"
|
|
|
|
#include "td/telegram/net/NetStatsManager.h"
|
|
|
|
#include "td/telegram/net/NetType.h"
|
2019-07-20 15:13:36 +02:00
|
|
|
#include "td/telegram/net/Proxy.h"
|
2019-07-22 04:04:18 +02:00
|
|
|
#include "td/telegram/net/PublicRsaKeyShared.h"
|
2019-01-19 22:54:29 +01:00
|
|
|
#include "td/telegram/net/TempAuthKeyWatchdog.h"
|
2018-11-10 00:08:47 +01:00
|
|
|
#include "td/telegram/NotificationGroupId.h"
|
|
|
|
#include "td/telegram/NotificationId.h"
|
2018-11-09 15:14:02 +01:00
|
|
|
#include "td/telegram/NotificationManager.h"
|
2018-09-29 02:29:57 +02:00
|
|
|
#include "td/telegram/NotificationSettings.h"
|
2022-04-04 23:40:22 +02:00
|
|
|
#include "td/telegram/NotificationSettingsManager.h"
|
2021-12-15 23:09:59 +01:00
|
|
|
#include "td/telegram/OptionManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/PasswordManager.h"
|
2018-09-28 22:57:34 +02:00
|
|
|
#include "td/telegram/Payments.h"
|
2019-02-16 17:01:47 +01:00
|
|
|
#include "td/telegram/PhoneNumberManager.h"
|
2018-03-09 14:56:42 +01:00
|
|
|
#include "td/telegram/Photo.h"
|
2019-08-14 02:13:34 +02:00
|
|
|
#include "td/telegram/PhotoSizeSource.h"
|
2019-02-19 14:45:32 +01:00
|
|
|
#include "td/telegram/PollManager.h"
|
2022-05-24 00:36:55 +02:00
|
|
|
#include "td/telegram/Premium.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/PrivacyManager.h"
|
2019-10-22 12:40:24 +02:00
|
|
|
#include "td/telegram/PublicDialogType.h"
|
2021-02-20 01:55:09 +01:00
|
|
|
#include "td/telegram/ReportReason.h"
|
2018-10-01 01:26:06 +02:00
|
|
|
#include "td/telegram/RequestActor.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/SecretChatId.h"
|
|
|
|
#include "td/telegram/SecretChatsManager.h"
|
2018-04-07 01:38:28 +02:00
|
|
|
#include "td/telegram/SecureManager.h"
|
|
|
|
#include "td/telegram/SecureValue.h"
|
2022-09-06 13:53:19 +02:00
|
|
|
#include "td/telegram/SentEmailCode.h"
|
2021-09-07 14:49:34 +02:00
|
|
|
#include "td/telegram/SponsoredMessageManager.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/StateManager.h"
|
2019-09-18 05:55:43 +02:00
|
|
|
#include "td/telegram/StickerSetId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/StickersManager.h"
|
2022-07-14 15:17:19 +02:00
|
|
|
#include "td/telegram/StickerType.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/StorageManager.h"
|
2020-07-12 14:04:49 +02:00
|
|
|
#include "td/telegram/SuggestedAction.h"
|
2022-08-15 13:32:35 +02:00
|
|
|
#include "td/telegram/Support.h"
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/telegram/td_api.hpp"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/TdDb.h"
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/telegram/telegram_api.hpp"
|
2021-08-27 14:51:50 +02:00
|
|
|
#include "td/telegram/ThemeManager.h"
|
2020-01-27 01:19:54 +01:00
|
|
|
#include "td/telegram/TopDialogCategory.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/TopDialogManager.h"
|
|
|
|
#include "td/telegram/UpdatesManager.h"
|
2021-05-07 19:52:54 +02:00
|
|
|
#include "td/telegram/Version.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/VideoNotesManager.h"
|
|
|
|
#include "td/telegram/VideosManager.h"
|
|
|
|
#include "td/telegram/VoiceNotesManager.h"
|
|
|
|
#include "td/telegram/WebPageId.h"
|
|
|
|
#include "td/telegram/WebPagesManager.h"
|
|
|
|
|
2018-07-20 02:00:17 +02:00
|
|
|
#include "td/db/binlog/BinlogEvent.h"
|
|
|
|
|
2021-07-05 20:20:07 +02:00
|
|
|
#include "td/mtproto/DhCallback.h"
|
2019-07-23 00:50:12 +02:00
|
|
|
#include "td/mtproto/Handshake.h"
|
2019-07-22 04:04:18 +02:00
|
|
|
#include "td/mtproto/HandshakeActor.h"
|
|
|
|
#include "td/mtproto/RawConnection.h"
|
2020-05-17 16:07:16 +02:00
|
|
|
#include "td/mtproto/RSA.h"
|
2019-07-23 00:50:12 +02:00
|
|
|
#include "td/mtproto/TransportType.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
2021-01-01 13:59:53 +01:00
|
|
|
#include "td/utils/algorithm.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/buffer.h"
|
2018-04-30 14:50:54 +02:00
|
|
|
#include "td/utils/filesystem.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/format.h"
|
|
|
|
#include "td/utils/MimeType.h"
|
|
|
|
#include "td/utils/misc.h"
|
|
|
|
#include "td/utils/PathView.h"
|
2019-07-23 00:50:12 +02:00
|
|
|
#include "td/utils/port/IPAddress.h"
|
|
|
|
#include "td/utils/port/SocketFd.h"
|
2020-06-19 02:45:24 +02:00
|
|
|
#include "td/utils/port/uname.h"
|
2018-02-28 11:25:07 +01:00
|
|
|
#include "td/utils/Random.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Slice.h"
|
2021-05-17 14:21:11 +02:00
|
|
|
#include "td/utils/SliceBuilder.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
#include "td/utils/Timer.h"
|
|
|
|
#include "td/utils/tl_parsers.h"
|
|
|
|
#include "td/utils/utf8.h"
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <tuple>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2020-10-05 17:07:23 +02:00
|
|
|
int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3;
|
|
|
|
int VERBOSITY_NAME(td_requests) = VERBOSITY_NAME(INFO);
|
|
|
|
|
2021-11-08 13:20:38 +01:00
|
|
|
void Td::ResultHandler::set_td(Td *td) {
|
|
|
|
CHECK(td_ == nullptr);
|
|
|
|
td_ = td;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::ResultHandler::send_query(NetQueryPtr query) {
|
2021-11-12 12:47:51 +01:00
|
|
|
CHECK(!is_query_sent_)
|
|
|
|
is_query_sent_ = true;
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->add_handler(query->id(), shared_from_this());
|
2021-11-12 12:39:04 +01:00
|
|
|
query->debug("Send to NetQueryDispatcher");
|
|
|
|
G()->net_query_dispatcher().dispatch(std::move(query));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetPromoDataQuery final : public Td::ResultHandler {
|
2020-04-30 20:00:58 +02:00
|
|
|
Promise<telegram_api::object_ptr<telegram_api::help_PromoData>> promise_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit GetPromoDataQuery(Promise<telegram_api::object_ptr<telegram_api::help_PromoData>> &&promise)
|
|
|
|
: promise_(std::move(promise)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void send() {
|
|
|
|
// we don't poll promo data before authorization
|
|
|
|
send_query(G()->net_query_creator().create(telegram_api::help_getPromoData()));
|
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2020-04-30 20:00:58 +02:00
|
|
|
auto result_ptr = fetch_result<telegram_api::help_getPromoData>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(result_ptr.move_as_error());
|
2020-04-30 20:00:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
promise_.set_value(result_ptr.move_as_ok());
|
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2020-04-30 20:00:58 +02:00
|
|
|
promise_.set_error(std::move(status));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetRecentMeUrlsQuery final : public Td::ResultHandler {
|
2018-12-31 20:04:05 +01:00
|
|
|
Promise<tl_object_ptr<td_api::tMeUrls>> promise_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit GetRecentMeUrlsQuery(Promise<tl_object_ptr<td_api::tMeUrls>> &&promise) : promise_(std::move(promise)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void send(const string &referrer) {
|
2020-03-15 22:17:11 +01:00
|
|
|
send_query(G()->net_query_creator().create(telegram_api::help_getRecentMeUrls(referrer)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto result_ptr = fetch_result<telegram_api::help_getRecentMeUrls>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(result_ptr.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto urls_full = result_ptr.move_as_ok();
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->contacts_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery");
|
|
|
|
td_->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery");
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
auto urls = std::move(urls_full->urls_);
|
|
|
|
auto results = make_tl_object<td_api::tMeUrls>();
|
|
|
|
results->urls_.reserve(urls.size());
|
|
|
|
for (auto &url_ptr : urls) {
|
|
|
|
CHECK(url_ptr != nullptr);
|
|
|
|
tl_object_ptr<td_api::tMeUrl> result = make_tl_object<td_api::tMeUrl>();
|
|
|
|
switch (url_ptr->get_id()) {
|
|
|
|
case telegram_api::recentMeUrlUser::ID: {
|
|
|
|
auto url = move_tl_object_as<telegram_api::recentMeUrlUser>(url_ptr);
|
|
|
|
result->url_ = std::move(url->url_);
|
|
|
|
UserId user_id(url->user_id_);
|
|
|
|
if (!user_id.is_valid()) {
|
|
|
|
LOG(ERROR) << "Receive invalid " << user_id;
|
|
|
|
result = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
2018-02-03 00:05:11 +01:00
|
|
|
result->type_ = make_tl_object<td_api::tMeUrlTypeUser>(
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->contacts_manager_->get_user_id_object(user_id, "tMeUrlTypeUser"));
|
2018-12-31 20:04:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case telegram_api::recentMeUrlChat::ID: {
|
|
|
|
auto url = move_tl_object_as<telegram_api::recentMeUrlChat>(url_ptr);
|
|
|
|
result->url_ = std::move(url->url_);
|
|
|
|
ChannelId channel_id(url->chat_id_);
|
|
|
|
if (!channel_id.is_valid()) {
|
|
|
|
LOG(ERROR) << "Receive invalid " << channel_id;
|
|
|
|
result = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
2018-02-03 00:05:11 +01:00
|
|
|
result->type_ = make_tl_object<td_api::tMeUrlTypeSupergroup>(
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->contacts_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup"));
|
2018-12-31 20:04:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case telegram_api::recentMeUrlChatInvite::ID: {
|
|
|
|
auto url = move_tl_object_as<telegram_api::recentMeUrlChatInvite>(url_ptr);
|
|
|
|
result->url_ = std::move(url->url_);
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->contacts_manager_->on_get_dialog_invite_link_info(result->url_, std::move(url->chat_invite_),
|
|
|
|
Promise<Unit>());
|
|
|
|
auto info_object = td_->contacts_manager_->get_chat_invite_link_info_object(result->url_);
|
2020-06-23 08:31:25 +02:00
|
|
|
if (info_object == nullptr) {
|
|
|
|
result = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
result->type_ = make_tl_object<td_api::tMeUrlTypeChatInvite>(std::move(info_object));
|
2018-12-31 20:04:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case telegram_api::recentMeUrlStickerSet::ID: {
|
|
|
|
auto url = move_tl_object_as<telegram_api::recentMeUrlStickerSet>(url_ptr);
|
|
|
|
result->url_ = std::move(url->url_);
|
2019-12-29 02:59:34 +01:00
|
|
|
auto sticker_set_id =
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->stickers_manager_->on_get_sticker_set_covered(std::move(url->set_), false, "recentMeUrlStickerSet");
|
2019-09-18 05:55:43 +02:00
|
|
|
if (!sticker_set_id.is_valid()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(ERROR) << "Receive invalid sticker set";
|
|
|
|
result = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
2019-09-18 05:55:43 +02:00
|
|
|
result->type_ = make_tl_object<td_api::tMeUrlTypeStickerSet>(sticker_set_id.get());
|
2018-12-31 20:04:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case telegram_api::recentMeUrlUnknown::ID:
|
|
|
|
// skip
|
|
|
|
result = nullptr;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
if (result != nullptr) {
|
|
|
|
results->urls_.push_back(std::move(result));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
promise_.set_value(std::move(results));
|
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
promise_.set_error(std::move(status));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SendCustomRequestQuery final : public Td::ResultHandler {
|
2020-02-13 22:42:03 +01:00
|
|
|
Promise<td_api::object_ptr<td_api::customRequestResult>> promise_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
public:
|
2020-02-13 22:42:03 +01:00
|
|
|
explicit SendCustomRequestQuery(Promise<td_api::object_ptr<td_api::customRequestResult>> &&promise)
|
|
|
|
: promise_(std::move(promise)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void send(const string &method, const string ¶meters) {
|
2020-03-15 22:17:11 +01:00
|
|
|
send_query(G()->net_query_creator().create(
|
|
|
|
telegram_api::bots_sendCustomRequest(method, make_tl_object<telegram_api::dataJSON>(parameters))));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto result_ptr = fetch_result<telegram_api::bots_sendCustomRequest>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(result_ptr.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-09-21 19:52:22 +02:00
|
|
|
auto result = result_ptr.move_as_ok();
|
2020-02-13 22:42:03 +01:00
|
|
|
promise_.set_value(td_api::make_object<td_api::customRequestResult>(result->data_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
promise_.set_error(std::move(status));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class AnswerCustomQueryQuery final : public Td::ResultHandler {
|
2018-12-31 20:04:05 +01:00
|
|
|
Promise<Unit> promise_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AnswerCustomQueryQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void send(int64 custom_query_id, const string &data) {
|
2020-03-15 22:17:11 +01:00
|
|
|
send_query(G()->net_query_creator().create(
|
|
|
|
telegram_api::bots_answerWebhookJSONQuery(custom_query_id, make_tl_object<telegram_api::dataJSON>(data))));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto result_ptr = fetch_result<telegram_api::bots_answerWebhookJSONQuery>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(result_ptr.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool result = result_ptr.ok();
|
|
|
|
if (!result) {
|
|
|
|
LOG(INFO) << "Sending answer to a custom query has failed";
|
|
|
|
}
|
|
|
|
promise_.set_value(Unit());
|
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
promise_.set_error(std::move(status));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SetBotUpdatesStatusQuery final : public Td::ResultHandler {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
void send(int32 pending_update_count, const string &error_message) {
|
2020-03-15 22:17:11 +01:00
|
|
|
send_query(
|
|
|
|
G()->net_query_creator().create(telegram_api::help_setBotUpdatesStatus(pending_update_count, error_message)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto result_ptr = fetch_result<telegram_api::help_setBotUpdatesStatus>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(result_ptr.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool result = result_ptr.ok();
|
|
|
|
LOG_IF(WARNING, !result) << "Set bot updates status has failed";
|
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2020-03-30 23:35:58 +02:00
|
|
|
if (!G()->is_expected_error(status)) {
|
2020-09-24 15:08:04 +02:00
|
|
|
LOG(WARNING) << "Receive error for SetBotUpdatesStatusQuery: " << status;
|
2019-02-14 16:36:16 +01:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
status.ignore();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class UpdateStatusQuery final : public Td::ResultHandler {
|
2018-03-10 15:10:23 +01:00
|
|
|
bool is_offline_;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2018-03-10 12:41:59 +01:00
|
|
|
NetQueryRef send(bool is_offline) {
|
2018-03-10 15:10:23 +01:00
|
|
|
is_offline_ = is_offline;
|
2020-03-15 22:17:11 +01:00
|
|
|
auto net_query = G()->net_query_creator().create(telegram_api::account_updateStatus(is_offline));
|
2018-03-10 12:41:59 +01:00
|
|
|
auto result = net_query.get_weak();
|
|
|
|
send_query(std::move(net_query));
|
|
|
|
return result;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto result_ptr = fetch_result<telegram_api::account_updateStatus>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(result_ptr.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool result = result_ptr.ok();
|
2021-11-08 15:11:35 +01:00
|
|
|
LOG(INFO) << "Receive result for UpdateStatusQuery: " << result;
|
2021-11-08 13:20:38 +01:00
|
|
|
td_->on_update_status_success(!is_offline_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2021-05-31 20:51:48 +02:00
|
|
|
if (status.code() != NetQuery::Canceled && !G()->is_expected_error(status)) {
|
2018-03-10 12:41:59 +01:00
|
|
|
LOG(ERROR) << "Receive error for UpdateStatusQuery: " << status;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
status.ignore();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-02 15:54:01 +02:00
|
|
|
class TestNetworkQuery final : public Td::ResultHandler {
|
|
|
|
Promise<Unit> promise_;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2021-10-02 15:54:01 +02:00
|
|
|
explicit TestNetworkQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void send() {
|
2020-03-15 23:01:14 +01:00
|
|
|
send_query(G()->net_query_creator().create_unauth(telegram_api::help_getConfig()));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_result(BufferSlice packet) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto result_ptr = fetch_result<telegram_api::help_getConfig>(packet);
|
|
|
|
if (result_ptr.is_error()) {
|
2021-11-08 12:19:57 +01:00
|
|
|
return on_error(Status::Error(500, "Fetch failed"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-10-02 15:54:01 +02:00
|
|
|
LOG(DEBUG) << "TestNetwork OK: " << to_string(result_ptr.ok());
|
|
|
|
promise_.set_value(Unit());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 12:19:57 +01:00
|
|
|
void on_error(Status status) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(ERROR) << "Test query failed: " << status;
|
2021-10-02 15:54:01 +02:00
|
|
|
promise_.set_error(std::move(status));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
2019-07-22 04:04:18 +02:00
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class TestProxyRequest final : public RequestOnceActor {
|
2019-09-24 17:18:17 +02:00
|
|
|
Proxy proxy_;
|
2019-09-23 03:13:42 +02:00
|
|
|
int16 dc_id_;
|
|
|
|
double timeout_;
|
2019-07-20 15:13:36 +02:00
|
|
|
ActorOwn<> child_;
|
2019-07-22 13:22:31 +02:00
|
|
|
Promise<> promise_;
|
2019-07-20 15:13:36 +02:00
|
|
|
|
|
|
|
auto get_transport() {
|
2019-08-02 01:14:25 +02:00
|
|
|
return mtproto::TransportType{mtproto::TransportType::ObfuscatedTcp, dc_id_, proxy_.secret()};
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2019-09-23 03:13:42 +02:00
|
|
|
set_timeout_in(timeout_);
|
|
|
|
|
2019-07-22 13:22:31 +02:00
|
|
|
promise_ = std::move(promise);
|
2021-03-27 03:19:22 +01:00
|
|
|
IPAddress ip_address;
|
|
|
|
auto status = ip_address.init_host_port(proxy_.server(), proxy_.port());
|
2019-07-20 15:13:36 +02:00
|
|
|
if (status.is_error()) {
|
2019-07-22 13:22:31 +02:00
|
|
|
return promise_.set_error(Status::Error(400, status.public_message()));
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
2021-03-27 03:19:22 +01:00
|
|
|
auto r_socket_fd = SocketFd::open(ip_address);
|
2019-07-20 15:13:36 +02:00
|
|
|
if (r_socket_fd.is_error()) {
|
2019-07-22 13:22:31 +02:00
|
|
|
return promise_.set_error(Status::Error(400, r_socket_fd.error().public_message()));
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
|
|
|
|
2019-07-22 04:04:18 +02:00
|
|
|
auto dc_options = ConnectionCreator::get_default_dc_options(false);
|
2020-05-16 22:32:32 +02:00
|
|
|
IPAddress mtproto_ip_address;
|
2019-07-22 04:04:18 +02:00
|
|
|
for (auto &dc_option : dc_options.dc_options) {
|
2019-08-02 01:14:25 +02:00
|
|
|
if (dc_option.get_dc_id().get_raw_id() == dc_id_) {
|
2020-05-16 22:32:32 +02:00
|
|
|
mtproto_ip_address = dc_option.get_ip_address();
|
2019-07-22 04:04:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-22 13:22:31 +02:00
|
|
|
auto connection_promise =
|
|
|
|
PromiseCreator::lambda([actor_id = actor_id(this)](Result<ConnectionCreator::ConnectionData> r_data) mutable {
|
|
|
|
send_closure(actor_id, &TestProxyRequest::on_connection_data, std::move(r_data));
|
|
|
|
});
|
2019-07-20 15:13:36 +02:00
|
|
|
|
2021-03-27 03:19:22 +01:00
|
|
|
child_ = ConnectionCreator::prepare_connection(ip_address, r_socket_fd.move_as_ok(), proxy_, mtproto_ip_address,
|
|
|
|
get_transport(), "Test", "TestPingDC2", nullptr, {}, false,
|
|
|
|
std::move(connection_promise));
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
|
|
|
|
2019-07-22 13:22:31 +02:00
|
|
|
void on_connection_data(Result<ConnectionCreator::ConnectionData> r_data) {
|
2019-07-22 04:04:18 +02:00
|
|
|
if (r_data.is_error()) {
|
2019-07-22 13:22:31 +02:00
|
|
|
return promise_.set_error(r_data.move_as_error());
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
2021-07-04 04:58:54 +02:00
|
|
|
class HandshakeContext final : public mtproto::AuthKeyHandshakeContext {
|
2019-07-20 15:13:36 +02:00
|
|
|
public:
|
2021-07-05 20:04:23 +02:00
|
|
|
mtproto::DhCallback *get_dh_callback() final {
|
2019-07-20 15:13:36 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-07-05 20:04:23 +02:00
|
|
|
mtproto::PublicRsaKeyInterface *get_public_rsa_key_interface() final {
|
2019-07-20 15:13:36 +02:00
|
|
|
return &public_rsa_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PublicRsaKeyShared public_rsa_key{DcId::empty(), false};
|
|
|
|
};
|
2019-08-02 01:14:25 +02:00
|
|
|
auto handshake = make_unique<mtproto::AuthKeyHandshake>(dc_id_, 3600);
|
2019-07-22 04:04:18 +02:00
|
|
|
auto data = r_data.move_as_ok();
|
2021-03-26 16:52:45 +01:00
|
|
|
auto raw_connection =
|
2021-10-22 18:59:15 +02:00
|
|
|
mtproto::RawConnection::create(data.ip_address, std::move(data.buffered_socket_fd), get_transport(), nullptr);
|
2019-07-20 15:13:36 +02:00
|
|
|
child_ = create_actor<mtproto::HandshakeActor>(
|
|
|
|
"HandshakeActor", std::move(handshake), std::move(raw_connection), make_unique<HandshakeContext>(), 10.0,
|
2019-07-22 13:22:31 +02:00
|
|
|
PromiseCreator::lambda([actor_id = actor_id(this)](Result<unique_ptr<mtproto::RawConnection>> raw_connection) {
|
|
|
|
send_closure(actor_id, &TestProxyRequest::on_handshake_connection, std::move(raw_connection));
|
|
|
|
}),
|
2019-07-20 15:13:36 +02:00
|
|
|
PromiseCreator::lambda(
|
2019-07-22 13:22:31 +02:00
|
|
|
[actor_id = actor_id(this)](Result<unique_ptr<mtproto::AuthKeyHandshake>> handshake) mutable {
|
|
|
|
send_closure(actor_id, &TestProxyRequest::on_handshake, std::move(handshake));
|
2019-07-20 15:13:36 +02:00
|
|
|
}));
|
|
|
|
}
|
2019-07-22 13:22:31 +02:00
|
|
|
void on_handshake_connection(Result<unique_ptr<mtproto::RawConnection>> r_raw_connection) {
|
|
|
|
if (r_raw_connection.is_error()) {
|
2019-07-23 00:13:20 +02:00
|
|
|
return promise_.set_error(Status::Error(400, r_raw_connection.move_as_error().public_message()));
|
2019-07-22 13:22:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void on_handshake(Result<unique_ptr<mtproto::AuthKeyHandshake>> r_handshake) {
|
|
|
|
if (!promise_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (r_handshake.is_error()) {
|
2019-07-23 00:13:20 +02:00
|
|
|
return promise_.set_error(Status::Error(400, r_handshake.move_as_error().public_message()));
|
2019-07-22 13:22:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
auto handshake = r_handshake.move_as_ok();
|
|
|
|
if (!handshake->is_ready_for_finish()) {
|
|
|
|
promise_.set_error(Status::Error(400, "Handshake is not ready"));
|
|
|
|
}
|
2019-07-23 00:13:20 +02:00
|
|
|
promise_.set_value(Unit());
|
2019-07-22 13:22:31 +02:00
|
|
|
}
|
2019-07-20 15:13:36 +02:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void timeout_expired() final {
|
2019-09-23 03:13:42 +02:00
|
|
|
send_error(Status::Error(400, "Timeout expired"));
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
2019-07-20 15:13:36 +02:00
|
|
|
public:
|
2019-09-23 03:13:42 +02:00
|
|
|
TestProxyRequest(ActorShared<Td> td, uint64 request_id, Proxy proxy, int32 dc_id, double timeout)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, proxy_(std::move(proxy))
|
|
|
|
, dc_id_(static_cast<int16>(dc_id))
|
|
|
|
, timeout_(timeout) {
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
|
|
|
};
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetMeRequest final : public RequestActor<> {
|
2018-03-09 01:27:39 +01:00
|
|
|
UserId user_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
user_id_ = td_->contacts_manager_->get_me(std::move(promise));
|
2018-03-09 01:27:39 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
2018-03-09 01:27:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-03-09 02:17:38 +01:00
|
|
|
GetMeRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
2018-03-09 01:27:39 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetUserRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->get_user(user_id_, get_tries(), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetUserRequest(ActorShared<Td> td, uint64 request_id, int64 user_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), user_id_(user_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetUserFullInfoRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->load_user_full(user_id_, get_tries() < 2, std::move(promise), "GetUserFullInfoRequest");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_user_full_info_object(user_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetUserFullInfoRequest(ActorShared<Td> td, uint64 request_id, int64 user_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), user_id_(user_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetGroupRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
ChatId chat_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->get_chat(chat_id_, get_tries(), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_basic_group_object(chat_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetGroupRequest(ActorShared<Td> td, uint64 request_id, int64 chat_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), chat_id_(chat_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetGroupFullInfoRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
ChatId chat_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->load_chat_full(chat_id_, get_tries() < 2, std::move(promise), "getBasicGroupFullInfo");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_basic_group_full_info_object(chat_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetGroupFullInfoRequest(ActorShared<Td> td, uint64 request_id, int64 chat_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), chat_id_(chat_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetSupergroupRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
ChannelId channel_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->get_channel(channel_id_, get_tries(), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_supergroup_object(channel_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetSupergroupRequest(ActorShared<Td> td, uint64 request_id, int64 channel_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), channel_id_(channel_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetSupergroupFullInfoRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
ChannelId channel_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->load_channel_full(channel_id_, get_tries() < 2, std::move(promise),
|
|
|
|
"GetSupergroupFullInfoRequest");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_supergroup_full_info_object(channel_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetSupergroupFullInfoRequest(ActorShared<Td> td, uint64 request_id, int64 channel_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), channel_id_(channel_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetSecretChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
SecretChatId secret_chat_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->get_secret_chat(secret_chat_id_, get_tries() < 2, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_secret_chat_object(secret_chat_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetSecretChatRequest(ActorShared<Td> td, uint64 request_id, int32 secret_chat_id)
|
|
|
|
: RequestActor(std::move(td), request_id), secret_chat_id_(secret_chat_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
|
|
|
|
bool dialog_found_ = false;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_found_ = td_->messages_manager_->load_dialog(dialog_id_, get_tries(), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (!dialog_found_) {
|
|
|
|
send_error(Status::Error(400, "Chat is not accessible"));
|
|
|
|
} else {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
|
|
|
|
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatFilterRequest final : public RequestActor<> {
|
2020-05-18 01:29:28 +02:00
|
|
|
DialogFilterId dialog_filter_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->load_dialog_filter(dialog_filter_id_, get_tries() < 2, std::move(promise));
|
2020-05-18 01:29:28 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_filter_object(dialog_filter_id_));
|
2020-05-18 01:29:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatFilterRequest(ActorShared<Td> td, uint64 request_id, int32 dialog_filter_id)
|
|
|
|
: RequestActor(std::move(td), request_id), dialog_filter_id_(dialog_filter_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-02-18 16:13:10 +01:00
|
|
|
class SearchUserByPhoneNumberRequest final : public RequestActor<> {
|
|
|
|
string phone_number_;
|
|
|
|
|
|
|
|
UserId user_id_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
|
|
|
user_id_ = td_->contacts_manager_->search_user_by_phone_number(phone_number_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_send_result() final {
|
|
|
|
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchUserByPhoneNumberRequest(ActorShared<Td> td, uint64 request_id, string &&phone_number)
|
|
|
|
: RequestActor(std::move(td), request_id), phone_number_(std::move(phone_number)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-10 16:52:31 +02:00
|
|
|
class LoadChatsRequest final : public RequestActor<> {
|
|
|
|
DialogListId dialog_list_id_;
|
|
|
|
DialogDate offset_;
|
|
|
|
int32 limit_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_dialogs(dialog_list_id_, offset_, limit_, false, get_tries() < 2, std::move(promise));
|
2021-08-10 16:52:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
LoadChatsRequest(ActorShared<Td> td, uint64 request_id, DialogListId dialog_list_id, DialogDate offset, int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), dialog_list_id_(dialog_list_id), offset_(offset), limit_(limit) {
|
|
|
|
// 1 for database + 1 for server request + 1 for server request at the end + 1 for return + 1 just in case
|
|
|
|
set_tries(5);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
if (limit_ > 100) {
|
|
|
|
limit_ = 100;
|
2021-08-11 14:59:09 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchPublicChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string username_;
|
|
|
|
|
|
|
|
DialogId dialog_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_id_ = td_->messages_manager_->search_public_dialog(username_, get_tries() < 3, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchPublicChatRequest(ActorShared<Td> td, uint64 request_id, string username)
|
|
|
|
: RequestActor(std::move(td), request_id), username_(std::move(username)) {
|
2021-06-03 19:16:14 +02:00
|
|
|
set_tries(4); // 1 for server request + 1 for reload voice chat + 1 for reload dialog + 1 for result
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchPublicChatsRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string query_;
|
|
|
|
|
|
|
|
vector<DialogId> dialog_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->messages_manager_->search_public_dialogs(query_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2020-09-19 23:28:26 +02:00
|
|
|
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchPublicChatsRequest(ActorShared<Td> td, uint64 request_id, string query)
|
|
|
|
: RequestActor(std::move(td), request_id), query_(std::move(query)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchChatsRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string query_;
|
|
|
|
int32 limit_;
|
|
|
|
|
2020-09-19 23:28:26 +02:00
|
|
|
std::pair<int32, vector<DialogId>> dialog_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->messages_manager_->search_dialogs(query_, limit_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchChatsRequest(ActorShared<Td> td, uint64 request_id, string query, int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), query_(std::move(query)), limit_(limit) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchChatsOnServerRequest final : public RequestActor<> {
|
2018-01-16 19:56:59 +01:00
|
|
|
string query_;
|
|
|
|
int32 limit_;
|
|
|
|
|
|
|
|
vector<DialogId> dialog_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->messages_manager_->search_dialogs_on_server(query_, limit_, std::move(promise));
|
2018-01-16 19:56:59 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2020-09-19 23:28:26 +02:00
|
|
|
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
2018-01-16 19:56:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchChatsOnServerRequest(ActorShared<Td> td, uint64 request_id, string query, int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), query_(std::move(query)), limit_(limit) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetGroupsInCommonRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id_;
|
|
|
|
DialogId offset_dialog_id_;
|
|
|
|
int32 limit_;
|
|
|
|
|
2020-09-19 23:28:26 +02:00
|
|
|
std::pair<int32, vector<DialogId>> dialog_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->messages_manager_->get_common_dialogs(user_id_, offset_dialog_id_, limit_, get_tries() < 2,
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetGroupsInCommonRequest(ActorShared<Td> td, uint64 request_id, int64 user_id, int64 offset_dialog_id, int32 limit)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), user_id_(user_id), offset_dialog_id_(offset_dialog_id), limit_(limit) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetSuitableDiscussionChatsRequest final : public RequestActor<> {
|
2019-09-13 19:25:17 +02:00
|
|
|
vector<DialogId> dialog_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->contacts_manager_->get_dialogs_for_discussion(std::move(promise));
|
2019-09-13 19:25:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2020-09-19 23:28:26 +02:00
|
|
|
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
2019-09-13 19:25:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetSuitableDiscussionChatsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetInactiveSupergroupChatsRequest final : public RequestActor<> {
|
2019-12-13 15:27:44 +01:00
|
|
|
vector<DialogId> dialog_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->contacts_manager_->get_inactive_channels(std::move(promise));
|
2019-12-13 15:27:44 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2020-09-19 23:28:26 +02:00
|
|
|
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
2019-12-13 15:27:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetInactiveSupergroupChatsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-09-14 13:18:37 +02:00
|
|
|
class GetRecentlyOpenedChatsRequest final : public RequestActor<> {
|
|
|
|
int32 limit_;
|
|
|
|
|
|
|
|
std::pair<int32, vector<DialogId>> dialog_ids_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->messages_manager_->get_recently_opened_dialogs(limit_, std::move(promise));
|
2021-09-14 13:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void do_send_result() final {
|
|
|
|
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetRecentlyOpenedChatsRequest(ActorShared<Td> td, uint64 request_id, int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), limit_(limit) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetMessageRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_message(full_message_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(full_message_id_, "GetMessageRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetMessageRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), full_message_id_(DialogId(dialog_id), MessageId(message_id)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetRepliedMessageRequest final : public RequestOnceActor {
|
2018-02-07 00:31:38 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
MessageId message_id_;
|
|
|
|
|
2020-09-10 15:29:10 +02:00
|
|
|
FullMessageId replied_message_id_;
|
2018-02-07 00:31:38 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2018-02-07 00:31:38 +01:00
|
|
|
replied_message_id_ =
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_replied_message(dialog_id_, message_id_, get_tries() < 3, std::move(promise));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(replied_message_id_, "GetRepliedMessageRequest"));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetRepliedMessageRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), dialog_id_(dialog_id), message_id_(message_id) {
|
2019-02-01 13:19:32 +01:00
|
|
|
set_tries(3); // 1 to get initial message, 1 to get the reply and 1 for result
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-08-12 21:00:27 +02:00
|
|
|
class GetMessageThreadRequest final : public RequestActor<MessageThreadInfo> {
|
2020-09-15 16:07:34 +02:00
|
|
|
DialogId dialog_id_;
|
|
|
|
MessageId message_id_;
|
|
|
|
|
2021-08-12 21:00:27 +02:00
|
|
|
MessageThreadInfo message_thread_info_;
|
2020-09-15 16:07:34 +02:00
|
|
|
|
2021-08-12 21:00:27 +02:00
|
|
|
void do_run(Promise<MessageThreadInfo> &&promise) final {
|
2020-09-22 16:27:35 +02:00
|
|
|
if (get_tries() < 2) {
|
|
|
|
promise.set_value(std::move(message_thread_info_));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_message_thread(dialog_id_, message_id_, std::move(promise));
|
2020-09-22 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
2021-08-12 21:00:27 +02:00
|
|
|
void do_set_result(MessageThreadInfo &&result) final {
|
2020-09-22 16:27:35 +02:00
|
|
|
message_thread_info_ = std::move(result);
|
2020-09-15 16:07:34 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_thread_info_object(message_thread_info_));
|
2020-09-15 16:07:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-09-22 16:27:35 +02:00
|
|
|
GetMessageThreadRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id)
|
|
|
|
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id), message_id_(message_id) {
|
2020-09-15 16:07:34 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatPinnedMessageRequest final : public RequestOnceActor {
|
2018-02-07 00:31:38 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
|
|
|
|
MessageId pinned_message_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
pinned_message_id_ = td_->messages_manager_->get_dialog_pinned_message(dialog_id_, std::move(promise));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-10-03 13:54:40 +02:00
|
|
|
send_result(
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_message_object({dialog_id_, pinned_message_id_}, "GetChatPinnedMessageRequest"));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatPinnedMessageRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
|
2019-02-01 13:19:32 +01:00
|
|
|
: RequestOnceActor(std::move(td), request_id), dialog_id_(dialog_id) {
|
|
|
|
set_tries(3); // 1 to get pinned_message_id, 1 to get the message and 1 for result
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetCallbackQueryMessageRequest final : public RequestOnceActor {
|
2020-10-28 23:06:07 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
MessageId message_id_;
|
|
|
|
int64 callback_query_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_callback_query_message(dialog_id_, message_id_, callback_query_id_, std::move(promise));
|
2020-10-28 23:06:07 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(
|
|
|
|
td_->messages_manager_->get_message_object({dialog_id_, message_id_}, "GetCallbackQueryMessageRequest"));
|
2020-10-28 23:06:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetCallbackQueryMessageRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
int64 callback_query_id)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, message_id_(message_id)
|
|
|
|
, callback_query_id_(callback_query_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetMessagesRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
vector<MessageId> message_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_messages(dialog_id_, message_ids_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_messages_object(-1, dialog_id_, message_ids_, false, "GetMessagesRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, const vector<int64> &message_ids)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, message_ids_(MessagesManager::get_message_ids(message_ids)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetMessageEmbeddingCodeRequest final : public RequestActor<> {
|
2020-09-20 17:17:47 +02:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
bool for_group_;
|
|
|
|
|
|
|
|
string html_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
html_ = td_->messages_manager_->get_message_embedding_code(full_message_id_, for_group_, std::move(promise));
|
2020-09-20 17:17:47 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2020-09-20 17:17:47 +02:00
|
|
|
send_result(make_tl_object<td_api::text>(html_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetMessageEmbeddingCodeRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
bool for_group)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
|
|
|
, for_group_(for_group) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetMessageLinkInfoRequest final : public RequestActor<MessageLinkInfo> {
|
2019-08-05 11:12:59 +02:00
|
|
|
string url_;
|
|
|
|
|
2021-05-27 19:47:04 +02:00
|
|
|
MessageLinkInfo message_link_info_;
|
2019-08-05 11:12:59 +02:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<MessageLinkInfo> &&promise) final {
|
2019-08-05 11:12:59 +02:00
|
|
|
if (get_tries() < 2) {
|
|
|
|
promise.set_value(std::move(message_link_info_));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_message_link_info(url_, std::move(promise));
|
2019-08-05 11:12:59 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_set_result(MessageLinkInfo &&result) final {
|
2019-08-05 11:12:59 +02:00
|
|
|
message_link_info_ = std::move(result);
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_link_info_object(message_link_info_));
|
2019-08-05 11:12:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetMessageLinkInfoRequest(ActorShared<Td> td, uint64 request_id, string url)
|
|
|
|
: RequestActor(std::move(td), request_id), url_(std::move(url)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class EditMessageTextRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
|
|
|
tl_object_ptr<td_api::InputMessageContent> input_message_content_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->edit_message_text(full_message_id_, std::move(reply_markup_),
|
|
|
|
std::move(input_message_content_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageTextRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
EditMessageTextRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
|
|
|
|
tl_object_ptr<td_api::InputMessageContent> input_message_content)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
|
|
|
, reply_markup_(std::move(reply_markup))
|
|
|
|
, input_message_content_(std::move(input_message_content)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class EditMessageLiveLocationRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
|
|
|
tl_object_ptr<td_api::location> location_;
|
2020-10-16 22:08:28 +02:00
|
|
|
int32 heading_;
|
2020-10-30 13:51:20 +01:00
|
|
|
int32 proximity_alert_radius_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->edit_message_live_location(full_message_id_, std::move(reply_markup_), std::move(location_),
|
|
|
|
heading_, proximity_alert_radius_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageLiveLocationRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
EditMessageLiveLocationRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
|
2020-10-30 13:51:20 +01:00
|
|
|
tl_object_ptr<td_api::location> location, int32 heading, int32 proximity_alert_radius)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
|
|
|
, reply_markup_(std::move(reply_markup))
|
2020-10-16 22:08:28 +02:00
|
|
|
, location_(std::move(location))
|
2020-10-24 23:49:41 +02:00
|
|
|
, heading_(heading)
|
2020-10-30 13:51:20 +01:00
|
|
|
, proximity_alert_radius_(proximity_alert_radius) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class EditMessageMediaRequest final : public RequestOnceActor {
|
2018-06-19 01:31:34 +02:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
|
|
|
tl_object_ptr<td_api::InputMessageContent> input_message_content_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->edit_message_media(full_message_id_, std::move(reply_markup_),
|
|
|
|
std::move(input_message_content_), std::move(promise));
|
2018-06-19 01:31:34 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageMediaRequest"));
|
2018-06-19 01:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
EditMessageMediaRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
|
|
|
|
tl_object_ptr<td_api::InputMessageContent> input_message_content)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
|
|
|
, reply_markup_(std::move(reply_markup))
|
|
|
|
, input_message_content_(std::move(input_message_content)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class EditMessageCaptionRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
2018-01-30 18:06:54 +01:00
|
|
|
tl_object_ptr<td_api::formattedText> caption_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->edit_message_caption(full_message_id_, std::move(reply_markup_), std::move(caption_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageCaptionRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
EditMessageCaptionRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
2018-01-30 18:06:54 +01:00
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
|
|
|
|
tl_object_ptr<td_api::formattedText> caption)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
|
|
|
, reply_markup_(std::move(reply_markup))
|
|
|
|
, caption_(std::move(caption)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class EditMessageReplyMarkupRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
FullMessageId full_message_id_;
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->edit_message_reply_markup(full_message_id_, std::move(reply_markup_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_message_object(full_message_id_, "EditMessageReplyMarkupRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
EditMessageReplyMarkupRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
tl_object_ptr<td_api::ReplyMarkup> reply_markup)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
|
|
|
, reply_markup_(std::move(reply_markup)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatHistoryRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
MessageId from_message_id_;
|
|
|
|
int32 offset_;
|
|
|
|
int32 limit_;
|
|
|
|
bool only_local_;
|
|
|
|
|
|
|
|
tl_object_ptr<td_api::messages> messages_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
messages_ = td_->messages_manager_->get_dialog_history(dialog_id_, from_message_id_, offset_, limit_,
|
|
|
|
get_tries() - 1, only_local_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_result(std::move(messages_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatHistoryRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 from_message_id, int32 offset,
|
|
|
|
int32 limit, bool only_local)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, from_message_id_(from_message_id)
|
|
|
|
, offset_(offset)
|
|
|
|
, limit_(limit)
|
|
|
|
, only_local_(only_local) {
|
|
|
|
if (!only_local_) {
|
|
|
|
set_tries(4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetMessageThreadHistoryRequest final : public RequestActor<> {
|
2020-09-30 03:26:39 +02:00
|
|
|
DialogId dialog_id_;
|
|
|
|
MessageId message_id_;
|
|
|
|
MessageId from_message_id_;
|
|
|
|
int32 offset_;
|
|
|
|
int32 limit_;
|
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
std::pair<DialogId, vector<MessageId>> messages_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
messages_ = td_->messages_manager_->get_message_thread_history(dialog_id_, message_id_, from_message_id_, offset_,
|
|
|
|
limit_, random_id_, std::move(promise));
|
2020-09-30 03:26:39 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_messages_object(-1, messages_.first, messages_.second, true,
|
|
|
|
"GetMessageThreadHistoryRequest"));
|
2020-09-30 03:26:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetMessageThreadHistoryRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
|
|
|
int64 from_message_id, int32 offset, int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, message_id_(message_id)
|
|
|
|
, from_message_id_(from_message_id)
|
|
|
|
, offset_(offset)
|
|
|
|
, limit_(limit)
|
|
|
|
, random_id_(0) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-30 02:34:49 +02:00
|
|
|
class GetChatMessageCalendarRequest final : public RequestActor<> {
|
|
|
|
DialogId dialog_id_;
|
|
|
|
MessageId from_message_id_;
|
|
|
|
MessageSearchFilter filter_;
|
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::messageCalendar> calendar_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
calendar_ = td_->messages_manager_->get_dialog_message_calendar(dialog_id_, from_message_id_, filter_, random_id_,
|
|
|
|
get_tries() == 3, std::move(promise));
|
2021-10-30 02:34:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void do_send_result() final {
|
|
|
|
send_result(std::move(calendar_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatMessageCalendarRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 from_message_id,
|
|
|
|
tl_object_ptr<td_api::SearchMessagesFilter> filter)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, from_message_id_(from_message_id)
|
|
|
|
, filter_(get_message_search_filter(filter))
|
|
|
|
, random_id_(0) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchChatMessagesRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
string query_;
|
2021-11-15 15:25:24 +01:00
|
|
|
td_api::object_ptr<td_api::MessageSender> sender_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId from_message_id_;
|
|
|
|
int32 offset_;
|
|
|
|
int32 limit_;
|
2020-08-22 09:48:36 +02:00
|
|
|
MessageSearchFilter filter_;
|
2020-09-08 13:17:56 +02:00
|
|
|
MessageId top_thread_message_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
std::pair<int32, vector<MessageId>> messages_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-15 15:25:24 +01:00
|
|
|
messages_ = td_->messages_manager_->search_dialog_messages(dialog_id_, query_, sender_id_, from_message_id_,
|
|
|
|
offset_, limit_, filter_, top_thread_message_id_,
|
|
|
|
random_id_, get_tries() == 3, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_messages_object(messages_.first, dialog_id_, messages_.second, true,
|
|
|
|
"SearchChatMessagesRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_error(Status &&status) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (status.message() == "SEARCH_QUERY_EMPTY") {
|
|
|
|
messages_.first = 0;
|
|
|
|
messages_.second.clear();
|
|
|
|
return do_send_result();
|
|
|
|
}
|
|
|
|
send_error(std::move(status));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-10-14 13:41:04 +02:00
|
|
|
SearchChatMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query,
|
2021-11-15 15:25:24 +01:00
|
|
|
td_api::object_ptr<td_api::MessageSender> sender_id, int64 from_message_id, int32 offset,
|
2020-10-14 13:41:04 +02:00
|
|
|
int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter, int64 message_thread_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, query_(std::move(query))
|
2021-11-15 15:25:24 +01:00
|
|
|
, sender_id_(std::move(sender_id))
|
2018-12-31 20:04:05 +01:00
|
|
|
, from_message_id_(from_message_id)
|
|
|
|
, offset_(offset)
|
|
|
|
, limit_(limit)
|
2020-08-22 09:48:36 +02:00
|
|
|
, filter_(get_message_search_filter(filter))
|
2020-09-08 13:17:56 +02:00
|
|
|
, top_thread_message_id_(message_thread_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
, random_id_(0) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchSecretMessagesRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
string query_;
|
2020-08-18 14:10:03 +02:00
|
|
|
string offset_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 limit_;
|
2020-08-22 09:48:36 +02:00
|
|
|
MessageSearchFilter filter_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 random_id_;
|
|
|
|
|
2020-08-21 13:47:43 +02:00
|
|
|
MessagesManager::FoundMessages found_messages_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
found_messages_ = td_->messages_manager_->offline_search_messages(dialog_id_, query_, offset_, limit_, filter_,
|
|
|
|
random_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_found_messages_object(found_messages_, "SearchSecretMessagesRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-08-18 14:10:03 +02:00
|
|
|
SearchSecretMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query, string offset,
|
|
|
|
int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, query_(std::move(query))
|
2020-08-18 14:10:03 +02:00
|
|
|
, offset_(std::move(offset))
|
2018-12-31 20:04:05 +01:00
|
|
|
, limit_(limit)
|
2020-08-22 09:48:36 +02:00
|
|
|
, filter_(get_message_search_filter(filter))
|
2018-12-31 20:04:05 +01:00
|
|
|
, random_id_(0) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchMessagesRequest final : public RequestActor<> {
|
2019-10-22 14:06:11 +02:00
|
|
|
FolderId folder_id_;
|
|
|
|
bool ignore_folder_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
string query_;
|
|
|
|
int32 offset_date_;
|
|
|
|
DialogId offset_dialog_id_;
|
|
|
|
MessageId offset_message_id_;
|
|
|
|
int32 limit_;
|
2020-08-22 09:48:36 +02:00
|
|
|
MessageSearchFilter filter_;
|
2020-09-08 13:58:02 +02:00
|
|
|
int32 min_date_;
|
|
|
|
int32 max_date_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
std::pair<int32, vector<FullMessageId>> messages_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
messages_ = td_->messages_manager_->search_messages(folder_id_, ignore_folder_id_, query_, offset_date_,
|
|
|
|
offset_dialog_id_, offset_message_id_, limit_, filter_,
|
|
|
|
min_date_, max_date_, random_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-10-03 13:54:40 +02:00
|
|
|
send_result(
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_messages_object(messages_.first, messages_.second, true, "SearchMessagesRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_error(Status &&status) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (status.message() == "SEARCH_QUERY_EMPTY") {
|
|
|
|
messages_.first = 0;
|
|
|
|
messages_.second.clear();
|
|
|
|
return do_send_result();
|
|
|
|
}
|
|
|
|
send_error(std::move(status));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2019-10-22 14:06:11 +02:00
|
|
|
SearchMessagesRequest(ActorShared<Td> td, uint64 request_id, FolderId folder_id, bool ignore_folder_id, string query,
|
2020-08-21 16:40:05 +02:00
|
|
|
int32 offset_date, int64 offset_dialog_id, int64 offset_message_id, int32 limit,
|
2020-09-08 13:58:02 +02:00
|
|
|
tl_object_ptr<td_api::SearchMessagesFilter> &&filter, int32 min_date, int32 max_date)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id)
|
2019-10-22 14:06:11 +02:00
|
|
|
, folder_id_(folder_id)
|
|
|
|
, ignore_folder_id_(ignore_folder_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
, query_(std::move(query))
|
|
|
|
, offset_date_(offset_date)
|
|
|
|
, offset_dialog_id_(offset_dialog_id)
|
|
|
|
, offset_message_id_(offset_message_id)
|
|
|
|
, limit_(limit)
|
2020-08-22 09:48:36 +02:00
|
|
|
, filter_(get_message_search_filter(filter))
|
2020-09-08 13:58:02 +02:00
|
|
|
, min_date_(min_date)
|
|
|
|
, max_date_(max_date)
|
2018-12-31 20:04:05 +01:00
|
|
|
, random_id_(0) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchCallMessagesRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
MessageId from_message_id_;
|
|
|
|
int32 limit_;
|
|
|
|
bool only_missed_;
|
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
std::pair<int32, vector<FullMessageId>> messages_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
messages_ = td_->messages_manager_->search_call_messages(from_message_id_, limit_, only_missed_, random_id_,
|
|
|
|
get_tries() == 3, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_messages_object(messages_.first, messages_.second, true,
|
|
|
|
"SearchCallMessagesRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchCallMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 from_message_id, int32 limit, bool only_missed)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, from_message_id_(from_message_id)
|
|
|
|
, limit_(limit)
|
|
|
|
, only_missed_(only_missed)
|
|
|
|
, random_id_(0) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetActiveLiveLocationMessagesRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FullMessageId> full_message_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
full_message_ids_ = td_->messages_manager_->get_active_live_location_messages(std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_messages_object(-1, full_message_ids_, true,
|
|
|
|
"GetActiveLiveLocationMessagesRequest"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetActiveLiveLocationMessagesRequest(ActorShared<Td> td, uint64 request_id)
|
|
|
|
: RequestActor(std::move(td), request_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatMessageByDateRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
int32 date_;
|
|
|
|
|
|
|
|
int64 random_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
random_id_ = td_->messages_manager_->get_dialog_message_by_date(dialog_id_, date_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_dialog_message_by_date_object(random_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatMessageByDateRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int32 date)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), dialog_id_(dialog_id), date_(date), random_id_(0) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatScheduledMessagesRequest final : public RequestActor<> {
|
2019-12-04 18:06:39 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
|
|
|
|
vector<MessageId> message_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2020-02-27 19:31:19 +01:00
|
|
|
message_ids_ =
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->get_dialog_scheduled_messages(dialog_id_, get_tries() < 2, false, std::move(promise));
|
2019-12-04 18:06:39 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_messages_object(-1, dialog_id_, message_ids_, true,
|
|
|
|
"GetChatScheduledMessagesRequest"));
|
2019-12-04 18:06:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatScheduledMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
|
|
|
|
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id) {
|
2020-02-27 19:31:19 +01:00
|
|
|
set_tries(4);
|
2019-12-04 18:06:39 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetWebPagePreviewRequest final : public RequestOnceActor {
|
2018-02-20 22:20:45 +01:00
|
|
|
td_api::object_ptr<td_api::formattedText> text_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-02-20 22:20:45 +01:00
|
|
|
int64 request_id_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
request_id_ = td_->web_pages_manager_->get_web_page_preview(std::move(text_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->web_pages_manager_->get_web_page_preview_result(request_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-02-20 22:20:45 +01:00
|
|
|
GetWebPagePreviewRequest(ActorShared<Td> td, uint64 request_id, td_api::object_ptr<td_api::formattedText> text)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), text_(std::move(text)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-07 11:49:46 +02:00
|
|
|
class GetWebPageInstantViewRequest final : public RequestActor<WebPageId> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string url_;
|
|
|
|
bool force_full_;
|
|
|
|
|
|
|
|
WebPageId web_page_id_;
|
|
|
|
|
2021-10-07 11:49:46 +02:00
|
|
|
void do_run(Promise<WebPageId> &&promise) final {
|
|
|
|
if (get_tries() < 2) {
|
|
|
|
promise.set_value(std::move(web_page_id_));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->web_pages_manager_->get_web_page_instant_view(url_, force_full_, std::move(promise));
|
2021-10-07 11:49:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void do_set_result(WebPageId &&result) final {
|
|
|
|
web_page_id_ = result;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->web_pages_manager_->get_web_page_instant_view_object(web_page_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetWebPageInstantViewRequest(ActorShared<Td> td, uint64 request_id, string url, bool force_full)
|
|
|
|
: RequestActor(std::move(td), request_id), url_(std::move(url)), force_full_(force_full) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CreateChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id_;
|
2018-01-23 22:45:26 +01:00
|
|
|
bool force_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->create_dialog(dialog_id_, force_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-01-23 22:45:26 +01:00
|
|
|
CreateChatRequest(ActorShared<Td> td, uint64 request_id, DialogId dialog_id, bool force)
|
|
|
|
: RequestActor<>(std::move(td), request_id), dialog_id_(dialog_id), force_(force) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CreateNewGroupChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<UserId> user_ids_;
|
|
|
|
string title_;
|
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
DialogId dialog_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_id_ = td_->messages_manager_->create_new_group_chat(user_ids_, title_, random_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(dialog_id_.is_valid());
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-03-28 23:50:15 +02:00
|
|
|
CreateNewGroupChatRequest(ActorShared<Td> td, uint64 request_id, vector<UserId> user_ids, string title)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, user_ids_(std::move(user_ids))
|
|
|
|
, title_(std::move(title))
|
|
|
|
, random_id_(0) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CreateNewSecretChatRequest final : public RequestActor<SecretChatId> {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id_;
|
|
|
|
SecretChatId secret_chat_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<SecretChatId> &&promise) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (get_tries() < 2) {
|
|
|
|
promise.set_value(std::move(secret_chat_id_));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->create_new_secret_chat(user_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_set_result(SecretChatId &&result) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
secret_chat_id_ = result;
|
|
|
|
LOG(INFO) << "New " << secret_chat_id_ << " created";
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(secret_chat_id_.is_valid());
|
2021-06-24 19:09:10 +02:00
|
|
|
// SecretChatActor will send this update by itself
|
2018-12-31 20:04:05 +01:00
|
|
|
// But since the update may still be on its way, we will update essential fields here.
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->on_update_secret_chat(
|
2018-12-31 20:04:05 +01:00
|
|
|
secret_chat_id_, 0 /* no access_hash */, user_id_, SecretChatState::Unknown, true /* it is outbound chat */,
|
2021-02-02 00:33:48 +01:00
|
|
|
-1 /* unknown TTL */, 0 /* unknown creation date */, "" /* no key_hash */, 0, FolderId());
|
2018-12-31 20:04:05 +01:00
|
|
|
DialogId dialog_id(secret_chat_id_);
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->messages_manager_->force_create_dialog(dialog_id, "create new secret chat", true);
|
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
CreateNewSecretChatRequest(ActorShared<Td> td, uint64 request_id, int64 user_id)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), user_id_(user_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CreateNewSupergroupChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string title_;
|
|
|
|
bool is_megagroup_;
|
|
|
|
string description_;
|
2019-10-14 16:51:12 +02:00
|
|
|
DialogLocation location_;
|
2021-01-22 17:23:44 +01:00
|
|
|
bool for_import_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
DialogId dialog_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_id_ = td_->messages_manager_->create_new_channel_chat(title_, is_megagroup_, description_, location_,
|
|
|
|
for_import_, random_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(dialog_id_.is_valid());
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
CreateNewSupergroupChatRequest(ActorShared<Td> td, uint64 request_id, string title, bool is_megagroup,
|
2021-01-22 17:23:44 +01:00
|
|
|
string description, td_api::object_ptr<td_api::chatLocation> &&location,
|
|
|
|
bool for_import)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, title_(std::move(title))
|
|
|
|
, is_megagroup_(is_megagroup)
|
|
|
|
, description_(std::move(description))
|
2019-10-14 16:51:12 +02:00
|
|
|
, location_(std::move(location))
|
2021-01-22 17:23:44 +01:00
|
|
|
, for_import_(for_import)
|
2018-12-31 20:04:05 +01:00
|
|
|
, random_id_(0) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class UpgradeGroupChatToSupergroupChatRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string title_;
|
|
|
|
DialogId dialog_id_;
|
|
|
|
|
|
|
|
DialogId result_dialog_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
result_dialog_id_ = td_->messages_manager_->migrate_dialog_to_megagroup(dialog_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(result_dialog_id_.is_valid());
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(result_dialog_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
UpgradeGroupChatToSupergroupChatRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
|
|
|
|
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CheckChatInviteLinkRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string invite_link_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2022-03-11 11:00:25 +01:00
|
|
|
td_->contacts_manager_->check_dialog_invite_link(invite_link_, get_tries() < 2, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
auto result = td_->contacts_manager_->get_chat_invite_link_info_object(invite_link_);
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(result != nullptr);
|
|
|
|
send_result(std::move(result));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
CheckChatInviteLinkRequest(ActorShared<Td> td, uint64 request_id, string invite_link)
|
|
|
|
: RequestActor(std::move(td), request_id), invite_link_(std::move(invite_link)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class JoinChatByInviteLinkRequest final : public RequestActor<DialogId> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string invite_link_;
|
|
|
|
|
2018-02-28 23:08:45 +01:00
|
|
|
DialogId dialog_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<DialogId> &&promise) final {
|
2018-02-28 23:08:45 +01:00
|
|
|
if (get_tries() < 2) {
|
|
|
|
promise.set_value(std::move(dialog_id_));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->import_dialog_invite_link(invite_link_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_set_result(DialogId &&result) final {
|
2018-02-28 23:08:45 +01:00
|
|
|
dialog_id_ = result;
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-02-28 23:08:45 +01:00
|
|
|
CHECK(dialog_id_.is_valid());
|
2021-12-23 12:18:32 +01:00
|
|
|
td_->messages_manager_->force_create_dialog(dialog_id_, "join chat via an invite link");
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->messages_manager_->get_chat_object(dialog_id_));
|
2018-02-28 23:08:45 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
JoinChatByInviteLinkRequest(ActorShared<Td> td, uint64 request_id, string invite_link)
|
2018-02-28 23:08:45 +01:00
|
|
|
: RequestActor(std::move(td), request_id), invite_link_(std::move(invite_link)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class ImportContactsRequest final : public RequestActor<> {
|
2021-09-30 13:18:01 +02:00
|
|
|
vector<Contact> contacts_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
std::pair<vector<UserId>, vector<int32>> imported_contacts_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
imported_contacts_ = td_->contacts_manager_->import_contacts(contacts_, random_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(imported_contacts_.first.size() == contacts_.size());
|
|
|
|
CHECK(imported_contacts_.second.size() == contacts_.size());
|
2018-02-03 00:05:11 +01:00
|
|
|
send_result(make_tl_object<td_api::importedContacts>(transform(imported_contacts_.first,
|
|
|
|
[this](UserId user_id) {
|
2021-11-08 13:26:22 +01:00
|
|
|
return td_->contacts_manager_->get_user_id_object(
|
2018-02-03 00:05:11 +01:00
|
|
|
user_id, "ImportContactsRequest");
|
|
|
|
}),
|
|
|
|
std::move(imported_contacts_.second)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-30 13:18:01 +02:00
|
|
|
ImportContactsRequest(ActorShared<Td> td, uint64 request_id, vector<Contact> &&contacts)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), contacts_(std::move(contacts)), random_id_(0) {
|
|
|
|
set_tries(3); // load_contacts + import_contacts
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchContactsRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string query_;
|
|
|
|
int32 limit_;
|
|
|
|
|
|
|
|
std::pair<int32, vector<UserId>> user_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
user_ids_ = td_->contacts_manager_->search_contacts(query_, limit_, std::move(promise));
|
2018-06-28 23:06:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_users_object(user_ids_.first, user_ids_.second));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-06-28 23:06:17 +02:00
|
|
|
SearchContactsRequest(ActorShared<Td> td, uint64 request_id, string query, int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), query_(std::move(query)), limit_(limit) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class RemoveContactsRequest final : public RequestActor<> {
|
2018-06-28 23:06:17 +02:00
|
|
|
vector<UserId> user_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->contacts_manager_->remove_contacts(user_ids_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-03-28 23:50:15 +02:00
|
|
|
RemoveContactsRequest(ActorShared<Td> td, uint64 request_id, vector<UserId> &&user_ids)
|
|
|
|
: RequestActor(std::move(td), request_id), user_ids_(std::move(user_ids)) {
|
2018-06-28 23:06:17 +02:00
|
|
|
set_tries(3); // load_contacts + delete_contacts
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetImportedContactCountRequest final : public RequestActor<> {
|
2018-06-28 23:06:17 +02:00
|
|
|
int32 imported_contact_count_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
imported_contact_count_ = td_->contacts_manager_->get_imported_contact_count(std::move(promise));
|
2018-06-28 23:06:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-06-28 23:06:17 +02:00
|
|
|
send_result(td_api::make_object<td_api::count>(imported_contact_count_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-06-28 23:06:17 +02:00
|
|
|
GetImportedContactCountRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class ChangeImportedContactsRequest final : public RequestActor<> {
|
2021-09-30 13:18:01 +02:00
|
|
|
vector<Contact> contacts_;
|
2018-06-28 23:06:17 +02:00
|
|
|
size_t contacts_size_;
|
|
|
|
int64 random_id_;
|
|
|
|
|
|
|
|
std::pair<vector<UserId>, vector<int32>> imported_contacts_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
imported_contacts_ = td_->contacts_manager_->change_imported_contacts(contacts_, random_id_, std::move(promise));
|
2018-06-28 23:06:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-06-28 23:06:17 +02:00
|
|
|
CHECK(imported_contacts_.first.size() == contacts_size_);
|
|
|
|
CHECK(imported_contacts_.second.size() == contacts_size_);
|
|
|
|
send_result(make_tl_object<td_api::importedContacts>(transform(imported_contacts_.first,
|
|
|
|
[this](UserId user_id) {
|
2021-11-08 13:26:22 +01:00
|
|
|
return td_->contacts_manager_->get_user_id_object(
|
2018-06-28 23:06:17 +02:00
|
|
|
user_id, "ChangeImportedContactsRequest");
|
|
|
|
}),
|
|
|
|
std::move(imported_contacts_.second)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-30 13:18:01 +02:00
|
|
|
ChangeImportedContactsRequest(ActorShared<Td> td, uint64 request_id, vector<Contact> &&contacts)
|
2018-06-28 23:06:17 +02:00
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, contacts_(std::move(contacts))
|
|
|
|
, contacts_size_(contacts_.size())
|
|
|
|
, random_id_(0) {
|
|
|
|
set_tries(4); // load_contacts + load_local_contacts + (import_contacts + delete_contacts)
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetRecentInlineBotsRequest final : public RequestActor<> {
|
2018-06-28 23:06:17 +02:00
|
|
|
vector<UserId> user_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
user_ids_ = td_->inline_queries_manager_->get_recent_inline_bots(std::move(promise));
|
2018-06-28 23:06:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->contacts_manager_->get_users_object(-1, user_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-06-28 23:06:17 +02:00
|
|
|
GetRecentInlineBotsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetUserProfilePhotosRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id_;
|
|
|
|
int32 offset_;
|
|
|
|
int32 limit_;
|
|
|
|
std::pair<int32, vector<const Photo *>> photos;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
photos = td_->contacts_manager_->get_user_profile_photos(user_id_, offset_, limit_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
// TODO create function get_user_profile_photos_object
|
2021-11-08 13:26:22 +01:00
|
|
|
auto result = transform(photos.second, [file_manager = td_->file_manager_.get()](const Photo *photo) {
|
2020-07-06 17:45:43 +02:00
|
|
|
CHECK(photo != nullptr);
|
2020-07-07 13:19:54 +02:00
|
|
|
CHECK(!photo->is_empty());
|
|
|
|
return get_chat_photo_object(file_manager, *photo);
|
2018-09-12 22:59:10 +02:00
|
|
|
});
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2020-07-07 13:19:54 +02:00
|
|
|
send_result(make_tl_object<td_api::chatPhotos>(photos.first, std::move(result)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetUserProfilePhotosRequest(ActorShared<Td> td, uint64 request_id, int64 user_id, int32 offset, int32 limit)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), user_id_(user_id), offset_(offset), limit_(limit) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetChatNotificationSettingsExceptionsRequest final : public RequestActor<> {
|
2019-02-14 19:44:20 +01:00
|
|
|
NotificationSettingsScope scope_;
|
|
|
|
bool filter_scope_;
|
|
|
|
bool compare_sound_;
|
|
|
|
|
|
|
|
vector<DialogId> dialog_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
dialog_ids_ = td_->messages_manager_->get_dialog_notification_settings_exceptions(
|
2019-03-05 15:15:17 +01:00
|
|
|
scope_, filter_scope_, compare_sound_, get_tries() < 3, std::move(promise));
|
2019-02-14 19:44:20 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2020-09-19 23:28:26 +02:00
|
|
|
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
2019-02-14 19:44:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetChatNotificationSettingsExceptionsRequest(ActorShared<Td> td, uint64 request_id, NotificationSettingsScope scope,
|
|
|
|
bool filter_scope, bool compare_sound)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, scope_(scope)
|
|
|
|
, filter_scope_(filter_scope)
|
|
|
|
, compare_sound_(compare_sound) {
|
2019-03-05 15:15:17 +01:00
|
|
|
set_tries(3);
|
2019-02-14 19:44:20 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetScopeNotificationSettingsRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
NotificationSettingsScope scope_;
|
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
const ScopeNotificationSettings *notification_settings_ = nullptr;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2022-04-11 11:45:52 +02:00
|
|
|
notification_settings_ =
|
|
|
|
td_->notification_settings_manager_->get_scope_notification_settings(scope_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(notification_settings_ != nullptr);
|
2018-09-29 02:29:57 +02:00
|
|
|
send_result(get_scope_notification_settings_object(notification_settings_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-04-09 18:30:27 +02:00
|
|
|
GetScopeNotificationSettingsRequest(ActorShared<Td> td, uint64 request_id, NotificationSettingsScope scope)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id), scope_(scope) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetStickersRequest final : public RequestActor<> {
|
2022-07-24 13:53:48 +02:00
|
|
|
StickerType sticker_type_;
|
2022-09-27 19:52:47 +02:00
|
|
|
string query_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 limit_;
|
2022-08-05 13:06:06 +02:00
|
|
|
DialogId dialog_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
vector<FileId> sticker_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2022-09-27 19:52:47 +02:00
|
|
|
sticker_ids_ = td_->stickers_manager_->get_stickers(sticker_type_, query_, limit_, dialog_id_, get_tries() < 2,
|
2022-08-05 13:06:06 +02:00
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_stickers_object(sticker_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2022-09-27 19:52:47 +02:00
|
|
|
GetStickersRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type, string &&query, int32 limit,
|
2022-08-05 13:06:06 +02:00
|
|
|
int64 dialog_id)
|
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, sticker_type_(sticker_type)
|
2022-09-27 19:52:47 +02:00
|
|
|
, query_(std::move(query))
|
2022-08-05 13:06:06 +02:00
|
|
|
, limit_(limit)
|
|
|
|
, dialog_id_(dialog_id) {
|
2022-08-06 22:39:54 +02:00
|
|
|
set_tries(4);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetInstalledStickerSetsRequest final : public RequestActor<> {
|
2022-07-14 15:17:19 +02:00
|
|
|
StickerType sticker_type_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> sticker_set_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2022-07-14 15:17:19 +02:00
|
|
|
sticker_set_ids_ = td_->stickers_manager_->get_installed_sticker_sets(sticker_type_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_sets_object(-1, sticker_set_ids_, 1));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2022-07-14 15:17:19 +02:00
|
|
|
GetInstalledStickerSetsRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type)
|
|
|
|
: RequestActor(std::move(td), request_id), sticker_type_(sticker_type) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetArchivedStickerSetsRequest final : public RequestActor<> {
|
2022-07-14 15:17:19 +02:00
|
|
|
StickerType sticker_type_;
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId offset_sticker_set_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 limit_;
|
|
|
|
|
2021-11-11 15:39:09 +01:00
|
|
|
int32 total_count_ = -1;
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> sticker_set_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
std::tie(total_count_, sticker_set_ids_) = td_->stickers_manager_->get_archived_sticker_sets(
|
2022-07-14 15:17:19 +02:00
|
|
|
sticker_type_, offset_sticker_set_id_, limit_, get_tries() < 2, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_sets_object(total_count_, sticker_set_ids_, 1));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2022-07-14 15:17:19 +02:00
|
|
|
GetArchivedStickerSetsRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type,
|
|
|
|
int64 offset_sticker_set_id, int32 limit)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestActor(std::move(td), request_id)
|
2022-07-14 15:17:19 +02:00
|
|
|
, sticker_type_(sticker_type)
|
2018-12-31 20:04:05 +01:00
|
|
|
, offset_sticker_set_id_(offset_sticker_set_id)
|
|
|
|
, limit_(limit) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetTrendingStickerSetsRequest final : public RequestActor<> {
|
2022-06-17 18:16:17 +02:00
|
|
|
td_api::object_ptr<td_api::trendingStickerSets> result_;
|
2022-07-17 21:39:22 +02:00
|
|
|
StickerType sticker_type_;
|
2020-04-18 00:55:54 +02:00
|
|
|
int32 offset_;
|
|
|
|
int32 limit_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2022-07-17 21:39:22 +02:00
|
|
|
result_ = td_->stickers_manager_->get_featured_sticker_sets(sticker_type_, offset_, limit_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2022-06-17 18:16:17 +02:00
|
|
|
send_result(std::move(result_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2022-07-17 21:39:22 +02:00
|
|
|
GetTrendingStickerSetsRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type, int32 offset,
|
|
|
|
int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), sticker_type_(sticker_type), offset_(offset), limit_(limit) {
|
2020-04-18 00:55:54 +02:00
|
|
|
set_tries(3);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetAttachedStickerSetsRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
FileId file_id_;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> sticker_set_ids_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
sticker_set_ids_ = td_->stickers_manager_->get_attached_sticker_sets(file_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_sets_object(-1, sticker_set_ids_, 5));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetAttachedStickerSetsRequest(ActorShared<Td> td, uint64 request_id, int32 file_id)
|
2018-03-07 00:37:39 +01:00
|
|
|
: RequestActor(std::move(td), request_id), file_id_(file_id, 0) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetStickerSetRequest final : public RequestActor<> {
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId set_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId sticker_set_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
sticker_set_id_ = td_->stickers_manager_->get_sticker_set(set_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_set_object(sticker_set_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetStickerSetRequest(ActorShared<Td> td, uint64 request_id, int64 set_id)
|
|
|
|
: RequestActor(std::move(td), request_id), set_id_(set_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchStickerSetRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
string name_;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId sticker_set_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
sticker_set_id_ = td_->stickers_manager_->search_sticker_set(name_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_set_object(sticker_set_id_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchStickerSetRequest(ActorShared<Td> td, uint64 request_id, string &&name)
|
|
|
|
: RequestActor(std::move(td), request_id), name_(std::move(name)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchInstalledStickerSetsRequest final : public RequestActor<> {
|
2022-07-14 15:17:19 +02:00
|
|
|
StickerType sticker_type_;
|
2018-03-05 23:44:11 +01:00
|
|
|
string query_;
|
|
|
|
int32 limit_;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
std::pair<int32, vector<StickerSetId>> sticker_set_ids_;
|
2018-03-05 23:44:11 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2018-03-05 23:44:11 +01:00
|
|
|
sticker_set_ids_ =
|
2022-07-14 15:17:19 +02:00
|
|
|
td_->stickers_manager_->search_installed_sticker_sets(sticker_type_, query_, limit_, std::move(promise));
|
2018-03-05 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_sets_object(sticker_set_ids_.first, sticker_set_ids_.second, 5));
|
2018-03-05 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2022-07-14 15:17:19 +02:00
|
|
|
SearchInstalledStickerSetsRequest(ActorShared<Td> td, uint64 request_id, StickerType sticker_type, string &&query,
|
|
|
|
int32 limit)
|
|
|
|
: RequestActor(std::move(td), request_id), sticker_type_(sticker_type), query_(std::move(query)), limit_(limit) {
|
2018-03-05 23:44:11 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchStickerSetsRequest final : public RequestActor<> {
|
2018-03-05 23:44:11 +01:00
|
|
|
string query_;
|
|
|
|
|
2019-09-18 05:55:43 +02:00
|
|
|
vector<StickerSetId> sticker_set_ids_;
|
2018-03-05 23:44:11 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
sticker_set_ids_ = td_->stickers_manager_->search_sticker_sets(query_, std::move(promise));
|
2018-03-05 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_sticker_sets_object(-1, sticker_set_ids_, 5));
|
2018-03-05 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchStickerSetsRequest(ActorShared<Td> td, uint64 request_id, string &&query)
|
|
|
|
: RequestActor(std::move(td), request_id), query_(std::move(query)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class ChangeStickerSetRequest final : public RequestOnceActor {
|
2019-09-18 05:55:43 +02:00
|
|
|
StickerSetId set_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_installed_;
|
|
|
|
bool is_archived_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->stickers_manager_->change_sticker_set(set_id_, is_installed_, is_archived_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
ChangeStickerSetRequest(ActorShared<Td> td, uint64 request_id, int64 set_id, bool is_installed, bool is_archived)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, set_id_(set_id)
|
|
|
|
, is_installed_(is_installed)
|
|
|
|
, is_archived_(is_archived) {
|
2018-03-10 12:15:23 +01:00
|
|
|
set_tries(4);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class UploadStickerFileRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId user_id_;
|
2022-01-25 14:56:10 +01:00
|
|
|
tl_object_ptr<td_api::inputSticker> sticker_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
FileId file_id;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
file_id = td_->stickers_manager_->upload_sticker_file(user_id_, std::move(sticker_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->file_manager_->get_file_object(file_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
UploadStickerFileRequest(ActorShared<Td> td, uint64 request_id, int64 user_id,
|
2022-01-25 14:56:10 +01:00
|
|
|
tl_object_ptr<td_api::inputSticker> &&sticker)
|
2018-12-31 20:04:05 +01:00
|
|
|
: RequestOnceActor(std::move(td), request_id), user_id_(user_id), sticker_(std::move(sticker)) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetRecentStickersRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_attached_;
|
|
|
|
|
|
|
|
vector<FileId> sticker_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
sticker_ids_ = td_->stickers_manager_->get_recent_stickers(is_attached_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_stickers_object(sticker_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetRecentStickersRequest(ActorShared<Td> td, uint64 request_id, bool is_attached)
|
|
|
|
: RequestActor(std::move(td), request_id), is_attached_(is_attached) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class AddRecentStickerRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_attached_;
|
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->stickers_manager_->add_recent_sticker(is_attached_, input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
AddRecentStickerRequest(ActorShared<Td> td, uint64 request_id, bool is_attached,
|
|
|
|
tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestActor(std::move(td), request_id), is_attached_(is_attached), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class RemoveRecentStickerRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_attached_;
|
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->stickers_manager_->remove_recent_sticker(is_attached_, input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
RemoveRecentStickerRequest(ActorShared<Td> td, uint64 request_id, bool is_attached,
|
|
|
|
tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestActor(std::move(td), request_id), is_attached_(is_attached), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class ClearRecentStickersRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_attached_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->stickers_manager_->clear_recent_stickers(is_attached_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
ClearRecentStickersRequest(ActorShared<Td> td, uint64 request_id, bool is_attached)
|
|
|
|
: RequestActor(std::move(td), request_id), is_attached_(is_attached) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetFavoriteStickersRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FileId> sticker_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
sticker_ids_ = td_->stickers_manager_->get_favorite_stickers(std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_stickers_object(sticker_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetFavoriteStickersRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class AddFavoriteStickerRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->stickers_manager_->add_favorite_sticker(input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
AddFavoriteStickerRequest(ActorShared<Td> td, uint64 request_id, tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class RemoveFavoriteStickerRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->stickers_manager_->remove_favorite_sticker(input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
RemoveFavoriteStickerRequest(ActorShared<Td> td, uint64 request_id, tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetStickerEmojisRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
|
|
|
vector<string> emojis_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
emojis_ = td_->stickers_manager_->get_sticker_emojis(input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2019-05-21 17:48:35 +02:00
|
|
|
send_result(td_api::make_object<td_api::emojis>(std::move(emojis_)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetStickerEmojisRequest(ActorShared<Td> td, uint64 request_id, tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestActor(std::move(td), request_id), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchEmojisRequest final : public RequestActor<> {
|
2019-05-21 17:48:35 +02:00
|
|
|
string text_;
|
|
|
|
bool exact_match_;
|
2020-04-22 14:17:53 +02:00
|
|
|
vector<string> input_language_codes_;
|
2019-05-21 17:48:35 +02:00
|
|
|
|
|
|
|
vector<string> emojis_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
emojis_ = td_->stickers_manager_->search_emojis(text_, exact_match_, input_language_codes_, get_tries() < 2,
|
|
|
|
std::move(promise));
|
2019-05-21 17:48:35 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2019-05-21 17:48:35 +02:00
|
|
|
send_result(td_api::make_object<td_api::emojis>(std::move(emojis_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-01-08 17:07:40 +01:00
|
|
|
SearchEmojisRequest(ActorShared<Td> td, uint64 request_id, string &&text, bool exact_match,
|
2020-04-22 14:17:53 +02:00
|
|
|
vector<string> &&input_language_codes)
|
2020-01-08 17:07:40 +01:00
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, text_(std::move(text))
|
|
|
|
, exact_match_(exact_match)
|
2020-04-22 14:17:53 +02:00
|
|
|
, input_language_codes_(std::move(input_language_codes)) {
|
2019-05-21 17:48:35 +02:00
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetEmojiSuggestionsUrlRequest final : public RequestOnceActor {
|
2019-05-21 21:44:13 +02:00
|
|
|
string language_code_;
|
|
|
|
|
|
|
|
int64 random_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
random_id_ = td_->stickers_manager_->get_emoji_suggestions_url(language_code_, std::move(promise));
|
2019-05-21 21:44:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->stickers_manager_->get_emoji_suggestions_url_result(random_id_));
|
2019-05-21 21:44:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetEmojiSuggestionsUrlRequest(ActorShared<Td> td, uint64 request_id, string &&language_code)
|
2021-11-11 15:39:09 +01:00
|
|
|
: RequestOnceActor(std::move(td), request_id), language_code_(std::move(language_code)), random_id_(0) {
|
2019-05-21 21:44:13 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetSavedAnimationsRequest final : public RequestActor<> {
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<FileId> animation_ids_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
animation_ids_ = td_->animations_manager_->get_saved_animations(std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2022-04-13 21:14:40 +02:00
|
|
|
send_result(make_tl_object<td_api::animations>(transform(animation_ids_, [td = td_](FileId animation_id) {
|
|
|
|
return td->animations_manager_->get_animation_object(animation_id);
|
|
|
|
})));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetSavedAnimationsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class AddSavedAnimationRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->animations_manager_->add_saved_animation(input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
AddSavedAnimationRequest(ActorShared<Td> td, uint64 request_id, tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class RemoveSavedAnimationRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<td_api::InputFile> input_file_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
td_->animations_manager_->remove_saved_animation(input_file_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
RemoveSavedAnimationRequest(ActorShared<Td> td, uint64 request_id, tl_object_ptr<td_api::InputFile> &&input_file)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), input_file_(std::move(input_file)) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-14 12:23:43 +02:00
|
|
|
class GetSavedNotificationSoundRequest final : public RequestActor<> {
|
|
|
|
int64 ringtone_id_;
|
|
|
|
FileId ringtone_file_id_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
|
|
|
ringtone_file_id_ = td_->notification_settings_manager_->get_saved_ringtone(ringtone_id_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_send_result() final {
|
|
|
|
send_result(td_->audios_manager_->get_notification_sound_object(ringtone_file_id_));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetSavedNotificationSoundRequest(ActorShared<Td> td, uint64 request_id, int64 ringtone_id)
|
|
|
|
: RequestActor(std::move(td), request_id), ringtone_id_(ringtone_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-13 21:14:40 +02:00
|
|
|
class GetSavedNotificationSoundsRequest final : public RequestActor<> {
|
|
|
|
vector<FileId> ringtone_file_ids_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
|
|
|
ringtone_file_ids_ = td_->notification_settings_manager_->get_saved_ringtones(std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_send_result() final {
|
|
|
|
send_result(td_api::make_object<td_api::notificationSounds>(
|
|
|
|
transform(ringtone_file_ids_, [td = td_](FileId ringtone_file_id) {
|
|
|
|
return td->audios_manager_->get_notification_sound_object(ringtone_file_id);
|
|
|
|
})));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
GetSavedNotificationSoundsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-14 13:31:18 +02:00
|
|
|
class RemoveSavedNotificationSoundRequest final : public RequestOnceActor {
|
|
|
|
int64 ringtone_id_;
|
|
|
|
|
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
|
|
|
td_->notification_settings_manager_->remove_saved_ringtone(ringtone_id_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
RemoveSavedNotificationSoundRequest(ActorShared<Td> td, uint64 request_id, int64 ringtone_id)
|
|
|
|
: RequestOnceActor(std::move(td), request_id), ringtone_id_(ringtone_id) {
|
|
|
|
set_tries(3);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class GetInlineQueryResultsRequest final : public RequestOnceActor {
|
2018-12-31 20:04:05 +01:00
|
|
|
UserId bot_user_id_;
|
|
|
|
DialogId dialog_id_;
|
|
|
|
Location user_location_;
|
|
|
|
string query_;
|
|
|
|
string offset_;
|
|
|
|
|
|
|
|
uint64 query_hash_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
query_hash_ = td_->inline_queries_manager_->send_inline_query(bot_user_id_, dialog_id_, user_location_, query_,
|
|
|
|
offset_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->inline_queries_manager_->get_inline_query_results_object(query_hash_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2021-09-03 11:27:59 +02:00
|
|
|
GetInlineQueryResultsRequest(ActorShared<Td> td, uint64 request_id, int64 bot_user_id, int64 dialog_id,
|
2018-12-31 20:04:05 +01:00
|
|
|
const tl_object_ptr<td_api::location> &user_location, string query, string offset)
|
|
|
|
: RequestOnceActor(std::move(td), request_id)
|
|
|
|
, bot_user_id_(bot_user_id)
|
|
|
|
, dialog_id_(dialog_id)
|
|
|
|
, user_location_(user_location)
|
|
|
|
, query_(std::move(query))
|
|
|
|
, offset_(std::move(offset))
|
|
|
|
, query_hash_(0) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SearchBackgroundRequest final : public RequestActor<> {
|
2019-05-07 17:21:57 +02:00
|
|
|
string name_;
|
|
|
|
|
2021-05-26 19:17:05 +02:00
|
|
|
std::pair<BackgroundId, BackgroundType> background_;
|
2019-05-07 17:21:57 +02:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
background_ = td_->background_manager_->search_background(name_, std::move(promise));
|
2019-05-07 17:21:57 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->background_manager_->get_background_object(background_.first, false, &background_.second));
|
2019-05-07 17:21:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SearchBackgroundRequest(ActorShared<Td> td, uint64 request_id, string &&name)
|
|
|
|
: RequestActor(std::move(td), request_id), name_(std::move(name)) {
|
2019-07-19 04:34:49 +02:00
|
|
|
set_tries(3);
|
2019-05-07 17:21:57 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class SetBackgroundRequest final : public RequestActor<> {
|
2019-05-10 14:36:37 +02:00
|
|
|
td_api::object_ptr<td_api::InputBackground> input_background_;
|
|
|
|
td_api::object_ptr<td_api::BackgroundType> background_type_;
|
2019-06-18 00:39:57 +02:00
|
|
|
bool for_dark_theme_ = false;
|
2019-05-10 14:36:37 +02:00
|
|
|
|
|
|
|
BackgroundId background_id_;
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_run(Promise<Unit> &&promise) final {
|
2021-11-08 13:26:22 +01:00
|
|
|
background_id_ = td_->background_manager_->set_background(input_background_.get(), background_type_.get(),
|
|
|
|
for_dark_theme_, std::move(promise));
|
2019-05-10 14:36:37 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void do_send_result() final {
|
2021-11-08 13:26:22 +01:00
|
|
|
send_result(td_->background_manager_->get_background_object(background_id_, for_dark_theme_, nullptr));
|
2019-05-10 14:36:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
SetBackgroundRequest(ActorShared<Td> td, uint64 request_id,
|
|
|
|
td_api::object_ptr<td_api::InputBackground> &&input_background,
|
2019-06-18 00:39:57 +02:00
|
|
|
td_api::object_ptr<td_api::BackgroundType> background_type, bool for_dark_theme)
|
2019-05-10 14:36:37 +02:00
|
|
|
: RequestActor(std::move(td), request_id)
|
|
|
|
, input_background_(std::move(input_background))
|
2019-06-18 00:39:57 +02:00
|
|
|
, background_type_(std::move(background_type))
|
|
|
|
, for_dark_theme_(for_dark_theme) {
|
2019-05-10 14:36:37 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
Td::Td(unique_ptr<TdCallback> callback, Options options)
|
|
|
|
: callback_(std::move(callback)), td_options_(std::move(options)) {
|
2020-09-02 22:35:54 +02:00
|
|
|
CHECK(callback_ != nullptr);
|
2021-05-07 19:52:54 +02:00
|
|
|
LOG(INFO) << "Create Td with layer " << MTPROTO_LAYER << ", database version " << current_db_version()
|
2021-12-06 18:11:25 +01:00
|
|
|
<< " and version " << static_cast<int32>(Version::Next) - 1 << " on "
|
|
|
|
<< Scheduler::instance()->sched_count() << " threads";
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-04-27 00:21:08 +02:00
|
|
|
Td::~Td() = default;
|
|
|
|
|
2018-02-09 16:59:13 +01:00
|
|
|
void Td::on_alarm_timeout_callback(void *td_ptr, int64 alarm_id) {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto td = static_cast<Td *>(td_ptr);
|
|
|
|
auto td_id = td->actor_id(td);
|
2018-02-09 16:59:13 +01:00
|
|
|
send_closure_later(td_id, &Td::on_alarm_timeout, alarm_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-02-09 16:59:13 +01:00
|
|
|
void Td::on_alarm_timeout(int64 alarm_id) {
|
2018-02-11 19:33:32 +01:00
|
|
|
if (alarm_id == ONLINE_ALARM_ID) {
|
2018-12-31 20:04:05 +01:00
|
|
|
on_online_updated(false, true);
|
|
|
|
return;
|
|
|
|
}
|
2018-06-13 20:21:29 +02:00
|
|
|
if (alarm_id == PING_SERVER_ALARM_ID) {
|
2020-11-01 19:36:42 +01:00
|
|
|
if (!close_flag_ && updates_manager_ != nullptr && auth_manager_->is_authorized()) {
|
2018-06-13 20:21:29 +02:00
|
|
|
updates_manager_->ping_server();
|
|
|
|
alarm_timeout_.set_timeout_in(PING_SERVER_ALARM_ID,
|
|
|
|
PING_SERVER_TIMEOUT + Random::fast(0, PING_SERVER_TIMEOUT / 5));
|
2021-03-02 02:06:02 +01:00
|
|
|
set_is_bot_online(false);
|
2018-06-13 20:21:29 +02:00
|
|
|
}
|
2018-02-11 19:33:32 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-06-13 20:21:29 +02:00
|
|
|
if (alarm_id == TERMS_OF_SERVICE_ALARM_ID) {
|
2019-04-18 17:18:20 +02:00
|
|
|
if (!close_flag_ && !auth_manager_->is_bot()) {
|
2018-06-13 20:21:29 +02:00
|
|
|
get_terms_of_service(
|
|
|
|
this, PromiseCreator::lambda([actor_id = actor_id(this)](Result<std::pair<int32, TermsOfService>> result) {
|
|
|
|
send_closure(actor_id, &Td::on_get_terms_of_service, std::move(result), false);
|
|
|
|
}));
|
|
|
|
}
|
2018-06-08 00:19:34 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-04-30 20:00:58 +02:00
|
|
|
if (alarm_id == PROMO_DATA_ALARM_ID) {
|
|
|
|
if (!close_flag_ && !auth_manager_->is_bot()) {
|
|
|
|
auto promise = PromiseCreator::lambda(
|
|
|
|
[actor_id = actor_id(this)](Result<telegram_api::object_ptr<telegram_api::help_PromoData>> result) {
|
|
|
|
send_closure(actor_id, &Td::on_get_promo_data, std::move(result), false);
|
|
|
|
});
|
|
|
|
create_handler<GetPromoDataQuery>(std::move(promise))->send();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2018-12-18 08:43:28 +01:00
|
|
|
if (close_flag_ >= 2) {
|
|
|
|
// pending_alarms_ was already cleared
|
|
|
|
return;
|
|
|
|
}
|
2018-06-13 20:21:29 +02:00
|
|
|
|
2018-02-09 16:59:13 +01:00
|
|
|
auto it = pending_alarms_.find(alarm_id);
|
2018-12-18 08:43:28 +01:00
|
|
|
CHECK(it != pending_alarms_.end());
|
2018-02-09 16:59:13 +01:00
|
|
|
uint64 request_id = it->second;
|
|
|
|
pending_alarms_.erase(alarm_id);
|
|
|
|
send_result(request_id, make_tl_object<td_api::ok>());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_online_updated(bool force, bool send_update) {
|
2020-01-05 13:24:37 +01:00
|
|
|
if (close_flag_ >= 2 || !auth_manager_->is_authorized() || auth_manager_->is_bot()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (force || is_online_) {
|
2018-03-10 15:10:23 +01:00
|
|
|
contacts_manager_->set_my_online_status(is_online_, send_update, true);
|
2018-03-10 12:41:59 +01:00
|
|
|
if (!update_status_query_.empty()) {
|
|
|
|
LOG(INFO) << "Cancel previous update status query";
|
|
|
|
cancel_query(update_status_query_);
|
|
|
|
}
|
|
|
|
update_status_query_ = create_handler<UpdateStatusQuery>()->send(!is_online_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (is_online_) {
|
2020-09-30 21:21:32 +02:00
|
|
|
alarm_timeout_.set_timeout_in(
|
2022-08-17 15:11:13 +02:00
|
|
|
ONLINE_ALARM_ID, static_cast<double>(G()->get_option_integer("online_update_period_ms", 210000)) * 1e-3);
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
2018-02-11 19:33:32 +01:00
|
|
|
alarm_timeout_.cancel_timeout(ONLINE_ALARM_ID);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 15:10:23 +01:00
|
|
|
void Td::on_update_status_success(bool is_online) {
|
|
|
|
if (is_online == is_online_) {
|
|
|
|
if (!update_status_query_.empty()) {
|
|
|
|
update_status_query_ = NetQueryRef();
|
|
|
|
}
|
|
|
|
contacts_manager_->set_my_online_status(is_online_, true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-20 22:08:55 +02:00
|
|
|
td_api::object_ptr<td_api::updateTermsOfService> Td::get_update_terms_of_service_object() const {
|
|
|
|
auto terms_of_service = pending_terms_of_service_.get_terms_of_service_object();
|
|
|
|
if (terms_of_service == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::updateTermsOfService>(pending_terms_of_service_.get_id().str(),
|
|
|
|
std::move(terms_of_service));
|
|
|
|
}
|
|
|
|
|
2018-06-08 00:19:34 +02:00
|
|
|
void Td::on_get_terms_of_service(Result<std::pair<int32, TermsOfService>> result, bool dummy) {
|
|
|
|
int32 expires_in = 0;
|
|
|
|
if (result.is_error()) {
|
|
|
|
expires_in = Random::fast(10, 60);
|
|
|
|
} else {
|
2021-10-19 17:11:16 +02:00
|
|
|
auto terms = result.move_as_ok();
|
|
|
|
pending_terms_of_service_ = std::move(terms.second);
|
2018-09-20 22:08:55 +02:00
|
|
|
auto update = get_update_terms_of_service_object();
|
|
|
|
if (update == nullptr) {
|
2021-10-19 17:11:16 +02:00
|
|
|
expires_in = min(max(terms.first, G()->unix_time() + 3600) - G()->unix_time(), 86400);
|
2018-06-08 00:19:34 +02:00
|
|
|
} else {
|
2018-09-20 22:08:55 +02:00
|
|
|
send_update(std::move(update));
|
2018-06-08 00:19:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (expires_in > 0) {
|
|
|
|
schedule_get_terms_of_service(expires_in);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::schedule_get_terms_of_service(int32 expires_in) {
|
2018-09-20 22:08:55 +02:00
|
|
|
if (expires_in == 0) {
|
|
|
|
// drop pending Terms of Service after successful accept
|
|
|
|
pending_terms_of_service_ = TermsOfService();
|
|
|
|
}
|
2018-06-08 18:20:09 +02:00
|
|
|
if (!close_flag_ && !auth_manager_->is_bot()) {
|
2018-06-08 00:19:34 +02:00
|
|
|
alarm_timeout_.set_timeout_in(TERMS_OF_SERVICE_ALARM_ID, expires_in);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:00:58 +02:00
|
|
|
void Td::on_get_promo_data(Result<telegram_api::object_ptr<telegram_api::help_PromoData>> r_promo_data, bool dummy) {
|
|
|
|
if (G()->close_flag()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r_promo_data.is_error()) {
|
2021-02-08 13:56:08 +01:00
|
|
|
LOG(ERROR) << "Receive error for GetPromoData: " << r_promo_data.error();
|
2020-04-30 20:00:58 +02:00
|
|
|
return schedule_get_promo_data(60);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto promo_data_ptr = r_promo_data.move_as_ok();
|
|
|
|
CHECK(promo_data_ptr != nullptr);
|
|
|
|
LOG(DEBUG) << "Receive " << to_string(promo_data_ptr);
|
2020-12-15 11:28:41 +01:00
|
|
|
int32 expires_at = 0;
|
2020-04-30 20:00:58 +02:00
|
|
|
switch (promo_data_ptr->get_id()) {
|
|
|
|
case telegram_api::help_promoDataEmpty::ID: {
|
|
|
|
auto promo = telegram_api::move_object_as<telegram_api::help_promoDataEmpty>(promo_data_ptr);
|
2020-12-15 11:28:41 +01:00
|
|
|
expires_at = promo->expires_;
|
2020-04-30 20:00:58 +02:00
|
|
|
messages_manager_->remove_sponsored_dialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case telegram_api::help_promoData::ID: {
|
|
|
|
auto promo = telegram_api::move_object_as<telegram_api::help_promoData>(promo_data_ptr);
|
2020-12-15 11:28:41 +01:00
|
|
|
expires_at = promo->expires_;
|
2021-11-01 19:53:23 +01:00
|
|
|
bool is_proxy = promo->proxy_;
|
2020-04-30 20:00:58 +02:00
|
|
|
messages_manager_->on_get_sponsored_dialog(
|
|
|
|
std::move(promo->peer_),
|
|
|
|
is_proxy ? DialogSource::mtproto_proxy()
|
|
|
|
: DialogSource::public_service_announcement(promo->psa_type_, promo->psa_message_),
|
|
|
|
std::move(promo->users_), std::move(promo->chats_));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
2020-12-15 11:28:41 +01:00
|
|
|
schedule_get_promo_data(expires_at == 0 ? 0 : expires_at - G()->unix_time());
|
2020-04-30 20:00:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::schedule_get_promo_data(int32 expires_in) {
|
2021-01-23 19:39:41 +01:00
|
|
|
expires_in = expires_in <= 0 ? 0 : clamp(expires_in, 60, 86400);
|
2020-08-16 09:17:46 +02:00
|
|
|
if (!close_flag_ && auth_manager_->is_authorized() && !auth_manager_->is_bot()) {
|
2020-06-18 02:49:31 +02:00
|
|
|
LOG(INFO) << "Schedule getPromoData in " << expires_in;
|
2020-04-30 20:00:58 +02:00
|
|
|
alarm_timeout_.set_timeout_in(PROMO_DATA_ALARM_ID, expires_in);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-31 10:18:40 +01:00
|
|
|
bool Td::is_online() const {
|
|
|
|
return is_online_;
|
|
|
|
}
|
|
|
|
|
2021-12-16 11:13:14 +01:00
|
|
|
void Td::set_is_online(bool is_online) {
|
|
|
|
if (is_online == is_online_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
is_online_ = is_online;
|
|
|
|
if (auth_manager_ != nullptr) { // postpone if there is no AuthManager yet
|
|
|
|
on_online_updated(true, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 02:06:02 +01:00
|
|
|
void Td::set_is_bot_online(bool is_bot_online) {
|
2022-08-17 15:11:13 +02:00
|
|
|
if (G()->get_option_integer("session_count") > 1) {
|
2021-04-08 14:51:29 +02:00
|
|
|
is_bot_online = false;
|
|
|
|
}
|
|
|
|
|
2021-03-02 02:06:02 +01:00
|
|
|
if (is_bot_online == is_bot_online_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
is_bot_online_ = is_bot_online;
|
|
|
|
send_closure(G()->state_manager(), &StateManager::on_online, is_bot_online_);
|
|
|
|
}
|
|
|
|
|
2018-05-15 22:04:27 +02:00
|
|
|
bool Td::is_authentication_request(int32 id) {
|
|
|
|
switch (id) {
|
|
|
|
case td_api::setTdlibParameters::ID:
|
|
|
|
case td_api::getAuthorizationState::ID:
|
|
|
|
case td_api::setAuthenticationPhoneNumber::ID:
|
2022-09-06 16:17:39 +02:00
|
|
|
case td_api::setAuthenticationEmailAddress::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::resendAuthenticationCode::ID:
|
2022-09-06 16:17:39 +02:00
|
|
|
case td_api::checkAuthenticationEmailCode::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::checkAuthenticationCode::ID:
|
2019-07-16 21:08:34 +02:00
|
|
|
case td_api::registerUser::ID:
|
2019-12-17 17:17:57 +01:00
|
|
|
case td_api::requestQrCodeAuthentication::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::checkAuthenticationPassword::ID:
|
|
|
|
case td_api::requestAuthenticationPasswordRecovery::ID:
|
2021-06-28 21:33:08 +02:00
|
|
|
case td_api::checkAuthenticationPasswordRecoveryCode::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::recoverAuthenticationPassword::ID:
|
2018-06-27 20:26:52 +02:00
|
|
|
case td_api::deleteAccount::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::logOut::ID:
|
|
|
|
case td_api::close::ID:
|
|
|
|
case td_api::destroy::ID:
|
|
|
|
case td_api::checkAuthenticationBotToken::ID:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-11 12:33:56 +02:00
|
|
|
bool Td::is_synchronous_request(const td_api::Function *function) {
|
|
|
|
switch (function->get_id()) {
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::getTextEntities::ID:
|
|
|
|
case td_api::parseTextEntities::ID:
|
2020-03-09 21:55:32 +01:00
|
|
|
case td_api::parseMarkdown::ID:
|
2020-03-12 04:22:14 +01:00
|
|
|
case td_api::getMarkdownText::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::getFileMimeType::ID:
|
|
|
|
case td_api::getFileExtension::ID:
|
|
|
|
case td_api::cleanFileName::ID:
|
2018-07-23 19:29:14 +02:00
|
|
|
case td_api::getLanguagePackString::ID:
|
2021-08-30 21:26:02 +02:00
|
|
|
case td_api::getPhoneNumberInfoSync::ID:
|
2020-06-05 02:43:13 +02:00
|
|
|
case td_api::getChatFilterDefaultIconName::ID:
|
2018-12-10 02:01:02 +01:00
|
|
|
case td_api::getJsonValue::ID:
|
|
|
|
case td_api::getJsonString::ID:
|
2022-03-29 19:22:38 +02:00
|
|
|
case td_api::getThemeParametersJsonString::ID:
|
2019-02-23 19:32:20 +01:00
|
|
|
case td_api::getPushReceiverId::ID:
|
2018-10-24 17:42:40 +02:00
|
|
|
case td_api::setLogStream::ID:
|
|
|
|
case td_api::getLogStream::ID:
|
|
|
|
case td_api::setLogVerbosityLevel::ID:
|
|
|
|
case td_api::getLogVerbosityLevel::ID:
|
|
|
|
case td_api::getLogTags::ID:
|
|
|
|
case td_api::setLogTagVerbosityLevel::ID:
|
|
|
|
case td_api::getLogTagVerbosityLevel::ID:
|
2019-04-13 20:40:31 +02:00
|
|
|
case td_api::addLogMessage::ID:
|
2019-08-06 02:29:16 +02:00
|
|
|
case td_api::testReturnError::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
return true;
|
2022-07-11 12:33:56 +02:00
|
|
|
case td_api::getOption::ID:
|
|
|
|
return OptionManager::is_synchronous_option(static_cast<const td_api::getOption *>(function)->name_);
|
2018-05-15 22:04:27 +02:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Td::is_preinitialization_request(int32 id) {
|
|
|
|
switch (id) {
|
2018-09-20 18:33:41 +02:00
|
|
|
case td_api::getCurrentState::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::setAlarm::ID:
|
|
|
|
case td_api::testUseUpdate::ID:
|
|
|
|
case td_api::testCallEmpty::ID:
|
|
|
|
case td_api::testSquareInt::ID:
|
|
|
|
case td_api::testCallString::ID:
|
|
|
|
case td_api::testCallBytes::ID:
|
|
|
|
case td_api::testCallVectorInt::ID:
|
|
|
|
case td_api::testCallVectorIntObject::ID:
|
|
|
|
case td_api::testCallVectorString::ID:
|
|
|
|
case td_api::testCallVectorStringObject::ID:
|
2019-07-20 15:13:36 +02:00
|
|
|
case td_api::testProxy::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Td::is_preauthentication_request(int32 id) {
|
|
|
|
switch (id) {
|
2021-06-01 04:41:32 +02:00
|
|
|
case td_api::getInternalLinkType::ID:
|
2018-09-04 03:29:26 +02:00
|
|
|
case td_api::getLocalizationTargetInfo::ID:
|
2019-02-23 19:32:20 +01:00
|
|
|
case td_api::getLanguagePackInfo::ID:
|
2018-07-03 19:28:00 +02:00
|
|
|
case td_api::getLanguagePackStrings::ID:
|
2019-02-23 18:27:14 +01:00
|
|
|
case td_api::synchronizeLanguagePack::ID:
|
2019-02-23 19:32:20 +01:00
|
|
|
case td_api::addCustomServerLanguagePack::ID:
|
2018-09-04 03:29:26 +02:00
|
|
|
case td_api::setCustomLanguagePack::ID:
|
|
|
|
case td_api::editCustomLanguagePackInfo::ID:
|
|
|
|
case td_api::setCustomLanguagePackString::ID:
|
|
|
|
case td_api::deleteLanguagePack::ID:
|
2019-02-23 19:32:20 +01:00
|
|
|
case td_api::processPushNotification::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::getOption::ID:
|
|
|
|
case td_api::setOption::ID:
|
2019-02-23 19:32:20 +01:00
|
|
|
case td_api::getStorageStatistics::ID:
|
|
|
|
case td_api::getStorageStatisticsFast::ID:
|
2019-04-17 11:17:51 +02:00
|
|
|
case td_api::getDatabaseStatistics::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::setNetworkType::ID:
|
|
|
|
case td_api::getNetworkStatistics::ID:
|
|
|
|
case td_api::addNetworkStatistics::ID:
|
|
|
|
case td_api::resetNetworkStatistics::ID:
|
2020-08-24 22:38:45 +02:00
|
|
|
case td_api::getCountries::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::getCountryCode::ID:
|
2020-08-25 12:42:14 +02:00
|
|
|
case td_api::getPhoneNumberInfo::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::getDeepLinkInfo::ID:
|
2018-12-10 20:08:58 +01:00
|
|
|
case td_api::getApplicationConfig::ID:
|
|
|
|
case td_api::saveApplicationLogEvent::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::addProxy::ID:
|
2018-07-27 17:10:45 +02:00
|
|
|
case td_api::editProxy::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::enableProxy::ID:
|
|
|
|
case td_api::disableProxy::ID:
|
|
|
|
case td_api::removeProxy::ID:
|
|
|
|
case td_api::getProxies::ID:
|
2019-02-23 19:32:20 +01:00
|
|
|
case td_api::getProxyLink::ID:
|
2018-05-15 22:04:27 +02:00
|
|
|
case td_api::pingProxy::ID:
|
|
|
|
case td_api::testNetwork::ID:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-20 18:33:41 +02:00
|
|
|
td_api::object_ptr<td_api::AuthorizationState> Td::get_fake_authorization_state_object() const {
|
|
|
|
switch (state_) {
|
|
|
|
case State::WaitParameters:
|
|
|
|
return td_api::make_object<td_api::authorizationStateWaitTdlibParameters>();
|
|
|
|
case State::Run:
|
|
|
|
UNREACHABLE();
|
|
|
|
return nullptr;
|
|
|
|
case State::Close:
|
|
|
|
if (close_flag_ == 5) {
|
|
|
|
return td_api::make_object<td_api::authorizationStateClosed>();
|
|
|
|
} else {
|
|
|
|
return td_api::make_object<td_api::authorizationStateClosing>();
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-11 14:36:29 +02:00
|
|
|
vector<td_api::object_ptr<td_api::Update>> Td::get_fake_current_state() const {
|
|
|
|
CHECK(state_ != State::Run);
|
|
|
|
vector<td_api::object_ptr<td_api::Update>> updates;
|
|
|
|
OptionManager::get_common_state(updates);
|
|
|
|
updates.push_back(td_api::make_object<td_api::updateAuthorizationState>(get_fake_authorization_state_object()));
|
|
|
|
return updates;
|
|
|
|
}
|
|
|
|
|
2018-10-01 22:18:05 +02:00
|
|
|
DbKey Td::as_db_key(string key) {
|
|
|
|
// Database will still be effectively not encrypted, but
|
2018-12-13 23:48:36 +01:00
|
|
|
// 1. SQLite database will be protected from corruption, because that's how sqlcipher works
|
2018-10-01 22:18:05 +02:00
|
|
|
// 2. security through obscurity
|
2018-12-13 23:48:36 +01:00
|
|
|
// 3. no need for reencryption of SQLite database
|
2018-10-01 22:18:05 +02:00
|
|
|
if (key.empty()) {
|
|
|
|
return DbKey::raw_key("cucumber");
|
|
|
|
}
|
|
|
|
return DbKey::raw_key(std::move(key));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
|
|
|
if (id == 0) {
|
2021-03-15 01:32:14 +01:00
|
|
|
LOG(ERROR) << "Ignore request with ID == 0: " << to_string(function);
|
2018-09-14 18:35:34 +02:00
|
|
|
return;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-09-14 18:35:34 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
if (function == nullptr) {
|
2022-08-18 20:32:36 +02:00
|
|
|
return callback_->on_error(id, make_error(400, "Request is empty"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
VLOG(td_requests) << "Receive request " << id << ": " << to_string(function);
|
2022-08-18 20:32:36 +02:00
|
|
|
request_set_.emplace(id, function->get_id());
|
2022-07-11 12:33:56 +02:00
|
|
|
if (is_synchronous_request(function.get())) {
|
2018-09-20 18:33:41 +02:00
|
|
|
// send response synchronously
|
|
|
|
return send_result(id, static_request(std::move(function)));
|
|
|
|
}
|
2022-06-10 15:44:53 +02:00
|
|
|
|
|
|
|
run_request(id, std::move(function));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::run_request(uint64 id, tl_object_ptr<td_api::Function> function) {
|
2022-06-21 01:02:48 +02:00
|
|
|
if (set_parameters_request_id_ > 0) {
|
|
|
|
pending_set_parameters_requests_.emplace_back(id, std::move(function));
|
|
|
|
return;
|
|
|
|
}
|
2022-06-10 15:44:53 +02:00
|
|
|
|
|
|
|
int32 function_id = function->get_id();
|
2018-09-20 18:33:41 +02:00
|
|
|
if (state_ != State::Run) {
|
|
|
|
switch (function_id) {
|
|
|
|
case td_api::getAuthorizationState::ID:
|
|
|
|
// send response synchronously to prevent "Request aborted"
|
|
|
|
return send_result(id, get_fake_authorization_state_object());
|
2022-07-11 14:36:29 +02:00
|
|
|
case td_api::getCurrentState::ID:
|
2018-09-20 18:33:41 +02:00
|
|
|
// send response synchronously to prevent "Request aborted"
|
2022-07-11 14:36:29 +02:00
|
|
|
return send_result(id, td_api::make_object<td_api::updates>(get_fake_current_state()));
|
2018-09-20 18:33:41 +02:00
|
|
|
case td_api::close::ID:
|
2021-10-25 05:47:20 +02:00
|
|
|
// need to send response before actual closing
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::ok>());
|
|
|
|
send_closure(actor_id(this), &Td::close);
|
|
|
|
return;
|
2018-09-20 18:33:41 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
switch (state_) {
|
|
|
|
case State::WaitParameters: {
|
2018-05-15 22:04:27 +02:00
|
|
|
switch (function_id) {
|
2022-06-21 01:02:48 +02:00
|
|
|
case td_api::setTdlibParameters::ID: {
|
2022-09-07 21:19:08 +02:00
|
|
|
auto parameters = move_tl_object_as<td_api::setTdlibParameters>(function);
|
2022-09-07 21:31:26 +02:00
|
|
|
auto database_encryption_key = as_db_key(std::move(parameters->database_encryption_key_));
|
2022-09-07 21:19:08 +02:00
|
|
|
auto status = set_parameters(std::move(parameters));
|
2022-06-21 01:02:48 +02:00
|
|
|
if (status.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, std::move(status));
|
|
|
|
}
|
|
|
|
|
2022-09-07 20:50:41 +02:00
|
|
|
VLOG(td_init) << "Begin to open database";
|
2022-06-21 01:02:48 +02:00
|
|
|
set_parameters_request_id_ = id;
|
2022-09-07 20:50:41 +02:00
|
|
|
|
2022-06-21 01:02:48 +02:00
|
|
|
auto promise =
|
2022-09-07 20:50:41 +02:00
|
|
|
PromiseCreator::lambda([actor_id = actor_id(this)](Result<TdDb::OpenedDatabase> r_opened_database) {
|
|
|
|
send_closure(actor_id, &Td::init, std::move(r_opened_database));
|
2022-06-21 01:02:48 +02:00
|
|
|
});
|
2022-09-07 21:31:26 +02:00
|
|
|
return TdDb::open(get_database_scheduler_id(), parameters_, std::move(database_encryption_key),
|
2022-09-07 20:50:41 +02:00
|
|
|
std::move(promise));
|
2022-06-21 01:02:48 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
default:
|
2018-09-20 18:33:41 +02:00
|
|
|
if (is_preinitialization_request(function_id)) {
|
2018-05-15 22:04:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (is_preauthentication_request(function_id)) {
|
2018-05-16 17:40:26 +02:00
|
|
|
pending_preauthentication_requests_.emplace_back(id, std::move(function));
|
2018-05-16 21:35:27 +02:00
|
|
|
return;
|
2018-05-15 22:04:27 +02:00
|
|
|
}
|
2020-10-07 23:51:49 +02:00
|
|
|
return send_error_impl(
|
|
|
|
id, make_error(400, "Initialization parameters are needed: call setTdlibParameters first"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-09-20 18:33:41 +02:00
|
|
|
case State::Close:
|
2020-10-06 01:12:50 +02:00
|
|
|
if (destroy_flag_) {
|
2020-10-07 23:51:49 +02:00
|
|
|
return send_error_impl(id, make_error(401, "Unauthorized"));
|
2020-10-06 01:12:50 +02:00
|
|
|
} else {
|
2020-10-07 23:51:49 +02:00
|
|
|
return send_error_impl(id, make_error(500, "Request aborted"));
|
2020-10-06 01:12:50 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
case State::Run:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-05-16 21:47:42 +02:00
|
|
|
if ((auth_manager_ == nullptr || !auth_manager_->is_authorized()) && !is_preauthentication_request(function_id) &&
|
2018-09-20 18:33:41 +02:00
|
|
|
!is_preinitialization_request(function_id) && !is_authentication_request(function_id)) {
|
2020-10-07 23:51:49 +02:00
|
|
|
return send_error_impl(id, make_error(401, "Unauthorized"));
|
2018-05-16 21:47:42 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
downcast_call(*function, [this, id](auto &request) { this->on_request(id, request); });
|
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> Td::static_request(td_api::object_ptr<td_api::Function> function) {
|
2019-03-09 16:30:25 +01:00
|
|
|
if (function == nullptr) {
|
|
|
|
return td_api::make_object<td_api::error>(400, "Request is empty");
|
|
|
|
}
|
2019-03-12 21:46:43 +01:00
|
|
|
|
2020-01-11 22:19:43 +01:00
|
|
|
auto function_id = function->get_id();
|
|
|
|
bool need_logging = [function_id] {
|
|
|
|
switch (function_id) {
|
2018-11-20 14:23:35 +01:00
|
|
|
case td_api::parseTextEntities::ID:
|
2020-03-09 21:55:32 +01:00
|
|
|
case td_api::parseMarkdown::ID:
|
2020-03-12 04:22:14 +01:00
|
|
|
case td_api::getMarkdownText::ID:
|
2018-11-20 14:23:35 +01:00
|
|
|
case td_api::getFileMimeType::ID:
|
|
|
|
case td_api::getFileExtension::ID:
|
|
|
|
case td_api::cleanFileName::ID:
|
2020-06-05 02:43:13 +02:00
|
|
|
case td_api::getChatFilterDefaultIconName::ID:
|
2018-12-10 02:01:02 +01:00
|
|
|
case td_api::getJsonValue::ID:
|
|
|
|
case td_api::getJsonString::ID:
|
2022-03-29 19:22:38 +02:00
|
|
|
case td_api::getThemeParametersJsonString::ID:
|
2019-08-06 02:29:16 +02:00
|
|
|
case td_api::testReturnError::ID:
|
2018-11-20 14:23:35 +01:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
|
|
|
|
if (need_logging) {
|
|
|
|
VLOG(td_requests) << "Receive static request: " << to_string(function);
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> response;
|
|
|
|
downcast_call(*function, [&response](auto &request) { response = Td::do_static_request(request); });
|
2020-01-11 22:19:43 +01:00
|
|
|
LOG_CHECK(response != nullptr) << function_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-11-20 14:23:35 +01:00
|
|
|
if (need_logging) {
|
|
|
|
VLOG(td_requests) << "Sending result for static request: " << to_string(response);
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::add_handler(uint64 id, std::shared_ptr<ResultHandler> handler) {
|
2021-10-02 13:39:20 +02:00
|
|
|
result_handlers_[id] = std::move(handler);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Td::ResultHandler> Td::extract_handler(uint64 id) {
|
2021-10-02 13:39:20 +02:00
|
|
|
auto it = result_handlers_.find(id);
|
|
|
|
if (it == result_handlers_.end()) {
|
|
|
|
return nullptr;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-10-02 13:39:20 +02:00
|
|
|
auto result = std::move(it->second);
|
|
|
|
result_handlers_.erase(it);
|
2018-12-31 20:04:05 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-09-10 16:32:39 +02:00
|
|
|
void Td::on_update(BufferSlice &&update) {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (close_flag_ > 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-10 16:32:39 +02:00
|
|
|
TlBufferParser parser(&update);
|
|
|
|
auto ptr = telegram_api::Updates::fetch(parser);
|
|
|
|
parser.fetch_end();
|
|
|
|
if (parser.get_error()) {
|
|
|
|
LOG(ERROR) << "Failed to fetch update: " << parser.get_error() << format::as_hex_dump<4>(update.as_slice());
|
|
|
|
updates_manager_->schedule_get_difference("failed to fetch update");
|
|
|
|
} else {
|
|
|
|
updates_manager_->on_get_updates(std::move(ptr), Promise<Unit>());
|
|
|
|
if (auth_manager_->is_bot() && auth_manager_->is_authorized()) {
|
|
|
|
alarm_timeout_.set_timeout_in(PING_SERVER_ALARM_ID,
|
|
|
|
PING_SERVER_TIMEOUT + Random::fast(0, PING_SERVER_TIMEOUT / 5));
|
|
|
|
set_is_bot_online(true);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-09-10 16:32:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_result(NetQueryPtr query) {
|
|
|
|
query->debug("Td: received from DcManager");
|
|
|
|
VLOG(net_query) << "Receive result of " << query;
|
|
|
|
if (close_flag_ > 1) {
|
2018-12-31 20:04:05 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-09-10 16:32:39 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
auto handler = extract_handler(query->id());
|
2021-11-08 12:35:40 +01:00
|
|
|
if (handler != nullptr) {
|
|
|
|
CHECK(query->is_ready());
|
|
|
|
if (query->is_ok()) {
|
|
|
|
handler->on_result(std::move(query->ok()));
|
|
|
|
} else {
|
|
|
|
handler->on_error(std::move(query->error()));
|
|
|
|
}
|
|
|
|
} else if (!query->is_ok() || query->ok_tl_constructor() != telegram_api::upload_file::ID) {
|
|
|
|
LOG(WARNING) << query << " is ignored: no handlers found";
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-11-08 12:35:40 +01:00
|
|
|
query->clear();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-09-16 17:23:10 +02:00
|
|
|
void Td::on_connection_state_changed(ConnectionState new_state) {
|
2022-08-10 12:57:41 +02:00
|
|
|
if (G()->close_flag()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-08-10 12:57:41 +02:00
|
|
|
if (new_state == connection_state_) {
|
|
|
|
LOG(ERROR) << "State manager sends update about unchanged state " << static_cast<int32>(new_state);
|
2021-09-16 16:54:04 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
connection_state_ = new_state;
|
|
|
|
|
2021-09-16 17:23:10 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_update, get_update_connection_state_object(connection_state_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::start_up() {
|
2018-02-01 14:01:16 +01:00
|
|
|
always_wait_for_mailbox();
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
uint64 check_endianness = 0x0706050403020100;
|
|
|
|
auto check_endianness_raw = reinterpret_cast<const unsigned char *>(&check_endianness);
|
|
|
|
for (unsigned char c = 0; c < 8; c++) {
|
|
|
|
auto symbol = check_endianness_raw[static_cast<size_t>(c)];
|
|
|
|
LOG_IF(FATAL, symbol != c) << "TDLib requires little-endian platform";
|
|
|
|
}
|
|
|
|
|
2019-07-23 23:15:49 +02:00
|
|
|
VLOG(td_init) << "Create Global";
|
2020-09-02 22:35:54 +02:00
|
|
|
old_context_ = set_context(std::make_shared<Global>());
|
2020-07-30 16:28:56 +02:00
|
|
|
G()->set_net_query_stats(td_options_.net_query_stats);
|
2019-07-23 23:15:49 +02:00
|
|
|
inc_request_actor_refcnt(); // guard
|
|
|
|
inc_actor_refcnt(); // guard
|
|
|
|
|
2018-05-15 22:04:27 +02:00
|
|
|
alarm_timeout_.set_callback(on_alarm_timeout_callback);
|
|
|
|
alarm_timeout_.set_callback_data(static_cast<void *>(this));
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(state_ == State::WaitParameters);
|
2022-07-11 14:36:29 +02:00
|
|
|
for (auto &update : get_fake_current_state()) {
|
|
|
|
send_update(std::move(update));
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::tear_down() {
|
2019-06-06 19:26:11 +02:00
|
|
|
LOG_CHECK(close_flag_ == 5) << close_flag_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::hangup_shared() {
|
|
|
|
auto token = get_link_token();
|
|
|
|
auto type = Container<int>::type_from_id(token);
|
|
|
|
|
|
|
|
if (type == RequestActorIdType) {
|
2021-09-10 17:58:36 +02:00
|
|
|
request_actors_.erase(token);
|
2018-12-31 20:04:05 +01:00
|
|
|
dec_request_actor_refcnt();
|
|
|
|
} else if (type == ActorIdType) {
|
|
|
|
dec_actor_refcnt();
|
|
|
|
} else {
|
2018-02-11 15:07:16 +01:00
|
|
|
LOG(FATAL) << "Unknown hangup_shared of type " << type;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::hangup() {
|
2019-07-23 23:15:49 +02:00
|
|
|
LOG(INFO) << "Receive Td::hangup";
|
2018-12-31 20:04:05 +01:00
|
|
|
close();
|
|
|
|
dec_stop_cnt();
|
|
|
|
}
|
|
|
|
|
|
|
|
ActorShared<Td> Td::create_reference() {
|
|
|
|
inc_actor_refcnt();
|
|
|
|
return actor_shared(this, ActorIdType);
|
|
|
|
}
|
2020-08-02 22:03:06 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::inc_actor_refcnt() {
|
|
|
|
actor_refcnt_++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::dec_actor_refcnt() {
|
|
|
|
actor_refcnt_--;
|
2020-09-11 16:51:01 +02:00
|
|
|
if (actor_refcnt_ < 3) {
|
|
|
|
LOG(DEBUG) << "Decrease reference count to " << actor_refcnt_;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
if (actor_refcnt_ == 0) {
|
|
|
|
if (close_flag_ == 2) {
|
|
|
|
create_reference();
|
|
|
|
close_flag_ = 3;
|
|
|
|
} else if (close_flag_ == 3) {
|
2021-12-20 19:11:02 +01:00
|
|
|
LOG(INFO) << "All actors were closed";
|
2018-12-31 20:04:05 +01:00
|
|
|
Timer timer;
|
|
|
|
animations_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "AnimationsManager was cleared" << timer;
|
2022-03-25 12:17:09 +01:00
|
|
|
attach_menu_manager_.reset();
|
|
|
|
LOG(DEBUG) << "AttachMenuManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
audios_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "AudiosManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
auth_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "AuthManager was cleared" << timer;
|
2019-05-07 04:51:56 +02:00
|
|
|
background_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "BackgroundManager was cleared" << timer;
|
2020-08-23 23:43:31 +02:00
|
|
|
callback_queries_manager_.reset();
|
|
|
|
LOG(DEBUG) << "CallbackQueriesManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
contacts_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "ContactsManager was cleared" << timer;
|
2020-08-23 23:43:31 +02:00
|
|
|
country_info_manager_.reset();
|
|
|
|
LOG(DEBUG) << "CountryInfoManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
documents_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "DocumentsManager was cleared" << timer;
|
2022-02-23 19:34:09 +01:00
|
|
|
download_manager_.reset();
|
|
|
|
LOG(DEBUG) << "DownloadManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
file_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "FileManager was cleared" << timer;
|
2019-01-03 16:26:44 +01:00
|
|
|
file_reference_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "FileReferenceManager was cleared" << timer;
|
2021-09-07 09:02:44 +02:00
|
|
|
game_manager_.reset();
|
|
|
|
LOG(DEBUG) << "GameManager was cleared" << timer;
|
2020-11-24 16:22:00 +01:00
|
|
|
group_call_manager_.reset();
|
|
|
|
LOG(DEBUG) << "GroupCallManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
inline_queries_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "InlineQueriesManager was cleared" << timer;
|
2021-05-25 01:24:30 +02:00
|
|
|
link_manager_.reset();
|
|
|
|
LOG(DEBUG) << "LinkManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
messages_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "MessagesManager was cleared" << timer;
|
2018-11-09 15:14:02 +01:00
|
|
|
notification_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "NotificationManager was cleared" << timer;
|
2022-04-04 23:40:22 +02:00
|
|
|
notification_settings_manager_.reset();
|
|
|
|
LOG(DEBUG) << "NotificationSettingsManager was cleared" << timer;
|
2019-02-19 14:45:32 +01:00
|
|
|
poll_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "PollManager was cleared" << timer;
|
2021-09-07 14:49:34 +02:00
|
|
|
sponsored_message_manager_.reset();
|
|
|
|
LOG(DEBUG) << "SponsoredMessageManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
stickers_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "StickersManager was cleared" << timer;
|
2021-08-27 14:51:50 +02:00
|
|
|
theme_manager_.reset();
|
|
|
|
LOG(DEBUG) << "ThemeManager was cleared" << timer;
|
2021-09-24 22:17:38 +02:00
|
|
|
top_dialog_manager_.reset();
|
|
|
|
LOG(DEBUG) << "TopDialogManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
updates_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "UpdatesManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
video_notes_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "VideoNotesManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
videos_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "VideosManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
voice_notes_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "VoiceNotesManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
web_pages_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "WebPagesManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-08-18 17:52:59 +02:00
|
|
|
G()->set_option_manager(nullptr);
|
2022-08-18 16:00:18 +02:00
|
|
|
option_manager_.reset();
|
|
|
|
LOG(DEBUG) << "OptionManager was cleared" << timer;
|
|
|
|
|
|
|
|
Promise<> promise = PromiseCreator::lambda([actor_id = create_reference()](Unit) mutable { actor_id.reset(); });
|
2018-12-31 20:04:05 +01:00
|
|
|
if (destroy_flag_) {
|
|
|
|
G()->close_and_destroy_all(std::move(promise));
|
|
|
|
} else {
|
|
|
|
G()->close_all(std::move(promise));
|
|
|
|
}
|
|
|
|
// NetQueryDispatcher will be closed automatically
|
|
|
|
close_flag_ = 4;
|
|
|
|
} else if (close_flag_ == 4) {
|
2018-02-09 11:29:50 +01:00
|
|
|
on_closed();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-09 11:29:50 +01:00
|
|
|
void Td::on_closed() {
|
|
|
|
close_flag_ = 5;
|
2018-02-09 16:59:13 +01:00
|
|
|
send_update(
|
|
|
|
td_api::make_object<td_api::updateAuthorizationState>(td_api::make_object<td_api::authorizationStateClosed>()));
|
2018-02-09 11:29:50 +01:00
|
|
|
dec_stop_cnt();
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::dec_stop_cnt() {
|
|
|
|
stop_cnt_--;
|
|
|
|
if (stop_cnt_ == 0) {
|
2021-12-20 19:11:02 +01:00
|
|
|
LOG(INFO) << "Stop Td";
|
2020-09-02 22:35:54 +02:00
|
|
|
set_context(std::move(old_context_));
|
2018-12-31 20:04:05 +01:00
|
|
|
stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::inc_request_actor_refcnt() {
|
|
|
|
request_actor_refcnt_++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::dec_request_actor_refcnt() {
|
|
|
|
request_actor_refcnt_--;
|
2020-08-24 13:39:03 +02:00
|
|
|
LOG(DEBUG) << "Decrease request actor count to " << request_actor_refcnt_;
|
2018-12-31 20:04:05 +01:00
|
|
|
if (request_actor_refcnt_ == 0) {
|
2021-12-20 19:11:02 +01:00
|
|
|
LOG(INFO) << "Have no request actors";
|
2018-12-31 20:04:05 +01:00
|
|
|
clear();
|
|
|
|
dec_actor_refcnt(); // remove guard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-16 17:40:26 +02:00
|
|
|
void Td::clear_requests() {
|
|
|
|
while (!pending_alarms_.empty()) {
|
|
|
|
auto it = pending_alarms_.begin();
|
|
|
|
auto alarm_id = it->first;
|
|
|
|
pending_alarms_.erase(it);
|
|
|
|
alarm_timeout_.cancel_timeout(alarm_id);
|
|
|
|
}
|
|
|
|
while (!request_set_.empty()) {
|
2022-08-18 20:32:36 +02:00
|
|
|
uint64 id = request_set_.begin()->first;
|
2018-05-16 17:40:26 +02:00
|
|
|
if (destroy_flag_) {
|
|
|
|
send_error_impl(id, make_error(401, "Unauthorized"));
|
|
|
|
} else {
|
2018-06-28 23:06:17 +02:00
|
|
|
send_error_impl(id, make_error(500, "Request aborted"));
|
2018-05-16 17:40:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::clear() {
|
|
|
|
if (close_flag_ >= 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-13 20:21:29 +02:00
|
|
|
LOG(INFO) << "Clear Td";
|
2018-12-31 20:04:05 +01:00
|
|
|
close_flag_ = 2;
|
|
|
|
|
|
|
|
Timer timer;
|
|
|
|
if (destroy_flag_) {
|
2022-08-18 13:54:57 +02:00
|
|
|
option_manager_->clear_options();
|
2019-12-30 01:39:49 +01:00
|
|
|
if (!auth_manager_->is_bot()) {
|
|
|
|
notification_manager_->destroy_all_notifications();
|
|
|
|
}
|
2018-12-24 03:53:24 +01:00
|
|
|
} else {
|
2019-12-30 01:39:49 +01:00
|
|
|
if (!auth_manager_->is_bot()) {
|
|
|
|
notification_manager_->flush_all_notifications();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
G()->net_query_creator().stop_check();
|
2021-10-02 13:39:20 +02:00
|
|
|
result_handlers_.clear();
|
2021-12-15 23:45:43 +01:00
|
|
|
LOG(DEBUG) << "Handlers were cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
G()->net_query_dispatcher().stop();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "NetQueryDispatcher was stopped" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
state_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "StateManager was cleared" << timer;
|
2018-05-16 17:40:26 +02:00
|
|
|
clear_requests();
|
2018-12-31 20:04:05 +01:00
|
|
|
if (is_online_) {
|
|
|
|
is_online_ = false;
|
2018-02-11 19:33:32 +01:00
|
|
|
alarm_timeout_.cancel_timeout(ONLINE_ALARM_ID);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-02-11 19:33:32 +01:00
|
|
|
alarm_timeout_.cancel_timeout(PING_SERVER_ALARM_ID);
|
2018-06-08 00:19:34 +02:00
|
|
|
alarm_timeout_.cancel_timeout(TERMS_OF_SERVICE_ALARM_ID);
|
2020-04-30 20:00:58 +02:00
|
|
|
alarm_timeout_.cancel_timeout(PROMO_DATA_ALARM_ID);
|
2021-12-15 23:45:43 +01:00
|
|
|
LOG(DEBUG) << "Requests were answered" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
// close all pure actors
|
|
|
|
call_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "CallManager was cleared" << timer;
|
2018-06-27 20:26:52 +02:00
|
|
|
change_phone_number_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "ChangePhoneNumberManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
config_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "ConfigManager was cleared" << timer;
|
2018-06-27 20:26:52 +02:00
|
|
|
confirm_phone_number_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "ConfirmPhoneNumberManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
device_token_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "DeviceTokenManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
hashtag_hints_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "HashtagHints was cleared" << timer;
|
2018-07-03 19:28:00 +02:00
|
|
|
language_pack_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "LanguagePackManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
net_stats_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "NetStatsManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
password_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "PasswordManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
privacy_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "PrivacyManager was cleared" << timer;
|
2018-04-05 13:18:47 +02:00
|
|
|
secure_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "SecureManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
secret_chats_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "SecretChatsManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
storage_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "StorageManager was cleared" << timer;
|
2018-06-27 20:26:52 +02:00
|
|
|
verify_phone_number_manager_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "VerifyPhoneNumberManager was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
G()->set_connection_creator(ActorOwn<ConnectionCreator>());
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "ConnectionCreator was cleared" << timer;
|
2020-07-19 17:02:45 +02:00
|
|
|
G()->set_temp_auth_key_watchdog(ActorOwn<TempAuthKeyWatchdog>());
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "TempAuthKeyWatchdog was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
// clear actors which are unique pointers
|
|
|
|
animations_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "AnimationsManager actor was cleared" << timer;
|
2022-03-25 12:17:09 +01:00
|
|
|
attach_menu_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "AttachMenuManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
auth_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "AuthManager actor was cleared" << timer;
|
2019-05-07 04:51:56 +02:00
|
|
|
background_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "BackgroundManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
contacts_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "ContactsManager actor was cleared" << timer;
|
2020-08-24 13:39:03 +02:00
|
|
|
country_info_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "CountryInfoManager actor was cleared" << timer;
|
2022-02-23 20:56:03 +01:00
|
|
|
download_manager_actor_.reset();
|
2022-02-23 19:34:09 +01:00
|
|
|
LOG(DEBUG) << "DownloadManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
file_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "FileManager actor was cleared" << timer;
|
2019-01-03 16:26:44 +01:00
|
|
|
file_reference_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "FileReferenceManager actor was cleared" << timer;
|
2021-09-07 09:02:44 +02:00
|
|
|
game_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "GameManager actor was cleared" << timer;
|
2020-11-24 16:22:00 +01:00
|
|
|
group_call_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "GroupCallManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
inline_queries_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "InlineQueriesManager actor was cleared" << timer;
|
2021-05-25 01:24:30 +02:00
|
|
|
link_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "LinkManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
messages_manager_actor_.reset(); // TODO: Stop silent
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "MessagesManager actor was cleared" << timer;
|
2018-11-11 13:58:52 +01:00
|
|
|
notification_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "NotificationManager actor was cleared" << timer;
|
2022-04-04 23:40:22 +02:00
|
|
|
notification_settings_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "NotificationSettingsManager actor was cleared" << timer;
|
2019-02-19 14:45:32 +01:00
|
|
|
poll_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "PollManager actor was cleared" << timer;
|
2021-09-07 14:49:34 +02:00
|
|
|
sponsored_message_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "SponsoredMessageManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
stickers_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "StickersManager actor was cleared" << timer;
|
2021-08-27 14:51:50 +02:00
|
|
|
theme_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "ThemeManager actor was cleared" << timer;
|
2021-09-24 22:17:38 +02:00
|
|
|
top_dialog_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "TopDialogManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
updates_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "UpdatesManager actor was cleared" << timer;
|
2022-05-27 18:07:37 +02:00
|
|
|
voice_notes_manager_actor_.reset();
|
|
|
|
LOG(DEBUG) << "VoiceNotesManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
web_pages_manager_actor_.reset();
|
2020-07-22 15:58:26 +02:00
|
|
|
LOG(DEBUG) << "WebPagesManager actor was cleared" << timer;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::close() {
|
|
|
|
close_impl(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::destroy() {
|
|
|
|
close_impl(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::close_impl(bool destroy_flag) {
|
|
|
|
destroy_flag_ |= destroy_flag;
|
|
|
|
if (close_flag_) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-23 23:15:49 +02:00
|
|
|
|
|
|
|
LOG(WARNING) << (destroy_flag ? "Destroy" : "Close") << " Td in state " << static_cast<int32>(state_);
|
2022-09-07 20:27:23 +02:00
|
|
|
if (state_ == State::WaitParameters) {
|
2018-05-16 17:40:26 +02:00
|
|
|
clear_requests();
|
2018-12-31 20:04:05 +01:00
|
|
|
state_ = State::Close;
|
|
|
|
close_flag_ = 4;
|
2019-07-23 23:15:49 +02:00
|
|
|
G()->set_close_flag();
|
2021-09-29 14:41:53 +02:00
|
|
|
send_update(td_api::make_object<td_api::updateAuthorizationState>(
|
|
|
|
td_api::make_object<td_api::authorizationStateClosing>()));
|
2019-07-23 23:15:49 +02:00
|
|
|
|
|
|
|
request_actors_.clear();
|
|
|
|
return send_closure_later(actor_id(this), &Td::dec_request_actor_refcnt); // remove guard
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-07-23 23:15:49 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
state_ = State::Close;
|
|
|
|
close_flag_ = 1;
|
|
|
|
G()->set_close_flag();
|
2018-12-26 20:04:46 +01:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::on_closing, destroy_flag);
|
2021-09-29 14:41:53 +02:00
|
|
|
updates_manager_->timeout_expired(); // save pts and qts
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-09-29 14:41:53 +02:00
|
|
|
// wait till all request_actors will stop
|
2018-12-31 20:04:05 +01:00
|
|
|
request_actors_.clear();
|
|
|
|
G()->td_db()->flush_all();
|
|
|
|
send_closure_later(actor_id(this), &Td::dec_request_actor_refcnt); // remove guard
|
|
|
|
}
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class Td::DownloadFileCallback final : public FileManager::DownloadCallback {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_download_ok(FileId file_id) final {
|
2019-03-27 19:43:46 +01:00
|
|
|
send_closure(G()->td(), &Td::on_file_download_finished, file_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_download_error(FileId file_id, Status error) final {
|
2019-03-27 19:43:46 +01:00
|
|
|
send_closure(G()->td(), &Td::on_file_download_finished, file_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class Td::UploadFileCallback final : public FileManager::UploadCallback {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_upload_ok(FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
// cancel file upload of the file to allow next upload with the same file to succeed
|
2019-01-25 02:52:38 +01:00
|
|
|
send_closure(G()->file_manager(), &FileManager::cancel_upload, file_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_upload_encrypted_ok(FileId file_id, tl_object_ptr<telegram_api::InputEncryptedFile> input_file) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
// cancel file upload of the file to allow next upload with the same file to succeed
|
2019-01-25 02:52:38 +01:00
|
|
|
send_closure(G()->file_manager(), &FileManager::cancel_upload, file_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_upload_secure_ok(FileId file_id, tl_object_ptr<telegram_api::InputSecureFile> input_file) final {
|
2018-03-27 15:11:15 +02:00
|
|
|
// cancel file upload of the file to allow next upload with the same file to succeed
|
2019-01-25 02:52:38 +01:00
|
|
|
send_closure(G()->file_manager(), &FileManager::cancel_upload, file_id);
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_upload_error(FileId file_id, Status error) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-05-16 21:35:27 +02:00
|
|
|
template <class T>
|
|
|
|
void Td::complete_pending_preauthentication_requests(const T &func) {
|
|
|
|
for (auto &request : pending_preauthentication_requests_) {
|
|
|
|
if (request.second != nullptr && func(request.second->get_id())) {
|
|
|
|
downcast_call(*request.second, [this, id = request.first](auto &request) { this->on_request(id, request); });
|
|
|
|
request.second = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-20 21:02:45 +02:00
|
|
|
int32 Td::get_database_scheduler_id() {
|
|
|
|
auto current_scheduler_id = Scheduler::instance()->sched_id();
|
|
|
|
auto scheduler_count = Scheduler::instance()->sched_count();
|
|
|
|
return min(current_scheduler_id + 1, scheduler_count - 1);
|
|
|
|
}
|
|
|
|
|
2022-06-21 01:02:48 +02:00
|
|
|
void Td::finish_set_parameters() {
|
|
|
|
CHECK(set_parameters_request_id_ != 0);
|
|
|
|
set_parameters_request_id_ = 0;
|
|
|
|
|
|
|
|
if (pending_set_parameters_requests_.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VLOG(td_init) << "Continue to execute " << pending_set_parameters_requests_.size() << " pending requests";
|
|
|
|
auto requests = std::move(pending_set_parameters_requests_);
|
|
|
|
for (auto &request : requests) {
|
|
|
|
run_request(request.first, std::move(request.second));
|
|
|
|
}
|
|
|
|
CHECK(pending_set_parameters_requests_.size() < requests.size());
|
|
|
|
}
|
|
|
|
|
2022-06-10 15:44:53 +02:00
|
|
|
void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
|
2022-09-07 20:27:23 +02:00
|
|
|
CHECK(set_parameters_request_id_ != 0);
|
2022-06-10 15:44:53 +02:00
|
|
|
if (r_opened_database.is_error()) {
|
|
|
|
LOG(WARNING) << "Failed to open database: " << r_opened_database.error();
|
2022-09-07 20:27:23 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_error, set_parameters_request_id_,
|
2022-06-10 15:44:53 +02:00
|
|
|
Status::Error(400, r_opened_database.error().message()));
|
2022-09-07 20:27:23 +02:00
|
|
|
return finish_set_parameters();
|
2018-10-08 20:18:06 +02:00
|
|
|
}
|
2022-09-07 20:50:41 +02:00
|
|
|
auto events = r_opened_database.move_as_ok();
|
|
|
|
|
|
|
|
parameters_.database_directory = std::move(events.database_directory);
|
|
|
|
parameters_.files_directory = std::move(events.files_directory);
|
2022-06-10 15:44:53 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(INFO) << "Successfully inited database in " << tag("database_directory", parameters_.database_directory)
|
|
|
|
<< " and " << tag("files_directory", parameters_.files_directory);
|
2019-04-11 22:24:39 +02:00
|
|
|
VLOG(td_init) << "Successfully inited database";
|
2020-01-08 21:41:03 +01:00
|
|
|
|
2022-06-10 15:44:53 +02:00
|
|
|
G()->init(parameters_, actor_id(this), std::move(events.database)).ensure();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
init_options_and_network();
|
|
|
|
|
2022-08-18 13:54:57 +02:00
|
|
|
// we need to process td_api::getOption along with td_api::setOption for consistency
|
|
|
|
// we need to process td_api::setOption before managers and MTProto header are created,
|
|
|
|
// because their initialiation may be affected by the options
|
2019-04-26 21:44:32 +02:00
|
|
|
complete_pending_preauthentication_requests([](int32 id) {
|
|
|
|
switch (id) {
|
|
|
|
case td_api::getOption::ID:
|
|
|
|
case td_api::setOption::ID:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-08-17 15:11:13 +02:00
|
|
|
options_.language_pack = G()->get_option_string("localization_target");
|
|
|
|
options_.language_code = G()->get_option_string("language_pack_id");
|
|
|
|
options_.parameters = G()->get_option_string("connection_parameters");
|
|
|
|
options_.tz_offset = static_cast<int32>(G()->get_option_integer("utc_time_offset"));
|
|
|
|
options_.is_emulator = G()->get_option_boolean("is_emulator");
|
2019-04-26 21:44:32 +02:00
|
|
|
// options_.proxy = Proxy();
|
|
|
|
G()->set_mtproto_header(make_unique<MtprotoHeader>(options_));
|
2022-08-17 15:11:13 +02:00
|
|
|
G()->set_store_all_files_in_files_directory(G()->get_option_boolean("store_all_files_in_files_directory"));
|
2019-04-26 21:44:32 +02:00
|
|
|
|
|
|
|
VLOG(td_init) << "Create NetQueryDispatcher";
|
|
|
|
auto net_query_dispatcher = make_unique<NetQueryDispatcher>([&] { return create_reference(); });
|
|
|
|
G()->set_net_query_dispatcher(std::move(net_query_dispatcher));
|
|
|
|
|
|
|
|
complete_pending_preauthentication_requests([](int32 id) {
|
|
|
|
// pingProxy uses NetQueryDispatcher to get main_dc_id, so must be called after NetQueryDispatcher is created
|
|
|
|
return id == td_api::pingProxy::ID;
|
|
|
|
});
|
|
|
|
|
|
|
|
VLOG(td_init) << "Create AuthManager";
|
|
|
|
auth_manager_ = td::make_unique<AuthManager>(parameters_.api_id, parameters_.api_hash, create_reference());
|
|
|
|
auth_manager_actor_ = register_actor("AuthManager", auth_manager_.get());
|
2022-08-17 19:01:03 +02:00
|
|
|
G()->set_auth_manager(auth_manager_actor_.get());
|
2019-04-26 21:44:32 +02:00
|
|
|
|
|
|
|
init_file_manager();
|
|
|
|
|
|
|
|
init_managers();
|
|
|
|
|
2022-06-15 19:32:42 +02:00
|
|
|
storage_manager_ = create_actor<StorageManager>("StorageManager", create_reference(), G()->get_gc_scheduler_id());
|
2019-04-26 21:44:32 +02:00
|
|
|
G()->set_storage_manager(storage_manager_.get());
|
|
|
|
|
2022-08-18 18:12:15 +02:00
|
|
|
option_manager_->on_td_inited();
|
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
VLOG(td_init) << "Send binlog events";
|
|
|
|
for (auto &event : events.user_events) {
|
|
|
|
contacts_manager_->on_binlog_user_event(std::move(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &event : events.channel_events) {
|
|
|
|
contacts_manager_->on_binlog_channel_event(std::move(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
// chats may contain links to channels, so should be inited after
|
|
|
|
for (auto &event : events.chat_events) {
|
|
|
|
contacts_manager_->on_binlog_chat_event(std::move(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &event : events.secret_chat_events) {
|
|
|
|
contacts_manager_->on_binlog_secret_chat_event(std::move(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &event : events.web_page_events) {
|
|
|
|
web_pages_manager_->on_binlog_web_page_event(std::move(event));
|
|
|
|
}
|
|
|
|
|
2022-07-18 18:21:47 +02:00
|
|
|
for (auto &event : events.save_app_log_events) {
|
|
|
|
on_save_app_log_binlog_event(this, std::move(event));
|
|
|
|
}
|
|
|
|
|
2022-08-18 13:54:57 +02:00
|
|
|
if (option_manager_->get_option_boolean("default_reaction_needs_sync")) {
|
|
|
|
send_set_default_reaction_query(this);
|
|
|
|
}
|
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
if (is_online_) {
|
|
|
|
on_online_updated(true, true);
|
|
|
|
}
|
2021-01-11 20:22:18 +01:00
|
|
|
if (auth_manager_->is_bot()) {
|
2021-03-02 02:06:02 +01:00
|
|
|
set_is_bot_online(true);
|
2021-01-11 20:22:18 +01:00
|
|
|
}
|
2019-04-26 21:44:32 +02:00
|
|
|
|
|
|
|
// Send binlog events to managers
|
|
|
|
//
|
|
|
|
// 1. Actors must receive all binlog events before other queries.
|
|
|
|
//
|
|
|
|
// -- All actors have one "entry point". So there is only one way to send query to them. So all queries are ordered
|
2020-01-07 01:38:10 +01:00
|
|
|
// for each Actor.
|
2019-04-26 21:44:32 +02:00
|
|
|
//
|
|
|
|
// 2. An actor must not make some decisions before all binlog events are processed.
|
2020-09-22 01:15:09 +02:00
|
|
|
// For example, SecretChatActor must not send RequestKey, before it receives log event with RequestKey and understands
|
2019-04-26 21:44:32 +02:00
|
|
|
// that RequestKey was already sent.
|
|
|
|
//
|
|
|
|
// 3. During replay of binlog some queries may be sent to other actors. They shouldn't process such events before all
|
2020-01-23 23:08:21 +01:00
|
|
|
// their binlog events are processed. So actor may receive some old queries. It must be in its actual state in
|
2019-04-26 21:44:32 +02:00
|
|
|
// orded to handle them properly.
|
|
|
|
//
|
|
|
|
// -- Use send_closure_later, so actors don't even start process binlog events, before all binlog events are sent
|
|
|
|
|
|
|
|
for (auto &event : events.to_secret_chats_manager) {
|
|
|
|
send_closure_later(secret_chats_manager_, &SecretChatsManager::replay_binlog_event, std::move(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
send_closure_later(poll_manager_actor_, &PollManager::on_binlog_events, std::move(events.to_poll_manager));
|
|
|
|
|
|
|
|
send_closure_later(messages_manager_actor_, &MessagesManager::on_binlog_events,
|
|
|
|
std::move(events.to_messages_manager));
|
|
|
|
|
|
|
|
send_closure_later(notification_manager_actor_, &NotificationManager::on_binlog_events,
|
|
|
|
std::move(events.to_notification_manager));
|
|
|
|
|
2022-04-11 11:45:52 +02:00
|
|
|
send_closure_later(notification_settings_manager_actor_, &NotificationSettingsManager::on_binlog_events,
|
|
|
|
std::move(events.to_notification_settings_manager));
|
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
send_closure(secret_chats_manager_, &SecretChatsManager::binlog_replay_finish);
|
|
|
|
|
|
|
|
VLOG(td_init) << "Ping datacenter";
|
|
|
|
if (!auth_manager_->is_authorized()) {
|
2020-08-23 23:43:31 +02:00
|
|
|
country_info_manager_->get_current_country_code(Promise<string>());
|
2019-04-26 21:44:32 +02:00
|
|
|
} else {
|
|
|
|
updates_manager_->get_difference("init");
|
|
|
|
schedule_get_terms_of_service(0);
|
2020-04-30 20:00:58 +02:00
|
|
|
schedule_get_promo_data(0);
|
2019-04-26 21:44:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
complete_pending_preauthentication_requests([](int32 id) { return true; });
|
|
|
|
|
|
|
|
VLOG(td_init) << "Finish initialization";
|
|
|
|
|
|
|
|
state_ = State::Run;
|
2022-06-10 15:44:53 +02:00
|
|
|
|
2022-09-07 20:27:23 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_result, set_parameters_request_id_, td_api::make_object<td_api::ok>());
|
|
|
|
return finish_set_parameters();
|
2019-04-26 21:44:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::init_options_and_network() {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Create StateManager";
|
2021-07-04 04:58:54 +02:00
|
|
|
class StateManagerCallback final : public StateManager::Callback {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
explicit StateManagerCallback(ActorShared<Td> td) : td_(std::move(td)) {
|
|
|
|
}
|
2021-09-16 17:23:10 +02:00
|
|
|
bool on_state(ConnectionState state) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(td_, &Td::on_connection_state_changed, state);
|
|
|
|
return td_.is_alive();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ActorShared<Td> td_;
|
|
|
|
};
|
2020-07-19 18:29:43 +02:00
|
|
|
state_manager_ = create_actor<StateManager>("State manager", create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(state_manager_, &StateManager::add_callback, make_unique<StateManagerCallback>(create_reference()));
|
|
|
|
G()->set_state_manager(state_manager_.get());
|
|
|
|
|
2022-08-18 13:54:57 +02:00
|
|
|
VLOG(td_init) << "Create OptionManager";
|
2022-08-18 17:52:59 +02:00
|
|
|
option_manager_ = make_unique<OptionManager>(this);
|
|
|
|
G()->set_option_manager(option_manager_.get());
|
2019-01-17 21:12:31 +01:00
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
init_connection_creator();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Create TempAuthKeyWatchdog";
|
2020-07-19 17:18:54 +02:00
|
|
|
auto temp_auth_key_watchdog = create_actor<TempAuthKeyWatchdog>("TempAuthKeyWatchdog", create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
G()->set_temp_auth_key_watchdog(std::move(temp_auth_key_watchdog));
|
|
|
|
|
2019-01-17 21:12:31 +01:00
|
|
|
VLOG(td_init) << "Create ConfigManager";
|
|
|
|
config_manager_ = create_actor<ConfigManager>("ConfigManager", create_reference());
|
|
|
|
G()->set_config_manager(config_manager_.get());
|
2019-04-26 21:44:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::init_connection_creator() {
|
|
|
|
VLOG(td_init) << "Create ConnectionCreator";
|
|
|
|
auto connection_creator = create_actor<ConnectionCreator>("ConnectionCreator", create_reference());
|
|
|
|
auto net_stats_manager = create_actor<NetStatsManager>("NetStatsManager", create_reference());
|
|
|
|
|
|
|
|
// How else could I let two actor know about each other, without quite complex async logic?
|
|
|
|
auto net_stats_manager_ptr = net_stats_manager->get_actor_unsafe();
|
|
|
|
net_stats_manager_ptr->init();
|
|
|
|
connection_creator->get_actor_unsafe()->set_net_stats_callback(net_stats_manager_ptr->get_common_stats_callback(),
|
|
|
|
net_stats_manager_ptr->get_media_stats_callback());
|
|
|
|
G()->set_net_stats_file_callbacks(net_stats_manager_ptr->get_file_stats_callbacks());
|
|
|
|
|
|
|
|
G()->set_connection_creator(std::move(connection_creator));
|
|
|
|
net_stats_manager_ = std::move(net_stats_manager);
|
2018-09-04 03:29:26 +02:00
|
|
|
|
2018-05-16 21:35:27 +02:00
|
|
|
complete_pending_preauthentication_requests([](int32 id) {
|
|
|
|
switch (id) {
|
2019-04-26 21:44:32 +02:00
|
|
|
case td_api::setNetworkType::ID:
|
|
|
|
case td_api::getNetworkStatistics::ID:
|
|
|
|
case td_api::addNetworkStatistics::ID:
|
|
|
|
case td_api::resetNetworkStatistics::ID:
|
|
|
|
case td_api::addProxy::ID:
|
|
|
|
case td_api::editProxy::ID:
|
|
|
|
case td_api::enableProxy::ID:
|
|
|
|
case td_api::disableProxy::ID:
|
|
|
|
case td_api::removeProxy::ID:
|
|
|
|
case td_api::getProxies::ID:
|
|
|
|
case td_api::getProxyLink::ID:
|
2018-05-16 21:35:27 +02:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2019-04-26 21:44:32 +02:00
|
|
|
}
|
2018-05-16 21:35:27 +02:00
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
void Td::init_file_manager() {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Create FileManager";
|
2018-12-31 20:04:05 +01:00
|
|
|
download_file_callback_ = std::make_shared<DownloadFileCallback>();
|
|
|
|
upload_file_callback_ = std::make_shared<UploadFileCallback>();
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class FileManagerContext final : public FileManager::Context {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
|
|
|
explicit FileManagerContext(Td *td) : td_(td) {
|
|
|
|
}
|
2019-01-30 22:37:38 +01:00
|
|
|
|
2022-07-23 22:50:28 +02:00
|
|
|
bool need_notify_on_new_files() final {
|
|
|
|
return !td_->auth_manager_->is_bot();
|
|
|
|
}
|
|
|
|
|
2020-02-19 15:57:30 +01:00
|
|
|
void on_new_file(int64 size, int64 real_size, int32 cnt) final {
|
|
|
|
send_closure(G()->storage_manager(), &StorageManager::on_new_file, size, real_size, cnt);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-01-30 22:37:38 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_file_updated(FileId file_id) final {
|
|
|
|
send_closure(G()->td(), &Td::send_update,
|
|
|
|
make_tl_object<td_api::updateFile>(td_->file_manager_->get_file_object(file_id)));
|
|
|
|
}
|
2019-01-30 22:37:38 +01:00
|
|
|
|
|
|
|
bool add_file_source(FileId file_id, FileSourceId file_source_id) final {
|
|
|
|
return td_->file_reference_manager_->add_file_source(file_id, file_source_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool remove_file_source(FileId file_id, FileSourceId file_source_id) final {
|
|
|
|
return td_->file_reference_manager_->remove_file_source(file_id, file_source_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_merge_files(FileId to_file_id, FileId from_file_id) final {
|
|
|
|
td_->file_reference_manager_->merge(to_file_id, from_file_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<FileSourceId> get_some_file_sources(FileId file_id) final {
|
|
|
|
return td_->file_reference_manager_->get_some_file_sources(file_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void repair_file_reference(FileId file_id, Promise<Unit> promise) final {
|
|
|
|
send_closure(G()->file_reference_manager(), &FileReferenceManager::repair_file_reference, file_id,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-07-30 16:42:36 +02:00
|
|
|
void reload_photo(PhotoSizeSource source, Promise<Unit> promise) final {
|
2021-10-19 17:11:16 +02:00
|
|
|
FileReferenceManager::reload_photo(std::move(source), std::move(promise));
|
2019-07-30 16:42:36 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
ActorShared<> create_reference() final {
|
|
|
|
return td_->create_reference();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Td *td_;
|
|
|
|
};
|
2018-12-05 10:32:31 +01:00
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
file_manager_ = make_unique<FileManager>(make_unique<FileManagerContext>(this));
|
2018-12-31 20:04:05 +01:00
|
|
|
file_manager_actor_ = register_actor("FileManager", file_manager_.get());
|
|
|
|
file_manager_->init_actor();
|
|
|
|
G()->set_file_manager(file_manager_actor_.get());
|
|
|
|
|
2022-08-09 16:00:36 +02:00
|
|
|
file_reference_manager_ = make_unique<FileReferenceManager>(create_reference());
|
2019-01-03 16:26:44 +01:00
|
|
|
file_reference_manager_actor_ = register_actor("FileReferenceManager", file_reference_manager_.get());
|
|
|
|
G()->set_file_reference_manager(file_reference_manager_actor_.get());
|
2019-04-26 21:44:32 +02:00
|
|
|
}
|
2019-01-03 16:26:44 +01:00
|
|
|
|
2019-04-26 21:44:32 +02:00
|
|
|
void Td::init_managers() {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Create Managers";
|
2018-12-31 20:04:05 +01:00
|
|
|
audios_manager_ = make_unique<AudiosManager>(this);
|
|
|
|
callback_queries_manager_ = make_unique<CallbackQueriesManager>(this);
|
|
|
|
documents_manager_ = make_unique<DocumentsManager>(this);
|
|
|
|
video_notes_manager_ = make_unique<VideoNotesManager>(this);
|
|
|
|
videos_manager_ = make_unique<VideosManager>(this);
|
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
animations_manager_ = make_unique<AnimationsManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
animations_manager_actor_ = register_actor("AnimationsManager", animations_manager_.get());
|
|
|
|
G()->set_animations_manager(animations_manager_actor_.get());
|
2022-03-25 12:17:09 +01:00
|
|
|
attach_menu_manager_ = make_unique<AttachMenuManager>(this, create_reference());
|
|
|
|
attach_menu_manager_actor_ = register_actor("AttachMenuManager", attach_menu_manager_.get());
|
2022-08-10 20:12:05 +02:00
|
|
|
G()->set_attach_menu_manager(attach_menu_manager_actor_.get());
|
2019-05-07 04:51:56 +02:00
|
|
|
background_manager_ = make_unique<BackgroundManager>(this, create_reference());
|
|
|
|
background_manager_actor_ = register_actor("BackgroundManager", background_manager_.get());
|
|
|
|
G()->set_background_manager(background_manager_actor_.get());
|
2018-09-27 03:19:03 +02:00
|
|
|
contacts_manager_ = make_unique<ContactsManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
contacts_manager_actor_ = register_actor("ContactsManager", contacts_manager_.get());
|
|
|
|
G()->set_contacts_manager(contacts_manager_actor_.get());
|
2020-08-24 13:39:03 +02:00
|
|
|
country_info_manager_ = make_unique<CountryInfoManager>(this, create_reference());
|
|
|
|
country_info_manager_actor_ = register_actor("CountryInfoManager", country_info_manager_.get());
|
2022-03-02 12:16:06 +01:00
|
|
|
download_manager_ = DownloadManager::create(td::make_unique<DownloadManagerCallback>(this, create_reference()));
|
2022-03-02 11:56:04 +01:00
|
|
|
download_manager_actor_ = register_actor("DownloadManager", download_manager_.get());
|
2022-03-03 16:58:51 +01:00
|
|
|
G()->set_download_manager(download_manager_actor_.get());
|
2021-09-07 09:02:44 +02:00
|
|
|
game_manager_ = make_unique<GameManager>(this, create_reference());
|
|
|
|
game_manager_actor_ = register_actor("GameManager", game_manager_.get());
|
|
|
|
G()->set_game_manager(game_manager_actor_.get());
|
2020-11-24 16:22:00 +01:00
|
|
|
group_call_manager_ = make_unique<GroupCallManager>(this, create_reference());
|
|
|
|
group_call_manager_actor_ = register_actor("GroupCallManager", group_call_manager_.get());
|
2020-11-25 15:04:32 +01:00
|
|
|
G()->set_group_call_manager(group_call_manager_actor_.get());
|
2018-09-27 03:19:03 +02:00
|
|
|
inline_queries_manager_ = make_unique<InlineQueriesManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
inline_queries_manager_actor_ = register_actor("InlineQueriesManager", inline_queries_manager_.get());
|
2021-05-25 01:24:30 +02:00
|
|
|
link_manager_ = make_unique<LinkManager>(this, create_reference());
|
|
|
|
link_manager_actor_ = register_actor("LinkManager", link_manager_.get());
|
2021-05-25 01:39:29 +02:00
|
|
|
G()->set_link_manager(link_manager_actor_.get());
|
2018-09-27 03:19:03 +02:00
|
|
|
messages_manager_ = make_unique<MessagesManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
messages_manager_actor_ = register_actor("MessagesManager", messages_manager_.get());
|
|
|
|
G()->set_messages_manager(messages_manager_actor_.get());
|
2018-11-11 13:58:52 +01:00
|
|
|
notification_manager_ = make_unique<NotificationManager>(this, create_reference());
|
|
|
|
notification_manager_actor_ = register_actor("NotificationManager", notification_manager_.get());
|
2021-12-15 23:09:59 +01:00
|
|
|
G()->set_notification_manager(notification_manager_actor_.get());
|
2022-04-04 23:40:22 +02:00
|
|
|
notification_settings_manager_ = make_unique<NotificationSettingsManager>(this, create_reference());
|
|
|
|
notification_settings_manager_actor_ =
|
|
|
|
register_actor("NotificationSettingsManager", notification_settings_manager_.get());
|
2022-04-14 13:31:18 +02:00
|
|
|
G()->set_notification_settings_manager(notification_settings_manager_actor_.get());
|
2019-02-19 14:45:32 +01:00
|
|
|
poll_manager_ = make_unique<PollManager>(this, create_reference());
|
|
|
|
poll_manager_actor_ = register_actor("PollManager", poll_manager_.get());
|
2021-09-07 14:49:34 +02:00
|
|
|
sponsored_message_manager_ = make_unique<SponsoredMessageManager>(this, create_reference());
|
|
|
|
sponsored_message_manager_actor_ = register_actor("SponsoredMessageManager", sponsored_message_manager_.get());
|
|
|
|
G()->set_sponsored_message_manager(sponsored_message_manager_actor_.get());
|
2018-09-27 03:19:03 +02:00
|
|
|
stickers_manager_ = make_unique<StickersManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
stickers_manager_actor_ = register_actor("StickersManager", stickers_manager_.get());
|
|
|
|
G()->set_stickers_manager(stickers_manager_actor_.get());
|
2021-08-27 14:51:50 +02:00
|
|
|
theme_manager_ = make_unique<ThemeManager>(this, create_reference());
|
|
|
|
theme_manager_actor_ = register_actor("ThemeManager", theme_manager_.get());
|
|
|
|
G()->set_theme_manager(theme_manager_actor_.get());
|
2021-09-24 22:17:38 +02:00
|
|
|
top_dialog_manager_ = make_unique<TopDialogManager>(this, create_reference());
|
|
|
|
top_dialog_manager_actor_ = register_actor("TopDialogManager", top_dialog_manager_.get());
|
|
|
|
G()->set_top_dialog_manager(top_dialog_manager_actor_.get());
|
2018-09-27 03:19:03 +02:00
|
|
|
updates_manager_ = make_unique<UpdatesManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
updates_manager_actor_ = register_actor("UpdatesManager", updates_manager_.get());
|
|
|
|
G()->set_updates_manager(updates_manager_actor_.get());
|
2022-05-27 18:07:37 +02:00
|
|
|
voice_notes_manager_ = make_unique<VoiceNotesManager>(this, create_reference());
|
|
|
|
voice_notes_manager_actor_ = register_actor("VoiceNotesManager", voice_notes_manager_.get());
|
2018-09-27 03:19:03 +02:00
|
|
|
web_pages_manager_ = make_unique<WebPagesManager>(this, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
web_pages_manager_actor_ = register_actor("WebPagesManager", web_pages_manager_.get());
|
|
|
|
G()->set_web_pages_manager(web_pages_manager_actor_.get());
|
|
|
|
|
|
|
|
call_manager_ = create_actor<CallManager>("CallManager", create_reference());
|
|
|
|
G()->set_call_manager(call_manager_.get());
|
2018-06-27 20:26:52 +02:00
|
|
|
change_phone_number_manager_ = create_actor<PhoneNumberManager>(
|
|
|
|
"ChangePhoneNumberManager", PhoneNumberManager::Type::ChangePhone, create_reference());
|
|
|
|
confirm_phone_number_manager_ = create_actor<PhoneNumberManager>(
|
|
|
|
"ConfirmPhoneNumberManager", PhoneNumberManager::Type::ConfirmPhone, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
device_token_manager_ = create_actor<DeviceTokenManager>("DeviceTokenManager", create_reference());
|
|
|
|
hashtag_hints_ = create_actor<HashtagHints>("HashtagHints", "text", create_reference());
|
2018-07-03 19:28:00 +02:00
|
|
|
language_pack_manager_ = create_actor<LanguagePackManager>("LanguagePackManager", create_reference());
|
2018-07-17 04:58:34 +02:00
|
|
|
G()->set_language_pack_manager(language_pack_manager_.get());
|
2018-12-31 20:04:05 +01:00
|
|
|
password_manager_ = create_actor<PasswordManager>("PasswordManager", create_reference());
|
2018-03-27 15:11:15 +02:00
|
|
|
G()->set_password_manager(password_manager_.get());
|
2018-12-31 20:04:05 +01:00
|
|
|
privacy_manager_ = create_actor<PrivacyManager>("PrivacyManager", create_reference());
|
|
|
|
secret_chats_manager_ = create_actor<SecretChatsManager>("SecretChatsManager", create_reference());
|
|
|
|
G()->set_secret_chats_manager(secret_chats_manager_.get());
|
2018-06-27 20:26:52 +02:00
|
|
|
secure_manager_ = create_actor<SecureManager>("SecureManager", create_reference());
|
|
|
|
verify_phone_number_manager_ = create_actor<PhoneNumberManager>(
|
|
|
|
"VerifyPhoneNumberManager", PhoneNumberManager::Type::VerifyPhone, create_reference());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::send_update(tl_object_ptr<td_api::Update> &&object) {
|
2020-05-09 22:39:11 +02:00
|
|
|
CHECK(object != nullptr);
|
2018-04-03 02:08:17 +02:00
|
|
|
auto object_id = object->get_id();
|
|
|
|
if (close_flag_ >= 5 && object_id != td_api::updateAuthorizationState::ID) {
|
|
|
|
// just in case
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (object_id) {
|
2021-09-13 14:55:01 +02:00
|
|
|
case td_api::updateChatThemes::ID:
|
2018-12-31 20:04:05 +01:00
|
|
|
case td_api::updateFavoriteStickers::ID:
|
|
|
|
case td_api::updateInstalledStickerSets::ID:
|
|
|
|
case td_api::updateRecentStickers::ID:
|
|
|
|
case td_api::updateSavedAnimations::ID:
|
2022-04-15 20:54:47 +02:00
|
|
|
case td_api::updateSavedNotificationSounds::ID:
|
2018-12-31 20:04:05 +01:00
|
|
|
case td_api::updateUserStatus::ID:
|
|
|
|
VLOG(td_requests) << "Sending update: " << oneline(to_string(object));
|
|
|
|
break;
|
2020-04-18 00:55:54 +02:00
|
|
|
case td_api::updateTrendingStickerSets::ID: {
|
2022-07-17 21:39:22 +02:00
|
|
|
auto update = static_cast<const td_api::updateTrendingStickerSets *>(object.get());
|
|
|
|
auto sticker_sets = update->sticker_sets_.get();
|
|
|
|
VLOG(td_requests) << "Sending update: updateTrendingStickerSets { " << oneline(to_string(update->sticker_type_))
|
|
|
|
<< ", total_count = " << sticker_sets->total_count_
|
2020-04-18 00:55:54 +02:00
|
|
|
<< ", count = " << sticker_sets->sets_.size() << " }";
|
2018-12-31 20:04:05 +01:00
|
|
|
break;
|
2020-04-18 00:55:54 +02:00
|
|
|
}
|
2021-09-17 18:59:31 +02:00
|
|
|
case td_api::updateAnimatedEmojiMessageClicked::ID / 2:
|
2020-01-08 21:41:03 +01:00
|
|
|
case td_api::updateOption::ID / 2:
|
2019-03-15 01:16:44 +01:00
|
|
|
case td_api::updateChatReadInbox::ID / 2:
|
|
|
|
case td_api::updateUnreadMessageCount::ID / 2:
|
|
|
|
case td_api::updateUnreadChatCount::ID / 2:
|
|
|
|
case td_api::updateChatOnlineMemberCount::ID / 2:
|
2021-11-23 12:29:49 +01:00
|
|
|
case td_api::updateChatAction::ID / 2:
|
2020-05-15 00:39:28 +02:00
|
|
|
case td_api::updateChatFilters::ID / 2:
|
2020-05-29 05:57:55 +02:00
|
|
|
case td_api::updateChatPosition::ID / 2:
|
2022-03-06 01:20:18 +01:00
|
|
|
case td_api::updateFileAddedToDownloads::ID / 2:
|
|
|
|
case td_api::updateFileDownload::ID / 2:
|
|
|
|
case td_api::updateFileRemovedFromDownloads::ID / 2:
|
2022-08-22 21:12:00 +02:00
|
|
|
case td_api::updateDefaultReactionType::ID / 2:
|
2018-05-02 12:30:52 +02:00
|
|
|
LOG(ERROR) << "Sending update: " << oneline(to_string(object));
|
|
|
|
break;
|
2018-12-31 20:04:05 +01:00
|
|
|
default:
|
|
|
|
VLOG(td_requests) << "Sending update: " << to_string(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
callback_->on_result(0, std::move(object));
|
2020-04-21 02:29:20 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void Td::send_result(uint64 id, tl_object_ptr<td_api::Object> object) {
|
2018-02-11 19:33:32 +01:00
|
|
|
if (id == 0) {
|
|
|
|
LOG(ERROR) << "Sending " << to_string(object) << " through send_result";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-09 16:59:13 +01:00
|
|
|
auto it = request_set_.find(id);
|
|
|
|
if (it != request_set_.end()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (object == nullptr) {
|
|
|
|
object = make_tl_object<td_api::error>(404, "Not Found");
|
|
|
|
}
|
2022-08-18 20:32:36 +02:00
|
|
|
VLOG(td_requests) << "Sending result for request " << id << ": " << to_string(object);
|
|
|
|
request_set_.erase(it);
|
2018-12-31 20:04:05 +01:00
|
|
|
callback_->on_result(id, std::move(object));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::send_error_impl(uint64 id, tl_object_ptr<td_api::error> error) {
|
|
|
|
CHECK(id != 0);
|
|
|
|
CHECK(error != nullptr);
|
2018-02-09 16:59:13 +01:00
|
|
|
auto it = request_set_.find(id);
|
|
|
|
if (it != request_set_.end()) {
|
2022-07-08 10:22:13 +02:00
|
|
|
if (error->code_ == 0 && error->message_ == "Lost promise") {
|
2022-08-18 20:32:36 +02:00
|
|
|
LOG(FATAL) << "Lost promise for query " << id << " of type " << it->second;
|
2022-07-08 10:22:13 +02:00
|
|
|
}
|
2022-08-18 20:32:36 +02:00
|
|
|
VLOG(td_requests) << "Sending error for request " << id << ": " << oneline(to_string(error));
|
|
|
|
request_set_.erase(it);
|
2018-12-31 20:04:05 +01:00
|
|
|
callback_->on_error(id, std::move(error));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::send_error(uint64 id, Status error) {
|
|
|
|
send_error_impl(id, make_tl_object<td_api::error>(error.code(), error.message().str()));
|
|
|
|
error.ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::send_error_raw(uint64 id, int32 code, CSlice error) {
|
2018-02-19 22:20:47 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_error_impl, id, make_error(code, error));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::answer_ok_query(uint64 id, Status status) {
|
|
|
|
if (status.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, std::move(status));
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-11 20:13:46 +02:00
|
|
|
Promise<Unit> Td::create_ok_request_promise(uint64 id) {
|
2019-03-20 19:13:45 +01:00
|
|
|
return PromiseCreator::lambda([id = id, actor_id = actor_id(this)](Result<Unit> result) {
|
2018-04-11 20:13:46 +02:00
|
|
|
if (result.is_error()) {
|
|
|
|
send_closure(actor_id, &Td::send_error, id, result.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id, &Td::send_result, id, td_api::make_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
#define CLEAN_INPUT_STRING(field_name) \
|
|
|
|
if (!clean_input_string(field_name)) { \
|
|
|
|
return send_error_raw(id, 400, "Strings must be encoded in UTF-8"); \
|
|
|
|
}
|
|
|
|
#define CHECK_IS_BOT() \
|
|
|
|
if (!auth_manager_->is_bot()) { \
|
|
|
|
return send_error_raw(id, 400, "Only bots can use the method"); \
|
|
|
|
}
|
|
|
|
#define CHECK_IS_USER() \
|
|
|
|
if (auth_manager_->is_bot()) { \
|
|
|
|
return send_error_raw(id, 400, "The method is not available for bots"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CREATE_NO_ARGS_REQUEST(name) \
|
|
|
|
auto slot_id = request_actors_.create(ActorOwn<>(), RequestActorIdType); \
|
|
|
|
inc_request_actor_refcnt(); \
|
|
|
|
*request_actors_.get(slot_id) = create_actor<name>(#name, actor_shared(this, slot_id), id);
|
|
|
|
#define CREATE_REQUEST(name, ...) \
|
|
|
|
auto slot_id = request_actors_.create(ActorOwn<>(), RequestActorIdType); \
|
|
|
|
inc_request_actor_refcnt(); \
|
|
|
|
*request_actors_.get(slot_id) = create_actor<name>(#name, actor_shared(this, slot_id), id, __VA_ARGS__);
|
2018-06-28 21:17:38 +02:00
|
|
|
#define CREATE_REQUEST_PROMISE() auto promise = create_request_promise<std::decay_t<decltype(request)>::ReturnType>(id)
|
|
|
|
#define CREATE_OK_REQUEST_PROMISE() \
|
2018-04-11 20:13:46 +02:00
|
|
|
static_assert(std::is_same<std::decay_t<decltype(request)>::ReturnType, td_api::object_ptr<td_api::ok>>::value, ""); \
|
2018-06-28 21:17:38 +02:00
|
|
|
auto promise = create_ok_request_promise(id)
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
Status Td::fix_parameters(TdParameters ¶meters) {
|
|
|
|
if (parameters.database_directory.empty()) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Fix database_directory";
|
2018-12-31 20:04:05 +01:00
|
|
|
parameters.database_directory = ".";
|
|
|
|
}
|
|
|
|
if (parameters.files_directory.empty()) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Fix files_directory";
|
2018-12-31 20:04:05 +01:00
|
|
|
parameters.files_directory = parameters.database_directory;
|
|
|
|
}
|
2019-04-11 22:24:39 +02:00
|
|
|
if (parameters.use_message_db && !parameters.use_chat_info_db) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Fix use_chat_info_db";
|
2018-12-31 20:04:05 +01:00
|
|
|
parameters.use_chat_info_db = true;
|
|
|
|
}
|
2019-04-11 22:24:39 +02:00
|
|
|
if (parameters.use_chat_info_db && !parameters.use_file_db) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Fix use_file_db";
|
2018-12-31 20:04:05 +01:00
|
|
|
parameters.use_file_db = true;
|
|
|
|
}
|
2018-02-23 23:28:23 +01:00
|
|
|
if (parameters.api_id <= 0) {
|
|
|
|
VLOG(td_init) << "Invalid api_id";
|
2018-12-31 20:04:05 +01:00
|
|
|
return Status::Error(400, "Valid api_id must be provided. Can be obtained at https://my.telegram.org");
|
|
|
|
}
|
|
|
|
if (parameters.api_hash.empty()) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Invalid api_hash";
|
2018-12-31 20:04:05 +01:00
|
|
|
return Status::Error(400, "Valid api_hash must be provided. Can be obtained at https://my.telegram.org");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
2022-09-07 21:19:08 +02:00
|
|
|
Status Td::set_parameters(td_api::object_ptr<td_api::setTdlibParameters> parameters) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Begin to set TDLib parameters";
|
2022-06-21 01:02:48 +02:00
|
|
|
if (!clean_input_string(parameters->api_hash_) || !clean_input_string(parameters->system_language_code_) ||
|
|
|
|
!clean_input_string(parameters->device_model_) || !clean_input_string(parameters->system_version_) ||
|
2018-12-31 20:04:05 +01:00
|
|
|
!clean_input_string(parameters->application_version_)) {
|
2018-02-23 23:28:23 +01:00
|
|
|
VLOG(td_init) << "Wrong string encoding";
|
2018-12-31 20:04:05 +01:00
|
|
|
return Status::Error(400, "Strings must be encoded in UTF-8");
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters_.use_test_dc = parameters->use_test_dc_;
|
|
|
|
parameters_.database_directory = parameters->database_directory_;
|
|
|
|
parameters_.files_directory = parameters->files_directory_;
|
|
|
|
parameters_.api_id = parameters->api_id_;
|
|
|
|
parameters_.api_hash = parameters->api_hash_;
|
|
|
|
parameters_.use_file_db = parameters->use_file_database_;
|
|
|
|
parameters_.enable_storage_optimizer = parameters->enable_storage_optimizer_;
|
|
|
|
parameters_.ignore_file_names = parameters->ignore_file_names_;
|
|
|
|
parameters_.use_secret_chats = parameters->use_secret_chats_;
|
|
|
|
parameters_.use_chat_info_db = parameters->use_chat_info_database_;
|
|
|
|
parameters_.use_message_db = parameters->use_message_database_;
|
|
|
|
|
|
|
|
TRY_STATUS(fix_parameters(parameters_));
|
|
|
|
|
2018-07-02 22:36:45 +02:00
|
|
|
VLOG(td_init) << "Create MtprotoHeader::Options";
|
|
|
|
options_.api_id = parameters->api_id_;
|
|
|
|
options_.system_language_code = trim(parameters->system_language_code_);
|
|
|
|
options_.device_model = trim(parameters->device_model_);
|
|
|
|
options_.system_version = trim(parameters->system_version_);
|
|
|
|
options_.application_version = trim(parameters->application_version_);
|
|
|
|
if (options_.system_language_code.empty()) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return Status::Error(400, "System language code must be non-empty");
|
|
|
|
}
|
2018-07-02 22:36:45 +02:00
|
|
|
if (options_.device_model.empty()) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return Status::Error(400, "Device model must be non-empty");
|
|
|
|
}
|
2018-07-02 22:36:45 +02:00
|
|
|
if (options_.system_version.empty()) {
|
2020-06-19 02:45:24 +02:00
|
|
|
options_.system_version = get_operating_system_version().str();
|
2020-06-20 01:39:33 +02:00
|
|
|
VLOG(td_init) << "Set system version to " << options_.system_version;
|
2018-02-19 22:20:47 +01:00
|
|
|
}
|
2018-07-02 22:36:45 +02:00
|
|
|
if (options_.application_version.empty()) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return Status::Error(400, "Application version must be non-empty");
|
|
|
|
}
|
2018-07-02 22:36:45 +02:00
|
|
|
if (options_.api_id != 21724) {
|
|
|
|
options_.application_version += ", TDLib ";
|
2022-07-11 13:01:56 +02:00
|
|
|
auto version = OptionManager::get_option_synchronously("version");
|
|
|
|
CHECK(version->get_id() == td_api::optionValueString::ID);
|
|
|
|
options_.application_version += static_cast<const td_api::optionValueString *>(version.get())->value_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-11-01 20:32:49 +01:00
|
|
|
options_.language_pack = string();
|
|
|
|
options_.language_code = string();
|
|
|
|
options_.parameters = string();
|
2018-07-02 22:36:45 +02:00
|
|
|
options_.is_emulator = false;
|
|
|
|
options_.proxy = Proxy();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setTdlibParameters &request) {
|
|
|
|
send_error_raw(id, 400, "Unexpected setTdlibParameters");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setDatabaseEncryptionKey &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-04-11 20:13:46 +02:00
|
|
|
G()->td_db()->get_binlog()->change_key(as_db_key(std::move(request.new_encryption_key_)), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getAuthorizationState &request) {
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::get_state, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setAuthenticationPhoneNumber &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.phone_number_);
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::set_phone_number, id, std::move(request.phone_number_),
|
2019-05-03 04:44:59 +02:00
|
|
|
std::move(request.settings_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-09-06 13:04:39 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setAuthenticationEmailAddress &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.email_address_);
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::set_email_address, id, std::move(request.email_address_));
|
|
|
|
}
|
|
|
|
|
2018-03-09 01:27:39 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::resendAuthenticationCode &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::resend_authentication_code, id);
|
|
|
|
}
|
|
|
|
|
2022-09-06 16:17:39 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::checkAuthenticationEmailCode &request) {
|
2022-09-06 22:29:57 +02:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::check_email_code, id, EmailVerification(std::move(request.code_)));
|
2022-09-06 16:17:39 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::checkAuthenticationCode &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.code_);
|
2019-07-16 21:08:34 +02:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::check_code, id, std::move(request.code_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::registerUser &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CLEAN_INPUT_STRING(request.first_name_);
|
|
|
|
CLEAN_INPUT_STRING(request.last_name_);
|
2019-07-16 21:08:34 +02:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::register_user, id, std::move(request.first_name_),
|
|
|
|
std::move(request.last_name_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 17:17:57 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::requestQrCodeAuthentication &request) {
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::request_qr_code_authentication, id,
|
2021-03-28 23:50:15 +02:00
|
|
|
UserId::get_user_ids(request.other_user_ids_));
|
2019-12-17 17:17:57 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::checkAuthenticationPassword &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::check_password, id, std::move(request.password_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::requestAuthenticationPasswordRecovery &request) {
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::request_password_recovery, id);
|
|
|
|
}
|
|
|
|
|
2021-06-28 21:33:08 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::checkAuthenticationPasswordRecoveryCode &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::check_password_recovery_code, id, std::move(request.recovery_code_));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::recoverAuthenticationPassword &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
2021-06-28 21:33:08 +02:00
|
|
|
CLEAN_INPUT_STRING(request.new_password_);
|
|
|
|
CLEAN_INPUT_STRING(request.new_hint_);
|
2021-06-28 18:47:23 +02:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::recover_password, id, std::move(request.recovery_code_),
|
|
|
|
std::move(request.new_password_), std::move(request.new_hint_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::logOut &request) {
|
|
|
|
// will call Td::destroy later
|
2020-07-22 23:19:47 +02:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::log_out, id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::close &request) {
|
2018-04-05 22:26:58 +02:00
|
|
|
// send response before actually closing
|
2018-02-16 23:00:22 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::ok>());
|
2021-10-25 05:47:20 +02:00
|
|
|
send_closure(actor_id(this), &Td::close);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::destroy &request) {
|
2018-04-05 22:26:58 +02:00
|
|
|
// send response before actually destroying
|
2018-02-16 23:00:22 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::ok>());
|
2021-10-25 05:47:20 +02:00
|
|
|
send_closure(actor_id(this), &Td::destroy);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::checkAuthenticationBotToken &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.token_);
|
|
|
|
send_closure(auth_manager_actor_, &AuthManager::check_bot_token, id, std::move(request.token_));
|
|
|
|
}
|
|
|
|
|
2019-12-17 17:17:57 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::confirmQrCodeAuthentication &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.link_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-16 11:02:07 +01:00
|
|
|
confirm_qr_code_authentication(this, request.link_, std::move(promise));
|
2019-12-17 17:17:57 +01:00
|
|
|
}
|
|
|
|
|
2018-09-20 18:33:41 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getCurrentState &request) {
|
2018-09-20 19:41:22 +02:00
|
|
|
vector<td_api::object_ptr<td_api::Update>> updates;
|
|
|
|
|
2021-12-16 10:16:09 +01:00
|
|
|
option_manager_->get_current_state(updates);
|
2018-09-20 19:41:22 +02:00
|
|
|
|
|
|
|
auto state = auth_manager_->get_current_authorization_state_object();
|
|
|
|
if (state != nullptr) {
|
|
|
|
updates.push_back(td_api::make_object<td_api::updateAuthorizationState>(std::move(state)));
|
|
|
|
}
|
|
|
|
|
2021-09-16 17:23:10 +02:00
|
|
|
updates.push_back(get_update_connection_state_object(connection_state_));
|
2018-09-20 19:41:22 +02:00
|
|
|
|
2018-09-20 21:38:19 +02:00
|
|
|
if (auth_manager_->is_authorized()) {
|
|
|
|
contacts_manager_->get_current_state(updates);
|
|
|
|
|
2019-05-10 18:04:14 +02:00
|
|
|
background_manager_->get_current_state(updates);
|
|
|
|
|
2018-09-20 21:38:19 +02:00
|
|
|
animations_manager_->get_current_state(updates);
|
|
|
|
|
2022-03-25 12:17:09 +01:00
|
|
|
attach_menu_manager_->get_current_state(updates);
|
|
|
|
|
2018-09-20 21:38:19 +02:00
|
|
|
stickers_manager_->get_current_state(updates);
|
|
|
|
|
2022-04-11 11:45:52 +02:00
|
|
|
notification_settings_manager_->get_current_state(updates);
|
|
|
|
|
2018-09-21 09:15:07 +02:00
|
|
|
messages_manager_->get_current_state(updates);
|
2018-09-21 09:34:15 +02:00
|
|
|
|
2018-12-05 17:11:28 +01:00
|
|
|
notification_manager_->get_current_state(updates);
|
|
|
|
|
2020-07-11 22:50:21 +02:00
|
|
|
config_manager_->get_actor_unsafe()->get_current_state(updates);
|
|
|
|
|
2018-09-21 09:34:15 +02:00
|
|
|
// TODO updateFileGenerationStart generation_id:int64 original_path:string destination_path:string conversion:string = Update;
|
|
|
|
// TODO updateCall call:call = Update;
|
2020-11-24 16:22:00 +01:00
|
|
|
// TODO updateGroupCall call:groupCall = Update;
|
2018-09-20 21:38:19 +02:00
|
|
|
}
|
2018-09-20 19:41:22 +02:00
|
|
|
|
2018-09-20 22:08:55 +02:00
|
|
|
auto update_terms_of_service = get_update_terms_of_service_object();
|
|
|
|
if (update_terms_of_service != nullptr) {
|
|
|
|
updates.push_back(std::move(update_terms_of_service));
|
|
|
|
}
|
|
|
|
|
2018-09-20 20:37:35 +02:00
|
|
|
// send response synchronously to prevent "Request aborted" or other changes of the current state
|
2018-09-20 19:41:22 +02:00
|
|
|
send_result(id, td_api::make_object<td_api::updates>(std::move(updates)));
|
2018-09-20 18:33:41 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getPasswordState &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::get_state, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setPassword &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.old_password_);
|
|
|
|
CLEAN_INPUT_STRING(request.new_password_);
|
|
|
|
CLEAN_INPUT_STRING(request.new_hint_);
|
|
|
|
CLEAN_INPUT_STRING(request.new_recovery_email_address_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::set_password, std::move(request.old_password_),
|
|
|
|
std::move(request.new_password_), std::move(request.new_hint_), request.set_recovery_email_address_,
|
|
|
|
std::move(request.new_recovery_email_address_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-09-07 12:49:48 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setLoginEmailAddress &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.new_login_email_address_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<SentEmailCode> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_email_address_authentication_code_info_object());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(password_manager_, &PasswordManager::set_login_email_address,
|
|
|
|
std::move(request.new_login_email_address_), std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2022-09-07 13:39:33 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::resendLoginEmailAddressCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<SentEmailCode> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_email_address_authentication_code_info_object());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(password_manager_, &PasswordManager::resend_login_email_address_code, std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2022-09-07 14:18:43 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::checkLoginEmailAddressCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(password_manager_, &PasswordManager::check_login_email_address_code,
|
|
|
|
EmailVerification(std::move(request.code_)), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setRecoveryEmailAddress &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
|
|
|
CLEAN_INPUT_STRING(request.new_recovery_email_address_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::set_recovery_email_address, std::move(request.password_),
|
|
|
|
std::move(request.new_recovery_email_address_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getRecoveryEmailAddress &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::get_recovery_email_address, std::move(request.password_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-02-10 21:16:52 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::checkRecoveryEmailAddressCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.code_);
|
2019-02-25 19:37:26 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
send_closure(password_manager_, &PasswordManager::check_recovery_email_address_code, std::move(request.code_),
|
2019-02-10 21:16:52 +01:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-02-10 21:32:49 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::resendRecoveryEmailAddressCode &request) {
|
|
|
|
CHECK_IS_USER();
|
2019-02-25 19:37:26 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2019-02-10 21:32:49 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::resend_recovery_email_address_code, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::requestPasswordRecovery &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-09-06 13:53:19 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<SentEmailCode> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_email_address_authentication_code_info_object());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(password_manager_, &PasswordManager::request_password_recovery, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-06-28 22:47:54 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::checkPasswordRecoveryCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(password_manager_, &PasswordManager::check_password_recovery_code, std::move(request.recovery_code_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::recoverPassword &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.recovery_code_);
|
2021-06-28 21:33:08 +02:00
|
|
|
CLEAN_INPUT_STRING(request.new_password_);
|
|
|
|
CLEAN_INPUT_STRING(request.new_hint_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::recover_password, std::move(request.recovery_code_),
|
2021-06-28 18:47:23 +02:00
|
|
|
std::move(request.new_password_), std::move(request.new_hint_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-06-29 04:16:48 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::resetPassword &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
send_closure(password_manager_, &PasswordManager::reset_password, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-06-30 18:49:52 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::cancelPasswordReset &request) {
|
2021-06-29 04:24:55 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-06-30 18:49:52 +02:00
|
|
|
send_closure(password_manager_, &PasswordManager::cancel_password_reset, std::move(promise));
|
2021-06-29 04:24:55 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getTemporaryPasswordState &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::get_temp_password_state, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::createTemporaryPassword &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(password_manager_, &PasswordManager::create_temp_password, std::move(request.password_),
|
|
|
|
request.valid_for_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-24 01:12:59 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::processPushNotification &request) {
|
2019-04-23 02:09:00 +02:00
|
|
|
CHECK_IS_USER();
|
2018-12-24 01:12:59 +01:00
|
|
|
CLEAN_INPUT_STRING(request.payload_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(G()->notification_manager(), &NotificationManager::process_push_notification,
|
|
|
|
std::move(request.payload_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::registerDevice &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
if (request.device_token_ == nullptr) {
|
2020-03-02 10:52:13 +01:00
|
|
|
return send_error_raw(id, 400, "Device token must be non-empty");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(device_token_manager_, &DeviceTokenManager::register_device, std::move(request.device_token_),
|
2021-03-28 23:50:15 +02:00
|
|
|
UserId::get_user_ids(request.other_user_ids_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getUserPrivacySettingRules &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(privacy_manager_, &PrivacyManager::get_privacy, std::move(request.setting_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setUserPrivacySettingRules &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-12-28 23:48:32 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(privacy_manager_, &PrivacyManager::set_privacy, std::move(request.setting_), std::move(request.rules_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getAccountTtl &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 17:28:42 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<int32> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(td_api::make_object<td_api::accountTtl>(result.ok()));
|
|
|
|
}
|
|
|
|
});
|
2021-11-16 11:02:07 +01:00
|
|
|
get_account_ttl(this, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setAccountTtl &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
if (request.ttl_ == nullptr) {
|
2020-03-02 10:52:13 +01:00
|
|
|
return send_error_raw(id, 400, "New account TTL must be non-empty");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-16 11:02:07 +01:00
|
|
|
set_account_ttl(this, request.ttl_->days_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::deleteAccount &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.reason_);
|
2022-07-01 20:25:34 +02:00
|
|
|
send_closure(auth_manager_actor_, &AuthManager::delete_account, id, request.reason_, request.password_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::changePhoneNumber &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.phone_number_);
|
2018-04-09 16:20:12 +02:00
|
|
|
send_closure(change_phone_number_manager_, &PhoneNumberManager::set_phone_number, id,
|
2019-05-03 04:44:59 +02:00
|
|
|
std::move(request.phone_number_), std::move(request.settings_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::checkChangePhoneNumberCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.code_);
|
2018-04-09 16:20:12 +02:00
|
|
|
send_closure(change_phone_number_manager_, &PhoneNumberManager::check_code, id, std::move(request.code_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::resendChangePhoneNumberCode &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-04-09 16:20:12 +02:00
|
|
|
send_closure(change_phone_number_manager_, &PhoneNumberManager::resend_authentication_code, id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getActiveSessions &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-16 11:02:07 +01:00
|
|
|
get_active_sessions(this, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::terminateSession &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-16 11:02:07 +01:00
|
|
|
terminate_session(this, request.session_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::terminateAllOtherSessions &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-16 11:02:07 +01:00
|
|
|
terminate_all_other_sessions(this, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-24 15:59:17 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSessionCanAcceptCalls &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
toggle_session_can_accept_calls(this, request.session_id_, request.can_accept_calls_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-11-16 13:22:00 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSessionCanAcceptSecretChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
toggle_session_can_accept_secret_chats(this, request.session_id_, request.can_accept_secret_chats_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-11-24 12:03:35 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setInactiveSessionTtl &request) {
|
2021-11-16 14:04:19 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
set_inactive_session_ttl_days(this, request.inactive_session_ttl_days_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-02-07 00:31:38 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getConnectedWebsites &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-16 11:13:06 +01:00
|
|
|
get_connected_websites(this, std::move(promise));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::disconnectWebsite &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-16 11:13:06 +01:00
|
|
|
disconnect_website(this, request.website_id_, std::move(promise));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::disconnectAllWebsites &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-16 11:13:06 +01:00
|
|
|
disconnect_all_websites(this, std::move(promise));
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
|
2018-03-09 01:27:39 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMe &request) {
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetMeRequest);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getUser &request) {
|
|
|
|
CREATE_REQUEST(GetUserRequest, request.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getUserFullInfo &request) {
|
|
|
|
CREATE_REQUEST(GetUserFullInfoRequest, request.user_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getBasicGroup &request) {
|
|
|
|
CREATE_REQUEST(GetGroupRequest, request.basic_group_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getBasicGroupFullInfo &request) {
|
|
|
|
CREATE_REQUEST(GetGroupFullInfoRequest, request.basic_group_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getSupergroup &request) {
|
|
|
|
CREATE_REQUEST(GetSupergroupRequest, request.supergroup_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getSupergroupFullInfo &request) {
|
|
|
|
CREATE_REQUEST(GetSupergroupFullInfoRequest, request.supergroup_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getSecretChat &request) {
|
|
|
|
CREATE_REQUEST(GetSecretChatRequest, request.secret_chat_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getChat &request) {
|
|
|
|
CREATE_REQUEST(GetChatRequest, request.chat_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getMessage &request) {
|
|
|
|
CREATE_REQUEST(GetMessageRequest, request.chat_id_, request.message_id_);
|
|
|
|
}
|
|
|
|
|
2019-01-09 03:57:43 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageLocally &request) {
|
|
|
|
FullMessageId full_message_id(DialogId(request.chat_id_), MessageId(request.message_id_));
|
2021-10-03 13:54:40 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
|
|
|
messages_manager_->get_message_object(full_message_id, "getMessageLocally"));
|
2019-01-09 03:57:43 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 00:31:38 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getRepliedMessage &request) {
|
|
|
|
CREATE_REQUEST(GetRepliedMessageRequest, request.chat_id_, request.message_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getChatPinnedMessage &request) {
|
|
|
|
CREATE_REQUEST(GetChatPinnedMessageRequest, request.chat_id_);
|
|
|
|
}
|
|
|
|
|
2020-10-28 23:06:07 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getCallbackQueryMessage &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_REQUEST(GetCallbackQueryMessageRequest, request.chat_id_, request.message_id_, request.callback_query_id_);
|
2020-09-22 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessages &request) {
|
|
|
|
CREATE_REQUEST(GetMessagesRequest, request.chat_id_, request.message_ids_);
|
|
|
|
}
|
|
|
|
|
2021-12-21 12:19:48 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatSponsoredMessage &request) {
|
2021-08-24 22:44:47 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-12-21 12:19:48 +01:00
|
|
|
sponsored_message_manager_->get_dialog_sponsored_message(DialogId(request.chat_id_), std::move(promise));
|
2021-08-25 21:34:18 +02:00
|
|
|
}
|
|
|
|
|
2020-10-28 23:06:07 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageThread &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetMessageThreadRequest, request.chat_id_, request.message_id_);
|
|
|
|
}
|
|
|
|
|
2021-09-03 15:14:03 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageViewers &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_message_viewers({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-04-08 03:50:26 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageLink &request) {
|
2021-07-26 03:01:10 +02:00
|
|
|
auto r_message_link =
|
|
|
|
messages_manager_->get_message_link({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
request.media_timestamp_, request.for_album_, request.for_comment_);
|
2020-09-20 21:07:27 +02:00
|
|
|
if (r_message_link.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_message_link.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
|
|
|
td_api::make_object<td_api::messageLink>(r_message_link.ok().first, r_message_link.ok().second));
|
|
|
|
}
|
2019-04-08 01:42:16 +02:00
|
|
|
}
|
|
|
|
|
2020-09-20 17:17:47 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageEmbeddingCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetMessageEmbeddingCodeRequest, request.chat_id_, request.message_id_, request.for_album_);
|
|
|
|
}
|
|
|
|
|
2019-08-05 11:12:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getMessageLinkInfo &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.url_);
|
|
|
|
CREATE_REQUEST(GetMessageLinkInfoRequest, std::move(request.url_));
|
|
|
|
}
|
|
|
|
|
2022-01-29 21:43:57 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::translateText &request) {
|
2022-01-14 20:28:28 +01:00
|
|
|
CHECK_IS_USER();
|
2022-01-29 21:43:57 +01:00
|
|
|
CLEAN_INPUT_STRING(request.text_);
|
2022-01-14 20:28:28 +01:00
|
|
|
CLEAN_INPUT_STRING(request.from_language_code_);
|
|
|
|
CLEAN_INPUT_STRING(request.to_language_code_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-01-29 21:43:57 +01:00
|
|
|
messages_manager_->translate_text(request.text_, request.from_language_code_, request.to_language_code_,
|
|
|
|
std::move(promise));
|
2022-01-14 20:28:28 +01:00
|
|
|
}
|
|
|
|
|
2022-05-25 20:18:40 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::recognizeSpeech &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
voice_notes_manager_->recognize_speech({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-05-26 19:40:43 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::rateSpeechRecognition &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
voice_notes_manager_->rate_speech_recognition({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
request.is_good_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getFile &request) {
|
2018-03-07 00:37:39 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, file_manager_->get_file_object(FileId(request.file_id_, 0)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getRemoteFile &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.remote_file_id_);
|
2020-06-22 03:28:03 +02:00
|
|
|
auto file_type = request.file_type_ == nullptr ? FileType::Temp : get_file_type(*request.file_type_);
|
2019-01-22 15:35:29 +01:00
|
|
|
auto r_file_id = file_manager_->from_persistent_id(request.remote_file_id_, file_type);
|
2018-12-31 20:04:05 +01:00
|
|
|
if (r_file_id.is_error()) {
|
2018-07-10 15:56:37 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_file_id.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, file_manager_->get_file_object(r_file_id.ok()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getStorageStatistics &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<FileStats> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-06-22 03:28:03 +02:00
|
|
|
promise.set_value(result.ok().get_storage_statistics_object());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
});
|
2019-08-02 15:05:01 +02:00
|
|
|
send_closure(storage_manager_, &StorageManager::get_storage_stats, false /*need_all_files*/, request.chat_limit_,
|
|
|
|
std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getStorageStatisticsFast &request) {
|
2022-07-23 22:50:28 +02:00
|
|
|
CHECK_IS_USER();
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<FileStatsFast> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-06-22 03:28:03 +02:00
|
|
|
promise.set_value(result.ok().get_storage_statistics_fast_object());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(storage_manager_, &StorageManager::get_storage_stats_fast, std::move(query_promise));
|
|
|
|
}
|
2019-04-17 11:17:51 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getDatabaseStatistics &request) {
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<DatabaseStats> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-06-22 03:28:03 +02:00
|
|
|
promise.set_value(result.ok().get_database_statistics_object());
|
2019-04-17 11:17:51 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(storage_manager_, &StorageManager::get_database_stats, std::move(query_promise));
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::optimizeStorage &request) {
|
|
|
|
std::vector<FileType> file_types;
|
|
|
|
for (auto &file_type : request.file_types_) {
|
|
|
|
if (file_type == nullptr) {
|
2020-03-02 10:52:13 +01:00
|
|
|
return send_error_raw(id, 400, "File type must be non-empty");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-06-22 03:28:03 +02:00
|
|
|
file_types.push_back(get_file_type(*file_type));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
std::vector<DialogId> owner_dialog_ids;
|
|
|
|
for (auto chat_id : request.chat_ids_) {
|
|
|
|
DialogId dialog_id(chat_id);
|
|
|
|
if (!dialog_id.is_valid() && dialog_id != DialogId()) {
|
2020-04-19 12:45:37 +02:00
|
|
|
return send_error_raw(id, 400, "Wrong chat identifier");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
owner_dialog_ids.push_back(dialog_id);
|
|
|
|
}
|
|
|
|
std::vector<DialogId> exclude_owner_dialog_ids;
|
|
|
|
for (auto chat_id : request.exclude_chat_ids_) {
|
|
|
|
DialogId dialog_id(chat_id);
|
|
|
|
if (!dialog_id.is_valid() && dialog_id != DialogId()) {
|
2020-04-19 12:45:37 +02:00
|
|
|
return send_error_raw(id, 400, "Wrong chat identifier");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
exclude_owner_dialog_ids.push_back(dialog_id);
|
|
|
|
}
|
|
|
|
FileGcParameters parameters(request.size_, request.ttl_, request.count_, request.immunity_delay_,
|
|
|
|
std::move(file_types), std::move(owner_dialog_ids), std::move(exclude_owner_dialog_ids),
|
|
|
|
request.chat_limit_);
|
|
|
|
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<FileStats> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-06-22 03:28:03 +02:00
|
|
|
promise.set_value(result.ok().get_storage_statistics_object());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
});
|
2020-03-02 09:59:47 +01:00
|
|
|
send_closure(storage_manager_, &StorageManager::run_gc, std::move(parameters),
|
|
|
|
request.return_deleted_file_statistics_, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getNetworkStatistics &request) {
|
2022-08-17 15:11:13 +02:00
|
|
|
if (!request.only_current_ && G()->get_option_boolean("disable_persistent_network_statistics")) {
|
2020-07-13 15:56:31 +02:00
|
|
|
return send_error_raw(id, 400, "Persistent network statistics is disabled");
|
|
|
|
}
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<NetworkStats> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-06-22 03:28:03 +02:00
|
|
|
promise.set_value(result.ok().get_network_statistics_object());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(net_stats_manager_, &NetStatsManager::get_network_stats, request.only_current_,
|
|
|
|
std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::resetNetworkStatistics &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(net_stats_manager_, &NetStatsManager::reset_network_stats);
|
2018-04-11 20:13:46 +02:00
|
|
|
promise.set_value(Unit());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::addNetworkStatistics &request) {
|
|
|
|
if (request.entry_ == nullptr) {
|
2020-03-02 10:52:13 +01:00
|
|
|
return send_error_raw(id, 400, "Network statistics entry must be non-empty");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NetworkStatsEntry entry;
|
|
|
|
switch (request.entry_->get_id()) {
|
|
|
|
case td_api::networkStatisticsEntryFile::ID: {
|
|
|
|
auto file_entry = move_tl_object_as<td_api::networkStatisticsEntryFile>(request.entry_);
|
|
|
|
entry.is_call = false;
|
|
|
|
if (file_entry->file_type_ != nullptr) {
|
2020-06-22 03:28:03 +02:00
|
|
|
entry.file_type = get_file_type(*file_entry->file_type_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2020-06-22 03:28:03 +02:00
|
|
|
entry.net_type = get_net_type(file_entry->network_type_);
|
2018-12-31 20:04:05 +01:00
|
|
|
entry.rx = file_entry->received_bytes_;
|
|
|
|
entry.tx = file_entry->sent_bytes_;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case td_api::networkStatisticsEntryCall::ID: {
|
|
|
|
auto call_entry = move_tl_object_as<td_api::networkStatisticsEntryCall>(request.entry_);
|
|
|
|
entry.is_call = true;
|
2020-06-22 03:28:03 +02:00
|
|
|
entry.net_type = get_net_type(call_entry->network_type_);
|
2018-12-31 20:04:05 +01:00
|
|
|
entry.rx = call_entry->received_bytes_;
|
|
|
|
entry.tx = call_entry->sent_bytes_;
|
|
|
|
entry.duration = call_entry->duration_;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.net_type == NetType::None) {
|
|
|
|
return send_error_raw(id, 400, "Network statistics entry can't be increased for NetworkTypeNone");
|
|
|
|
}
|
2021-12-31 07:36:24 +01:00
|
|
|
if (entry.rx > (static_cast<int64>(1) << 40) || entry.rx < 0) {
|
2018-12-31 20:04:05 +01:00
|
|
|
return send_error_raw(id, 400, "Wrong received bytes value");
|
|
|
|
}
|
2021-12-31 07:36:24 +01:00
|
|
|
if (entry.tx > (static_cast<int64>(1) << 40) || entry.tx < 0) {
|
2018-12-31 20:04:05 +01:00
|
|
|
return send_error_raw(id, 400, "Wrong sent bytes value");
|
|
|
|
}
|
|
|
|
if (entry.count > (1 << 30) || entry.count < 0) {
|
|
|
|
return send_error_raw(id, 400, "Wrong count value");
|
|
|
|
}
|
|
|
|
if (entry.duration > (1 << 30) || entry.duration < 0) {
|
|
|
|
return send_error_raw(id, 400, "Wrong duration value");
|
|
|
|
}
|
|
|
|
|
|
|
|
send_closure(net_stats_manager_, &NetStatsManager::add_network_stats, entry);
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
2019-05-14 01:03:05 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setNetworkType &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-06-22 03:28:03 +02:00
|
|
|
send_closure(state_manager_, &StateManager::on_network, get_net_type(request.type_));
|
2018-04-11 20:13:46 +02:00
|
|
|
promise.set_value(Unit());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-05-14 01:03:05 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getAutoDownloadSettingsPresets &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_auto_download_settings_presets(this, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setAutoDownloadSettings &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
if (request.settings_ == nullptr) {
|
|
|
|
return send_error_raw(id, 400, "New settings must be non-empty");
|
|
|
|
}
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-06-22 03:28:03 +02:00
|
|
|
set_auto_download_settings(this, get_net_type(request.type_), get_auto_download_settings(request.settings_),
|
2019-05-14 01:03:05 +02:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-09-25 10:37:32 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getTopChats &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<vector<DialogId>> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-09-19 23:28:26 +02:00
|
|
|
promise.set_value(MessagesManager::get_chats_object(-1, result.ok()));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
});
|
2022-08-18 12:29:51 +02:00
|
|
|
send_closure(top_dialog_manager_actor_, &TopDialogManager::get_top_dialogs,
|
|
|
|
get_top_dialog_category(request.category_), request.limit_, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::removeTopChat &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-09-25 10:37:32 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-08-18 12:29:51 +02:00
|
|
|
send_closure(top_dialog_manager_actor_, &TopDialogManager::remove_dialog, get_top_dialog_category(request.category_),
|
|
|
|
DialogId(request.chat_id_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-08-10 16:52:31 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::loadChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
|
|
|
|
DialogListId dialog_list_id(request.chat_list_);
|
|
|
|
auto r_offset = messages_manager_->get_dialog_list_last_date(dialog_list_id);
|
|
|
|
if (r_offset.is_error()) {
|
|
|
|
return send_error_raw(id, 400, r_offset.error().message());
|
|
|
|
}
|
|
|
|
auto offset = r_offset.move_as_ok();
|
|
|
|
if (offset == MAX_DIALOG_DATE) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_result, id, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
CREATE_REQUEST(LoadChatsRequest, dialog_list_id, offset, request.limit_);
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChats &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-08-11 14:59:09 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_dialogs_from_list(DialogListId(request.chat_list_), request.limit_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchPublicChat &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.username_);
|
|
|
|
CREATE_REQUEST(SearchPublicChatRequest, request.username_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchPublicChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST(SearchPublicChatsRequest, request.query_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST(SearchChatsRequest, request.query_, request.limit_);
|
|
|
|
}
|
|
|
|
|
2018-01-16 19:56:59 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchChatsOnServer &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST(SearchChatsOnServerRequest, request.query_, request.limit_);
|
|
|
|
}
|
|
|
|
|
2019-10-16 20:55:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::searchChatsNearby &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->search_dialogs_nearby(Location(request.location_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getGroupsInCommon &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetGroupsInCommonRequest, request.user_id_, request.offset_chat_id_, request.limit_);
|
|
|
|
}
|
|
|
|
|
2018-03-02 00:19:00 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::checkChatUsername &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.username_);
|
2019-10-17 20:54:18 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-18 02:06:20 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda(
|
|
|
|
[promise = std::move(promise)](Result<ContactsManager::CheckDialogUsernameResult> result) mutable {
|
2019-10-17 20:54:18 +02:00
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(ContactsManager::get_check_chat_username_result_object(result.ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
contacts_manager_->check_dialog_username(DialogId(request.chat_id_), request.username_, std::move(query_promise));
|
2018-03-02 00:19:00 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getCreatedPublicChats &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-12-03 13:40:39 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-12-03 18:10:30 +01:00
|
|
|
contacts_manager_->get_created_public_dialogs(get_public_dialog_type(request.type_), std::move(promise), false);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-10-22 13:06:46 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::checkCreatedPublicChatsLimit &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->check_created_public_dialogs_limit(get_public_dialog_type(request.type_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-09-13 19:25:17 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getSuitableDiscussionChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetSuitableDiscussionChatsRequest);
|
|
|
|
}
|
|
|
|
|
2019-12-13 15:27:44 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getInactiveSupergroupChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetInactiveSupergroupChatsRequest);
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::addRecentlyFoundChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->add_recently_found_dialog(DialogId(request.chat_id_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::removeRecentlyFoundChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->remove_recently_found_dialog(DialogId(request.chat_id_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::clearRecentlyFoundChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
messages_manager_->clear_recently_found_dialogs();
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
2021-09-14 13:18:37 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getRecentlyOpenedChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetRecentlyOpenedChatsRequest, request.limit_);
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::openChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->open_dialog(DialogId(request.chat_id_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::closeChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->close_dialog(DialogId(request.chat_id_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::viewMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-09-22 00:13:06 +02:00
|
|
|
answer_ok_query(id, messages_manager_->view_messages(
|
|
|
|
DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
|
|
|
MessagesManager::get_message_ids(request.message_ids_), request.force_read_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::openMessageContent &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(
|
|
|
|
id, messages_manager_->open_message_content({DialogId(request.chat_id_), MessageId(request.message_id_)}));
|
|
|
|
}
|
|
|
|
|
2021-09-15 23:41:40 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::clickAnimatedEmojiMessage &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->click_animated_emoji_message({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-06-01 04:41:32 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getInternalLinkType &request) {
|
2022-07-01 18:27:59 +02:00
|
|
|
auto type = LinkManager::parse_internal_link(request.link_);
|
2021-06-01 04:41:32 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, type == nullptr ? nullptr : type->get_internal_link_type_object());
|
|
|
|
}
|
|
|
|
|
2021-03-15 22:52:37 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getExternalLinkInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.link_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-03 22:19:35 +02:00
|
|
|
link_manager_->get_external_link_info(std::move(request.link_), std::move(promise));
|
2021-03-15 22:52:37 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 12:36:11 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getExternalLink &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.link_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-05-25 01:39:29 +02:00
|
|
|
link_manager_->get_link_login_url(request.link_, request.allow_write_access_, std::move(promise));
|
2021-02-04 12:36:11 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatHistory &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetChatHistoryRequest, request.chat_id_, request.from_message_id_, request.offset_, request.limit_,
|
|
|
|
request.only_local_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::deleteChatHistory &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-03-27 21:17:41 +01:00
|
|
|
messages_manager_->delete_dialog_history(DialogId(request.chat_id_), request.remove_from_chat_list_, request.revoke_,
|
2018-06-28 23:06:17 +02:00
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-01-20 12:49:18 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
DialogId dialog_id(request.chat_id_);
|
|
|
|
auto query_promise = [actor_id = messages_manager_actor_.get(), dialog_id,
|
|
|
|
promise = std::move(promise)](Result<Unit> &&result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2021-02-04 14:01:04 +01:00
|
|
|
send_closure(actor_id, &MessagesManager::on_dialog_deleted, dialog_id, std::move(promise));
|
2021-01-20 12:49:18 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
contacts_manager_->delete_dialog(dialog_id, std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2020-09-30 03:26:39 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageThreadHistory &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetMessageThreadHistoryRequest, request.chat_id_, request.message_id_, request.from_message_id_,
|
|
|
|
request.offset_, request.limit_);
|
|
|
|
}
|
|
|
|
|
2021-10-30 02:34:49 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getChatMessageCalendar &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetChatMessageCalendarRequest, request.chat_id_, request.from_message_id_, std::move(request.filter_));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
2021-11-15 15:25:24 +01:00
|
|
|
CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.sender_id_),
|
2020-09-08 13:17:56 +02:00
|
|
|
request.from_message_id_, request.offset_, request.limit_, std::move(request.filter_),
|
|
|
|
request.message_thread_id_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchSecretMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
2020-08-21 13:47:43 +02:00
|
|
|
CLEAN_INPUT_STRING(request.offset_);
|
2020-08-18 14:10:03 +02:00
|
|
|
CREATE_REQUEST(SearchSecretMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.offset_),
|
2018-12-31 20:04:05 +01:00
|
|
|
request.limit_, std::move(request.filter_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogListId dialog_list_id(request.chat_list_);
|
|
|
|
if (!dialog_list_id.is_folder()) {
|
|
|
|
return send_error_raw(id, 400, "Wrong chat list specified");
|
|
|
|
}
|
|
|
|
CREATE_REQUEST(SearchMessagesRequest, dialog_list_id.get_folder_id(), request.chat_list_ == nullptr,
|
2019-10-22 14:06:11 +02:00
|
|
|
std::move(request.query_), request.offset_date_, request.offset_chat_id_, request.offset_message_id_,
|
2020-09-08 13:58:02 +02:00
|
|
|
request.limit_, std::move(request.filter_), request.min_date_, request.max_date_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 13:58:16 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::searchCallMessages &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(SearchCallMessagesRequest, request.from_message_id_, request.limit_, request.only_missed_);
|
|
|
|
}
|
|
|
|
|
2022-02-22 13:58:16 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchOutgoingDocumentMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->search_outgoing_document_messages(request.query_, request.limit_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-01-19 11:21:50 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteAllCallMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->delete_all_call_messages(request.revoke_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::searchChatRecentLocationMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-10-06 13:22:42 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->search_dialog_recent_location_messages(DialogId(request.chat_id_), request.limit_,
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getActiveLiveLocationMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetActiveLiveLocationMessagesRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getChatMessageByDate &request) {
|
|
|
|
CREATE_REQUEST(GetChatMessageByDateRequest, request.chat_id_, request.date_);
|
|
|
|
}
|
|
|
|
|
2021-10-15 16:40:30 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatSparseMessagePositions &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_dialog_sparse_message_positions(
|
|
|
|
DialogId(request.chat_id_), get_message_search_filter(request.filter_), MessageId(request.from_message_id_),
|
|
|
|
request.limit_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getChatMessageCount &request) {
|
2018-07-19 15:58:09 +02:00
|
|
|
CHECK_IS_USER();
|
2021-10-03 12:47:50 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<int32> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::count>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messages_manager_->get_dialog_message_count(DialogId(request.chat_id_), get_message_search_filter(request.filter_),
|
|
|
|
request.return_local_, std::move(query_promise));
|
2018-07-19 15:58:09 +02:00
|
|
|
}
|
|
|
|
|
2022-09-30 19:04:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatMessagePosition &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<int32> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::count>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messages_manager_->get_dialog_message_position({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
get_message_search_filter(request.filter_),
|
|
|
|
MessageId(request.message_thread_id_), std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2019-12-04 18:06:39 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatScheduledMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetChatScheduledMessagesRequest, request.chat_id_);
|
|
|
|
}
|
|
|
|
|
2022-09-12 14:03:35 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getEmojiReaction &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, stickers_manager_->get_emoji_reaction_object(request.emoji_));
|
|
|
|
}
|
|
|
|
|
2022-09-12 14:44:37 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getCustomEmojiReactionAnimations &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->get_custom_emoji_reaction_generic_animations(false, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-01-26 13:25:03 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageAvailableReactions &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-09-13 18:19:35 +02:00
|
|
|
auto r_reactions = messages_manager_->get_message_available_reactions(
|
|
|
|
{DialogId(request.chat_id_), MessageId(request.message_id_)}, request.row_size_);
|
2022-01-26 13:25:03 +01:00
|
|
|
if (r_reactions.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_reactions.move_as_error());
|
|
|
|
} else {
|
2022-09-13 18:19:35 +02:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, r_reactions.move_as_ok());
|
2022-01-26 13:25:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-12 18:37:45 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::clearRecentReactions &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->clear_recent_reactions(std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-09-09 14:56:45 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::addMessageReaction &request) {
|
2022-01-21 18:39:55 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-09-09 14:56:45 +02:00
|
|
|
messages_manager_->add_message_reaction({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
2022-08-16 21:42:29 +02:00
|
|
|
get_message_reaction_string(request.reaction_type_), request.is_big_,
|
2022-09-05 21:04:50 +02:00
|
|
|
request.update_recent_reactions_, std::move(promise));
|
2022-01-21 18:39:55 +01:00
|
|
|
}
|
|
|
|
|
2022-09-09 14:56:45 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::removeMessageReaction &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->remove_message_reaction({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
get_message_reaction_string(request.reaction_type_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-01-26 23:52:21 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getMessageAddedReactions &request) {
|
2022-01-21 14:46:16 +01:00
|
|
|
CHECK_IS_USER();
|
2022-01-21 18:39:55 +01:00
|
|
|
CLEAN_INPUT_STRING(request.offset_);
|
2022-01-21 14:46:16 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-01-26 23:52:21 +01:00
|
|
|
get_message_added_reactions(this, {DialogId(request.chat_id_), MessageId(request.message_id_)},
|
2022-08-16 21:42:29 +02:00
|
|
|
get_message_reaction_string(request.reaction_type_), std::move(request.offset_),
|
|
|
|
request.limit_, std::move(promise));
|
2022-01-21 14:46:16 +01:00
|
|
|
}
|
|
|
|
|
2022-08-16 22:08:36 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setDefaultReactionType &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
set_default_reaction(this, get_message_reaction_string(request.reaction_type_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-08-21 13:47:43 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getMessagePublicForwards &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.offset_);
|
2021-09-23 21:56:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_message_public_forwards({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
2021-09-24 08:07:38 +02:00
|
|
|
std::move(request.offset_), request.limit_, std::move(promise));
|
2020-08-21 13:47:43 +02:00
|
|
|
}
|
|
|
|
|
2018-11-08 19:00:03 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::removeNotification &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-08-18 12:29:51 +02:00
|
|
|
send_closure(notification_manager_actor_, &NotificationManager::remove_notification,
|
|
|
|
NotificationGroupId(request.notification_group_id_), NotificationId(request.notification_id_), false,
|
|
|
|
true, std::move(promise), "td_api::removeNotification");
|
2018-11-08 19:00:03 +01:00
|
|
|
}
|
|
|
|
|
2018-11-09 23:56:00 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::removeNotificationGroup &request) {
|
2018-11-08 19:00:03 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-08-18 12:29:51 +02:00
|
|
|
send_closure(notification_manager_actor_, &NotificationManager::remove_notification_group,
|
|
|
|
NotificationGroupId(request.notification_group_id_), NotificationId(request.max_notification_id_),
|
|
|
|
MessageId(), -1, true, std::move(promise));
|
2018-11-08 19:00:03 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteMessages &request) {
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->delete_messages(DialogId(request.chat_id_), MessagesManager::get_message_ids(request.message_ids_),
|
|
|
|
request.revoke_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-19 13:48:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteChatMessagesBySender &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-19 15:12:38 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, sender_dialog_id, get_message_sender_dialog_id(this, request.sender_id_, false, false));
|
|
|
|
messages_manager_->delete_dialog_messages_by_sender(DialogId(request.chat_id_), sender_dialog_id, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-10-25 19:39:22 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteChatMessagesByDate &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->delete_dialog_messages_by_date(DialogId(request.chat_id_), request.min_date_, request.max_date_,
|
|
|
|
request.revoke_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::readAllChatMentions &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->read_all_dialog_mentions(DialogId(request.chat_id_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-01-30 10:37:24 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::readAllChatReactions &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->read_all_dialog_reactions(DialogId(request.chat_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-11-12 15:11:01 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatAvailableMessageSenders &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-15 15:08:37 +01:00
|
|
|
messages_manager_->get_dialog_send_message_as_dialog_ids(DialogId(request.chat_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-12-21 11:49:26 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setChatMessageSender &request) {
|
2021-11-15 15:08:37 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
TRY_RESULT_PROMISE(promise, message_sender_dialog_id,
|
2021-12-21 11:49:26 +01:00
|
|
|
get_message_sender_dialog_id(this, request.message_sender_id_, true, false));
|
2021-11-15 15:08:37 +01:00
|
|
|
messages_manager_->set_dialog_default_send_message_as_dialog_id(DialogId(request.chat_id_), message_sender_dialog_id,
|
|
|
|
std::move(promise));
|
2021-11-12 15:11:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::sendMessage &request) {
|
2021-08-31 21:34:46 +02:00
|
|
|
auto r_sent_message = messages_manager_->send_message(
|
|
|
|
DialogId(request.chat_id_), MessageId(request.message_thread_id_), MessageId(request.reply_to_message_id_),
|
2020-09-23 00:52:16 +02:00
|
|
|
std::move(request.options_), std::move(request.reply_markup_), std::move(request.input_message_content_));
|
2021-08-31 21:34:46 +02:00
|
|
|
if (r_sent_message.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_sent_message.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, r_sent_message.move_as_ok());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendMessageAlbum &request) {
|
2022-02-22 19:51:35 +01:00
|
|
|
auto r_messages = messages_manager_->send_message_group(
|
|
|
|
DialogId(request.chat_id_), MessageId(request.message_thread_id_), MessageId(request.reply_to_message_id_),
|
2022-02-22 20:42:46 +01:00
|
|
|
std::move(request.options_), std::move(request.input_message_contents_), request.only_preview_);
|
2022-02-22 19:51:35 +01:00
|
|
|
if (r_messages.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_messages.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, r_messages.move_as_ok());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendBotStartMessage &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.parameter_);
|
|
|
|
|
|
|
|
DialogId dialog_id(request.chat_id_);
|
|
|
|
auto r_new_message_id =
|
|
|
|
messages_manager_->send_bot_start_message(UserId(request.bot_user_id_), dialog_id, request.parameter_);
|
|
|
|
if (r_new_message_id.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_new_message_id.move_as_error());
|
|
|
|
}
|
|
|
|
|
2019-12-05 18:34:19 +01:00
|
|
|
CHECK(r_new_message_id.ok().is_valid() || r_new_message_id.ok().is_valid_scheduled());
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
2021-10-03 13:54:40 +02:00
|
|
|
messages_manager_->get_message_object({dialog_id, r_new_message_id.ok()}, "sendBotStartMessage"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendInlineQueryResultMessage &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.result_id_);
|
|
|
|
|
|
|
|
DialogId dialog_id(request.chat_id_);
|
|
|
|
auto r_new_message_id = messages_manager_->send_inline_query_result_message(
|
2020-09-23 00:52:16 +02:00
|
|
|
dialog_id, MessageId(request.message_thread_id_), MessageId(request.reply_to_message_id_),
|
|
|
|
std::move(request.options_), request.query_id_, request.result_id_, request.hide_via_bot_);
|
2018-12-31 20:04:05 +01:00
|
|
|
if (r_new_message_id.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_new_message_id.move_as_error());
|
|
|
|
}
|
|
|
|
|
2019-12-05 18:34:19 +01:00
|
|
|
CHECK(r_new_message_id.ok().is_valid() || r_new_message_id.ok().is_valid_scheduled());
|
2021-10-03 13:54:40 +02:00
|
|
|
send_closure(
|
|
|
|
actor_id(this), &Td::send_result, id,
|
|
|
|
messages_manager_->get_message_object({dialog_id, r_new_message_id.ok()}, "sendInlineQueryResultMessage"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-03-26 22:20:56 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::addLocalMessage &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
|
|
|
|
DialogId dialog_id(request.chat_id_);
|
2018-03-27 16:55:33 +02:00
|
|
|
auto r_new_message_id = messages_manager_->add_local_message(
|
2021-11-15 15:25:24 +01:00
|
|
|
dialog_id, std::move(request.sender_id_), MessageId(request.reply_to_message_id_), request.disable_notification_,
|
2020-10-14 20:47:20 +02:00
|
|
|
std::move(request.input_message_content_));
|
2018-03-26 22:20:56 +02:00
|
|
|
if (r_new_message_id.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_new_message_id.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CHECK(r_new_message_id.ok().is_valid());
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
2021-10-03 13:54:40 +02:00
|
|
|
messages_manager_->get_message_object({dialog_id, r_new_message_id.ok()}, "addLocalMessage"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::editMessageText &request) {
|
|
|
|
CREATE_REQUEST(EditMessageTextRequest, request.chat_id_, request.message_id_, std::move(request.reply_markup_),
|
|
|
|
std::move(request.input_message_content_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::editMessageLiveLocation &request) {
|
|
|
|
CREATE_REQUEST(EditMessageLiveLocationRequest, request.chat_id_, request.message_id_,
|
2020-10-24 23:49:41 +02:00
|
|
|
std::move(request.reply_markup_), std::move(request.location_), request.heading_,
|
2020-10-30 13:51:20 +01:00
|
|
|
request.proximity_alert_radius_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-06-19 01:31:34 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::editMessageMedia &request) {
|
|
|
|
CREATE_REQUEST(EditMessageMediaRequest, request.chat_id_, request.message_id_, std::move(request.reply_markup_),
|
|
|
|
std::move(request.input_message_content_));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::editMessageCaption &request) {
|
|
|
|
CREATE_REQUEST(EditMessageCaptionRequest, request.chat_id_, request.message_id_, std::move(request.reply_markup_),
|
|
|
|
std::move(request.caption_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::editMessageReplyMarkup &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_REQUEST(EditMessageReplyMarkupRequest, request.chat_id_, request.message_id_,
|
|
|
|
std::move(request.reply_markup_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::editInlineMessageText &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
messages_manager_->edit_inline_message_text(request.inline_message_id_, std::move(request.reply_markup_),
|
2018-06-28 23:06:17 +02:00
|
|
|
std::move(request.input_message_content_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::editInlineMessageLiveLocation &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
messages_manager_->edit_inline_message_live_location(request.inline_message_id_, std::move(request.reply_markup_),
|
|
|
|
std::move(request.location_), request.heading_,
|
|
|
|
request.proximity_alert_radius_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-06-19 01:31:34 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::editInlineMessageMedia &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
messages_manager_->edit_inline_message_media(request.inline_message_id_, std::move(request.reply_markup_),
|
2018-06-28 23:06:17 +02:00
|
|
|
std::move(request.input_message_content_), std::move(promise));
|
2018-06-19 01:31:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::editInlineMessageCaption &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
messages_manager_->edit_inline_message_caption(request.inline_message_id_, std::move(request.reply_markup_),
|
|
|
|
std::move(request.caption_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::editInlineMessageReplyMarkup &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
messages_manager_->edit_inline_message_reply_markup(request.inline_message_id_, std::move(request.reply_markup_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::editMessageSchedulingState &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 23:20:33 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->edit_message_scheduling_state({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(request.scheduling_state_), std::move(promise));
|
2019-12-03 02:36:23 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setGameScore &request) {
|
|
|
|
CHECK_IS_BOT();
|
2021-09-07 11:05:44 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
game_manager_->set_game_score({DialogId(request.chat_id_), MessageId(request.message_id_)}, request.edit_message_,
|
|
|
|
UserId(request.user_id_), request.score_, request.force_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setInlineGameScore &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
game_manager_->set_inline_game_score(request.inline_message_id_, request.edit_message_, UserId(request.user_id_),
|
|
|
|
request.score_, request.force_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getGameHighScores &request) {
|
|
|
|
CHECK_IS_BOT();
|
2021-09-05 09:54:20 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-09-07 09:45:01 +02:00
|
|
|
game_manager_->get_game_high_scores({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
UserId(request.user_id_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getInlineGameHighScores &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.inline_message_id_);
|
2021-09-05 09:54:20 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-09-07 09:45:01 +02:00
|
|
|
game_manager_->get_inline_game_high_scores(request.inline_message_id_, UserId(request.user_id_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::deleteChatReplyMarkup &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(
|
|
|
|
id, messages_manager_->delete_dialog_reply_markup(DialogId(request.chat_id_), MessageId(request.message_id_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendChatAction &request) {
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-09-18 18:42:31 +02:00
|
|
|
messages_manager_->send_dialog_action(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
2020-10-01 18:28:10 +02:00
|
|
|
DialogAction(std::move(request.action_)), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendChatScreenshotTakenNotification &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->send_screenshot_taken_notification_message(DialogId(request.chat_id_)));
|
|
|
|
}
|
|
|
|
|
2019-12-06 00:32:23 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::forwardMessages &request) {
|
2020-08-09 13:18:08 +02:00
|
|
|
auto input_message_ids = MessagesManager::get_message_ids(request.message_ids_);
|
|
|
|
auto message_copy_options =
|
2020-08-11 09:35:19 +02:00
|
|
|
transform(input_message_ids, [send_copy = request.send_copy_, remove_caption = request.remove_caption_](
|
|
|
|
MessageId) { return MessageCopyOptions(send_copy, remove_caption); });
|
2021-08-31 21:34:46 +02:00
|
|
|
auto r_messages = messages_manager_->forward_messages(DialogId(request.chat_id_), DialogId(request.from_chat_id_),
|
|
|
|
std::move(input_message_ids), std::move(request.options_),
|
2021-08-31 22:37:21 +02:00
|
|
|
false, std::move(message_copy_options), request.only_preview_);
|
2021-08-31 21:34:46 +02:00
|
|
|
if (r_messages.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_messages.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, r_messages.move_as_ok());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-11 03:05:00 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::resendMessages &request) {
|
|
|
|
DialogId dialog_id(request.chat_id_);
|
|
|
|
auto r_message_ids =
|
|
|
|
messages_manager_->resend_messages(dialog_id, MessagesManager::get_message_ids(request.message_ids_));
|
|
|
|
if (r_message_ids.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_message_ids.move_as_error());
|
|
|
|
}
|
|
|
|
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
2021-10-03 13:54:40 +02:00
|
|
|
messages_manager_->get_messages_object(-1, dialog_id, r_message_ids.ok(), false, "resendMessages"));
|
2019-08-11 03:05:00 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getWebPagePreview &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-02-20 22:20:45 +01:00
|
|
|
CREATE_REQUEST(GetWebPagePreviewRequest, std::move(request.text_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getWebPageInstantView &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.url_);
|
|
|
|
CREATE_REQUEST(GetWebPageInstantViewRequest, std::move(request.url_), request.force_full_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::createPrivateChat &request) {
|
2018-01-23 22:45:26 +01:00
|
|
|
CREATE_REQUEST(CreateChatRequest, DialogId(UserId(request.user_id_)), request.force_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::createBasicGroupChat &request) {
|
2018-01-23 22:45:26 +01:00
|
|
|
CREATE_REQUEST(CreateChatRequest, DialogId(ChatId(request.basic_group_id_)), request.force_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::createSupergroupChat &request) {
|
2018-01-23 22:45:26 +01:00
|
|
|
CREATE_REQUEST(CreateChatRequest, DialogId(ChannelId(request.supergroup_id_)), request.force_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::createSecretChat &request) {
|
2018-01-23 22:45:26 +01:00
|
|
|
CREATE_REQUEST(CreateChatRequest, DialogId(SecretChatId(request.secret_chat_id_)), true);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::createNewBasicGroupChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
2021-03-28 23:50:15 +02:00
|
|
|
CREATE_REQUEST(CreateNewGroupChatRequest, UserId::get_user_ids(request.user_ids_), std::move(request.title_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
|
|
|
CLEAN_INPUT_STRING(request.description_);
|
|
|
|
CREATE_REQUEST(CreateNewSupergroupChatRequest, std::move(request.title_), !request.is_channel_,
|
2021-01-22 17:23:44 +01:00
|
|
|
std::move(request.description_), std::move(request.location_), request.for_import_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
void Td::on_request(uint64 id, td_api::createNewSecretChat &request) {
|
|
|
|
CREATE_REQUEST(CreateNewSecretChatRequest, request.user_id_);
|
|
|
|
}
|
|
|
|
|
2020-08-10 10:34:28 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::createCall &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
|
2021-02-13 19:49:24 +01:00
|
|
|
if (request.protocol_ == nullptr) {
|
|
|
|
return send_error_raw(id, 400, "Call protocol must be non-empty");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
UserId user_id(request.user_id_);
|
2021-12-16 20:46:03 +01:00
|
|
|
auto r_input_user = contacts_manager_->get_input_user(user_id);
|
|
|
|
if (r_input_user.is_error()) {
|
|
|
|
return send_error_raw(id, r_input_user.error().code(), r_input_user.error().message());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-08-17 15:11:13 +02:00
|
|
|
if (!G()->get_option_boolean("calls_enabled")) {
|
2021-02-13 19:49:24 +01:00
|
|
|
return send_error_raw(id, 400, "Calls are not enabled for the current user");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<CallId> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_call_id_object());
|
|
|
|
}
|
|
|
|
});
|
2021-12-16 20:46:03 +01:00
|
|
|
send_closure(G()->call_manager(), &CallManager::create_call, user_id, r_input_user.move_as_ok(),
|
2020-08-05 21:10:33 +02:00
|
|
|
CallProtocol(*request.protocol_), request.is_video_, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 10:34:28 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::acceptCall &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2021-02-13 19:49:24 +01:00
|
|
|
if (request.protocol_ == nullptr) {
|
|
|
|
return send_error_raw(id, 400, "Call protocol must be non-empty");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(G()->call_manager(), &CallManager::accept_call, CallId(request.call_id_),
|
2020-06-22 03:28:03 +02:00
|
|
|
CallProtocol(*request.protocol_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 10:34:28 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::sendCallSignalingData &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(G()->call_manager(), &CallManager::send_call_signaling_data, CallId(request.call_id_),
|
|
|
|
std::move(request.data_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::discardCall &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(G()->call_manager(), &CallManager::discard_call, CallId(request.call_id_), request.is_disconnected_,
|
|
|
|
request.duration_, request.is_video_, request.connection_id_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::sendCallRating &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.comment_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(G()->call_manager(), &CallManager::rate_call, CallId(request.call_id_), request.rating_,
|
2019-08-06 19:07:23 +02:00
|
|
|
std::move(request.comment_), std::move(request.problems_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendCallDebugInformation &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.debug_information_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(G()->call_manager(), &CallManager::send_call_debug_information, CallId(request.call_id_),
|
2018-04-11 20:13:46 +02:00
|
|
|
std::move(request.debug_information_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-04-22 14:16:09 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::sendCallLog &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(G()->call_manager(), &CallManager::send_call_log, CallId(request.call_id_), std::move(request.log_file_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-10-14 14:44:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getVideoChatAvailableParticipants &request) {
|
2021-03-08 18:25:56 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->get_group_call_join_as(DialogId(request.chat_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-10-14 14:44:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setVideoChatDefaultParticipant &request) {
|
2021-04-07 15:25:29 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, default_join_as_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.default_participant_id_, true, false));
|
|
|
|
group_call_manager_->set_group_call_default_join_as(DialogId(request.chat_id_), default_join_as_dialog_id,
|
|
|
|
std::move(promise));
|
2021-04-07 15:25:29 +02:00
|
|
|
}
|
|
|
|
|
2021-10-14 14:44:21 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::createVideoChat &request) {
|
2020-11-26 08:56:13 +01:00
|
|
|
CHECK_IS_USER();
|
2021-04-06 01:13:57 +02:00
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
2020-11-26 08:56:13 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2020-12-03 17:52:50 +01:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<GroupCallId> result) mutable {
|
2020-11-26 08:56:13 +01:00
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2020-12-03 17:52:50 +01:00
|
|
|
promise.set_value(td_api::make_object<td_api::groupCallId>(result.ok().get()));
|
2020-11-26 08:56:13 +01:00
|
|
|
}
|
|
|
|
});
|
2021-04-06 01:54:55 +02:00
|
|
|
group_call_manager_->create_voice_chat(DialogId(request.chat_id_), std::move(request.title_), request.start_date_,
|
2022-02-22 14:37:11 +01:00
|
|
|
request.is_rtmp_stream_, std::move(query_promise));
|
2020-11-26 08:56:13 +01:00
|
|
|
}
|
|
|
|
|
2022-02-25 15:58:03 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getVideoChatRtmpUrl &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->get_voice_chat_rtmp_stream_url(DialogId(request.chat_id_), false, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::replaceVideoChatRtmpUrl &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->get_voice_chat_rtmp_stream_url(DialogId(request.chat_id_), true, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-12-03 00:00:46 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getGroupCall &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2020-12-03 17:52:50 +01:00
|
|
|
group_call_manager_->get_group_call(GroupCallId(request.group_call_id_), std::move(promise));
|
2020-12-03 00:00:46 +01:00
|
|
|
}
|
|
|
|
|
2021-04-07 01:11:14 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::startScheduledGroupCall &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->start_scheduled_group_call(GroupCallId(request.group_call_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-04-07 02:04:56 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallEnabledStartNotification &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->toggle_group_call_start_subscribed(GroupCallId(request.group_call_id_),
|
|
|
|
request.enabled_start_notification_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-11-26 12:32:29 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::joinGroupCall &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-03-12 16:36:55 +01:00
|
|
|
CLEAN_INPUT_STRING(request.invite_hash_);
|
2021-04-30 16:49:00 +02:00
|
|
|
CLEAN_INPUT_STRING(request.payload_);
|
2020-11-26 12:32:29 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, join_as_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.participant_id_, true, true));
|
2021-04-30 16:49:00 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
2021-11-15 11:31:07 +01:00
|
|
|
group_call_manager_->join_group_call(GroupCallId(request.group_call_id_), join_as_dialog_id, request.audio_source_id_,
|
|
|
|
std::move(request.payload_), request.is_muted_, request.is_my_video_enabled_,
|
|
|
|
request.invite_hash_, std::move(query_promise));
|
2020-11-26 12:32:29 +01:00
|
|
|
}
|
|
|
|
|
2021-04-30 18:53:39 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::startGroupCallScreenSharing &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.payload_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
2021-07-06 01:33:42 +02:00
|
|
|
group_call_manager_->start_group_call_screen_sharing(GroupCallId(request.group_call_id_), request.audio_source_id_,
|
|
|
|
std::move(request.payload_), std::move(query_promise));
|
2021-04-30 18:53:39 +02:00
|
|
|
}
|
|
|
|
|
2021-06-04 00:17:15 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallScreenSharingIsPaused &request) {
|
2021-06-01 23:38:08 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->toggle_group_call_is_my_presentation_paused(GroupCallId(request.group_call_id_),
|
|
|
|
request.is_paused_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-04-30 19:21:07 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::endGroupCallScreenSharing &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-05-01 20:13:51 +02:00
|
|
|
group_call_manager_->end_group_call_screen_sharing(GroupCallId(request.group_call_id_), std::move(promise));
|
2021-04-30 19:21:07 +02:00
|
|
|
}
|
|
|
|
|
2021-03-02 17:44:57 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setGroupCallTitle &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->set_group_call_title(GroupCallId(request.group_call_id_), std::move(request.title_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-12-08 15:51:37 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewParticipants &request) {
|
2020-11-26 23:58:36 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-12-08 15:51:37 +01:00
|
|
|
group_call_manager_->toggle_group_call_mute_new_participants(GroupCallId(request.group_call_id_),
|
|
|
|
request.mute_new_participants_, std::move(promise));
|
2020-11-26 23:58:36 +01:00
|
|
|
}
|
|
|
|
|
2021-03-12 17:31:52 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::revokeGroupCallInviteLink &request) {
|
2021-03-12 16:58:43 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-12 17:31:52 +01:00
|
|
|
group_call_manager_->revoke_group_call_invite_link(GroupCallId(request.group_call_id_), std::move(promise));
|
2021-03-12 16:58:43 +01:00
|
|
|
}
|
|
|
|
|
2020-12-08 15:51:37 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::inviteGroupCallParticipants &request) {
|
2020-11-27 13:22:19 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-28 23:50:15 +02:00
|
|
|
group_call_manager_->invite_group_call_participants(GroupCallId(request.group_call_id_),
|
|
|
|
UserId::get_user_ids(request.user_ids_), std::move(promise));
|
2020-11-27 13:22:19 +01:00
|
|
|
}
|
|
|
|
|
2021-03-12 17:29:06 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getGroupCallInviteLink &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
group_call_manager_->get_group_call_invite_link(GroupCallId(request.group_call_id_), request.can_self_unmute_,
|
|
|
|
std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2021-03-11 20:19:19 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::startGroupCallRecording &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->toggle_group_call_recording(GroupCallId(request.group_call_id_), true, std::move(request.title_),
|
2021-08-23 14:29:03 +02:00
|
|
|
request.record_video_, request.use_portrait_orientation_,
|
2021-03-11 20:19:19 +01:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::endGroupCallRecording &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-08-23 14:29:03 +02:00
|
|
|
group_call_manager_->toggle_group_call_recording(GroupCallId(request.group_call_id_), false, string(), false, false,
|
2021-03-11 20:19:19 +01:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-06-01 19:11:18 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallIsMyVideoPaused &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->toggle_group_call_is_my_video_paused(GroupCallId(request.group_call_id_),
|
|
|
|
request.is_my_video_paused_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-05-02 01:40:22 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallIsMyVideoEnabled &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->toggle_group_call_is_my_video_enabled(GroupCallId(request.group_call_id_),
|
|
|
|
request.is_my_video_enabled_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-12-08 15:51:37 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setGroupCallParticipantIsSpeaking &request) {
|
2020-11-27 15:40:29 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-01-12 15:05:25 +01:00
|
|
|
group_call_manager_->set_group_call_participant_is_speaking(
|
|
|
|
GroupCallId(request.group_call_id_), request.audio_source_, request.is_speaking_, std::move(promise));
|
2020-12-04 15:06:37 +01:00
|
|
|
}
|
2020-11-27 15:40:29 +01:00
|
|
|
|
2020-12-08 15:51:37 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallParticipantIsMuted &request) {
|
2020-12-04 15:06:37 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, participant_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.participant_id_, true, false));
|
2020-12-08 15:51:37 +01:00
|
|
|
group_call_manager_->toggle_group_call_participant_is_muted(
|
2021-11-15 11:31:07 +01:00
|
|
|
GroupCallId(request.group_call_id_), participant_dialog_id, request.is_muted_, std::move(promise));
|
2020-11-27 15:40:29 +01:00
|
|
|
}
|
|
|
|
|
2021-01-02 20:59:48 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setGroupCallParticipantVolumeLevel &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, participant_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.participant_id_, true, false));
|
2021-03-05 14:03:49 +01:00
|
|
|
group_call_manager_->set_group_call_participant_volume_level(
|
2021-11-15 11:31:07 +01:00
|
|
|
GroupCallId(request.group_call_id_), participant_dialog_id, request.volume_level_, std::move(promise));
|
2021-01-02 20:59:48 +01:00
|
|
|
}
|
|
|
|
|
2021-03-14 23:56:59 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleGroupCallParticipantIsHandRaised &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, participant_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.participant_id_, true, false));
|
2021-03-14 23:56:59 +01:00
|
|
|
group_call_manager_->toggle_group_call_participant_is_hand_raised(
|
2021-11-15 11:31:07 +01:00
|
|
|
GroupCallId(request.group_call_id_), participant_dialog_id, request.is_hand_raised_, std::move(promise));
|
2021-03-14 23:56:59 +01:00
|
|
|
}
|
|
|
|
|
2020-12-11 17:39:27 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::loadGroupCallParticipants &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->load_group_call_participants(GroupCallId(request.group_call_id_), request.limit_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-11-26 09:37:54 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::leaveGroupCall &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-12-03 23:56:27 +01:00
|
|
|
group_call_manager_->leave_group_call(GroupCallId(request.group_call_id_), std::move(promise));
|
2020-11-26 09:37:54 +01:00
|
|
|
}
|
|
|
|
|
2021-12-23 11:00:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::endGroupCall &request) {
|
2020-11-26 09:21:26 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-12-03 17:52:50 +01:00
|
|
|
group_call_manager_->discard_group_call(GroupCallId(request.group_call_id_), std::move(promise));
|
2020-11-26 09:21:26 +01:00
|
|
|
}
|
|
|
|
|
2022-02-22 15:42:58 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getGroupCallStreams &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
group_call_manager_->get_group_call_streams(GroupCallId(request.group_call_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-08-23 15:59:00 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getGroupCallStreamSegment &request) {
|
2021-03-10 20:50:14 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2021-03-13 14:50:11 +01:00
|
|
|
auto file_part = td_api::make_object<td_api::filePart>();
|
2021-03-10 20:50:14 +01:00
|
|
|
file_part->data_ = result.move_as_ok();
|
|
|
|
promise.set_value(std::move(file_part));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
group_call_manager_->get_group_call_stream_segment(GroupCallId(request.group_call_id_), request.time_offset_,
|
2021-08-23 15:59:00 +02:00
|
|
|
request.scale_, request.channel_id_,
|
|
|
|
std::move(request.video_quality_), std::move(query_promise));
|
2021-03-10 20:50:14 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::upgradeBasicGroupChatToSupergroupChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(UpgradeGroupChatToSupergroupChatRequest, request.chat_id_);
|
|
|
|
}
|
|
|
|
|
2020-05-31 02:50:52 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatListsToAddChat &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
auto dialog_lists = messages_manager_->get_dialog_lists_to_add_dialog(DialogId(request.chat_id_));
|
|
|
|
auto chat_lists =
|
|
|
|
transform(dialog_lists, [](DialogListId dialog_list_id) { return dialog_list_id.get_chat_list_object(); });
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::chatLists>(std::move(chat_lists)));
|
|
|
|
}
|
|
|
|
|
2020-05-30 23:48:33 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::addChatToList &request) {
|
2019-08-27 16:23:01 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-05-30 23:48:33 +02:00
|
|
|
messages_manager_->add_dialog_to_list(DialogId(request.chat_id_), DialogListId(request.chat_list_),
|
|
|
|
std::move(promise));
|
2019-08-27 16:23:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-18 01:29:28 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatFilter &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetChatFilterRequest, request.chat_filter_id_);
|
|
|
|
}
|
|
|
|
|
2020-05-19 03:03:15 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getRecommendedChatFilters &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_recommended_dialog_filters(std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-05-18 21:26:44 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::createChatFilter &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
if (request.filter_ == nullptr) {
|
|
|
|
return send_error_raw(id, 400, "Chat filter must be non-empty");
|
|
|
|
}
|
|
|
|
CLEAN_INPUT_STRING(request.filter_->title_);
|
2020-06-01 15:55:31 +02:00
|
|
|
CLEAN_INPUT_STRING(request.filter_->icon_name_);
|
2020-06-07 21:16:30 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2020-05-18 21:26:44 +02:00
|
|
|
messages_manager_->create_dialog_filter(std::move(request.filter_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-05-18 23:47:34 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::editChatFilter &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
if (request.filter_ == nullptr) {
|
|
|
|
return send_error_raw(id, 400, "Chat filter must be non-empty");
|
|
|
|
}
|
|
|
|
CLEAN_INPUT_STRING(request.filter_->title_);
|
2020-06-01 15:55:31 +02:00
|
|
|
CLEAN_INPUT_STRING(request.filter_->icon_name_);
|
2020-06-07 21:16:30 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2020-05-18 23:47:34 +02:00
|
|
|
messages_manager_->edit_dialog_filter(DialogFilterId(request.chat_filter_id_), std::move(request.filter_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-05-19 00:06:24 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteChatFilter &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->delete_dialog_filter(DialogFilterId(request.chat_filter_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-05-19 01:41:07 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::reorderChatFilters &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->reorder_dialog_filters(
|
2022-05-19 20:19:06 +02:00
|
|
|
transform(request.chat_filter_ids_, [](int32 id) { return DialogFilterId(id); }),
|
|
|
|
request.main_chat_list_position_, std::move(promise));
|
2020-05-19 01:41:07 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatTitle &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->set_dialog_title(DialogId(request.chat_id_), request.title_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-06-28 23:06:17 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setChatPhoto &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->set_dialog_photo(DialogId(request.chat_id_), request.photo_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-12-21 12:06:15 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setChatMessageTtl &request) {
|
2021-02-05 12:21:16 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-12-21 12:06:15 +01:00
|
|
|
messages_manager_->set_dialog_message_ttl(DialogId(request.chat_id_), request.ttl_, std::move(promise));
|
2021-02-05 12:21:16 +01:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:58:13 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setChatPermissions &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->set_dialog_permissions(DialogId(request.chat_id_), request.permissions_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-08-27 18:23:22 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatTheme &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.theme_name_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->set_dialog_theme(DialogId(request.chat_id_), request.theme_name_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatDraftMessage &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(
|
2020-09-22 18:45:27 +02:00
|
|
|
id, messages_manager_->set_dialog_draft_message(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
|
|
|
std::move(request.draft_message_)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-12-06 19:43:55 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleChatHasProtectedContent &request) {
|
2021-11-25 09:44:51 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-12-06 19:43:55 +01:00
|
|
|
messages_manager_->toggle_dialog_has_protected_content(DialogId(request.chat_id_), request.has_protected_content_,
|
|
|
|
std::move(promise));
|
2021-11-25 09:44:51 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleChatIsPinned &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-05-21 18:39:34 +02:00
|
|
|
answer_ok_query(id, messages_manager_->toggle_dialog_is_pinned(DialogListId(request.chat_list_),
|
2020-05-19 03:21:50 +02:00
|
|
|
DialogId(request.chat_id_), request.is_pinned_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-06-27 23:08:44 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleChatIsMarkedAsUnread &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->toggle_dialog_is_marked_as_unread(DialogId(request.chat_id_),
|
|
|
|
request.is_marked_as_unread_));
|
|
|
|
}
|
|
|
|
|
2020-10-18 00:54:32 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleMessageSenderIsBlocked &request) {
|
2020-09-20 02:00:01 +02:00
|
|
|
CHECK_IS_USER();
|
2021-11-15 15:25:24 +01:00
|
|
|
answer_ok_query(id, messages_manager_->toggle_message_sender_is_blocked(request.sender_id_, request.is_blocked_));
|
2020-09-20 02:00:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-28 20:05:04 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleChatDefaultDisableNotification &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->toggle_dialog_silent_send_message(DialogId(request.chat_id_),
|
|
|
|
request.default_disable_notification_));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setPinnedChats &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->set_pinned_dialogs(
|
2020-05-21 18:39:34 +02:00
|
|
|
DialogListId(request.chat_list_),
|
2018-12-31 20:04:05 +01:00
|
|
|
transform(request.chat_ids_, [](int64 chat_id) { return DialogId(chat_id); })));
|
|
|
|
}
|
|
|
|
|
2022-04-14 21:56:27 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {
|
2022-03-29 14:00:00 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
attach_menu_manager_->get_attach_menu_bot(UserId(request.bot_user_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-04-14 21:56:27 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &request) {
|
2022-03-26 21:41:22 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
attach_menu_manager_->toggle_bot_is_added_to_attach_menu(UserId(request.bot_user_id_), request.is_added_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-01-05 14:23:35 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatAvailableReactions &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->set_dialog_available_reactions(DialogId(request.chat_id_), std::move(request.available_reactions_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatClientData &request) {
|
|
|
|
answer_ok_query(
|
|
|
|
id, messages_manager_->set_dialog_client_data(DialogId(request.chat_id_), std::move(request.client_data_)));
|
|
|
|
}
|
|
|
|
|
2019-03-18 03:24:25 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatDescription &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.description_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->set_dialog_description(DialogId(request.chat_id_), request.description_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-09-14 04:35:56 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setChatDiscussionGroup &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_channel_discussion_group(DialogId(request.chat_id_), DialogId(request.discussion_chat_id_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-10-14 18:07:31 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatLocation &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_channel_location(DialogId(request.chat_id_), DialogLocation(std::move(request.location_)),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-11-15 16:17:52 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setChatSlowModeDelay &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_channel_slow_mode_delay(DialogId(request.chat_id_), request.slow_mode_delay_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-03-18 03:24:25 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::pinChatMessage &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->pin_dialog_message(DialogId(request.chat_id_), MessageId(request.message_id_),
|
2020-10-23 01:12:32 +02:00
|
|
|
request.disable_notification_, request.only_for_self_, false,
|
|
|
|
std::move(promise));
|
2019-03-18 03:24:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::unpinChatMessage &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-10-23 01:12:32 +02:00
|
|
|
messages_manager_->pin_dialog_message(DialogId(request.chat_id_), MessageId(request.message_id_), false, false, true,
|
2020-10-20 14:48:13 +02:00
|
|
|
std::move(promise));
|
2019-03-18 03:24:25 +01:00
|
|
|
}
|
|
|
|
|
2020-10-23 00:56:06 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::unpinAllChatMessages &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->unpin_all_dialog_messages(DialogId(request.chat_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-08-16 19:09:23 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::joinChat &request) {
|
2019-01-01 23:26:03 +01:00
|
|
|
CHECK_IS_USER();
|
2018-08-16 19:09:23 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-01-27 00:16:17 +01:00
|
|
|
contacts_manager_->add_dialog_participant(DialogId(request.chat_id_), contacts_manager_->get_my_id(), 0,
|
2019-01-01 23:26:03 +01:00
|
|
|
std::move(promise));
|
2018-08-16 19:09:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::leaveChat &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-04-21 20:04:14 +02:00
|
|
|
DialogId dialog_id(request.chat_id_);
|
2022-04-04 15:19:41 +02:00
|
|
|
td_api::object_ptr<td_api::ChatMemberStatus> new_status = td_api::make_object<td_api::chatMemberStatusLeft>();
|
2021-04-07 23:51:32 +02:00
|
|
|
if (dialog_id.get_type() == DialogType::Channel && messages_manager_->have_dialog_force(dialog_id, "leaveChat")) {
|
2020-04-21 20:04:14 +02:00
|
|
|
auto status = contacts_manager_->get_channel_status(dialog_id.get_channel_id());
|
|
|
|
if (status.is_creator()) {
|
|
|
|
if (!status.is_member()) {
|
|
|
|
return promise.set_value(Unit());
|
|
|
|
}
|
|
|
|
|
2022-04-04 15:19:41 +02:00
|
|
|
new_status =
|
|
|
|
td_api::make_object<td_api::chatMemberStatusCreator>(status.get_rank(), status.is_anonymous(), false);
|
2020-04-21 20:04:14 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-15 15:57:00 +01:00
|
|
|
contacts_manager_->set_dialog_participant_status(dialog_id, DialogId(contacts_manager_->get_my_id()),
|
|
|
|
std::move(new_status), std::move(promise));
|
2018-08-16 19:09:23 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::addChatMember &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-01-27 00:16:17 +01:00
|
|
|
contacts_manager_->add_dialog_participant(DialogId(request.chat_id_), UserId(request.user_id_),
|
2018-06-28 23:06:17 +02:00
|
|
|
request.forward_limit_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::addChatMembers &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-28 23:50:15 +02:00
|
|
|
contacts_manager_->add_dialog_participants(DialogId(request.chat_id_), UserId::get_user_ids(request.user_ids_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-04-04 15:19:41 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatMemberStatus &request) {
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, participant_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.member_id_, false, false));
|
2021-11-15 15:57:00 +01:00
|
|
|
contacts_manager_->set_dialog_participant_status(DialogId(request.chat_id_), participant_dialog_id,
|
2022-04-04 15:19:41 +02:00
|
|
|
std::move(request.status_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-01-20 19:12:48 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::banChatMember &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, participant_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.member_id_, false, false));
|
2021-11-15 10:07:52 +01:00
|
|
|
contacts_manager_->ban_dialog_participant(DialogId(request.chat_id_), participant_dialog_id,
|
|
|
|
request.banned_until_date_, request.revoke_messages_, std::move(promise));
|
2021-01-20 19:12:48 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 18:43:41 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::canTransferOwnership &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-18 02:06:20 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda(
|
|
|
|
[promise = std::move(promise)](Result<ContactsManager::CanTransferOwnershipResult> result) mutable {
|
2019-10-17 18:43:41 +02:00
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(ContactsManager::get_can_transfer_ownership_result_object(result.ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
contacts_manager_->can_transfer_ownership(std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2019-10-17 16:05:01 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::transferChatOwnership &request) {
|
2019-10-17 18:43:41 +02:00
|
|
|
CHECK_IS_USER();
|
2019-10-17 16:05:01 +02:00
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-10-17 16:05:01 +02:00
|
|
|
contacts_manager_->transfer_dialog_ownership(DialogId(request.chat_id_), UserId(request.user_id_), request.password_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-11-15 10:07:52 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatMember &request) {
|
2021-07-19 03:17:29 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-15 11:31:07 +01:00
|
|
|
TRY_RESULT_PROMISE(promise, participant_dialog_id,
|
|
|
|
get_message_sender_dialog_id(this, request.member_id_, false, false));
|
2021-11-15 10:07:52 +01:00
|
|
|
contacts_manager_->get_dialog_participant(DialogId(request.chat_id_), participant_dialog_id, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchChatMembers &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
2021-01-25 15:26:04 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise =
|
|
|
|
PromiseCreator::lambda([promise = std::move(promise), td = this](Result<DialogParticipants> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_chat_members_object(td));
|
|
|
|
}
|
|
|
|
});
|
2021-01-27 00:16:17 +01:00
|
|
|
contacts_manager_->search_dialog_participants(DialogId(request.chat_id_), request.query_, request.limit_,
|
2022-03-19 19:37:46 +01:00
|
|
|
DialogParticipantFilter(request.filter_), std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-11-15 10:07:52 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatAdministrators &request) {
|
2021-12-18 20:44:25 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->get_dialog_administrators(DialogId(request.chat_id_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-02-24 10:19:55 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::replacePrimaryChatInviteLink &request) {
|
2021-01-18 21:04:56 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-10-27 12:04:34 +02:00
|
|
|
contacts_manager_->export_dialog_invite_link(DialogId(request.chat_id_), string(), 0, 0, false, true,
|
|
|
|
std::move(promise));
|
2021-01-18 21:04:56 +01:00
|
|
|
}
|
2021-02-02 00:00:28 +01:00
|
|
|
|
2021-10-27 12:04:34 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::createChatInviteLink &request) {
|
2021-11-04 07:52:27 +01:00
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2021-01-12 15:05:25 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-04 07:52:27 +01:00
|
|
|
contacts_manager_->export_dialog_invite_link(DialogId(request.chat_id_), std::move(request.name_),
|
2021-12-22 11:57:47 +01:00
|
|
|
request.expiration_date_, request.member_limit_,
|
2021-11-04 07:52:27 +01:00
|
|
|
request.creates_join_request_, false, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-01-12 17:21:12 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::editChatInviteLink &request) {
|
2021-11-04 07:52:27 +01:00
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2021-01-12 17:21:12 +01:00
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-11-04 07:52:27 +01:00
|
|
|
contacts_manager_->edit_dialog_invite_link(DialogId(request.chat_id_), request.invite_link_, std::move(request.name_),
|
2021-12-22 11:57:47 +01:00
|
|
|
request.expiration_date_, request.member_limit_,
|
|
|
|
request.creates_join_request_, std::move(promise));
|
2021-01-18 20:35:28 +01:00
|
|
|
}
|
|
|
|
|
2021-02-24 20:25:10 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getChatInviteLink &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->get_dialog_invite_link(DialogId(request.chat_id_), request.invite_link_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-02-02 17:23:45 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatInviteLinkCounts &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-02-02 17:23:45 +01:00
|
|
|
contacts_manager_->get_dialog_invite_link_counts(DialogId(request.chat_id_), std::move(promise));
|
2021-01-12 17:21:12 +01:00
|
|
|
}
|
|
|
|
|
2021-01-14 17:39:51 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getChatInviteLinks &request) {
|
2021-02-02 17:23:45 +01:00
|
|
|
CHECK_IS_USER();
|
2021-01-14 17:39:51 +01:00
|
|
|
CLEAN_INPUT_STRING(request.offset_invite_link_);
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-02-25 14:02:07 +01:00
|
|
|
contacts_manager_->get_dialog_invite_links(DialogId(request.chat_id_), UserId(request.creator_user_id_),
|
2021-01-20 15:30:26 +01:00
|
|
|
request.is_revoked_, request.offset_date_, request.offset_invite_link_,
|
|
|
|
request.limit_, std::move(promise));
|
2021-01-14 17:39:51 +01:00
|
|
|
}
|
|
|
|
|
2021-01-17 21:07:17 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getChatInviteLinkMembers &request) {
|
2021-02-02 17:23:45 +01:00
|
|
|
CHECK_IS_USER();
|
2021-01-14 21:21:23 +01:00
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-01-14 21:21:23 +01:00
|
|
|
contacts_manager_->get_dialog_invite_link_users(DialogId(request.chat_id_), request.invite_link_,
|
2021-01-17 21:07:17 +01:00
|
|
|
std::move(request.offset_member_), request.limit_,
|
|
|
|
std::move(promise));
|
2021-01-14 21:21:23 +01:00
|
|
|
}
|
|
|
|
|
2021-10-13 21:33:31 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getChatJoinRequests &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->get_dialog_join_requests(DialogId(request.chat_id_), request.invite_link_, request.query_,
|
|
|
|
std::move(request.offset_request_), request.limit_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-11-24 09:33:18 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::processChatJoinRequest &request) {
|
2021-10-13 22:10:47 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-24 10:02:23 +01:00
|
|
|
contacts_manager_->process_dialog_join_request(DialogId(request.chat_id_), UserId(request.user_id_), request.approve_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::processChatJoinRequests &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->process_dialog_join_requests(DialogId(request.chat_id_), request.invite_link_, request.approve_,
|
|
|
|
std::move(promise));
|
2021-10-13 22:10:47 +02:00
|
|
|
}
|
|
|
|
|
2021-02-02 17:23:45 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::revokeChatInviteLink &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-02-05 16:56:44 +01:00
|
|
|
contacts_manager_->revoke_dialog_invite_link(DialogId(request.chat_id_), request.invite_link_, std::move(promise));
|
2021-02-02 17:23:45 +01:00
|
|
|
}
|
|
|
|
|
2021-01-18 17:51:46 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::deleteRevokedChatInviteLink &request) {
|
2021-02-08 13:34:05 +01:00
|
|
|
CHECK_IS_USER();
|
2021-01-18 17:51:46 +01:00
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-01-18 17:51:46 +01:00
|
|
|
contacts_manager_->delete_revoked_dialog_invite_link(DialogId(request.chat_id_), request.invite_link_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-01-18 17:59:21 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteAllRevokedChatInviteLinks &request) {
|
2021-02-08 13:34:05 +01:00
|
|
|
CHECK_IS_USER();
|
2021-01-18 17:59:21 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-02-05 00:17:12 +01:00
|
|
|
contacts_manager_->delete_all_revoked_dialog_invite_links(DialogId(request.chat_id_),
|
2021-02-25 14:02:07 +01:00
|
|
|
UserId(request.creator_user_id_), std::move(promise));
|
2021-01-18 17:59:21 +01:00
|
|
|
}
|
2021-02-02 00:00:28 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::checkChatInviteLink &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
|
|
|
CREATE_REQUEST(CheckChatInviteLinkRequest, request.invite_link_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::joinChatByInviteLink &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.invite_link_);
|
|
|
|
CREATE_REQUEST(JoinChatByInviteLinkRequest, request.invite_link_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getChatEventLog &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
2021-11-09 14:54:49 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_dialog_event_log(this, DialogId(request.chat_id_), std::move(request.query_), request.from_event_id_,
|
|
|
|
request.limit_, std::move(request.filters_), UserId::get_user_ids(request.user_ids_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-07-17 05:46:27 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::clearAllDraftMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-07-19 16:23:18 +02:00
|
|
|
messages_manager_->clear_all_draft_messages(request.exclude_secret_chats_, std::move(promise));
|
2018-07-17 05:46:27 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::downloadFile &request) {
|
|
|
|
auto priority = request.priority_;
|
|
|
|
if (!(1 <= priority && priority <= 32)) {
|
2022-02-25 14:18:23 +01:00
|
|
|
return send_error_raw(id, 400, "Download priority must be between 1 and 32");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-03-27 19:43:46 +01:00
|
|
|
auto offset = request.offset_;
|
|
|
|
if (offset < 0) {
|
2021-09-29 18:19:24 +02:00
|
|
|
return send_error_raw(id, 400, "Download offset must be non-negative");
|
2018-12-27 02:21:08 +01:00
|
|
|
}
|
2019-03-27 19:43:46 +01:00
|
|
|
auto limit = request.limit_;
|
|
|
|
if (limit < 0) {
|
2021-09-29 18:19:24 +02:00
|
|
|
return send_error_raw(id, 400, "Download limit must be non-negative");
|
2019-03-27 19:43:46 +01:00
|
|
|
}
|
2018-11-11 12:38:04 +01:00
|
|
|
|
2019-03-27 19:43:46 +01:00
|
|
|
FileId file_id(request.file_id_, 0);
|
|
|
|
auto file_view = file_manager_->get_file_view(file_id);
|
|
|
|
if (file_view.empty()) {
|
2020-04-19 12:45:37 +02:00
|
|
|
return send_error_raw(id, 400, "Invalid file identifier");
|
2018-11-11 12:38:04 +01:00
|
|
|
}
|
|
|
|
|
2019-03-27 19:43:46 +01:00
|
|
|
auto info_it = pending_file_downloads_.find(file_id);
|
|
|
|
DownloadInfo *info = info_it == pending_file_downloads_.end() ? nullptr : &info_it->second;
|
|
|
|
if (info != nullptr && (offset != info->offset || limit != info->limit)) {
|
|
|
|
// we can't have two pending requests with different offset and limit, so cancel all previous requests
|
|
|
|
for (auto request_id : info->request_ids) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, request_id,
|
2021-05-31 20:51:48 +02:00
|
|
|
Status::Error(200, "Canceled by another downloadFile request"));
|
2019-03-27 19:43:46 +01:00
|
|
|
}
|
|
|
|
info->request_ids.clear();
|
|
|
|
}
|
|
|
|
if (request.synchronous_) {
|
|
|
|
if (info == nullptr) {
|
|
|
|
info = &pending_file_downloads_[file_id];
|
|
|
|
}
|
|
|
|
info->offset = offset;
|
|
|
|
info->limit = limit;
|
|
|
|
info->request_ids.push_back(id);
|
|
|
|
}
|
|
|
|
file_manager_->download(file_id, download_file_callback_, priority, offset, limit);
|
|
|
|
if (!request.synchronous_) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, file_manager_->get_file_object(file_id, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_file_download_finished(FileId file_id) {
|
|
|
|
auto it = pending_file_downloads_.find(file_id);
|
|
|
|
if (it == pending_file_downloads_.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto id : it->second.request_ids) {
|
|
|
|
// there was send_closure to call this function
|
|
|
|
auto file_object = file_manager_->get_file_object(file_id, false);
|
|
|
|
CHECK(file_object != nullptr);
|
|
|
|
auto download_offset = file_object->local_->download_offset_;
|
|
|
|
auto downloaded_size = file_object->local_->downloaded_prefix_size_;
|
|
|
|
auto file_size = file_object->size_;
|
2019-03-27 21:54:34 +01:00
|
|
|
auto limit = it->second.limit;
|
|
|
|
if (limit == 0) {
|
2022-05-11 16:17:20 +02:00
|
|
|
limit = std::numeric_limits<int64>::max();
|
2019-03-27 21:54:34 +01:00
|
|
|
}
|
2019-03-27 19:43:46 +01:00
|
|
|
if (file_object->local_->is_downloading_completed_ ||
|
|
|
|
(download_offset <= it->second.offset && download_offset + downloaded_size >= it->second.offset &&
|
|
|
|
((file_size != 0 && download_offset + downloaded_size == file_size) ||
|
2019-03-27 21:54:34 +01:00
|
|
|
download_offset + downloaded_size - it->second.offset >= limit))) {
|
2019-03-27 19:43:46 +01:00
|
|
|
send_result(id, std::move(file_object));
|
|
|
|
} else {
|
2021-05-31 20:51:48 +02:00
|
|
|
send_error_impl(id, td_api::make_object<td_api::error>(400, "File download has failed or was canceled"));
|
2019-03-27 19:43:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pending_file_downloads_.erase(it);
|
2018-11-11 12:38:04 +01:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-04-26 00:03:31 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getFileDownloadedPrefixSize &request) {
|
|
|
|
if (request.offset_ < 0) {
|
2021-09-29 18:19:24 +02:00
|
|
|
return send_error_raw(id, 400, "Parameter offset must be non-negative");
|
2019-04-26 00:03:31 +02:00
|
|
|
}
|
|
|
|
auto file_view = file_manager_->get_file_view(FileId(request.file_id_, 0));
|
|
|
|
if (file_view.empty()) {
|
2021-09-24 09:59:51 +02:00
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, Status::Error(400, "Unknown file ID"));
|
2019-04-26 00:03:31 +02:00
|
|
|
}
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
2022-05-11 16:17:20 +02:00
|
|
|
td_api::make_object<td_api::fileDownloadedPrefixSize>(file_view.downloaded_prefix(request.offset_)));
|
2019-04-26 00:03:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::cancelDownloadFile &request) {
|
2022-02-28 13:15:00 +01:00
|
|
|
file_manager_->download(FileId(request.file_id_, 0), nullptr, request.only_if_pending_ ? -1 : 0,
|
|
|
|
FileManager::KEEP_DOWNLOAD_OFFSET, FileManager::KEEP_DOWNLOAD_LIMIT);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
2021-07-24 06:19:22 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getSuggestedFileName &request) {
|
|
|
|
Result<string> r_file_name = file_manager_->get_suggested_file_name(FileId(request.file_id_, 0), request.directory_);
|
|
|
|
if (r_file_name.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_file_name.move_as_error());
|
|
|
|
}
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::text>(r_file_name.ok()));
|
|
|
|
}
|
|
|
|
|
2022-07-18 13:07:50 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::preliminaryUploadFile &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto priority = request.priority_;
|
|
|
|
if (!(1 <= priority && priority <= 32)) {
|
2022-02-25 14:18:23 +01:00
|
|
|
return send_error_raw(id, 400, "Upload priority must be between 1 and 32");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-06-22 03:28:03 +02:00
|
|
|
auto file_type = request.file_type_ == nullptr ? FileType::Temp : get_file_type(*request.file_type_);
|
2018-12-31 20:04:05 +01:00
|
|
|
bool is_secret = file_type == FileType::Encrypted || file_type == FileType::EncryptedThumbnail;
|
2022-04-25 18:00:40 +02:00
|
|
|
bool is_secure = file_type == FileType::SecureEncrypted;
|
2018-04-03 19:49:07 +02:00
|
|
|
auto r_file_id = file_manager_->get_input_file_id(file_type, request.file_, DialogId(), false, is_secret,
|
|
|
|
!is_secure && !is_secret, is_secure);
|
2018-12-31 20:04:05 +01:00
|
|
|
if (r_file_id.is_error()) {
|
|
|
|
return send_error_raw(id, 400, r_file_id.error().message());
|
|
|
|
}
|
|
|
|
auto file_id = r_file_id.ok();
|
|
|
|
auto upload_file_id = file_manager_->dup_file_id(file_id);
|
|
|
|
|
|
|
|
file_manager_->upload(upload_file_id, upload_file_callback_, priority, 0);
|
|
|
|
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, file_manager_->get_file_object(upload_file_id, false));
|
|
|
|
}
|
|
|
|
|
2022-07-18 13:07:50 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::cancelPreliminaryUploadFile &request) {
|
2019-01-25 02:52:38 +01:00
|
|
|
file_manager_->cancel_upload(FileId(request.file_id_, 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
2019-04-26 02:18:00 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::writeGeneratedFilePart &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(file_manager_actor_, &FileManager::external_file_generate_write_part, request.generation_id_,
|
|
|
|
request.offset_, std::move(request.data_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setFileGenerationProgress &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(file_manager_actor_, &FileManager::external_file_generate_progress, request.generation_id_,
|
2018-04-11 20:13:46 +02:00
|
|
|
request.expected_size_, request.local_prefix_size_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::finishFileGeneration &request) {
|
|
|
|
Status status;
|
|
|
|
if (request.error_ != nullptr) {
|
|
|
|
CLEAN_INPUT_STRING(request.error_->message_);
|
|
|
|
status = Status::Error(request.error_->code_, request.error_->message_);
|
|
|
|
}
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(file_manager_actor_, &FileManager::external_file_generate_finish, request.generation_id_,
|
2018-04-11 20:13:46 +02:00
|
|
|
std::move(status), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 00:03:31 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::readFilePart &request) {
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
send_closure(file_manager_actor_, &FileManager::read_file_part, FileId(request.file_id_, 0), request.offset_,
|
|
|
|
request.count_, 2, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::deleteFile &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-04-11 20:13:46 +02:00
|
|
|
send_closure(file_manager_actor_, &FileManager::delete_file, FileId(request.file_id_, 0), std::move(promise),
|
2018-12-31 20:04:05 +01:00
|
|
|
"td_api::deleteFile");
|
|
|
|
}
|
|
|
|
|
2022-02-17 23:37:04 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::addFileToDownloads &request) {
|
2022-02-25 13:11:10 +01:00
|
|
|
if (!(1 <= request.priority_ && request.priority_ <= 32)) {
|
2022-02-25 14:18:23 +01:00
|
|
|
return send_error_raw(id, 400, "Download priority must be between 1 and 32");
|
2022-02-25 13:11:10 +01:00
|
|
|
}
|
2022-02-25 14:18:23 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-02-23 20:56:03 +01:00
|
|
|
messages_manager_->add_message_file_to_downloads(
|
|
|
|
FullMessageId(DialogId(request.chat_id_), MessageId(request.message_id_)), FileId(request.file_id_, 0),
|
|
|
|
request.priority_, std::move(promise));
|
2022-02-17 23:37:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::toggleDownloadIsPaused &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-23 15:41:03 +02:00
|
|
|
send_closure(download_manager_actor_, &DownloadManager::toggle_is_paused, FileId(request.file_id_, 0),
|
|
|
|
request.is_paused_, std::move(promise));
|
2022-02-17 23:37:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::toggleAllDownloadsArePaused &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-23 15:41:03 +02:00
|
|
|
send_closure(download_manager_actor_, &DownloadManager::toggle_all_is_paused, request.are_paused_,
|
|
|
|
std::move(promise));
|
2022-02-17 23:37:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::removeFileFromDownloads &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-23 15:41:03 +02:00
|
|
|
send_closure(download_manager_actor_, &DownloadManager::remove_file, FileId(request.file_id_, 0), FileSourceId(),
|
|
|
|
request.delete_from_cache_, std::move(promise));
|
2022-02-17 23:37:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::removeAllFilesFromDownloads &request) {
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-23 15:41:03 +02:00
|
|
|
send_closure(download_manager_actor_, &DownloadManager::remove_all_files, request.only_active_,
|
|
|
|
request.only_completed_, request.delete_from_cache_, std::move(promise));
|
2022-02-17 23:37:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchFileDownloads &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CLEAN_INPUT_STRING(request.offset_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-02-25 13:11:10 +01:00
|
|
|
send_closure(download_manager_actor_, &DownloadManager::search, std::move(request.query_), request.only_active_,
|
2022-02-27 16:23:06 +01:00
|
|
|
request.only_completed_, std::move(request.offset_), request.limit_, std::move(promise));
|
2022-02-17 23:37:04 +01:00
|
|
|
}
|
|
|
|
|
2021-01-22 17:14:35 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getMessageFileType &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.message_file_head_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_message_file_type(request.message_file_head_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-02-23 00:03:24 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageImportConfirmationText &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messages_manager_->get_message_import_confirmation_text(DialogId(request.chat_id_), std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2021-01-21 20:00:08 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::importMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->import_messages(DialogId(request.chat_id_), request.message_file_, request.attached_files_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-10-18 00:26:36 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::blockMessageSenderFromReplies &request) {
|
2020-09-24 14:29:34 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2020-10-18 00:26:36 +02:00
|
|
|
messages_manager_->block_message_sender_from_replies(MessageId(request.message_id_), request.delete_message_,
|
|
|
|
request.delete_all_messages_, request.report_spam_,
|
|
|
|
std::move(promise));
|
2020-09-24 14:29:34 +02:00
|
|
|
}
|
|
|
|
|
2020-10-18 01:10:58 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getBlockedMessageSenders &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2021-10-09 21:05:23 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
messages_manager_->get_blocked_dialogs(request.offset_, request.limit_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 17:12:15 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::addContact &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-09-30 12:53:16 +02:00
|
|
|
auto r_contact = get_contact(std::move(request.contact_));
|
|
|
|
if (r_contact.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_contact.move_as_error());
|
2019-10-08 17:12:15 +02:00
|
|
|
}
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-09-30 12:53:16 +02:00
|
|
|
contacts_manager_->add_contact(r_contact.move_as_ok(), request.share_phone_number_, std::move(promise));
|
2019-10-08 17:12:15 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::importContacts &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-09-30 13:18:01 +02:00
|
|
|
vector<Contact> contacts;
|
|
|
|
contacts.reserve(request.contacts_.size());
|
2018-12-31 20:04:05 +01:00
|
|
|
for (auto &contact : request.contacts_) {
|
2021-09-30 13:18:01 +02:00
|
|
|
auto r_contact = get_contact(std::move(contact));
|
|
|
|
if (r_contact.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_contact.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-09-30 13:18:01 +02:00
|
|
|
contacts.push_back(r_contact.move_as_ok());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-09-30 13:18:01 +02:00
|
|
|
CREATE_REQUEST(ImportContactsRequest, std::move(contacts));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-08-16 19:09:23 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getContacts &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(SearchContactsRequest, string(), 1000000);
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchContacts &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST(SearchContactsRequest, request.query_, request.limit_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::removeContacts &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-03-28 23:50:15 +02:00
|
|
|
CREATE_REQUEST(RemoveContactsRequest, UserId::get_user_ids(request.user_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getImportedContactCount &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetImportedContactCountRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::changeImportedContacts &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-09-30 13:18:01 +02:00
|
|
|
vector<Contact> contacts;
|
|
|
|
contacts.reserve(request.contacts_.size());
|
2018-12-31 20:04:05 +01:00
|
|
|
for (auto &contact : request.contacts_) {
|
2021-09-30 13:18:01 +02:00
|
|
|
auto r_contact = get_contact(std::move(contact));
|
|
|
|
if (r_contact.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_contact.move_as_error());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-09-30 13:18:01 +02:00
|
|
|
contacts.push_back(r_contact.move_as_ok());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-09-30 13:18:01 +02:00
|
|
|
CREATE_REQUEST(ChangeImportedContactsRequest, std::move(contacts));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::clearImportedContacts &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->clear_imported_contacts(std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-02-18 16:13:10 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchUserByPhoneNumber &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.phone_number_);
|
|
|
|
CREATE_REQUEST(SearchUserByPhoneNumberRequest, std::move(request.phone_number_));
|
|
|
|
}
|
|
|
|
|
2019-10-11 16:59:04 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::sharePhoneNumber &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->share_phone_number(UserId(request.user_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getRecentInlineBots &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetRecentInlineBotsRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setName &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.first_name_);
|
|
|
|
CLEAN_INPUT_STRING(request.last_name_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_name(request.first_name_, request.last_name_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setBio &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.bio_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_bio(request.bio_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setUsername &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.username_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_username(request.username_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setEmojiStatus &request) {
|
2022-08-09 14:49:47 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-09-07 09:25:21 +02:00
|
|
|
contacts_manager_->set_emoji_status(EmojiStatus(request.emoji_status_, request.duration_), std::move(promise));
|
2022-08-09 14:49:47 +02:00
|
|
|
}
|
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getThemedEmojiStatuses &request) {
|
2022-09-02 14:02:37 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->get_default_emoji_statuses(false, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getDefaultEmojiStatuses &request) {
|
2022-08-30 17:03:57 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_default_emoji_statuses(this, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getRecentEmojiStatuses &request) {
|
2022-08-31 14:47:51 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_recent_emoji_statuses(this, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-09-07 09:25:21 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::clearRecentEmojiStatuses &request) {
|
2022-08-31 15:41:13 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
clear_recent_emoji_statuses(this, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-03-27 23:43:52 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setCommands &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-06-22 03:25:15 +02:00
|
|
|
set_commands(this, std::move(request.scope_), std::move(request.language_code_), std::move(request.commands_),
|
|
|
|
std::move(promise));
|
2020-03-27 23:43:52 +01:00
|
|
|
}
|
|
|
|
|
2021-06-22 03:17:44 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::deleteCommands &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-06-22 03:25:15 +02:00
|
|
|
delete_commands(this, std::move(request.scope_), std::move(request.language_code_), std::move(promise));
|
2021-06-22 03:17:44 +02:00
|
|
|
}
|
|
|
|
|
2021-06-19 03:18:02 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getCommands &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-22 03:25:15 +02:00
|
|
|
get_commands(this, std::move(request.scope_), std::move(request.language_code_), std::move(promise));
|
2021-06-19 03:18:02 +02:00
|
|
|
}
|
|
|
|
|
2022-04-07 17:15:58 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setMenuButton &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
set_menu_button(this, UserId(request.user_id_), std::move(request.menu_button_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-04-07 16:20:26 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMenuButton &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_menu_button(this, UserId(request.user_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-04-02 14:32:04 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setDefaultGroupAdministratorRights &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-04-04 15:19:41 +02:00
|
|
|
set_default_group_administrator_rights(
|
|
|
|
this, AdministratorRights(request.default_group_administrator_rights_, ChannelType::Megagroup),
|
|
|
|
std::move(promise));
|
2022-04-02 14:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setDefaultChannelAdministratorRights &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-04-04 15:19:41 +02:00
|
|
|
set_default_channel_administrator_rights(
|
|
|
|
this, AdministratorRights(request.default_channel_administrator_rights_, ChannelType::Broadcast),
|
|
|
|
std::move(promise));
|
2022-04-02 14:32:04 +02:00
|
|
|
}
|
|
|
|
|
2020-02-14 14:17:45 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::setLocation &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_location(Location(request.location_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setProfilePhoto &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_profile_photo(request.photo_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::deleteProfilePhoto &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->delete_profile_photo(request.profile_photo_id_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getUserProfilePhotos &request) {
|
|
|
|
CREATE_REQUEST(GetUserProfilePhotosRequest, request.user_id_, request.offset_, request.limit_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setSupergroupUsername &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.username_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->set_channel_username(ChannelId(request.supergroup_id_), request.username_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setSupergroupStickerSet &request) {
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-09-18 05:55:43 +02:00
|
|
|
contacts_manager_->set_channel_sticker_set(ChannelId(request.supergroup_id_), StickerSetId(request.sticker_set_id_),
|
2018-06-28 23:06:17 +02:00
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupSignMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->toggle_channel_sign_messages(ChannelId(request.supergroup_id_), request.sign_messages_,
|
|
|
|
std::move(promise));
|
2022-04-29 17:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupJoinToSendMessages &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->toggle_channel_join_to_send(ChannelId(request.supergroup_id_), request.join_to_send_messages_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupJoinByRequest &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->toggle_channel_join_request(ChannelId(request.supergroup_id_), request.join_by_request_,
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsAllHistoryAvailable &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->toggle_channel_is_all_history_available(ChannelId(request.supergroup_id_),
|
|
|
|
request.is_all_history_available_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-02-16 23:06:35 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsBroadcastGroup &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->convert_channel_to_gigagroup(ChannelId(request.supergroup_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-19 15:12:38 +01:00
|
|
|
contacts_manager_->report_channel_spam(ChannelId(request.supergroup_id_),
|
2018-06-28 23:06:17 +02:00
|
|
|
MessagesManager::get_message_ids(request.message_ids_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getSupergroupMembers &request) {
|
2021-01-25 15:26:04 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise =
|
|
|
|
PromiseCreator::lambda([promise = std::move(promise), td = this](Result<DialogParticipants> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_chat_members_object(td));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
contacts_manager_->get_channel_participants(ChannelId(request.supergroup_id_), std::move(request.filter_), string(),
|
2021-06-21 03:14:29 +02:00
|
|
|
request.offset_, request.limit_, -1, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::closeSecretChat &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-01-18 13:04:31 +01:00
|
|
|
send_closure(secret_chats_manager_, &SecretChatsManager::cancel_chat, SecretChatId(request.secret_chat_id_), false,
|
2018-04-11 20:13:46 +02:00
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getStickers &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-09-27 19:52:47 +02:00
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST(GetStickersRequest, get_sticker_type(request.sticker_type_), std::move(request.query_), request.limit_,
|
2022-08-05 13:06:06 +02:00
|
|
|
request.chat_id_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-03-09 18:04:44 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchStickers &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.emoji_);
|
2022-08-01 17:50:08 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->search_stickers(std::move(request.emoji_), request.limit_, std::move(promise));
|
2018-03-09 18:04:44 +01:00
|
|
|
}
|
|
|
|
|
2022-08-01 18:21:08 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPremiumStickers &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-08-06 23:33:16 +02:00
|
|
|
stickers_manager_->get_premium_stickers(request.limit_, std::move(promise));
|
2022-08-01 18:21:08 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getInstalledStickerSets &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-07-14 15:17:19 +02:00
|
|
|
CREATE_REQUEST(GetInstalledStickerSetsRequest, get_sticker_type(request.sticker_type_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getArchivedStickerSets &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-07-14 15:17:19 +02:00
|
|
|
CREATE_REQUEST(GetArchivedStickerSetsRequest, get_sticker_type(request.sticker_type_), request.offset_sticker_set_id_,
|
|
|
|
request.limit_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getTrendingStickerSets &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-07-17 21:39:22 +02:00
|
|
|
CREATE_REQUEST(GetTrendingStickerSetsRequest, get_sticker_type(request.sticker_type_), request.offset_,
|
|
|
|
request.limit_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getAttachedStickerSets &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetAttachedStickerSetsRequest, request.file_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getStickerSet &request) {
|
|
|
|
CREATE_REQUEST(GetStickerSetRequest, request.set_id_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchStickerSet &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
|
|
|
CREATE_REQUEST(SearchStickerSetRequest, std::move(request.name_));
|
|
|
|
}
|
|
|
|
|
2018-03-05 23:44:11 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::searchInstalledStickerSets &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
2022-07-14 15:17:19 +02:00
|
|
|
CREATE_REQUEST(SearchInstalledStickerSetsRequest, get_sticker_type(request.sticker_type_), std::move(request.query_),
|
|
|
|
request.limit_);
|
2018-03-05 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchStickerSets &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CREATE_REQUEST(SearchStickerSetsRequest, std::move(request.query_));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::changeStickerSet &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(ChangeStickerSetRequest, request.set_id_, request.is_installed_, request.is_archived_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::viewTrendingStickerSets &request) {
|
|
|
|
CHECK_IS_USER();
|
2019-09-18 05:55:43 +02:00
|
|
|
stickers_manager_->view_featured_sticker_sets(StickersManager::convert_sticker_set_ids(request.sticker_set_ids_));
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::reorderInstalledStickerSets &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-14 15:17:19 +02:00
|
|
|
stickers_manager_->reorder_installed_sticker_sets(get_sticker_type(request.sticker_type_),
|
|
|
|
StickersManager::convert_sticker_set_ids(request.sticker_set_ids_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::uploadStickerFile &request) {
|
2021-06-21 21:25:26 +02:00
|
|
|
CREATE_REQUEST(UploadStickerFileRequest, request.user_id_, std::move(request.sticker_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-06-17 19:38:03 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getSuggestedStickerSetName &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
stickers_manager_->get_suggested_sticker_set_name(std::move(request.title_), std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2021-06-17 20:29:07 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::checkStickerSetName &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-18 02:06:20 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda(
|
|
|
|
[promise = std::move(promise)](Result<StickersManager::CheckStickerSetNameResult> result) mutable {
|
2021-06-17 20:29:07 +02:00
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(StickersManager::get_check_sticker_set_name_result_object(result.ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
stickers_manager_->check_sticker_set_name(request.name_, std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::createNewStickerSet &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.title_);
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2021-06-18 17:45:57 +02:00
|
|
|
CLEAN_INPUT_STRING(request.source_);
|
2022-08-08 16:24:01 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->create_new_sticker_set(UserId(request.user_id_), std::move(request.title_),
|
|
|
|
std::move(request.name_), get_sticker_type(request.sticker_type_),
|
|
|
|
std::move(request.stickers_), std::move(request.source_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::addStickerToSet &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2022-08-08 16:01:04 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->add_sticker_to_set(UserId(request.user_id_), std::move(request.name_), std::move(request.sticker_),
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-03-20 14:36:07 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setStickerSetThumbnail &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2022-08-08 16:31:27 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->set_sticker_set_thumbnail(UserId(request.user_id_), std::move(request.name_),
|
|
|
|
std::move(request.thumbnail_), std::move(promise));
|
2020-03-20 14:36:07 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::setStickerPositionInSet &request) {
|
|
|
|
CHECK_IS_BOT();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->set_sticker_position_in_set(request.sticker_, request.position_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::removeStickerFromSet &request) {
|
|
|
|
CHECK_IS_BOT();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->remove_sticker_from_set(request.sticker_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getRecentStickers &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetRecentStickersRequest, request.is_attached_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::addRecentSticker &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(AddRecentStickerRequest, request.is_attached_, std::move(request.sticker_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::removeRecentSticker &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(RemoveRecentStickerRequest, request.is_attached_, std::move(request.sticker_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::clearRecentStickers &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(ClearRecentStickersRequest, request.is_attached_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getFavoriteStickers &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetFavoriteStickersRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::addFavoriteSticker &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(AddFavoriteStickerRequest, std::move(request.sticker_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::removeFavoriteSticker &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(RemoveFavoriteStickerRequest, std::move(request.sticker_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getStickerEmojis &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetStickerEmojisRequest, std::move(request.sticker_));
|
|
|
|
}
|
|
|
|
|
2019-05-21 17:48:35 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::searchEmojis &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.text_);
|
2020-04-22 14:17:53 +02:00
|
|
|
for (auto &input_language_code : request.input_language_codes_) {
|
|
|
|
CLEAN_INPUT_STRING(input_language_code);
|
|
|
|
}
|
2020-01-08 17:07:40 +01:00
|
|
|
CREATE_REQUEST(SearchEmojisRequest, std::move(request.text_), request.exact_match_,
|
2020-04-22 14:17:53 +02:00
|
|
|
std::move(request.input_language_codes_));
|
2019-05-21 17:48:35 +02:00
|
|
|
}
|
|
|
|
|
2021-10-26 16:59:15 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getAnimatedEmoji &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.emoji_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->get_animated_emoji(std::move(request.emoji_), false, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-05-21 21:44:13 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getEmojiSuggestionsUrl &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.language_code_);
|
|
|
|
CREATE_REQUEST(GetEmojiSuggestionsUrlRequest, std::move(request.language_code_));
|
|
|
|
}
|
|
|
|
|
2022-07-19 15:00:04 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getCustomEmojiStickers &request) {
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-07-25 22:04:53 +02:00
|
|
|
stickers_manager_->get_custom_emoji_stickers(std::move(request.custom_emoji_ids_), true, std::move(promise));
|
2022-07-19 15:00:04 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getSavedAnimations &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetSavedAnimationsRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::addSavedAnimation &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(AddSavedAnimationRequest, std::move(request.animation_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::removeSavedAnimation &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(RemoveSavedAnimationRequest, std::move(request.animation_));
|
|
|
|
}
|
|
|
|
|
2022-04-14 12:23:43 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getSavedNotificationSound &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(GetSavedNotificationSoundRequest, request.notification_sound_id_);
|
|
|
|
}
|
|
|
|
|
2022-04-13 21:14:40 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getSavedNotificationSounds &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_NO_ARGS_REQUEST(GetSavedNotificationSoundsRequest);
|
|
|
|
}
|
|
|
|
|
2022-04-14 21:39:25 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::addSavedNotificationSound &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
notification_settings_manager_->add_saved_ringtone(std::move(request.sound_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-04-14 13:31:18 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::removeSavedNotificationSound &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST(RemoveSavedNotificationSoundRequest, request.notification_sound_id_);
|
|
|
|
}
|
|
|
|
|
2019-02-14 19:44:20 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatNotificationSettingsExceptions &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
bool filter_scope = false;
|
|
|
|
NotificationSettingsScope scope = NotificationSettingsScope::Private;
|
|
|
|
if (request.scope_ != nullptr) {
|
|
|
|
filter_scope = true;
|
|
|
|
scope = get_notification_settings_scope(request.scope_);
|
|
|
|
}
|
|
|
|
CREATE_REQUEST(GetChatNotificationSettingsExceptionsRequest, scope, filter_scope, request.compare_sound_);
|
|
|
|
}
|
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getScopeNotificationSettings &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2018-04-09 18:30:27 +02:00
|
|
|
if (request.scope_ == nullptr) {
|
2020-05-18 21:54:18 +02:00
|
|
|
return send_error_raw(id, 400, "Scope must be non-empty");
|
2018-04-09 18:30:27 +02:00
|
|
|
}
|
2018-09-29 02:29:57 +02:00
|
|
|
CREATE_REQUEST(GetScopeNotificationSettingsRequest, get_notification_settings_scope(request.scope_));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-10-11 02:28:41 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::removeChatActionBar &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
messages_manager_->remove_dialog_action_bar(DialogId(request.chat_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::reportChat &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-02-20 01:55:09 +01:00
|
|
|
auto r_report_reason = ReportReason::get_report_reason(std::move(request.reason_), std::move(request.text_));
|
|
|
|
if (r_report_reason.is_error()) {
|
|
|
|
return send_error_raw(id, r_report_reason.error().code(), r_report_reason.error().message());
|
|
|
|
}
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-02-19 17:11:27 +01:00
|
|
|
messages_manager_->report_dialog(DialogId(request.chat_id_), MessagesManager::get_message_ids(request.message_ids_),
|
2021-02-20 01:55:09 +01:00
|
|
|
r_report_reason.move_as_ok(), std::move(promise));
|
2021-02-19 17:11:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::reportChatPhoto &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-02-20 01:55:09 +01:00
|
|
|
auto r_report_reason = ReportReason::get_report_reason(std::move(request.reason_), std::move(request.text_));
|
|
|
|
if (r_report_reason.is_error()) {
|
|
|
|
return send_error_raw(id, r_report_reason.error().code(), r_report_reason.error().message());
|
|
|
|
}
|
2021-02-19 17:11:27 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-02-20 01:55:09 +01:00
|
|
|
messages_manager_->report_dialog_photo(DialogId(request.chat_id_), FileId(request.file_id_, 0),
|
|
|
|
r_report_reason.move_as_ok(), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-08-23 13:39:10 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::reportMessageReactions &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
TRY_RESULT_PROMISE(promise, sender_dialog_id, get_message_sender_dialog_id(this, request.sender_id_, false, false));
|
|
|
|
report_message_reactions(this, {DialogId(request.chat_id_), MessageId(request.message_id_)}, sender_dialog_id,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-04-03 02:53:33 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatStatistics &request) {
|
2020-04-02 15:06:05 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2020-04-03 02:53:33 +02:00
|
|
|
contacts_manager_->get_channel_statistics(DialogId(request.chat_id_), request.is_dark_, std::move(promise));
|
2020-04-02 15:06:05 +02:00
|
|
|
}
|
|
|
|
|
2020-08-01 04:19:54 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMessageStatistics &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->get_channel_message_statistics({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
request.is_dark_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:23:26 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getStatisticalGraph &request) {
|
2020-04-02 15:06:05 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.token_);
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
contacts_manager_->load_statistics_graph(DialogId(request.chat_id_), std::move(request.token_), request.x_,
|
|
|
|
std::move(promise));
|
2020-04-02 15:06:05 +02:00
|
|
|
}
|
|
|
|
|
2018-04-09 18:30:27 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setChatNotificationSettings &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
answer_ok_query(id, messages_manager_->set_dialog_notification_settings(DialogId(request.chat_id_),
|
|
|
|
std::move(request.notification_settings_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setScopeNotificationSettings &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2018-04-09 18:30:27 +02:00
|
|
|
if (request.scope_ == nullptr) {
|
2020-05-18 21:54:18 +02:00
|
|
|
return send_error_raw(id, 400, "Scope must be non-empty");
|
2018-04-09 18:30:27 +02:00
|
|
|
}
|
2022-04-11 11:45:52 +02:00
|
|
|
answer_ok_query(id, notification_settings_manager_->set_scope_notification_settings(
|
2018-09-29 02:29:57 +02:00
|
|
|
get_notification_settings_scope(request.scope_), std::move(request.notification_settings_)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::resetAllNotificationSettings &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
messages_manager_->reset_all_notification_settings();
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
2018-08-13 22:18:27 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMapThumbnailFile &request) {
|
|
|
|
DialogId dialog_id(request.chat_id_);
|
2021-04-07 23:51:32 +02:00
|
|
|
if (!messages_manager_->have_dialog_force(dialog_id, "getMapThumbnailFile")) {
|
2018-08-13 22:18:27 +02:00
|
|
|
dialog_id = DialogId();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto r_file_id = file_manager_->get_map_thumbnail_file_id(Location(request.location_), request.zoom_, request.width_,
|
|
|
|
request.height_, request.scale_, dialog_id);
|
|
|
|
if (r_file_id.is_error()) {
|
|
|
|
send_closure(actor_id(this), &Td::send_error, id, r_file_id.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, file_manager_->get_file_object(r_file_id.ok()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-04 03:29:26 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getLocalizationTargetInfo &request) {
|
2018-07-03 19:28:00 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-09-04 14:01:08 +02:00
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::get_languages, request.only_local_, std::move(promise));
|
2018-07-03 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-12 02:15:45 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getLanguagePackInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.language_pack_id_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::search_language_info, request.language_pack_id_,
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-07-03 19:28:00 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getLanguagePackStrings &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-09-04 03:29:26 +02:00
|
|
|
CLEAN_INPUT_STRING(request.language_pack_id_);
|
2018-07-03 19:28:00 +02:00
|
|
|
for (auto &key : request.keys_) {
|
|
|
|
CLEAN_INPUT_STRING(key);
|
|
|
|
}
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::get_language_pack_strings,
|
2018-09-04 03:29:26 +02:00
|
|
|
std::move(request.language_pack_id_), std::move(request.keys_), std::move(promise));
|
2018-07-03 19:28:00 +02:00
|
|
|
}
|
|
|
|
|
2019-02-23 18:27:14 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::synchronizeLanguagePack &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.language_pack_id_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::synchronize_language_pack,
|
|
|
|
std::move(request.language_pack_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2019-02-11 19:53:10 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::addCustomServerLanguagePack &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.language_pack_id_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::add_custom_server_language,
|
|
|
|
std::move(request.language_pack_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-09-04 03:29:26 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setCustomLanguagePack &request) {
|
2018-08-06 16:22:22 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-02-11 18:57:35 +01:00
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::set_custom_language, std::move(request.info_),
|
|
|
|
std::move(request.strings_), std::move(promise));
|
2018-08-06 16:22:22 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 03:29:26 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::editCustomLanguagePackInfo &request) {
|
2018-08-31 19:18:12 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-02-11 18:57:35 +01:00
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::edit_custom_language_info, std::move(request.info_),
|
|
|
|
std::move(promise));
|
2018-08-31 19:18:12 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 03:29:26 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setCustomLanguagePackString &request) {
|
2018-08-22 22:11:54 +02:00
|
|
|
CHECK_IS_USER();
|
2018-09-04 03:29:26 +02:00
|
|
|
CLEAN_INPUT_STRING(request.language_pack_id_);
|
2018-08-22 22:11:54 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::set_custom_language_string,
|
2018-09-04 03:29:26 +02:00
|
|
|
std::move(request.language_pack_id_), std::move(request.new_string_), std::move(promise));
|
2018-08-22 22:11:54 +02:00
|
|
|
}
|
|
|
|
|
2018-09-04 03:29:26 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::deleteLanguagePack &request) {
|
2018-08-06 16:22:22 +02:00
|
|
|
CHECK_IS_USER();
|
2018-09-04 03:29:26 +02:00
|
|
|
CLEAN_INPUT_STRING(request.language_pack_id_);
|
2018-08-06 16:22:22 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-09-04 03:29:26 +02:00
|
|
|
send_closure(language_pack_manager_, &LanguagePackManager::delete_language, std::move(request.language_pack_id_),
|
2018-08-06 16:22:22 +02:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getOption &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2021-12-16 10:07:32 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
option_manager_->get_option(request.name_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setOption &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
2021-12-16 11:13:14 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
option_manager_->set_option(request.name_, std::move(request.value_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-02-21 13:23:05 +01:00
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setPollAnswer &request) {
|
2019-02-21 01:52:58 +01:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-02-21 13:23:05 +01:00
|
|
|
messages_manager_->set_poll_answer({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(request.option_ids_), std::move(promise));
|
2019-02-21 01:52:58 +01:00
|
|
|
}
|
2019-02-21 13:23:05 +01:00
|
|
|
|
2020-01-13 19:21:58 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getPollVoters &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda(
|
|
|
|
[promise = std::move(promise), td = this](Result<std::pair<int32, vector<UserId>>> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(td->contacts_manager_->get_users_object(result.ok().first, result.ok().second));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
messages_manager_->get_poll_voters({DialogId(request.chat_id_), MessageId(request.message_id_)}, request.option_id_,
|
2020-01-18 05:01:05 +01:00
|
|
|
request.offset_, request.limit_, std::move(query_promise));
|
2020-01-13 19:21:58 +01:00
|
|
|
}
|
|
|
|
|
2019-04-12 01:10:33 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::stopPoll &request) {
|
2019-02-22 16:09:55 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2019-04-12 01:10:33 +02:00
|
|
|
messages_manager_->stop_poll({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(request.reply_markup_), std::move(promise));
|
2019-02-22 16:09:55 +01:00
|
|
|
}
|
|
|
|
|
2020-07-12 14:04:49 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::hideSuggestedAction &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-11-26 12:48:43 +01:00
|
|
|
dismiss_suggested_action(SuggestedAction(request.action_), std::move(promise));
|
2020-07-12 14:04:49 +02:00
|
|
|
}
|
|
|
|
|
2019-09-07 01:07:56 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getLoginUrlInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-03 22:37:56 +02:00
|
|
|
link_manager_->get_login_url_info({DialogId(request.chat_id_), MessageId(request.message_id_)}, request.button_id_,
|
2021-05-25 01:39:29 +02:00
|
|
|
std::move(promise));
|
2019-09-07 01:07:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getLoginUrl &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-06-03 22:37:56 +02:00
|
|
|
link_manager_->get_login_url({DialogId(request.chat_id_), MessageId(request.message_id_)}, request.button_id_,
|
2021-05-25 01:39:29 +02:00
|
|
|
request.allow_write_access_, std::move(promise));
|
2019-09-07 01:07:56 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getInlineQueryResults &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.query_);
|
|
|
|
CLEAN_INPUT_STRING(request.offset_);
|
|
|
|
CREATE_REQUEST(GetInlineQueryResultsRequest, request.bot_user_id_, request.chat_id_, request.user_location_,
|
|
|
|
std::move(request.query_), std::move(request.offset_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::answerInlineQuery &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.next_offset_);
|
|
|
|
CLEAN_INPUT_STRING(request.switch_pm_text_);
|
|
|
|
CLEAN_INPUT_STRING(request.switch_pm_parameter_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
inline_queries_manager_->answer_inline_query(
|
|
|
|
request.inline_query_id_, request.is_personal_, std::move(request.results_), request.cache_time_,
|
|
|
|
request.next_offset_, request.switch_pm_text_, request.switch_pm_parameter_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-03-31 15:42:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getWebAppUrl &request) {
|
2022-03-30 15:27:01 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.url_);
|
2022-08-25 22:15:53 +02:00
|
|
|
CLEAN_INPUT_STRING(request.application_name_);
|
2022-03-30 15:27:01 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
inline_queries_manager_->get_simple_web_view_url(UserId(request.bot_user_id_), std::move(request.url_),
|
2022-08-25 22:15:53 +02:00
|
|
|
std::move(request.theme_), std::move(request.application_name_),
|
|
|
|
std::move(query_promise));
|
2022-03-30 15:27:01 +02:00
|
|
|
}
|
|
|
|
|
2022-03-31 15:42:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::sendWebAppData &request) {
|
2022-03-28 14:18:15 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.button_text_);
|
|
|
|
CLEAN_INPUT_STRING(request.data_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
inline_queries_manager_->send_web_view_data(UserId(request.bot_user_id_), std::move(request.button_text_),
|
|
|
|
std::move(request.data_), std::move(promise));
|
2022-03-31 14:05:08 +02:00
|
|
|
}
|
|
|
|
|
2022-03-31 15:42:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::openWebApp &request) {
|
2022-03-31 14:05:08 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.url_);
|
2022-08-25 22:15:53 +02:00
|
|
|
CLEAN_INPUT_STRING(request.application_name_);
|
2022-03-31 14:05:08 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-08-25 22:15:53 +02:00
|
|
|
attach_menu_manager_->request_web_view(
|
|
|
|
DialogId(request.chat_id_), UserId(request.bot_user_id_), MessageId(request.reply_to_message_id_),
|
|
|
|
std::move(request.url_), std::move(request.theme_), std::move(request.application_name_), std::move(promise));
|
2022-03-31 20:45:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::closeWebApp &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-03-31 21:02:19 +02:00
|
|
|
attach_menu_manager_->close_web_view(request.web_app_launch_id_, std::move(promise));
|
2022-03-28 14:18:15 +02:00
|
|
|
}
|
|
|
|
|
2022-03-31 15:42:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::answerWebAppQuery &request) {
|
2022-03-24 09:42:47 +01:00
|
|
|
CHECK_IS_BOT();
|
2022-03-31 15:42:59 +02:00
|
|
|
CLEAN_INPUT_STRING(request.web_app_query_id_);
|
2022-03-28 14:49:01 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-03-31 15:42:59 +02:00
|
|
|
inline_queries_manager_->answer_web_view_query(request.web_app_query_id_, std::move(request.result_),
|
2022-03-24 09:42:47 +01:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getCallbackQueryAnswer &request) {
|
|
|
|
CHECK_IS_USER();
|
2021-09-27 22:22:10 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
callback_queries_manager_->send_callback_query({DialogId(request.chat_id_), MessageId(request.message_id_)},
|
|
|
|
std::move(request.payload_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::answerCallbackQuery &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.text_);
|
|
|
|
CLEAN_INPUT_STRING(request.url_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
callback_queries_manager_->answer_callback_query(request.callback_query_id_, request.text_, request.show_alert_,
|
|
|
|
request.url_, request.cache_time_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::answerShippingQuery &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.error_message_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-31 02:18:00 +02:00
|
|
|
answer_shipping_query(this, request.shipping_query_id_, std::move(request.shipping_options_), request.error_message_,
|
2018-06-28 23:06:17 +02:00
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::answerPreCheckoutQuery &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.error_message_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-31 02:18:00 +02:00
|
|
|
answer_pre_checkout_query(this, request.pre_checkout_query_id_, request.error_message_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-02-13 17:20:34 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getBankCardInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.bank_card_number_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-03-31 02:18:00 +02:00
|
|
|
get_bank_card_info(this, request.bank_card_number_, std::move(promise));
|
2020-02-13 17:20:34 +01:00
|
|
|
}
|
|
|
|
|
2022-05-03 17:50:29 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getPaymentForm &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-05-03 17:50:29 +02:00
|
|
|
get_payment_form(this, std::move(request.input_invoice_), request.theme_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::validateOrderInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-05-03 17:50:29 +02:00
|
|
|
validate_order_info(this, std::move(request.input_invoice_), std::move(request.order_info_), request.allow_save_,
|
|
|
|
std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendPaymentForm &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.order_info_id_);
|
|
|
|
CLEAN_INPUT_STRING(request.shipping_option_id_);
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-05-03 17:50:29 +02:00
|
|
|
send_payment_form(this, std::move(request.input_invoice_), request.payment_form_id_, request.order_info_id_,
|
|
|
|
request.shipping_option_id_, request.credentials_, request.tip_amount_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getPaymentReceipt &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-03-31 03:15:02 +02:00
|
|
|
get_payment_receipt(this, {DialogId(request.chat_id_), MessageId(request.message_id_)}, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getSavedOrderInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-03-31 02:18:00 +02:00
|
|
|
get_saved_order_info(this, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::deleteSavedOrderInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-31 02:18:00 +02:00
|
|
|
delete_saved_order_info(this, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::deleteSavedCredentials &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-03-31 02:18:00 +02:00
|
|
|
delete_saved_credentials(this, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-09-26 23:21:16 +02:00
|
|
|
|
2022-05-06 15:37:11 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::createInvoiceLink &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
export_invoice(this, std::move(request.invoice_), std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2018-08-01 15:52:07 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getPassportElement &request) {
|
2018-03-27 15:11:15 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
|
|
|
if (request.type_ == nullptr) {
|
2020-05-18 21:54:18 +02:00
|
|
|
return send_error_raw(id, 400, "Type must be non-empty");
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-04-05 13:18:47 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::get_secure_value, std::move(request.password_),
|
2018-04-11 19:42:06 +02:00
|
|
|
get_secure_value_type_td_api(request.type_), std::move(promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 15:52:07 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getAllPassportElements &request) {
|
2018-04-07 00:29:36 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-04-07 00:29:36 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::get_all_secure_values, std::move(request.password_),
|
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-08-01 15:52:07 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setPassportElement &request) {
|
2018-03-27 15:11:15 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
2018-08-01 15:52:07 +02:00
|
|
|
auto r_secure_value = get_secure_value(file_manager_.get(), std::move(request.element_));
|
2018-03-27 15:11:15 +02:00
|
|
|
if (r_secure_value.is_error()) {
|
2021-02-13 19:49:24 +01:00
|
|
|
return send_error_raw(id, 400, r_secure_value.error().message());
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2021-02-13 19:49:24 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-04-05 13:18:47 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::set_secure_value, std::move(request.password_),
|
|
|
|
r_secure_value.move_as_ok(), std::move(promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 15:52:07 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::deletePassportElement &request) {
|
2018-03-27 15:11:15 +02:00
|
|
|
CHECK_IS_USER();
|
2018-04-11 19:42:06 +02:00
|
|
|
if (request.type_ == nullptr) {
|
2020-05-18 21:54:18 +02:00
|
|
|
return send_error_raw(id, 400, "Type must be non-empty");
|
2018-04-11 19:42:06 +02:00
|
|
|
}
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-04-11 19:42:06 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::delete_secure_value, get_secure_value_type_td_api(request.type_),
|
2018-04-11 20:13:46 +02:00
|
|
|
std::move(promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 15:52:07 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setPassportElementErrors &request) {
|
2018-04-17 17:04:09 +02:00
|
|
|
CHECK_IS_BOT();
|
2021-12-16 20:46:03 +01:00
|
|
|
auto r_input_user = contacts_manager_->get_input_user(UserId(request.user_id_));
|
|
|
|
if (r_input_user.is_error()) {
|
|
|
|
return send_error_raw(id, r_input_user.error().code(), r_input_user.error().message());
|
2018-04-17 17:04:09 +02:00
|
|
|
}
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-12-16 20:46:03 +01:00
|
|
|
send_closure(secure_manager_, &SecureManager::set_secure_value_errors, this, r_input_user.move_as_ok(),
|
2018-04-17 17:04:09 +02:00
|
|
|
std::move(request.errors_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-08-24 00:02:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getPreferredCountryLanguage &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.country_code_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2020-08-23 22:02:20 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::get_preferred_country_language, std::move(request.country_code_),
|
2018-08-24 00:02:59 +02:00
|
|
|
std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-03-27 15:11:15 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::sendPhoneNumberVerificationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.phone_number_);
|
2018-04-09 16:20:12 +02:00
|
|
|
send_closure(verify_phone_number_manager_, &PhoneNumberManager::set_phone_number, id,
|
2019-05-03 04:44:59 +02:00
|
|
|
std::move(request.phone_number_), std::move(request.settings_));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::resendPhoneNumberVerificationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-04-09 16:20:12 +02:00
|
|
|
send_closure(verify_phone_number_manager_, &PhoneNumberManager::resend_authentication_code, id);
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::checkPhoneNumberVerificationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.code_);
|
2018-04-09 16:20:12 +02:00
|
|
|
send_closure(verify_phone_number_manager_, &PhoneNumberManager::check_code, id, std::move(request.code_));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendEmailAddressVerificationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.email_address_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-09-06 13:53:19 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<SentEmailCode> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_email_address_authentication_code_info_object());
|
|
|
|
}
|
|
|
|
});
|
2021-10-19 17:11:16 +02:00
|
|
|
send_closure(password_manager_, &PasswordManager::send_email_address_verification_code,
|
2022-09-06 13:53:19 +02:00
|
|
|
std::move(request.email_address_), std::move(query_promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::resendEmailAddressVerificationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-09-06 13:53:19 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<SentEmailCode> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(result.ok().get_email_address_authentication_code_info_object());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(password_manager_, &PasswordManager::resend_email_address_verification_code, std::move(query_promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::checkEmailAddressVerificationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.code_);
|
2018-12-28 23:48:32 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2021-10-19 17:11:16 +02:00
|
|
|
send_closure(password_manager_, &PasswordManager::check_email_address_verification_code, std::move(request.code_),
|
2018-04-09 18:04:21 +02:00
|
|
|
std::move(promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getPassportAuthorizationForm &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.public_key_);
|
|
|
|
CLEAN_INPUT_STRING(request.scope_);
|
2018-08-17 21:16:55 +02:00
|
|
|
CLEAN_INPUT_STRING(request.nonce_);
|
2018-04-07 00:29:36 +02:00
|
|
|
UserId bot_user_id(request.bot_user_id_);
|
|
|
|
if (!bot_user_id.is_valid()) {
|
|
|
|
return send_error_raw(id, 400, "Bot user identifier invalid");
|
|
|
|
}
|
2018-08-17 21:16:55 +02:00
|
|
|
if (request.nonce_.empty()) {
|
|
|
|
return send_error_raw(id, 400, "Nonce must be non-empty");
|
2018-04-11 19:42:06 +02:00
|
|
|
}
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-09-25 04:12:41 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::get_passport_authorization_form, bot_user_id, std::move(request.scope_),
|
|
|
|
std::move(request.public_key_), std::move(request.nonce_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::getPassportAuthorizationFormAvailableElements &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.password_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
send_closure(secure_manager_, &SecureManager::get_passport_authorization_form_available_elements,
|
|
|
|
request.autorization_form_id_, std::move(request.password_), std::move(promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2018-04-06 21:37:30 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::sendPassportAuthorizationForm &request) {
|
2018-03-27 15:11:15 +02:00
|
|
|
CHECK_IS_USER();
|
2018-04-11 19:42:06 +02:00
|
|
|
for (auto &type : request.types_) {
|
|
|
|
if (type == nullptr) {
|
2020-05-18 21:54:18 +02:00
|
|
|
return send_error_raw(id, 400, "Type must be non-empty");
|
2018-04-11 19:42:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-08-12 15:46:05 +02:00
|
|
|
send_closure(secure_manager_, &SecureManager::send_passport_authorization_form, request.autorization_form_id_,
|
|
|
|
get_secure_value_types_td_api(request.types_), std::move(promise));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2018-06-27 20:26:52 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::sendPhoneNumberConfirmationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.phone_number_);
|
|
|
|
CLEAN_INPUT_STRING(request.hash_);
|
|
|
|
send_closure(confirm_phone_number_manager_, &PhoneNumberManager::set_phone_number_and_hash, id,
|
2019-05-03 04:44:59 +02:00
|
|
|
std::move(request.hash_), std::move(request.phone_number_), std::move(request.settings_));
|
2018-06-27 20:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::resendPhoneNumberConfirmationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
send_closure(confirm_phone_number_manager_, &PhoneNumberManager::resend_authentication_code, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::checkPhoneNumberConfirmationCode &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.code_);
|
|
|
|
send_closure(confirm_phone_number_manager_, &PhoneNumberManager::check_code, id, std::move(request.code_));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getSupportUser &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-05-14 17:54:21 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
contacts_manager_->get_support_user(std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-05-07 04:51:56 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getBackgrounds &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2021-09-03 08:07:18 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
background_manager_->get_backgrounds(request.for_dark_theme_, std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-05-07 16:10:20 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getBackgroundUrl &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
|
|
|
Result<string> r_url = background_manager_->get_background_url(request.name_, std::move(request.type_));
|
|
|
|
if (r_url.is_error()) {
|
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_url.move_as_error());
|
|
|
|
}
|
|
|
|
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, td_api::make_object<td_api::httpUrl>(r_url.ok()));
|
|
|
|
}
|
|
|
|
|
2019-05-07 17:21:57 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::searchBackground &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.name_);
|
|
|
|
CREATE_REQUEST(SearchBackgroundRequest, std::move(request.name_));
|
|
|
|
}
|
|
|
|
|
2019-05-10 14:36:37 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::setBackground &request) {
|
|
|
|
CHECK_IS_USER();
|
2019-06-18 00:39:57 +02:00
|
|
|
CREATE_REQUEST(SetBackgroundRequest, std::move(request.background_), std::move(request.type_),
|
|
|
|
request.for_dark_theme_);
|
2019-05-10 14:36:37 +02:00
|
|
|
}
|
|
|
|
|
2019-05-12 03:10:18 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::removeBackground &request) {
|
2019-05-10 22:55:26 +02:00
|
|
|
CHECK_IS_USER();
|
2020-02-13 23:20:33 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
background_manager_->remove_background(BackgroundId(request.background_id_), std::move(promise));
|
2019-05-10 22:55:26 +02:00
|
|
|
}
|
|
|
|
|
2019-05-12 03:10:18 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::resetBackgrounds &request) {
|
|
|
|
CHECK_IS_USER();
|
2020-02-13 23:20:33 +01:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
background_manager_->reset_backgrounds(std::move(promise));
|
2019-05-12 03:10:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, td_api::getRecentlyVisitedTMeUrls &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.referrer_);
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
create_handler<GetRecentMeUrlsQuery>(std::move(promise))->send(request.referrer_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setBotUpdatesStatus &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.error_message_);
|
|
|
|
create_handler<SetBotUpdatesStatusQuery>()->send(request.pending_update_count_, request.error_message_);
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::sendCustomRequest &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.method_);
|
|
|
|
CLEAN_INPUT_STRING(request.parameters_);
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
create_handler<SendCustomRequestQuery>(std::move(promise))->send(request.method_, request.parameters_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::answerCustomQuery &request) {
|
|
|
|
CHECK_IS_BOT();
|
|
|
|
CLEAN_INPUT_STRING(request.data_);
|
2018-06-28 23:06:17 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
create_handler<AnswerCustomQueryQuery>(std::move(promise))->send(request.custom_query_id_, request.data_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setAlarm &request) {
|
|
|
|
if (request.seconds_ < 0 || request.seconds_ > 3e9) {
|
|
|
|
return send_error_raw(id, 400, "Wrong parameter seconds specified");
|
|
|
|
}
|
2018-02-09 16:59:13 +01:00
|
|
|
|
|
|
|
int64 alarm_id = alarm_id_++;
|
|
|
|
pending_alarms_.emplace(alarm_id, id);
|
|
|
|
alarm_timeout_.set_timeout_in(alarm_id, request.seconds_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::searchHashtags &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.prefix_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-12-31 20:04:05 +01:00
|
|
|
auto query_promise =
|
|
|
|
PromiseCreator::lambda([promise = std::move(promise)](Result<std::vector<string>> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::hashtags>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(hashtag_hints_, &HashtagHints::query, std::move(request.prefix_), request.limit_,
|
|
|
|
std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::removeRecentHashtag &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.hashtag_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-04-11 20:13:46 +02:00
|
|
|
send_closure(hashtag_hints_, &HashtagHints::remove_hashtag, std::move(request.hashtag_), std::move(promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-05-24 01:55:03 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPremiumLimit &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_premium_limit(request.limit_type_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-05-23 14:56:31 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPremiumFeatures &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
2022-05-24 14:42:46 +02:00
|
|
|
get_premium_features(this, request.source_, std::move(promise));
|
2022-05-23 14:56:31 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 14:42:02 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPremiumStickerExamples &request) {
|
2022-06-03 17:16:12 +02:00
|
|
|
CHECK_IS_USER();
|
2022-08-01 17:50:08 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
stickers_manager_->search_stickers("⭐️⭐️", 100, std::move(promise));
|
2022-06-03 17:16:12 +02:00
|
|
|
}
|
|
|
|
|
2022-05-24 19:45:03 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::viewPremiumFeature &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
view_premium_feature(this, request.feature_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-05-25 14:34:36 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::clickPremiumSubscriptionButton &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
click_premium_subscription_button(this, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-06-01 14:14:09 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPremiumState &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_premium_state(this, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2022-07-15 13:09:37 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::canPurchasePremium &request) {
|
2022-06-24 16:07:10 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-15 13:09:37 +02:00
|
|
|
can_purchase_premium(this, std::move(request.purpose_), std::move(promise));
|
2022-06-24 16:07:10 +02:00
|
|
|
}
|
|
|
|
|
2022-07-01 18:27:59 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::assignAppStoreTransaction &request) {
|
2022-06-24 17:14:00 +02:00
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-01 18:27:59 +02:00
|
|
|
assign_app_store_transaction(this, request.receipt_, std::move(request.purpose_), std::move(promise));
|
2022-06-24 17:14:00 +02:00
|
|
|
}
|
|
|
|
|
2022-06-24 16:27:03 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::assignGooglePlayTransaction &request) {
|
|
|
|
CHECK_IS_USER();
|
2022-07-18 14:17:01 +02:00
|
|
|
CLEAN_INPUT_STRING(request.package_name_);
|
|
|
|
CLEAN_INPUT_STRING(request.store_product_id_);
|
2022-06-24 16:27:03 +02:00
|
|
|
CLEAN_INPUT_STRING(request.purchase_token_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-07-18 14:17:01 +02:00
|
|
|
assign_play_market_transaction(this, request.package_name_, request.store_product_id_, request.purchase_token_,
|
|
|
|
std::move(request.purpose_), std::move(promise));
|
2022-06-24 16:27:03 +02:00
|
|
|
}
|
|
|
|
|
2018-06-07 20:42:17 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CLEAN_INPUT_STRING(request.terms_of_service_id_);
|
2019-03-20 19:13:45 +01:00
|
|
|
auto promise = PromiseCreator::lambda([id = id, actor_id = actor_id(this)](Result<> result) {
|
2018-06-09 01:00:15 +02:00
|
|
|
if (result.is_error()) {
|
|
|
|
send_closure(actor_id, &Td::send_error, id, result.move_as_error());
|
|
|
|
} else {
|
|
|
|
send_closure(actor_id, &Td::send_result, id, td_api::make_object<td_api::ok>());
|
|
|
|
send_closure(actor_id, &Td::schedule_get_terms_of_service, 0);
|
|
|
|
}
|
|
|
|
});
|
2018-06-07 20:42:17 +02:00
|
|
|
accept_terms_of_service(this, std::move(request.terms_of_service_id_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2020-08-24 22:38:45 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getCountries &request) {
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
country_info_manager_->get_countries(std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-03-04 22:36:16 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getCountryCode &request) {
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
|
|
|
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
|
|
|
|
}
|
|
|
|
});
|
2020-08-23 23:43:31 +02:00
|
|
|
country_info_manager_->get_current_country_code(std::move(query_promise));
|
2018-03-04 22:36:16 +01:00
|
|
|
}
|
|
|
|
|
2020-08-25 12:42:14 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPhoneNumberInfo &request) {
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
country_info_manager_->get_phone_number_info(request.phone_number_prefix_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2021-06-04 18:31:18 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getApplicationDownloadLink &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK_IS_USER();
|
2020-02-13 22:42:03 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2021-06-04 18:31:18 +02:00
|
|
|
promise.set_value(make_tl_object<td_api::httpUrl>(result.move_as_ok()));
|
2020-02-13 22:42:03 +01:00
|
|
|
}
|
|
|
|
});
|
2022-05-24 13:56:02 +02:00
|
|
|
get_invite_text(this, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-04-12 22:51:42 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::getDeepLinkInfo &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.link_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2021-08-08 10:26:51 +02:00
|
|
|
link_manager_->get_deep_link_info(request.link_, std::move(promise));
|
2018-04-12 22:51:42 +02:00
|
|
|
}
|
|
|
|
|
2018-12-10 20:08:58 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getApplicationConfig &request) {
|
2019-04-23 02:09:00 +02:00
|
|
|
CHECK_IS_USER();
|
2018-12-10 20:08:58 +01:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2019-12-19 02:23:14 +01:00
|
|
|
send_closure(G()->config_manager(), &ConfigManager::get_app_config, std::move(promise));
|
2018-12-10 20:08:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::saveApplicationLogEvent &request) {
|
2019-04-23 02:09:00 +02:00
|
|
|
CHECK_IS_USER();
|
2018-12-10 20:08:58 +01:00
|
|
|
CLEAN_INPUT_STRING(request.type_);
|
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2022-05-24 13:56:02 +02:00
|
|
|
save_app_log(this, request.type_, DialogId(request.chat_id_), convert_json_value(std::move(request.data_)),
|
|
|
|
std::move(promise));
|
2018-12-10 20:08:58 +01:00
|
|
|
}
|
|
|
|
|
2018-05-14 21:00:38 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::addProxy &request) {
|
|
|
|
CLEAN_INPUT_STRING(request.server_);
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-07-27 17:10:45 +02:00
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::add_proxy, -1, std::move(request.server_), request.port_,
|
2018-05-14 21:00:38 +02:00
|
|
|
request.enable_, std::move(request.type_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-07-27 17:10:45 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::editProxy &request) {
|
|
|
|
if (request.proxy_id_ < 0) {
|
|
|
|
return send_error_raw(id, 400, "Proxy identifier invalid");
|
|
|
|
}
|
|
|
|
CLEAN_INPUT_STRING(request.server_);
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::add_proxy, request.proxy_id_, std::move(request.server_),
|
|
|
|
request.port_, request.enable_, std::move(request.type_), std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-05-14 21:00:38 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::enableProxy &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-05-14 21:00:38 +02:00
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::enable_proxy, request.proxy_id_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::disableProxy &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-05-14 21:00:38 +02:00
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::disable_proxy, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::removeProxy &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
2018-05-14 21:00:38 +02:00
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::remove_proxy, request.proxy_id_, std::move(promise));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getProxies &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-05-14 21:00:38 +02:00
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::get_proxies, std::move(promise));
|
|
|
|
}
|
|
|
|
|
2018-05-17 20:08:51 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getProxyLink &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-05-17 20:08:51 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
|
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2021-02-04 23:46:55 +01:00
|
|
|
promise.set_value(make_tl_object<td_api::httpUrl>(result.move_as_ok()));
|
2018-05-17 20:08:51 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::get_proxy_link, request.proxy_id_,
|
|
|
|
std::move(query_promise));
|
|
|
|
}
|
|
|
|
|
2018-05-14 21:00:38 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::pingProxy &request) {
|
2018-06-28 21:17:38 +02:00
|
|
|
CREATE_REQUEST_PROMISE();
|
2018-05-14 21:00:38 +02:00
|
|
|
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<double> result) mutable {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (result.is_error()) {
|
|
|
|
promise.set_error(result.move_as_error());
|
|
|
|
} else {
|
2018-05-14 21:00:38 +02:00
|
|
|
promise.set_value(make_tl_object<td_api::seconds>(result.move_as_ok()));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
});
|
2018-05-14 21:00:38 +02:00
|
|
|
send_closure(G()->connection_creator(), &ConnectionCreator::ping_proxy, request.proxy_id_, std::move(query_promise));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-08-15 13:32:35 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getUserSupportInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
get_user_info(this, UserId(request.user_id_), std::move(promise));
|
2022-08-15 15:58:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::setUserSupportInfo &request) {
|
|
|
|
CHECK_IS_USER();
|
|
|
|
CREATE_REQUEST_PROMISE();
|
|
|
|
set_user_info(this, UserId(request.user_id_), std::move(request.message_), std::move(promise));
|
2022-08-15 13:32:35 +02:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getTextEntities &request) {
|
2018-09-20 18:33:41 +02:00
|
|
|
UNREACHABLE();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-12-10 02:01:02 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::parseTextEntities &request) {
|
2018-09-20 18:33:41 +02:00
|
|
|
UNREACHABLE();
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
|
2020-03-09 21:55:32 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::parseMarkdown &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2020-03-12 04:22:14 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getMarkdownText &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getFileMimeType &request) {
|
2018-09-20 18:33:41 +02:00
|
|
|
UNREACHABLE();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getFileExtension &request) {
|
2018-09-20 18:33:41 +02:00
|
|
|
UNREACHABLE();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-04-30 14:50:54 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::cleanFileName &request) {
|
2018-09-20 18:33:41 +02:00
|
|
|
UNREACHABLE();
|
2018-04-30 14:50:54 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 19:29:14 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getLanguagePackString &request) {
|
2018-09-20 18:33:41 +02:00
|
|
|
UNREACHABLE();
|
2018-07-23 19:29:14 +02:00
|
|
|
}
|
|
|
|
|
2021-08-30 21:26:02 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPhoneNumberInfoSync &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-12-28 23:48:32 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getPushReceiverId &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2020-06-05 02:43:13 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getChatFilterDefaultIconName &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-12-10 02:01:02 +01:00
|
|
|
void Td::on_request(uint64 id, const td_api::getJsonValue &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getJsonString &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2022-03-29 19:22:38 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::getThemeParametersJsonString &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::setLogStream &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getLogStream &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setLogVerbosityLevel &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getLogVerbosityLevel &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getLogTags &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::setLogTagVerbosityLevel &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, const td_api::getLogTagVerbosityLevel &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2019-04-13 20:40:31 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::addLogMessage &request) {
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getTextEntities &request) {
|
|
|
|
if (!check_utf8(request.text_)) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return make_error(400, "Text must be encoded in UTF-8");
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-08-04 03:26:41 +02:00
|
|
|
auto text_entities = find_entities(request.text_, false, false);
|
2021-08-04 08:28:53 +02:00
|
|
|
return make_tl_object<td_api::textEntities>(
|
|
|
|
get_text_entities_object(text_entities, false, std::numeric_limits<int32>::max()));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-01-30 18:06:54 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseTextEntities &request) {
|
|
|
|
if (!check_utf8(request.text_)) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return make_error(400, "Text must be encoded in UTF-8");
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
if (request.parse_mode_ == nullptr) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return make_error(400, "Parse mode must be non-empty");
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
|
2018-06-27 18:24:42 +02:00
|
|
|
auto r_entities = [&]() -> Result<vector<MessageEntity>> {
|
2022-04-23 00:36:44 +02:00
|
|
|
if (utf8_length(request.text_) > 65536) {
|
|
|
|
return Status::Error("Text is too long");
|
|
|
|
}
|
2018-06-27 18:24:42 +02:00
|
|
|
switch (request.parse_mode_->get_id()) {
|
|
|
|
case td_api::textParseModeHTML::ID:
|
|
|
|
return parse_html(request.text_);
|
2019-10-03 01:39:10 +02:00
|
|
|
case td_api::textParseModeMarkdown::ID: {
|
|
|
|
auto version = static_cast<const td_api::textParseModeMarkdown *>(request.parse_mode_.get())->version_;
|
2019-12-30 22:58:11 +01:00
|
|
|
if (version == 0 || version == 1) {
|
2019-10-03 01:39:10 +02:00
|
|
|
return parse_markdown(request.text_);
|
|
|
|
}
|
2019-12-30 22:58:11 +01:00
|
|
|
if (version == 2) {
|
2019-10-03 01:39:10 +02:00
|
|
|
return parse_markdown_v2(request.text_);
|
|
|
|
}
|
|
|
|
return Status::Error("Wrong Markdown version specified");
|
|
|
|
}
|
2018-06-27 18:24:42 +02:00
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return Status::Error(500, "Unknown parse mode");
|
|
|
|
}
|
|
|
|
}();
|
2018-01-30 18:06:54 +01:00
|
|
|
if (r_entities.is_error()) {
|
2018-02-19 22:20:47 +01:00
|
|
|
return make_error(400, PSLICE() << "Can't parse entities: " << r_entities.error().message());
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
|
2021-07-22 04:39:16 +02:00
|
|
|
return make_tl_object<td_api::formattedText>(std::move(request.text_),
|
2021-08-04 08:28:53 +02:00
|
|
|
get_text_entities_object(r_entities.ok(), false, -1));
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
|
2020-03-09 21:55:32 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseMarkdown &request) {
|
|
|
|
if (request.text_ == nullptr) {
|
|
|
|
return make_error(400, "Text must be non-empty");
|
|
|
|
}
|
|
|
|
|
2020-03-10 01:51:56 +01:00
|
|
|
auto r_entities = get_message_entities(nullptr, std::move(request.text_->entities_), true);
|
2020-03-09 21:55:32 +01:00
|
|
|
if (r_entities.is_error()) {
|
|
|
|
return make_error(400, r_entities.error().message());
|
|
|
|
}
|
|
|
|
auto entities = r_entities.move_as_ok();
|
2021-07-26 21:48:33 +02:00
|
|
|
auto status = fix_formatted_text(request.text_->text_, entities, true, true, true, true, true);
|
2020-03-09 21:55:32 +01:00
|
|
|
if (status.is_error()) {
|
|
|
|
return make_error(400, status.error().message());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto parsed_text = parse_markdown_v3({std::move(request.text_->text_), std::move(entities)});
|
2021-07-26 21:48:33 +02:00
|
|
|
fix_formatted_text(parsed_text.text, parsed_text.entities, true, true, true, true, true).ensure();
|
2021-08-04 08:28:53 +02:00
|
|
|
return get_formatted_text_object(parsed_text, false, std::numeric_limits<int32>::max());
|
2020-03-12 04:22:14 +01:00
|
|
|
}
|
|
|
|
|
2022-07-11 12:33:56 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getOption &request) {
|
|
|
|
if (!is_synchronous_request(&request)) {
|
|
|
|
return make_error(400, "The option can't be get synchronously");
|
|
|
|
}
|
|
|
|
return OptionManager::get_option_synchronously(request.name_);
|
|
|
|
}
|
|
|
|
|
2020-03-12 04:22:14 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::getMarkdownText &request) {
|
|
|
|
if (request.text_ == nullptr) {
|
|
|
|
return make_error(400, "Text must be non-empty");
|
|
|
|
}
|
|
|
|
|
|
|
|
auto r_entities = get_message_entities(nullptr, std::move(request.text_->entities_));
|
|
|
|
if (r_entities.is_error()) {
|
|
|
|
return make_error(400, r_entities.error().message());
|
|
|
|
}
|
|
|
|
auto entities = r_entities.move_as_ok();
|
2021-07-26 21:48:33 +02:00
|
|
|
auto status = fix_formatted_text(request.text_->text_, entities, true, true, true, true, true);
|
2020-03-12 04:22:14 +01:00
|
|
|
if (status.is_error()) {
|
|
|
|
return make_error(400, status.error().message());
|
|
|
|
}
|
|
|
|
|
2021-08-04 08:28:53 +02:00
|
|
|
return get_formatted_text_object(get_markdown_v3({std::move(request.text_->text_), std::move(entities)}), false,
|
|
|
|
std::numeric_limits<int32>::max());
|
2020-03-09 21:55:32 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getFileMimeType &request) {
|
|
|
|
// don't check file name UTF-8 correctness
|
|
|
|
return make_tl_object<td_api::text>(MimeType::from_extension(PathView(request.file_name_).extension()));
|
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getFileExtension &request) {
|
|
|
|
// don't check MIME type UTF-8 correctness
|
|
|
|
return make_tl_object<td_api::text>(MimeType::to_extension(request.mime_type_));
|
|
|
|
}
|
|
|
|
|
2018-04-30 14:50:54 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::cleanFileName &request) {
|
|
|
|
// don't check file name UTF-8 correctness
|
|
|
|
return make_tl_object<td_api::text>(clean_filename(request.file_name_));
|
|
|
|
}
|
|
|
|
|
2018-07-23 19:29:14 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getLanguagePackString &request) {
|
2018-09-04 03:29:26 +02:00
|
|
|
return LanguagePackManager::get_language_pack_string(
|
|
|
|
request.language_pack_database_path_, request.localization_target_, request.language_pack_id_, request.key_);
|
2018-07-23 19:29:14 +02:00
|
|
|
}
|
|
|
|
|
2021-11-10 19:09:28 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::getPhoneNumberInfoSync &request) {
|
2021-08-30 21:26:02 +02:00
|
|
|
// don't check language_code/phone number UTF-8 correctness
|
2021-10-19 17:11:16 +02:00
|
|
|
return CountryInfoManager::get_phone_number_info_sync(request.language_code_,
|
|
|
|
std::move(request.phone_number_prefix_));
|
2021-08-30 21:26:02 +02:00
|
|
|
}
|
|
|
|
|
2018-12-28 23:48:32 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getPushReceiverId &request) {
|
|
|
|
// don't check push payload UTF-8 correctness
|
2019-01-13 20:56:38 +01:00
|
|
|
auto r_push_receiver_id = NotificationManager::get_push_receiver_id(request.payload_);
|
2018-12-28 23:48:32 +01:00
|
|
|
if (r_push_receiver_id.is_error()) {
|
2019-01-13 20:56:38 +01:00
|
|
|
VLOG(notifications) << "Failed to get push notification receiver from \"" << format::escaped(request.payload_)
|
|
|
|
<< '"';
|
2018-12-28 23:48:32 +01:00
|
|
|
return make_error(r_push_receiver_id.error().code(), r_push_receiver_id.error().message());
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::pushReceiverId>(r_push_receiver_id.ok());
|
|
|
|
}
|
|
|
|
|
2020-06-05 02:43:13 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getChatFilterDefaultIconName &request) {
|
|
|
|
if (request.filter_ == nullptr) {
|
|
|
|
return make_error(400, "Chat filter must be non-empty");
|
|
|
|
}
|
|
|
|
if (!check_utf8(request.filter_->title_)) {
|
|
|
|
return make_error(400, "Chat filter title must be encoded in UTF-8");
|
|
|
|
}
|
|
|
|
if (!check_utf8(request.filter_->icon_name_)) {
|
|
|
|
return make_error(400, "Chat filter icon name must be encoded in UTF-8");
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::text>(DialogFilter::get_default_icon_name(request.filter_.get()));
|
|
|
|
}
|
|
|
|
|
2018-12-10 02:01:02 +01:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::getJsonValue &request) {
|
|
|
|
if (!check_utf8(request.json_)) {
|
|
|
|
return make_error(400, "JSON has invalid encoding");
|
|
|
|
}
|
|
|
|
auto result = get_json_value(request.json_);
|
|
|
|
if (result.is_error()) {
|
|
|
|
return make_error(400, result.error().message());
|
|
|
|
} else {
|
|
|
|
return result.move_as_ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getJsonString &request) {
|
|
|
|
return td_api::make_object<td_api::text>(get_json_string(request.json_value_.get()));
|
|
|
|
}
|
|
|
|
|
2022-03-29 19:22:38 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getThemeParametersJsonString &request) {
|
|
|
|
return td_api::make_object<td_api::text>(ThemeManager::get_theme_parameters_json_string(request.theme_, true));
|
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::setLogStream &request) {
|
|
|
|
auto result = Logging::set_current_stream(std::move(request.log_stream_));
|
|
|
|
if (result.is_ok()) {
|
|
|
|
return td_api::make_object<td_api::ok>();
|
|
|
|
} else {
|
|
|
|
return make_error(400, result.message());
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getLogStream &request) {
|
|
|
|
auto result = Logging::get_current_stream();
|
|
|
|
if (result.is_ok()) {
|
|
|
|
return result.move_as_ok();
|
|
|
|
} else {
|
|
|
|
return make_error(400, result.error().message());
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::setLogVerbosityLevel &request) {
|
|
|
|
auto result = Logging::set_verbosity_level(static_cast<int>(request.new_verbosity_level_));
|
|
|
|
if (result.is_ok()) {
|
|
|
|
return td_api::make_object<td_api::ok>();
|
|
|
|
} else {
|
|
|
|
return make_error(400, result.message());
|
2018-09-26 01:59:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getLogVerbosityLevel &request) {
|
|
|
|
return td_api::make_object<td_api::logVerbosityLevel>(Logging::get_verbosity_level());
|
2018-09-26 01:59:29 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getLogTags &request) {
|
|
|
|
return td_api::make_object<td_api::logTags>(Logging::get_tags());
|
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::setLogTagVerbosityLevel &request) {
|
|
|
|
auto result = Logging::set_tag_verbosity_level(request.tag_, static_cast<int>(request.new_verbosity_level_));
|
|
|
|
if (result.is_ok()) {
|
|
|
|
return td_api::make_object<td_api::ok>();
|
|
|
|
} else {
|
|
|
|
return make_error(400, result.message());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getLogTagVerbosityLevel &request) {
|
|
|
|
auto result = Logging::get_tag_verbosity_level(request.tag_);
|
|
|
|
if (result.is_ok()) {
|
|
|
|
return td_api::make_object<td_api::logVerbosityLevel>(result.ok());
|
|
|
|
} else {
|
|
|
|
return make_error(400, result.error().message());
|
2018-09-26 01:59:29 +02:00
|
|
|
}
|
2018-10-24 17:42:40 +02:00
|
|
|
}
|
2018-09-26 01:59:29 +02:00
|
|
|
|
2019-04-13 20:40:31 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::addLogMessage &request) {
|
|
|
|
Logging::add_message(request.verbosity_level_, request.text_);
|
|
|
|
return td_api::make_object<td_api::ok>();
|
|
|
|
}
|
|
|
|
|
2019-08-06 02:29:16 +02:00
|
|
|
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::testReturnError &request) {
|
|
|
|
if (request.error_ == nullptr) {
|
|
|
|
return td_api::make_object<td_api::error>(404, "Not Found");
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::move(request.error_);
|
|
|
|
}
|
|
|
|
|
2018-10-24 17:42:40 +02:00
|
|
|
// test
|
2019-08-06 02:29:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::testNetwork &request) {
|
2021-10-02 15:54:01 +02:00
|
|
|
CREATE_OK_REQUEST_PROMISE();
|
|
|
|
create_handler<TestNetworkQuery>(std::move(promise))->send();
|
2018-10-24 17:42:40 +02:00
|
|
|
}
|
|
|
|
|
2019-07-20 15:13:36 +02:00
|
|
|
void Td::on_request(uint64 id, td_api::testProxy &request) {
|
2020-06-22 03:28:03 +02:00
|
|
|
auto r_proxy = Proxy::create_proxy(std::move(request.server_), request.port_, request.type_.get());
|
2019-07-20 15:13:36 +02:00
|
|
|
if (r_proxy.is_error()) {
|
2019-07-22 04:04:18 +02:00
|
|
|
return send_closure(actor_id(this), &Td::send_error, id, r_proxy.move_as_error());
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
2019-09-23 03:13:42 +02:00
|
|
|
CREATE_REQUEST(TestProxyRequest, r_proxy.move_as_ok(), request.dc_id_, request.timeout_);
|
2019-07-20 15:13:36 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:29:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::testGetDifference &request) {
|
2018-10-24 17:42:40 +02:00
|
|
|
updates_manager_->get_difference("testGetDifference");
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
2018-09-26 01:59:29 +02:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:29:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::testUseUpdate &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, nullptr);
|
|
|
|
}
|
|
|
|
|
2019-08-06 02:29:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::testReturnError &request) {
|
|
|
|
UNREACHABLE();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-08-06 02:29:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::testCallEmpty &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
|
|
|
|
}
|
|
|
|
|
2019-08-06 02:29:16 +02:00
|
|
|
void Td::on_request(uint64 id, const td_api::testSquareInt &request) {
|
2018-12-31 20:04:05 +01:00
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::testInt>(request.x_ * request.x_));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::testCallString &request) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::testString>(std::move(request.x_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::testCallBytes &request) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::testBytes>(std::move(request.x_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::testCallVectorInt &request) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::testVectorInt>(std::move(request.x_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::testCallVectorIntObject &request) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
|
|
|
make_tl_object<td_api::testVectorIntObject>(std::move(request.x_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::testCallVectorString &request) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::testVectorString>(std::move(request.x_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Td::on_request(uint64 id, td_api::testCallVectorStringObject &request) {
|
|
|
|
send_closure(actor_id(this), &Td::send_result, id,
|
|
|
|
make_tl_object<td_api::testVectorStringObject>(std::move(request.x_)));
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef CLEAN_INPUT_STRING
|
|
|
|
#undef CHECK_IS_BOT
|
|
|
|
#undef CHECK_IS_USER
|
|
|
|
#undef CREATE_NO_ARGS_REQUEST
|
|
|
|
#undef CREATE_REQUEST
|
|
|
|
#undef CREATE_REQUEST_PROMISE
|
2018-04-11 20:13:46 +02:00
|
|
|
#undef CREATE_OK_REQUEST_PROMISE
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
} // namespace td
|