2024-05-09 22:04:50 +02:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
|
|
|
//
|
|
|
|
// 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/net/NetQuery.h"
|
|
|
|
|
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/FlatHashMap.h"
|
2024-05-23 16:09:28 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2024-05-09 22:04:50 +02:00
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class NetQueryVerifier final : public Actor {
|
|
|
|
public:
|
|
|
|
explicit NetQueryVerifier(ActorShared<> parent) : parent_(std::move(parent)) {
|
|
|
|
}
|
2024-05-09 23:42:51 +02:00
|
|
|
|
2024-05-09 22:04:50 +02:00
|
|
|
void verify(NetQueryPtr query, string nonce);
|
|
|
|
|
2024-05-09 23:42:51 +02:00
|
|
|
void set_verification_token(int64 query_id, string &&token, Promise<Unit> &&promise);
|
|
|
|
|
2024-05-09 22:04:50 +02:00
|
|
|
private:
|
|
|
|
void tear_down() final;
|
|
|
|
|
|
|
|
ActorShared<> parent_;
|
|
|
|
|
|
|
|
FlatHashMap<int64, std::pair<NetQueryPtr, string>> queries_;
|
|
|
|
int64 next_query_id_ = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|