Add td_api::topChatCategoryWebAppBots.

This commit is contained in:
levlam 2024-07-16 10:25:41 +03:00
parent 29451992ac
commit c3f32a2090
6 changed files with 19 additions and 2 deletions

View File

@ -6845,6 +6845,9 @@ topChatCategoryChannels = TopChatCategory;
//@description A category containing frequently used chats with inline bots sorted by their usage in inline mode
topChatCategoryInlineBots = TopChatCategory;
//@description A category containing frequently used chats with bots, which Web Apps were opened
topChatCategoryWebAppBots = TopChatCategory;
//@description A category containing frequently used chats used for calls
topChatCategoryCalls = TopChatCategory;

View File

@ -18,12 +18,14 @@
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessageContent.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/ThemeManager.h"
#include "td/telegram/TopDialogCategory.h"
#include "td/telegram/UserManager.h"
#include "td/telegram/WebApp.h"
@ -831,6 +833,7 @@ void AttachMenuManager::request_app_web_view(DialogId dialog_id, UserId bot_user
}
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
on_dialog_used(TopDialogCategory::BotApp, DialogId(bot_user_id), G()->unix_time());
td_->create_handler<RequestAppWebViewQuery>(std::move(promise))
->send(dialog_id, std::move(input_user), web_app_short_name, start_parameter, theme, platform,
@ -846,6 +849,7 @@ void AttachMenuManager::request_web_view(DialogId dialog_id, UserId bot_user_id,
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
TRY_STATUS_PROMISE(
promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write, "request_web_view"));
on_dialog_used(TopDialogCategory::BotApp, DialogId(bot_user_id), G()->unix_time());
if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server() ||
dialog_id.get_type() != DialogType::Channel ||

View File

@ -37,6 +37,7 @@
#include "td/telegram/TdDb.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/ThemeManager.h"
#include "td/telegram/TopDialogCategory.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/UserManager.h"
#include "td/telegram/Venue.h"
@ -551,6 +552,7 @@ void InlineQueriesManager::get_simple_web_view_url(UserId bot_user_id, string &&
string &&platform, Promise<string> &&promise) {
TRY_RESULT_PROMISE(promise, input_user, td_->user_manager_->get_input_user(bot_user_id));
TRY_RESULT_PROMISE(promise, bot_data, td_->user_manager_->get_bot_data(bot_user_id));
on_dialog_used(TopDialogCategory::BotApp, DialogId(bot_user_id), G()->unix_time());
td_->create_handler<RequestSimpleWebViewQuery>(std::move(promise))
->send(std::move(input_user), std::move(url), theme, std::move(platform));

View File

@ -26,6 +26,8 @@ CSlice get_top_dialog_category_name(TopDialogCategory category) {
return CSlice("forward_users");
case TopDialogCategory::ForwardChats:
return CSlice("forward_chats");
case TopDialogCategory::BotApp:
return CSlice("bot_app");
default:
UNREACHABLE();
return CSlice();
@ -51,6 +53,8 @@ TopDialogCategory get_top_dialog_category(const td_api::object_ptr<td_api::TopCh
return TopDialogCategory::Call;
case td_api::topChatCategoryForwardChats::ID:
return TopDialogCategory::ForwardUsers;
case td_api::topChatCategoryWebAppBots::ID:
return TopDialogCategory::BotApp;
default:
UNREACHABLE();
return TopDialogCategory::Size;
@ -77,7 +81,7 @@ TopDialogCategory get_top_dialog_category(const telegram_api::object_ptr<telegra
case telegram_api::topPeerCategoryForwardChats::ID:
return TopDialogCategory::ForwardChats;
case telegram_api::topPeerCategoryBotsApp::ID:
return TopDialogCategory::ForwardChats;
return TopDialogCategory::BotApp;
default:
UNREACHABLE();
return TopDialogCategory::Size;
@ -102,6 +106,8 @@ telegram_api::object_ptr<telegram_api::TopPeerCategory> get_input_top_peer_categ
return make_tl_object<telegram_api::topPeerCategoryForwardUsers>();
case TopDialogCategory::ForwardChats:
return make_tl_object<telegram_api::topPeerCategoryForwardChats>();
case TopDialogCategory::BotApp:
return make_tl_object<telegram_api::topPeerCategoryBotsApp>();
default:
UNREACHABLE();
return nullptr;

View File

@ -23,6 +23,7 @@ enum class TopDialogCategory : int32 {
Call,
ForwardUsers,
ForwardChats,
BotApp,
Size
};

View File

@ -53,7 +53,8 @@ class GetTopPeersQuery final : public Td::ResultHandler {
telegram_api::contacts_getTopPeers::CORRESPONDENTS_MASK | telegram_api::contacts_getTopPeers::BOTS_PM_MASK |
telegram_api::contacts_getTopPeers::BOTS_INLINE_MASK | telegram_api::contacts_getTopPeers::GROUPS_MASK |
telegram_api::contacts_getTopPeers::CHANNELS_MASK | telegram_api::contacts_getTopPeers::PHONE_CALLS_MASK |
telegram_api::contacts_getTopPeers::FORWARD_USERS_MASK | telegram_api::contacts_getTopPeers::FORWARD_CHATS_MASK;
telegram_api::contacts_getTopPeers::FORWARD_USERS_MASK |
telegram_api::contacts_getTopPeers::FORWARD_CHATS_MASK | telegram_api::contacts_getTopPeers::BOTS_APP_MASK;
send_query(G()->net_query_creator().create(
telegram_api::contacts_getTopPeers(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,