tdlight/td/telegram/BusinessConnectionManager.h

66 lines
2.3 KiB
C
Raw Normal View History

2024-03-07 13:44:15 +01:00
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
2024-03-07 18:18:04 +01:00
#include "td/telegram/BusinessConnectionId.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/net/DcId.h"
2024-03-07 16:02:30 +01:00
#include "td/telegram/td_api.h"
2024-03-07 15:18:11 +01:00
#include "td/telegram/telegram_api.h"
2024-03-07 13:44:15 +01:00
#include "td/actor/actor.h"
#include "td/utils/common.h"
2024-03-07 16:02:30 +01:00
#include "td/utils/Promise.h"
#include "td/utils/Status.h"
2024-03-07 15:18:11 +01:00
#include "td/utils/WaitFreeHashMap.h"
2024-03-07 13:44:15 +01:00
namespace td {
class Td;
class BusinessConnectionManager final : public Actor {
public:
BusinessConnectionManager(Td *td, ActorShared<> parent);
2024-03-07 15:18:11 +01:00
BusinessConnectionManager(const BusinessConnectionManager &) = delete;
BusinessConnectionManager &operator=(const BusinessConnectionManager &) = delete;
BusinessConnectionManager(BusinessConnectionManager &&) = delete;
BusinessConnectionManager &operator=(BusinessConnectionManager &&) = delete;
~BusinessConnectionManager() final;
Status check_business_connection(const BusinessConnectionId &connection_id, DialogId dialog_id) const;
DcId get_business_connection_dc_id(const BusinessConnectionId &connection_id) const;
2024-03-07 15:18:11 +01:00
void on_update_bot_business_connect(telegram_api::object_ptr<telegram_api::botBusinessConnection> &&connection);
2024-03-07 13:44:15 +01:00
2024-03-09 00:14:02 +01:00
void on_update_bot_new_business_message(const BusinessConnectionId &connection_id,
telegram_api::object_ptr<telegram_api::Message> &&message);
2024-03-07 18:18:04 +01:00
void get_business_connection(const BusinessConnectionId &connection_id,
2024-03-07 16:02:30 +01:00
Promise<td_api::object_ptr<td_api::businessConnection>> &&promise);
2024-03-07 13:44:15 +01:00
private:
2024-03-07 15:18:11 +01:00
struct BusinessConnection;
2024-03-07 16:02:30 +01:00
void tear_down() final;
2024-03-07 18:18:04 +01:00
void on_get_business_connection(const BusinessConnectionId &connection_id,
2024-03-07 16:02:30 +01:00
Result<telegram_api::object_ptr<telegram_api::Updates>> r_updates);
2024-03-07 18:18:04 +01:00
WaitFreeHashMap<BusinessConnectionId, unique_ptr<BusinessConnection>, BusinessConnectionIdHash> business_connections_;
2024-03-07 15:18:11 +01:00
2024-03-07 18:18:04 +01:00
FlatHashMap<BusinessConnectionId, vector<Promise<td_api::object_ptr<td_api::businessConnection>>>,
BusinessConnectionIdHash>
get_business_connection_queries_;
2024-03-07 13:44:15 +01:00
Td *td_;
ActorShared<> parent_;
};
} // namespace td