Add utc_time_offset option.

This commit is contained in:
levlam 2021-11-01 22:32:49 +03:00
parent 0c1e268706
commit 88d7b284b4
5 changed files with 14 additions and 12 deletions

View File

@ -822,8 +822,8 @@ messagePositions total_count:int32 positions:vector<messagePosition> = MessagePo
//@description Contains information about found messages sent in a specific day @total_count Total number of found messages sent in the day @message First message sent in the day
messageCalendarDay total_count:int32 message:message = MessageCalendarDay;
//@description Contains information about found messages, splitted by days @total_count Total number of found messages @utc_time_offset UTC time offset in seconds, used to split messages by days @days Information about messages sent
messageCalendar total_count:int32 utc_time_offset:int32 days:vector<messageCalendarDay> = MessageCalendar;
//@description Contains information about found messages, splitted by days according to GetOption("utc_time_offset") @total_count Total number of found messages @days Information about messages sent
messageCalendar total_count:int32 days:vector<messageCalendarDay> = MessageCalendar;
//@description Describes a sponsored message @id Unique sponsored message identifier @sponsor_chat_id Chat identifier

View File

@ -67,7 +67,6 @@
#include "td/utils/format.h"
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/Random.h"
#include "td/utils/Slice.h"
#include "td/utils/SliceBuilder.h"
@ -9811,7 +9810,7 @@ void MessagesManager::on_get_message_search_result_calendar(
days.push_back(td_api::make_object<td_api::messageCalendarDay>(
period->count_, get_message_object(dialog_id, m, "on_get_message_search_result_calendar")));
}
it->second = td_api::make_object<td_api::messageCalendar>(total_count, Clocks::tz_offset(), std::move(days));
it->second = td_api::make_object<td_api::messageCalendar>(total_count, std::move(days));
promise.set_value(Unit());
}
@ -21540,7 +21539,7 @@ td_api::object_ptr<td_api::messageCalendar> MessagesManager::get_dialog_message_
db_query.dialog_id = dialog_id;
db_query.filter = filter;
db_query.from_message_id = fixed_from_message_id;
db_query.tz_offset = Clocks::tz_offset();
db_query.tz_offset = static_cast<int32>(G()->shared_config().get_option_integer("utc_time_offset"));
G()->td_db()->get_messages_db_async()->get_dialog_message_calendar(db_query, std::move(new_promise));
return {};
}
@ -21619,7 +21618,7 @@ void MessagesManager::on_get_message_calendar_from_database(int64 random_id, Dia
days.push_back(td_api::make_object<td_api::messageCalendarDay>(
period.second, get_message_object(dialog_id, m, "on_get_message_calendar_from_database")));
}
it->second = td_api::make_object<td_api::messageCalendar>(total_count, Clocks::tz_offset(), std::move(days));
it->second = td_api::make_object<td_api::messageCalendar>(total_count, std::move(days));
}
promise.set_value(Unit());
}

View File

@ -130,6 +130,7 @@
#include "td/utils/MimeType.h"
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/port/IPAddress.h"
#include "td/utils/port/path.h"
#include "td/utils/port/SocketFd.h"
@ -3867,6 +3868,7 @@ Status Td::init(DbKey key) {
options_.language_pack = G()->shared_config().get_option_string("localization_target");
options_.language_code = G()->shared_config().get_option_string("language_pack_id");
options_.parameters = G()->shared_config().get_option_string("connection_parameters");
options_.tz_offset = static_cast<int32>(G()->shared_config().get_option_integer("utc_time_offset"));
options_.is_emulator = G()->shared_config().get_option_boolean("is_emulator");
// options_.proxy = Proxy();
G()->set_mtproto_header(make_unique<MtprotoHeader>(options_));
@ -4023,6 +4025,7 @@ void Td::init_options_and_network() {
if (!G()->shared_config().have_option("suggested_video_note_audio_bitrate")) {
G()->shared_config().set_option_integer("suggested_video_note_audio_bitrate", 64);
}
G()->shared_config().set_option_integer("utc_time_offset", Clocks::tz_offset());
init_connection_creator();
@ -4463,9 +4466,9 @@ Status Td::set_parameters(td_api::object_ptr<td_api::tdlibParameters> parameters
options_.application_version += ", TDLib ";
options_.application_version += TDLIB_VERSION;
}
options_.language_pack = "";
options_.language_code = "";
options_.parameters = "";
options_.language_pack = string();
options_.language_code = string();
options_.parameters = string();
options_.is_emulator = false;
options_.proxy = Proxy();

View File

@ -13,7 +13,6 @@
#include "td/tl/tl_object_store.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/tl_helpers.h"
namespace td {
@ -89,12 +88,12 @@ class HeaderStorer {
for (auto &value : values) {
if (value->key_ == "tz_offset") {
has_tz_offset = true;
break;
value->value_ = make_tl_object<telegram_api::jsonNumber>(options.tz_offset);
}
}
if (!has_tz_offset) {
values.push_back(make_tl_object<telegram_api::jsonObjectValue>(
"tz_offset", make_tl_object<telegram_api::jsonNumber>(Clocks::tz_offset())));
"tz_offset", make_tl_object<telegram_api::jsonNumber>(options.tz_offset)));
}
}
TlStoreBoxedUnknown<TlStoreObject>::store(json_value, storer);

View File

@ -24,6 +24,7 @@ class MtprotoHeader {
string language_pack;
string language_code;
string parameters;
int32 tz_offset = 0;
bool is_emulator = false;
Proxy proxy;
};