Skip to content

Commit

Permalink
Add TopDialogCategory.h.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: ce481612a17e38268b8b2c3a9d7b9ebad5cb572d
  • Loading branch information
levlam committed Jan 27, 2020
1 parent c36d451 commit 985e051
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 44 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ set(TDLIB_SOURCE
td/telegram/TdDb.h
td/telegram/TdParameters.h
td/telegram/TermsOfService.h
td/telegram/TopDialogCategory.h
td/telegram/TopDialogManager.h
td/telegram/UniqueId.h
td/telegram/UpdatesManager.h
Expand Down
1 change: 1 addition & 0 deletions SplitSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ function ($matches) use ($needed_std_headers) {
'secret_chats_manager[_(-][^.]|SecretChatsManager' => 'SecretChatsManager',
'stickers_manager[_(-][^.]|StickersManager' => 'StickersManager',
'[>](td_db[(][)]|get_td_db_impl[(])|TdDb[^A-Za-z]' => 'TdDb',
'TopDialogCategory|top_dialog_category_from_td_api' => 'TopDialogCategory',
'top_dialog_manager[_(-][^.]|TopDialogManager' => 'TopDialogManager',
'updates_manager[_(-][^.]|UpdatesManager|get_difference[)]' => 'UpdatesManager',
'WebPageId(Hash)?' => 'WebPageId',
Expand Down
8 changes: 0 additions & 8 deletions td/telegram/ContactsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/Version.h"

Expand Down Expand Up @@ -7894,13 +7893,6 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo

if (u->is_deleted) {
td_->inline_queries_manager_->remove_recent_inline_bot(user_id, Promise<>());
/*
DialogId dialog_id(user_id);
for (auto category : {TopDialogCategory::Correspondent, TopDialogCategory::BotPM, TopDialogCategory::BotInline}) {
send_closure(G()->top_dialog_manager(), &TopDialogManager::delete_dialog, category, dialog_id,
get_input_peer_user(user_id, AccessRights::Read));
}
*/
}

LOG(DEBUG) << "Update " << user_id << ": need_save_to_database = " << u->need_save_to_database
Expand Down
1 change: 1 addition & 0 deletions td/telegram/MessagesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "td/telegram/SequenceDispatcher.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TopDialogCategory.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/Version.h"
Expand Down
1 change: 1 addition & 0 deletions td/telegram/Td.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#include "td/telegram/StickersManager.h"
#include "td/telegram/StorageManager.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/TopDialogCategory.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/VideoNotesManager.h"
Expand Down
48 changes: 48 additions & 0 deletions td/telegram/TopDialogCategory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Copyright Aliaksei Levin ([email protected]), Arseny Smirnov ([email protected]) 2014-2020
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once

#include "td/telegram/td_api.h"

#include "td/utils/common.h"

namespace td {

enum class TopDialogCategory : int32 {
Correspondent,
BotPM,
BotInline,
Group,
Channel,
Call,
ForwardUsers,
ForwardChats,
Size
};

inline TopDialogCategory top_dialog_category_from_td_api(const td_api::TopChatCategory &category) {
switch (category.get_id()) {
case td_api::topChatCategoryUsers::ID:
return TopDialogCategory::Correspondent;
case td_api::topChatCategoryBots::ID:
return TopDialogCategory::BotPM;
case td_api::topChatCategoryInlineBots::ID:
return TopDialogCategory::BotInline;
case td_api::topChatCategoryGroups::ID:
return TopDialogCategory::Group;
case td_api::topChatCategoryChannels::ID:
return TopDialogCategory::Channel;
case td_api::topChatCategoryCalls::ID:
return TopDialogCategory::Call;
case td_api::topChatCategoryForwardChats::ID:
return TopDialogCategory::ForwardUsers;
default:
UNREACHABLE();
}
}

} // namespace td
39 changes: 3 additions & 36 deletions td/telegram/TopDialogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"

#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"

#include "td/telegram/DialogId.h"
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/TopDialogCategory.h"

#include "td/utils/common.h"
#include "td/utils/Time.h"
Expand All @@ -23,39 +23,6 @@

namespace td {

enum class TopDialogCategory : int32 {
Correspondent,
BotPM,
BotInline,
Group,
Channel,
Call,
ForwardUsers,
ForwardChats,
Size
};

inline TopDialogCategory top_dialog_category_from_td_api(const td_api::TopChatCategory &category) {
switch (category.get_id()) {
case td_api::topChatCategoryUsers::ID:
return TopDialogCategory::Correspondent;
case td_api::topChatCategoryBots::ID:
return TopDialogCategory::BotPM;
case td_api::topChatCategoryInlineBots::ID:
return TopDialogCategory::BotInline;
case td_api::topChatCategoryGroups::ID:
return TopDialogCategory::Group;
case td_api::topChatCategoryChannels::ID:
return TopDialogCategory::Channel;
case td_api::topChatCategoryCalls::ID:
return TopDialogCategory::Call;
case td_api::topChatCategoryForwardChats::ID:
return TopDialogCategory::ForwardUsers;
default:
UNREACHABLE();
}
}

class TopDialogManager : public NetQueryCallback {
public:
explicit TopDialogManager(ActorShared<> parent) : parent_(std::move(parent)) {
Expand Down

0 comments on commit 985e051

Please sign in to comment.