Add NetQueryCreator.create_guest_dc.

GitOrigin-RevId: e8b0fffb5bb762ce288a9cbf1c446d584c7258e1
This commit is contained in:
levlam 2020-03-15 05:22:43 +03:00
parent 8d01251f8b
commit 2bd330a5aa
4 changed files with 28 additions and 20 deletions

View File

@ -2552,11 +2552,11 @@ class EditInlineMessageQuery : public Td::ResultHandler {
LOG(DEBUG) << "Edit inline message with flags " << flags;
auto dc_id = DcId::internal(input_bot_inline_message_id->dc_id_);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_editInlineBotMessage(
flags, false /*ignored*/, std::move(input_bot_inline_message_id), text,
std::move(input_media), std::move(reply_markup), std::move(entities))),
dc_id));
send_query(G()->net_query_creator().create_guest_dc(
create_storer(telegram_api::messages_editInlineBotMessage(
flags, false /*ignored*/, std::move(input_bot_inline_message_id), text, std::move(input_media),
std::move(reply_markup), std::move(entities))),
dc_id));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2657,7 +2657,7 @@ class SetInlineGameScoreQuery : public Td::ResultHandler {
LOG(INFO) << "Set inline game score to " << score;
auto dc_id = DcId::internal(input_bot_inline_message_id->dc_id_);
send_query(G()->net_query_creator().create(
send_query(G()->net_query_creator().create_guest_dc(
create_storer(telegram_api::messages_setInlineGameScore(flags, false /*ignored*/, false /*ignored*/,
std::move(input_bot_inline_message_id),
std::move(input_user), score)),
@ -2737,9 +2737,10 @@ class GetInlineGameHighScoresQuery : public Td::ResultHandler {
random_id_ = random_id;
auto dc_id = DcId::internal(input_bot_inline_message_id->dc_id_);
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getInlineGameHighScores(
std::move(input_bot_inline_message_id), std::move(input_user))),
dc_id));
send_query(
G()->net_query_creator().create_guest_dc(create_storer(telegram_api::messages_getInlineGameHighScores(
std::move(input_bot_inline_message_id), std::move(input_user))),
dc_id));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -496,8 +496,8 @@ class GetBankCardInfoQuery : public Td::ResultHandler {
}
void send(const string &bank_card_number) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::payments_getBankCardData(bank_card_number)),
G()->get_webfile_dc_id()));
send_query(G()->net_query_creator().create_guest_dc(
create_storer(telegram_api::payments_getBankCardData(bank_card_number)), G()->get_webfile_dc_id()));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -13,8 +13,8 @@
namespace td {
NetQueryCreator::Ptr NetQueryCreator::create(uint64 id, const Storer &storer, DcId dc_id, NetQuery::Type type,
NetQuery::AuthFlag auth_flag) {
NetQueryPtr NetQueryCreator::create(uint64 id, const Storer &storer, DcId dc_id, NetQuery::Type type,
NetQuery::AuthFlag auth_flag) {
BufferSlice slice(storer.size());
auto real_size = storer.store(slice.as_slice().ubegin());
LOG_CHECK(real_size == slice.size()) << real_size << " " << slice.size() << " "

View File

@ -6,6 +6,8 @@
//
#pragma once
#include "td/mtproto/utils.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/UniqueId.h"
@ -18,9 +20,6 @@ namespace td {
class NetQueryCreator {
public:
using Ptr = NetQueryPtr;
using Ref = NetQueryRef;
NetQueryCreator() {
object_pool_.set_check_empty(true);
}
@ -29,20 +28,28 @@ class NetQueryCreator {
object_pool_.set_check_empty(false);
}
Ptr create_update(BufferSlice &&buffer) {
NetQueryPtr create_update(BufferSlice &&buffer) {
return object_pool_.create(NetQuery::State::OK, 0, BufferSlice(), std::move(buffer), DcId::main(),
NetQuery::Type::Common, NetQuery::AuthFlag::On, NetQuery::GzipFlag::Off, 0);
}
Ptr create(const Storer &storer, DcId dc_id = DcId::main(), NetQuery::Type type = NetQuery::Type::Common) {
NetQueryPtr create(const Storer &storer) {
return create(UniqueId::next(), storer, DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::On);
}
NetQueryPtr create(const Storer &storer, DcId dc_id, NetQuery::Type type) {
return create(UniqueId::next(), storer, dc_id, type, NetQuery::AuthFlag::On);
}
Ptr create_unauth(const Storer &storer, DcId dc_id = DcId::main()) {
NetQueryPtr create_guest_dc(const Storer &storer, DcId dc_id) {
return create(UniqueId::next(), storer, dc_id, NetQuery::Type::Common, NetQuery::AuthFlag::On);
}
NetQueryPtr create_unauth(const Storer &storer, DcId dc_id = DcId::main()) {
return create(UniqueId::next(), storer, dc_id, NetQuery::Type::Common, NetQuery::AuthFlag::Off);
}
Ptr create(uint64 id, const Storer &storer, DcId dc_id, NetQuery::Type type, NetQuery::AuthFlag auth_flag);
NetQueryPtr create(uint64 id, const Storer &storer, DcId dc_id, NetQuery::Type type, NetQuery::AuthFlag auth_flag);
private:
ObjectPool<NetQuery> object_pool_;