Add tz_offset support.

GitOrigin-RevId: 4b3a1b1d214bf163ce6a72901726fde4243adb50
This commit is contained in:
levlam 2020-04-09 00:09:55 +03:00
parent 54279d23cd
commit d83a85038f
2 changed files with 28 additions and 5 deletions

View File

@ -48,6 +48,7 @@
#include "td/utils/base64.h"
#include "td/utils/buffer.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
@ -2754,7 +2755,8 @@ class GetBroadcastStatsQuery : public Td::ResultHandler {
flags |= telegram_api::stats_getBroadcastStats::DARK_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::stats_getBroadcastStats(flags, false /*ignored*/, std::move(input_channel), 0), dc_id));
telegram_api::stats_getBroadcastStats(flags, false /*ignored*/, std::move(input_channel), Clocks::tz_offset()),
dc_id));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -8,10 +8,12 @@
#include "td/telegram/JsonValue.h"
#include "td/telegram/LanguagePackManager.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/Version.h"
#include "td/tl/tl_object_store.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/tl_helpers.h"
namespace td {
@ -37,7 +39,7 @@ class HeaderStorer {
if (have_proxy) {
flags |= 1 << 0;
}
if (!options.parameters.empty()) {
if (!is_anonymous) {
flags |= 1 << 1;
}
if (options.is_emulator) {
@ -72,10 +74,29 @@ class HeaderStorer {
store(Slice(options.proxy.server()), storer);
store(options.proxy.port(), storer);
}
if (!options.parameters.empty()) {
auto parameters_copy = options.parameters;
auto json_value = get_input_json_value(parameters_copy).move_as_ok();
if (!is_anonymous) {
telegram_api::object_ptr<telegram_api::JSONValue> json_value;
if (options.parameters.empty()) {
json_value = make_tl_object<telegram_api::jsonObject>(vector<tl_object_ptr<telegram_api::jsonObjectValue>>());
} else {
auto parameters_copy = options.parameters;
json_value = get_input_json_value(parameters_copy).move_as_ok();
}
CHECK(json_value != nullptr);
if (json_value->get_id() == telegram_api::jsonObject::ID) {
auto &values = static_cast<telegram_api::jsonObject *>(json_value.get())->value_;
bool has_tz_offset = false;
for (auto &value : values) {
if (value->key_ == "tz_offset") {
has_tz_offset = true;
break;
}
}
if (!has_tz_offset) {
values.push_back(make_tl_object<telegram_api::jsonObjectValue>(
"tz_offset", make_tl_object<telegram_api::jsonNumber>(Clocks::tz_offset())));
}
}
TlStoreBoxedUnknown<TlStoreObject>::store(json_value, storer);
}
}