Use OptionManager directly if possible.
This commit is contained in:
parent
fef6ef3c2a
commit
04b98aa385
@ -16,6 +16,7 @@
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/PhotoFormat.h"
|
||||
#include "td/telegram/secret_api.h"
|
||||
#include "td/telegram/Td.h"
|
||||
@ -407,11 +408,11 @@ void AnimationsManager::on_update_animation_search_emojis() {
|
||||
return;
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
G()->set_option_empty("animation_search_emojis");
|
||||
td_->option_manager_->set_option_empty("animation_search_emojis");
|
||||
return;
|
||||
}
|
||||
|
||||
auto animation_search_emojis = G()->get_option_string("animation_search_emojis");
|
||||
auto animation_search_emojis = td_->option_manager_->get_option_string("animation_search_emojis");
|
||||
is_animation_search_emojis_inited_ = true;
|
||||
if (animation_search_emojis_ == animation_search_emojis) {
|
||||
return;
|
||||
@ -426,11 +427,11 @@ void AnimationsManager::on_update_animation_search_provider() {
|
||||
return;
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
G()->set_option_empty("animation_search_provider");
|
||||
td_->option_manager_->set_option_empty("animation_search_provider");
|
||||
return;
|
||||
}
|
||||
|
||||
string animation_search_provider = G()->get_option_string("animation_search_provider");
|
||||
string animation_search_provider = td_->option_manager_->get_option_string("animation_search_provider");
|
||||
is_animation_search_provider_inited_ = true;
|
||||
if (animation_search_provider_ == animation_search_provider) {
|
||||
return;
|
||||
@ -441,7 +442,11 @@ void AnimationsManager::on_update_animation_search_provider() {
|
||||
}
|
||||
|
||||
void AnimationsManager::on_update_saved_animations_limit() {
|
||||
int32 saved_animations_limit = narrow_cast<int32>(G()->get_option_integer("saved_animations_limit", 200));
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
int32 saved_animations_limit =
|
||||
narrow_cast<int32>(td_->option_manager_->get_option_integer("saved_animations_limit", 200));
|
||||
if (saved_animations_limit != saved_animations_limit_) {
|
||||
if (saved_animations_limit > 0) {
|
||||
LOG(INFO) << "Update saved animations limit to " << saved_animations_limit;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/NewPasswordState.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/PasswordManager.h"
|
||||
#include "td/telegram/StateManager.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
@ -50,7 +51,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
|
||||
if (my_id.is_valid()) {
|
||||
// just in case
|
||||
LOG(INFO) << "Logged in as " << my_id;
|
||||
G()->set_option_integer("my_id", my_id.get());
|
||||
td_->option_manager_->set_option_integer("my_id", my_id.get());
|
||||
update_state(State::Ok);
|
||||
} else {
|
||||
LOG(ERROR) << "Restore unknown my_id";
|
||||
@ -700,7 +701,8 @@ void AuthManager::on_log_out_result(NetQueryPtr &result) {
|
||||
if (r_log_out.is_ok()) {
|
||||
auto logged_out = r_log_out.move_as_ok();
|
||||
if (!logged_out->future_auth_token_.empty()) {
|
||||
G()->set_option_string("authentication_token", base64url_encode(logged_out->future_auth_token_.as_slice()));
|
||||
td_->option_manager_->set_option_string("authentication_token",
|
||||
base64url_encode(logged_out->future_auth_token_.as_slice()));
|
||||
}
|
||||
} else {
|
||||
status = r_log_out.move_as_error();
|
||||
@ -794,7 +796,7 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
||||
}
|
||||
auto auth = telegram_api::move_object_as<telegram_api::auth_authorization>(auth_ptr);
|
||||
|
||||
G()->set_option_integer("authorization_date", G()->unix_time());
|
||||
td_->option_manager_->set_option_integer("authorization_date", G()->unix_time());
|
||||
if (was_check_bot_token_) {
|
||||
is_bot_ = true;
|
||||
G()->td_db()->get_binlog_pmc()->set("auth_is_bot", "true");
|
||||
@ -817,10 +819,10 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
|
||||
return;
|
||||
}
|
||||
if ((auth->flags_ & telegram_api::auth_authorization::TMP_SESSIONS_MASK) != 0) {
|
||||
G()->set_option_integer("session_count", auth->tmp_sessions_);
|
||||
td_->option_manager_->set_option_integer("session_count", auth->tmp_sessions_);
|
||||
}
|
||||
if (auth->setup_password_required_ && auth->otherwise_relogin_days_ > 0) {
|
||||
G()->set_option_integer("otherwise_relogin_days", auth->otherwise_relogin_days_);
|
||||
td_->option_manager_->set_option_integer("otherwise_relogin_days", auth->otherwise_relogin_days_);
|
||||
}
|
||||
td_->attach_menu_manager_->init();
|
||||
td_->messages_manager_->on_authorization_success();
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/PasswordManager.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/Photo.hpp"
|
||||
@ -3332,11 +3333,11 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
|
||||
|
||||
my_id_ = load_my_id();
|
||||
|
||||
G()->set_option_integer("telegram_service_notifications_chat_id",
|
||||
td_->option_manager_->set_option_integer("telegram_service_notifications_chat_id",
|
||||
DialogId(get_service_notifications_user_id()).get());
|
||||
G()->set_option_integer("replies_bot_chat_id", DialogId(get_replies_bot_user_id()).get());
|
||||
G()->set_option_integer("group_anonymous_bot_user_id", get_anonymous_bot_user_id().get());
|
||||
G()->set_option_integer("channel_bot_user_id", get_channel_bot_user_id().get());
|
||||
td_->option_manager_->set_option_integer("replies_bot_chat_id", DialogId(get_replies_bot_user_id()).get());
|
||||
td_->option_manager_->set_option_integer("group_anonymous_bot_user_id", get_anonymous_bot_user_id().get());
|
||||
td_->option_manager_->set_option_integer("channel_bot_user_id", get_channel_bot_user_id().get());
|
||||
|
||||
if (G()->parameters().use_chat_info_db) {
|
||||
auto next_contacts_sync_date_string = G()->td_db()->get_binlog_pmc()->get("next_contacts_sync_date");
|
||||
@ -5098,7 +5099,7 @@ void ContactsManager::set_my_id(UserId my_id) {
|
||||
if (my_old_id != my_id) {
|
||||
my_id_ = my_id;
|
||||
G()->td_db()->get_binlog_pmc()->set("my_id", to_string(my_id.get()));
|
||||
G()->set_option_integer("my_id", my_id_.get());
|
||||
td_->option_manager_->set_option_integer("my_id", my_id_.get());
|
||||
G()->td_db()->get_binlog_pmc()->force_sync(Promise<Unit>());
|
||||
}
|
||||
}
|
||||
@ -6036,7 +6037,7 @@ void ContactsManager::set_location(const Location &location, Promise<Unit> &&pro
|
||||
}
|
||||
|
||||
void ContactsManager::set_location_visibility() {
|
||||
bool is_location_visible = G()->get_option_boolean("is_location_visible");
|
||||
bool is_location_visible = td_->option_manager_->get_option_boolean("is_location_visible");
|
||||
auto pending_location_visibility_expire_date = is_location_visible ? std::numeric_limits<int32>::max() : 0;
|
||||
if (pending_location_visibility_expire_date_ == -1 &&
|
||||
pending_location_visibility_expire_date == location_visibility_expire_date_) {
|
||||
@ -6259,7 +6260,7 @@ void ContactsManager::set_location_visibility_expire_date(int32 expire_date) {
|
||||
void ContactsManager::update_is_location_visible() {
|
||||
auto expire_date = pending_location_visibility_expire_date_ != -1 ? pending_location_visibility_expire_date_
|
||||
: location_visibility_expire_date_;
|
||||
G()->set_option_boolean("is_location_visible", expire_date != 0);
|
||||
td_->option_manager_->set_option_boolean("is_location_visible", expire_date != 0);
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_bot_commands(DialogId dialog_id, UserId bot_user_id,
|
||||
@ -6489,7 +6490,7 @@ void ContactsManager::set_name(const string &first_name, const string &last_name
|
||||
}
|
||||
|
||||
void ContactsManager::set_bio(const string &bio, Promise<Unit> &&promise) {
|
||||
auto max_bio_length = static_cast<size_t>(G()->get_option_integer("bio_length_max"));
|
||||
auto max_bio_length = static_cast<size_t>(td_->option_manager_->get_option_integer("bio_length_max"));
|
||||
auto new_bio = strip_empty_characters(bio, max_bio_length);
|
||||
for (auto &c : new_bio) {
|
||||
if (c == '\n') {
|
||||
@ -8611,7 +8612,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
|
||||
if (flags & USER_FLAG_IS_ME) {
|
||||
set_my_id(user_id);
|
||||
if (!is_bot) {
|
||||
G()->set_option_string("my_phone_number", user->phone_);
|
||||
td_->option_manager_->set_option_string("my_phone_number", user->phone_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10190,8 +10191,8 @@ void ContactsManager::for_each_secret_chat_with_user(UserId user_id, const std::
|
||||
void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, bool from_database) {
|
||||
CHECK(u != nullptr);
|
||||
if (user_id == get_my_id()) {
|
||||
if (G()->get_option_boolean("is_premium") != u->is_premium) {
|
||||
G()->set_option_boolean("is_premium", u->is_premium);
|
||||
if (td_->option_manager_->get_option_boolean("is_premium") != u->is_premium) {
|
||||
td_->option_manager_->set_option_boolean("is_premium", u->is_premium);
|
||||
send_closure(td_->config_manager_, &ConfigManager::request_config, true);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "td/telegram/MessageSender.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/Payments.h"
|
||||
#include "td/telegram/Payments.hpp"
|
||||
#include "td/telegram/Photo.h"
|
||||
@ -4670,7 +4671,7 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
}
|
||||
case MessageContentType::Sticker: {
|
||||
auto result = make_unique<MessageSticker>(*static_cast<const MessageSticker *>(content));
|
||||
result->is_premium = G()->get_option_boolean("is_premium");
|
||||
result->is_premium = td->option_manager_->get_option_boolean("is_premium");
|
||||
if (td->stickers_manager_->has_input_media(result->file_id, to_secret)) {
|
||||
return std::move(result);
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/SecretChatLayer.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
@ -4304,7 +4304,7 @@ Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
|
||||
|
||||
TRY_RESULT(entities, get_message_entities(td->contacts_manager_.get(), std::move(text->entities_)));
|
||||
auto need_skip_bot_commands = need_always_skip_bot_commands(td->contacts_manager_.get(), dialog_id, is_bot);
|
||||
bool parse_markdown = G()->get_option_boolean("always_parse_markdown");
|
||||
bool parse_markdown = td->option_manager_->get_option_boolean("always_parse_markdown");
|
||||
TRY_STATUS(fix_formatted_text(text->text_, entities, allow_empty, parse_markdown, need_skip_bot_commands,
|
||||
is_bot || skip_media_timestamps || parse_markdown, for_draft));
|
||||
|
||||
@ -4494,7 +4494,8 @@ void remove_unallowed_entities(const Td *td, FormattedText &text, DialogId dialo
|
||||
remove_intersecting_entities(text.entities);
|
||||
}
|
||||
}
|
||||
if (!G()->get_option_boolean("is_premium") && dialog_id != DialogId(td->contacts_manager_->get_my_id())) {
|
||||
if (!td->option_manager_->get_option_boolean("is_premium") &&
|
||||
dialog_id != DialogId(td->contacts_manager_->get_my_id())) {
|
||||
remove_premium_custom_emoji_entities(td, text.entities, false);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessageSender.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
@ -240,13 +241,13 @@ class SetDefaultReactionQuery final : public Td::ResultHandler {
|
||||
return on_error(Status::Error(400, "Receive false"));
|
||||
}
|
||||
|
||||
auto default_reaction = G()->get_option_string("default_reaction", "-");
|
||||
auto default_reaction = td_->option_manager_->get_option_string("default_reaction", "-");
|
||||
LOG(INFO) << "Successfully set reaction " << reaction_ << " as default, current default is " << default_reaction;
|
||||
|
||||
if (default_reaction != reaction_) {
|
||||
send_set_default_reaction_query(td_);
|
||||
} else {
|
||||
G()->set_option_empty("default_reaction_needs_sync");
|
||||
td_->option_manager_->set_option_empty("default_reaction_needs_sync");
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,7 +257,7 @@ class SetDefaultReactionQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
LOG(INFO) << "Failed to set default reaction: " << status;
|
||||
G()->set_option_empty("default_reaction_needs_sync");
|
||||
td_->option_manager_->set_option_empty("default_reaction_needs_sync");
|
||||
send_closure(G()->config_manager(), &ConfigManager::reget_app_config, Promise<Unit>());
|
||||
}
|
||||
};
|
||||
@ -594,17 +595,17 @@ void set_default_reaction(Td *td, string reaction, Promise<Unit> &&promise) {
|
||||
return promise.set_error(Status::Error(400, "Can't set incative reaction as default"));
|
||||
}
|
||||
|
||||
if (G()->get_option_string("default_reaction", "-") != reaction) {
|
||||
G()->set_option_string("default_reaction", reaction);
|
||||
if (!G()->get_option_boolean("default_reaction_needs_sync")) {
|
||||
G()->set_option_boolean("default_reaction_needs_sync", true);
|
||||
if (td->option_manager_->get_option_string("default_reaction", "-") != reaction) {
|
||||
td->option_manager_->set_option_string("default_reaction", reaction);
|
||||
if (!td->option_manager_->get_option_boolean("default_reaction_needs_sync")) {
|
||||
td->option_manager_->set_option_boolean("default_reaction_needs_sync", true);
|
||||
}
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void send_set_default_reaction_query(Td *td) {
|
||||
td->create_handler<SetDefaultReactionQuery>()->send(G()->get_option_string("default_reaction"));
|
||||
td->create_handler<SetDefaultReactionQuery>()->send(td->option_manager_->get_option_string("default_reaction"));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "td/telegram/NotificationSettingsManager.h"
|
||||
#include "td/telegram/NotificationSound.h"
|
||||
#include "td/telegram/NotificationType.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/PollId.h"
|
||||
#include "td/telegram/PublicDialogType.h"
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
@ -3211,7 +3212,7 @@ class SendMessageQuery final : public Td::ResultHandler {
|
||||
std::move(reply_markup), std::move(entities), schedule_date, std::move(as_input_peer)),
|
||||
{{dialog_id, MessageContentType::Text},
|
||||
{dialog_id, is_copy ? MessageContentType::Photo : MessageContentType::Text}});
|
||||
if (G()->get_option_boolean("use_quick_ack")) {
|
||||
if (td_->option_manager_->get_option_boolean("use_quick_ack")) {
|
||||
query->quick_ack_promise_ = PromiseCreator::lambda([random_id](Result<Unit> result) {
|
||||
if (result.is_ok()) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::on_send_message_get_quick_ack, random_id);
|
||||
@ -3282,7 +3283,7 @@ class StartBotQuery final : public Td::ResultHandler {
|
||||
auto query = G()->net_query_creator().create(
|
||||
telegram_api::messages_startBot(std::move(bot_input_user), std::move(input_peer), random_id, parameter),
|
||||
{{dialog_id, MessageContentType::Text}, {dialog_id, MessageContentType::Photo}});
|
||||
if (G()->get_option_boolean("use_quick_ack")) {
|
||||
if (td_->option_manager_->get_option_boolean("use_quick_ack")) {
|
||||
query->quick_ack_promise_ = PromiseCreator::lambda([random_id](Result<Unit> result) {
|
||||
if (result.is_ok()) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::on_send_message_get_quick_ack, random_id);
|
||||
@ -3524,7 +3525,7 @@ class SendMediaQuery final : public Td::ResultHandler {
|
||||
reply_to_message_id.get_server_message_id().get(), std::move(input_media), text, random_id,
|
||||
std::move(reply_markup), std::move(entities), schedule_date, std::move(as_input_peer)),
|
||||
{{dialog_id, content_type}, {dialog_id, is_copy ? MessageContentType::Text : content_type}});
|
||||
if (G()->get_option_boolean("use_quick_ack") && was_uploaded_) {
|
||||
if (td_->option_manager_->get_option_boolean("use_quick_ack") && was_uploaded_) {
|
||||
query->quick_ack_promise_ = PromiseCreator::lambda([random_id](Result<Unit> result) {
|
||||
if (result.is_ok()) {
|
||||
send_closure(G()->messages_manager(), &MessagesManager::on_send_message_get_quick_ack, random_id);
|
||||
@ -3888,7 +3889,7 @@ class ForwardMessagesQuery final : public Td::ResultHandler {
|
||||
false /*ignored*/, std::move(from_input_peer), MessagesManager::get_server_message_ids(message_ids),
|
||||
std::move(random_ids), std::move(to_input_peer), schedule_date, std::move(as_input_peer)),
|
||||
{{to_dialog_id, MessageContentType::Text}, {to_dialog_id, MessageContentType::Photo}});
|
||||
if (G()->get_option_boolean("use_quick_ack")) {
|
||||
if (td_->option_manager_->get_option_boolean("use_quick_ack")) {
|
||||
query->quick_ack_promise_ = PromiseCreator::lambda([random_ids = random_ids_](Result<Unit> result) {
|
||||
if (result.is_ok()) {
|
||||
for (auto random_id : random_ids) {
|
||||
@ -10695,8 +10696,9 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
|
||||
auto content_type = m->content->get_type();
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User: {
|
||||
bool can_revoke_incoming = G()->get_option_boolean("revoke_pm_inbox", true);
|
||||
int64 revoke_time_limit = G()->get_option_integer("revoke_pm_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
|
||||
bool can_revoke_incoming = td_->option_manager_->get_option_boolean("revoke_pm_inbox", true);
|
||||
int64 revoke_time_limit =
|
||||
td_->option_manager_->get_option_integer("revoke_pm_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
|
||||
|
||||
if (G()->unix_time_cached() - m->date < 86400 && content_type == MessageContentType::Dice) {
|
||||
return false;
|
||||
@ -10708,7 +10710,8 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
|
||||
case DialogType::Chat: {
|
||||
bool is_appointed_administrator =
|
||||
td_->contacts_manager_->is_appointed_chat_administrator(dialog_id.get_chat_id());
|
||||
int64 revoke_time_limit = G()->get_option_integer("revoke_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
|
||||
int64 revoke_time_limit =
|
||||
td_->option_manager_->get_option_integer("revoke_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
|
||||
|
||||
return ((m->is_outgoing && !is_service_message_content(content_type)) || is_appointed_administrator) &&
|
||||
G()->unix_time_cached() - m->date <= revoke_time_limit;
|
||||
@ -11046,7 +11049,7 @@ MessagesManager::CanDeleteDialog MessagesManager::can_delete_dialog(const Dialog
|
||||
td_->contacts_manager_->is_user_bot(d->dialog_id.get_user_id())) {
|
||||
return {true, false};
|
||||
}
|
||||
return {true, G()->get_option_boolean("revoke_pm_inbox", true)};
|
||||
return {true, td_->option_manager_->get_option_boolean("revoke_pm_inbox", true)};
|
||||
case DialogType::Chat:
|
||||
// chats can be deleted only for self and can be deleted for everyone by their creator
|
||||
return {true, td_->contacts_manager_->get_chat_status(d->dialog_id.get_chat_id()).is_creator()};
|
||||
@ -11584,7 +11587,7 @@ int32 MessagesManager::get_unload_dialog_delay() const {
|
||||
|
||||
CHECK(is_message_unload_enabled());
|
||||
auto default_unload_delay = td_->auth_manager_->is_bot() ? DIALOG_UNLOAD_BOT_DELAY : DIALOG_UNLOAD_DELAY;
|
||||
return narrow_cast<int32>(G()->get_option_integer("message_unload_delay", default_unload_delay));
|
||||
return narrow_cast<int32>(td_->option_manager_->get_option_integer("message_unload_delay", default_unload_delay));
|
||||
}
|
||||
|
||||
int32 MessagesManager::get_next_unload_dialog_delay() const {
|
||||
@ -13180,7 +13183,7 @@ void MessagesManager::init() {
|
||||
if (is_authorized && td_->auth_manager_->is_bot()) {
|
||||
disable_get_dialog_filter_ = true;
|
||||
}
|
||||
authorization_date_ = G()->get_option_integer("authorization_date");
|
||||
authorization_date_ = td_->option_manager_->get_option_integer("authorization_date");
|
||||
|
||||
if (was_authorized_user) {
|
||||
auto dialog_filters = G()->td_db()->get_binlog_pmc()->get("dialog_filters");
|
||||
@ -13189,7 +13192,7 @@ void MessagesManager::init() {
|
||||
if (log_event_parse(log_event, dialog_filters).is_ok()) {
|
||||
server_main_dialog_list_position_ = log_event.server_main_dialog_list_position;
|
||||
main_dialog_list_position_ = log_event.main_dialog_list_position;
|
||||
if (!G()->get_option_boolean("is_premium") &&
|
||||
if (!td_->option_manager_->get_option_boolean("is_premium") &&
|
||||
(server_main_dialog_list_position_ != 0 || main_dialog_list_position_ != 0)) {
|
||||
LOG(INFO) << "Ignore main chat list position " << server_main_dialog_list_position_ << '/'
|
||||
<< main_dialog_list_position_;
|
||||
@ -13581,7 +13584,7 @@ void MessagesManager::init() {
|
||||
|
||||
void MessagesManager::on_authorization_success() {
|
||||
CHECK(td_->auth_manager_->is_authorized());
|
||||
authorization_date_ = G()->get_option_integer("authorization_date");
|
||||
authorization_date_ = td_->option_manager_->get_option_integer("authorization_date");
|
||||
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
disable_get_dialog_filter_ = true;
|
||||
@ -17257,7 +17260,7 @@ void MessagesManager::on_get_dialog_filters(Result<vector<tl_object_ptr<telegram
|
||||
LOG(ERROR) << "Receive no dialogFilterDefault";
|
||||
server_main_dialog_list_position = 0;
|
||||
}
|
||||
if (server_main_dialog_list_position != 0 && !G()->get_option_boolean("is_premium")) {
|
||||
if (server_main_dialog_list_position != 0 && !td_->option_manager_->get_option_boolean("is_premium")) {
|
||||
LOG(INFO) << "Ignore server main chat list position " << server_main_dialog_list_position;
|
||||
server_main_dialog_list_position = 0;
|
||||
}
|
||||
@ -18292,7 +18295,8 @@ Status MessagesManager::can_get_message_viewers(DialogId dialog_id, const Messag
|
||||
if (!m->is_outgoing) {
|
||||
return Status::Error(400, "Can't get viewers of incoming messages");
|
||||
}
|
||||
if (G()->unix_time() - m->date > G()->get_option_integer("chat_read_mark_expire_period", 7 * 86400)) {
|
||||
if (G()->unix_time() - m->date >
|
||||
td_->option_manager_->get_option_integer("chat_read_mark_expire_period", 7 * 86400)) {
|
||||
return Status::Error(400, "Message is too old");
|
||||
}
|
||||
|
||||
@ -18325,7 +18329,7 @@ Status MessagesManager::can_get_message_viewers(DialogId dialog_id, const Messag
|
||||
if (participant_count == 0) {
|
||||
return Status::Error(400, "Chat is empty or have unknown number of members");
|
||||
}
|
||||
if (participant_count > G()->get_option_integer("chat_read_mark_size_threshold", 100)) {
|
||||
if (participant_count > td_->option_manager_->get_option_integer("chat_read_mark_size_threshold", 100)) {
|
||||
return Status::Error(400, "Chat is too big");
|
||||
}
|
||||
|
||||
@ -18743,7 +18747,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
||||
}
|
||||
|
||||
SliceBuilder sb;
|
||||
sb << G()->get_option_string("t_me_url", "https://t.me/");
|
||||
sb << td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||
|
||||
if (for_comment) {
|
||||
auto *top_m = get_message_force(d, m->top_thread_message_id, "get_public_message_link");
|
||||
@ -19124,8 +19128,8 @@ Result<unique_ptr<DialogFilter>> MessagesManager::create_dialog_filter(DialogFil
|
||||
void MessagesManager::create_dialog_filter(td_api::object_ptr<td_api::chatFilter> filter,
|
||||
Promise<td_api::object_ptr<td_api::chatFilterInfo>> &&promise) {
|
||||
CHECK(!td_->auth_manager_->is_bot());
|
||||
auto max_dialog_filters =
|
||||
clamp(G()->get_option_integer("chat_filter_count_max"), static_cast<int64>(0), static_cast<int64>(100));
|
||||
auto max_dialog_filters = clamp(td_->option_manager_->get_option_integer("chat_filter_count_max"),
|
||||
static_cast<int64>(0), static_cast<int64>(100));
|
||||
if (dialog_filters_.size() >= narrow_cast<size_t>(max_dialog_filters)) {
|
||||
return promise.set_error(Status::Error(400, "The maximum number of chat folders exceeded"));
|
||||
}
|
||||
@ -19296,7 +19300,7 @@ void MessagesManager::reorder_dialog_filters(vector<DialogFilterId> dialog_filte
|
||||
if (main_dialog_list_position < 0 || main_dialog_list_position > static_cast<int32>(dialog_filters_.size())) {
|
||||
return promise.set_error(Status::Error(400, "Invalid main chat list position specified"));
|
||||
}
|
||||
if (!G()->get_option_boolean("is_premium")) {
|
||||
if (!td_->option_manager_->get_option_boolean("is_premium")) {
|
||||
main_dialog_list_position = 0;
|
||||
}
|
||||
|
||||
@ -19867,7 +19871,7 @@ void MessagesManager::clear_all_draft_messages(bool exclude_secret_chats, Promis
|
||||
td_->create_handler<ClearAllDraftsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
int32 MessagesManager::get_pinned_dialogs_limit(DialogListId dialog_list_id) {
|
||||
int32 MessagesManager::get_pinned_dialogs_limit(DialogListId dialog_list_id) const {
|
||||
if (dialog_list_id.is_filter()) {
|
||||
return DialogFilter::get_max_filter_dialogs();
|
||||
}
|
||||
@ -19878,9 +19882,9 @@ int32 MessagesManager::get_pinned_dialogs_limit(DialogListId dialog_list_id) {
|
||||
key = Slice("pinned_archived_chat_count_max");
|
||||
default_limit = 100;
|
||||
}
|
||||
int32 limit = clamp(narrow_cast<int32>(G()->get_option_integer(key)), 0, 1000);
|
||||
int32 limit = clamp(narrow_cast<int32>(td_->option_manager_->get_option_integer(key)), 0, 1000);
|
||||
if (limit <= 0) {
|
||||
if (G()->get_option_boolean("is_premium")) {
|
||||
if (td_->option_manager_->get_option_boolean("is_premium")) {
|
||||
default_limit *= 2;
|
||||
}
|
||||
return default_limit;
|
||||
@ -22229,7 +22233,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 = static_cast<int32>(G()->get_option_integer("utc_time_offset"));
|
||||
db_query.tz_offset = static_cast<int32>(td_->option_manager_->get_option_integer("utc_time_offset"));
|
||||
G()->td_db()->get_messages_db_async()->get_dialog_message_calendar(db_query, std::move(new_promise));
|
||||
return {};
|
||||
}
|
||||
@ -24331,8 +24335,8 @@ vector<AvailableReaction> MessagesManager::get_message_available_reactions(const
|
||||
|
||||
vector<AvailableReaction> result;
|
||||
if (can_use_reactions) {
|
||||
bool is_premium = G()->get_option_boolean("is_premium");
|
||||
int64 reactions_uniq_max = G()->get_option_integer("reactions_uniq_max", 11);
|
||||
bool is_premium = td_->option_manager_->get_option_boolean("is_premium");
|
||||
int64 reactions_uniq_max = td_->option_manager_->get_option_integer("reactions_uniq_max", 11);
|
||||
bool can_add_new_reactions =
|
||||
m->reactions == nullptr || static_cast<int64>(m->reactions->reactions_.size()) < reactions_uniq_max;
|
||||
// can add only active available reactions or remove previously set reaction
|
||||
@ -24885,7 +24889,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
|
||||
m->is_copy = is_copy || m->forward_info != nullptr;
|
||||
|
||||
if (td_->auth_manager_->is_bot() || options.disable_notification ||
|
||||
G()->get_option_boolean("ignore_default_disable_notification")) {
|
||||
td_->option_manager_->get_option_boolean("ignore_default_disable_notification")) {
|
||||
m->disable_notification = options.disable_notification;
|
||||
} else {
|
||||
m->disable_notification = d->notification_settings.silent_send_message;
|
||||
@ -25030,7 +25034,8 @@ MessageId MessagesManager::get_reply_to_message_id(Dialog *d, MessageId top_thre
|
||||
}
|
||||
|
||||
void MessagesManager::fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id,
|
||||
DialogId reply_in_dialog_id, MessageId &reply_to_message_id) {
|
||||
DialogId reply_in_dialog_id,
|
||||
MessageId &reply_to_message_id) const {
|
||||
if (!reply_to_message_id.is_valid()) {
|
||||
if (reply_to_message_id.is_valid_scheduled()) {
|
||||
CHECK(message_id.is_scheduled());
|
||||
@ -25495,7 +25500,7 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
|
||||
UserId(), copied_message->send_emoji);
|
||||
}
|
||||
|
||||
bool is_premium = G()->get_option_boolean("is_premium");
|
||||
bool is_premium = td_->option_manager_->get_option_boolean("is_premium");
|
||||
TRY_RESULT(content, get_input_message_content(dialog_id, std::move(input_message_content), td_, is_premium));
|
||||
|
||||
if (content.ttl < 0 || content.ttl > MAX_PRIVATE_MESSAGE_TTL) {
|
||||
@ -26654,11 +26659,11 @@ void MessagesManager::do_send_inline_query_result_message(DialogId dialog_id, Me
|
||||
random_id, query_id, result_id);
|
||||
}
|
||||
|
||||
bool MessagesManager::has_qts_messages(DialogId dialog_id) {
|
||||
bool MessagesManager::has_qts_messages(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
case DialogType::Chat:
|
||||
return G()->get_option_integer("session_count") > 1;
|
||||
return td_->option_manager_->get_option_integer("session_count") > 1;
|
||||
case DialogType::Channel:
|
||||
case DialogType::SecretChat:
|
||||
return false;
|
||||
@ -26757,7 +26762,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
|
||||
|
||||
if (has_edit_time_limit) {
|
||||
const int32 DEFAULT_EDIT_TIME_LIMIT = 2 * 86400;
|
||||
int64 edit_time_limit = G()->get_option_integer("edit_time_limit", DEFAULT_EDIT_TIME_LIMIT);
|
||||
int64 edit_time_limit = td_->option_manager_->get_option_integer("edit_time_limit", DEFAULT_EDIT_TIME_LIMIT);
|
||||
if (G()->unix_time_cached() - m->date - (is_editing ? 300 : 0) >= edit_time_limit) {
|
||||
return false;
|
||||
}
|
||||
@ -29262,7 +29267,7 @@ Result<MessagesManager::MessagePushNotificationInfo> MessagesManager::get_messag
|
||||
}
|
||||
|
||||
if (is_from_scheduled && dialog_id != get_my_dialog_id() &&
|
||||
G()->get_option_boolean("disable_sent_scheduled_message_notifications")) {
|
||||
td_->option_manager_->get_option_boolean("disable_sent_scheduled_message_notifications")) {
|
||||
return Status::Error("Ignore notification about sent scheduled message");
|
||||
}
|
||||
|
||||
@ -30125,7 +30130,7 @@ bool MessagesManager::is_message_notification_disabled(const Dialog *d, const Me
|
||||
return true;
|
||||
}
|
||||
if (m->is_from_scheduled && d->dialog_id != get_my_dialog_id() &&
|
||||
G()->get_option_boolean("disable_sent_scheduled_message_notifications")) {
|
||||
td_->option_manager_->get_option_boolean("disable_sent_scheduled_message_notifications")) {
|
||||
return true;
|
||||
}
|
||||
if (m->forward_info != nullptr && m->forward_info->is_imported) {
|
||||
@ -34695,7 +34700,7 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
||||
|
||||
if (dialog_type == DialogType::Channel && !message->contains_unread_mention) {
|
||||
auto channel_read_media_period =
|
||||
G()->get_option_integer("channels_read_media_period", (G()->is_test_dc() ? 300 : 7 * 86400));
|
||||
td_->option_manager_->get_option_integer("channels_read_media_period", (G()->is_test_dc() ? 300 : 7 * 86400));
|
||||
if (message->date < G()->unix_time_cached() - channel_read_media_period) {
|
||||
update_opened_message_content(message->content.get());
|
||||
}
|
||||
|
@ -1892,7 +1892,7 @@ class MessagesManager final : public Actor {
|
||||
|
||||
bool can_edit_message(DialogId dialog_id, const Message *m, bool is_editing, bool only_reply_markup = false) const;
|
||||
|
||||
static bool has_qts_messages(DialogId dialog_id);
|
||||
bool has_qts_messages(DialogId dialog_id) const;
|
||||
|
||||
bool can_report_dialog(DialogId dialog_id) const;
|
||||
|
||||
@ -1916,8 +1916,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
MessageId get_reply_to_message_id(Dialog *d, MessageId top_thread_message_id, MessageId message_id, bool for_draft);
|
||||
|
||||
static void fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id, DialogId reply_in_dialog_id,
|
||||
MessageId &reply_to_message_id);
|
||||
void fix_server_reply_to_message_id(DialogId dialog_id, MessageId message_id, DialogId reply_in_dialog_id,
|
||||
MessageId &reply_to_message_id) const;
|
||||
|
||||
bool can_set_game_score(DialogId dialog_id, const Message *m) const;
|
||||
|
||||
@ -2586,7 +2586,7 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void remove_dialog_newer_messages(Dialog *d, MessageId from_message_id, const char *source);
|
||||
|
||||
static int32 get_pinned_dialogs_limit(DialogListId dialog_list_id);
|
||||
int32 get_pinned_dialogs_limit(DialogListId dialog_list_id) const;
|
||||
|
||||
static vector<DialogId> remove_secret_chat_dialog_ids(vector<DialogId> dialog_ids);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/ConnectionCreator.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/Photo.hpp"
|
||||
#include "td/telegram/SecretChatId.h"
|
||||
@ -202,7 +203,8 @@ void NotificationManager::init() {
|
||||
return;
|
||||
}
|
||||
|
||||
disable_contact_registered_notifications_ = G()->get_option_boolean("disable_contact_registered_notifications");
|
||||
disable_contact_registered_notifications_ =
|
||||
td_->option_manager_->get_option_boolean("disable_contact_registered_notifications");
|
||||
auto sync_state = G()->td_db()->get_binlog_pmc()->get(get_is_contact_registered_notifications_synchronized_key());
|
||||
if (sync_state.empty()) {
|
||||
sync_state = "00";
|
||||
@ -2386,8 +2388,8 @@ void NotificationManager::on_notification_group_count_max_changed(bool send_upda
|
||||
return;
|
||||
}
|
||||
|
||||
auto new_max_notification_group_count =
|
||||
narrow_cast<int32>(G()->get_option_integer("notification_group_count_max", DEFAULT_GROUP_COUNT_MAX));
|
||||
auto new_max_notification_group_count = narrow_cast<int32>(
|
||||
td_->option_manager_->get_option_integer("notification_group_count_max", DEFAULT_GROUP_COUNT_MAX));
|
||||
CHECK(MIN_NOTIFICATION_GROUP_COUNT_MAX <= new_max_notification_group_count &&
|
||||
new_max_notification_group_count <= MAX_NOTIFICATION_GROUP_COUNT_MAX);
|
||||
|
||||
@ -2450,8 +2452,8 @@ void NotificationManager::on_notification_group_size_max_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto new_max_notification_group_size =
|
||||
narrow_cast<int32>(G()->get_option_integer("notification_group_size_max", DEFAULT_GROUP_SIZE_MAX));
|
||||
auto new_max_notification_group_size = narrow_cast<int32>(
|
||||
td_->option_manager_->get_option_integer("notification_group_size_max", DEFAULT_GROUP_SIZE_MAX));
|
||||
CHECK(MIN_NOTIFICATION_GROUP_SIZE_MAX <= new_max_notification_group_size &&
|
||||
new_max_notification_group_size <= MAX_NOTIFICATION_GROUP_SIZE_MAX);
|
||||
|
||||
@ -2533,8 +2535,8 @@ void NotificationManager::on_online_cloud_timeout_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
online_cloud_timeout_ms_ =
|
||||
narrow_cast<int32>(G()->get_option_integer("online_cloud_timeout_ms", DEFAULT_ONLINE_CLOUD_TIMEOUT_MS));
|
||||
online_cloud_timeout_ms_ = narrow_cast<int32>(
|
||||
td_->option_manager_->get_option_integer("online_cloud_timeout_ms", DEFAULT_ONLINE_CLOUD_TIMEOUT_MS));
|
||||
VLOG(notifications) << "Set online_cloud_timeout_ms to " << online_cloud_timeout_ms_;
|
||||
}
|
||||
|
||||
@ -2543,8 +2545,8 @@ void NotificationManager::on_notification_cloud_delay_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
notification_cloud_delay_ms_ =
|
||||
narrow_cast<int32>(G()->get_option_integer("notification_cloud_delay_ms", DEFAULT_ONLINE_CLOUD_DELAY_MS));
|
||||
notification_cloud_delay_ms_ = narrow_cast<int32>(
|
||||
td_->option_manager_->get_option_integer("notification_cloud_delay_ms", DEFAULT_ONLINE_CLOUD_DELAY_MS));
|
||||
VLOG(notifications) << "Set notification_cloud_delay_ms to " << notification_cloud_delay_ms_;
|
||||
}
|
||||
|
||||
@ -2553,8 +2555,8 @@ void NotificationManager::on_notification_default_delay_changed() {
|
||||
return;
|
||||
}
|
||||
|
||||
notification_default_delay_ms_ =
|
||||
narrow_cast<int32>(G()->get_option_integer("notification_default_delay_ms", DEFAULT_DEFAULT_DELAY_MS));
|
||||
notification_default_delay_ms_ = narrow_cast<int32>(
|
||||
td_->option_manager_->get_option_integer("notification_default_delay_ms", DEFAULT_DEFAULT_DELAY_MS));
|
||||
VLOG(notifications) << "Set notification_default_delay_ms to " << notification_default_delay_ms_;
|
||||
}
|
||||
|
||||
@ -2563,7 +2565,7 @@ void NotificationManager::on_disable_contact_registered_notifications_changed()
|
||||
return;
|
||||
}
|
||||
|
||||
auto is_disabled = G()->get_option_boolean("disable_contact_registered_notifications");
|
||||
auto is_disabled = td_->option_manager_->get_option_boolean("disable_contact_registered_notifications");
|
||||
if (is_disabled == disable_contact_registered_notifications_) {
|
||||
return;
|
||||
}
|
||||
@ -2581,9 +2583,9 @@ void NotificationManager::on_get_disable_contact_registered_notifications(bool i
|
||||
disable_contact_registered_notifications_ = is_disabled;
|
||||
|
||||
if (is_disabled) {
|
||||
G()->set_option_boolean("disable_contact_registered_notifications", is_disabled);
|
||||
td_->option_manager_->set_option_boolean("disable_contact_registered_notifications", is_disabled);
|
||||
} else {
|
||||
G()->set_option_empty("disable_contact_registered_notifications");
|
||||
td_->option_manager_->set_option_empty("disable_contact_registered_notifications");
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/NotificationSettings.hpp"
|
||||
#include "td/telegram/NotificationSound.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
@ -873,7 +874,7 @@ void NotificationSettingsManager::add_saved_ringtone(td_api::object_ptr<td_api::
|
||||
FileId file_id = r_file_id.ok();
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(!file_view.empty());
|
||||
if (file_view.size() > G()->get_option_integer("notification_sound_size_max")) {
|
||||
if (file_view.size() > td_->option_manager_->get_option_integer("notification_sound_size_max")) {
|
||||
return promise.set_error(Status::Error(400, "Notification sound file is too big"));
|
||||
}
|
||||
auto file_type = file_view.get_type();
|
||||
@ -888,7 +889,7 @@ void NotificationSettingsManager::add_saved_ringtone(td_api::object_ptr<td_api::
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (duration > G()->get_option_integer("notification_sound_duration_max")) {
|
||||
if (duration > td_->option_manager_->get_option_integer("notification_sound_duration_max")) {
|
||||
return promise.set_error(Status::Error(400, "Notification sound is too long"));
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.is_encrypted()) {
|
||||
@ -1113,7 +1114,7 @@ void NotificationSettingsManager::on_remove_saved_ringtone(int64 ringtone_id, Pr
|
||||
|
||||
CHECK(are_saved_ringtones_loaded_);
|
||||
|
||||
auto max_count = G()->get_option_integer("notification_sound_count_max");
|
||||
auto max_count = td_->option_manager_->get_option_integer("notification_sound_count_max");
|
||||
if (saved_ringtone_file_ids_.size() >= static_cast<uint64>(max_count)) {
|
||||
// reload all saved ringtones to get ringtones besides the limit
|
||||
return reload_saved_ringtones(PromiseCreator::lambda([promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/net/NetQueryCreator.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
@ -168,7 +169,7 @@ td_api::object_ptr<td_api::sponsoredMessage> SponsoredMessageManager::get_sponso
|
||||
case DialogType::Channel:
|
||||
if (sponsored_message.server_message_id.is_valid()) {
|
||||
auto channel_id = sponsored_message.sponsor_dialog_id.get_channel_id();
|
||||
auto t_me = G()->get_option_string("t_me_url", "https://t.me/");
|
||||
auto t_me = td_->option_manager_->get_option_string("t_me_url", "https://t.me/");
|
||||
link = td_api::make_object<td_api::internalLinkTypeMessage>(
|
||||
PSTRING() << t_me << "c/" << channel_id.get() << '/' << sponsored_message.server_message_id.get());
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/net/MtprotoHeader.h"
|
||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/PhotoSizeSource.h"
|
||||
#include "td/telegram/secret_api.h"
|
||||
#include "td/telegram/SecretChatLayer.h"
|
||||
@ -1434,7 +1435,8 @@ void StickersManager::init() {
|
||||
auto &sticker_set = add_special_sticker_set(SpecialStickerSetType::premium_gifts());
|
||||
load_special_sticker_set_info_from_binlog(sticker_set);
|
||||
|
||||
dice_emojis_str_ = G()->get_option_string("dice_emojis", "🎲\x01🎯\x01🏀\x01⚽\x01⚽️\x01🎰\x01🎳");
|
||||
dice_emojis_str_ =
|
||||
td_->option_manager_->get_option_string("dice_emojis", "🎲\x01🎯\x01🏀\x01⚽\x01⚽️\x01🎰\x01🎳");
|
||||
dice_emojis_ = full_split(dice_emojis_str_, '\x01');
|
||||
for (auto &dice_emoji : dice_emojis_) {
|
||||
auto &animated_dice_sticker_set = add_special_sticker_set(SpecialStickerSetType::animated_dice(dice_emoji));
|
||||
@ -1470,8 +1472,8 @@ void StickersManager::init() {
|
||||
}
|
||||
|
||||
G()->td_db()->get_binlog_pmc()->erase("animated_dice_sticker_set"); // legacy
|
||||
G()->set_option_empty("animated_dice_sticker_set_name"); // legacy
|
||||
G()->set_option_empty("animated_emoji_sticker_set_name"); // legacy
|
||||
td_->option_manager_->set_option_empty("animated_dice_sticker_set_name"); // legacy
|
||||
td_->option_manager_->set_option_empty("animated_emoji_sticker_set_name"); // legacy
|
||||
}
|
||||
|
||||
void StickersManager::reload_reactions() {
|
||||
@ -2230,7 +2232,7 @@ tl_object_ptr<td_api::stickerSetInfo> StickersManager::get_sticker_set_info_obje
|
||||
vector<FileId> regular_sticker_ids;
|
||||
vector<FileId> premium_sticker_ids;
|
||||
std::tie(regular_sticker_ids, premium_sticker_ids) = split_stickers_by_premium(sticker_set);
|
||||
auto is_premium = G()->get_option_boolean("is_premium");
|
||||
auto is_premium = td_->option_manager_->get_option_boolean("is_premium");
|
||||
size_t max_premium_stickers = is_premium ? covers_limit : 1;
|
||||
if (premium_sticker_ids.size() > max_premium_stickers) {
|
||||
premium_sticker_ids.resize(max_premium_stickers);
|
||||
@ -4110,8 +4112,8 @@ vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string em
|
||||
vector<FileId> regular_sticker_ids;
|
||||
vector<FileId> premium_sticker_ids;
|
||||
std::tie(regular_sticker_ids, premium_sticker_ids) = split_stickers_by_premium(result);
|
||||
if (G()->get_option_boolean("is_premium") || allow_premium) {
|
||||
auto normal_count = G()->get_option_integer("stickers_normal_by_emoji_per_premium_num", 2);
|
||||
if (td_->option_manager_->get_option_boolean("is_premium") || allow_premium) {
|
||||
auto normal_count = td_->option_manager_->get_option_integer("stickers_normal_by_emoji_per_premium_num", 2);
|
||||
if (normal_count < 0) {
|
||||
normal_count = 2;
|
||||
}
|
||||
@ -4146,7 +4148,7 @@ vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string em
|
||||
}
|
||||
}
|
||||
if (sorted.size() < limit_size_t) {
|
||||
auto premium_count = G()->get_option_integer("stickers_premium_by_emoji_num", 0);
|
||||
auto premium_count = td_->option_manager_->get_option_integer("stickers_premium_by_emoji_num", 0);
|
||||
if (premium_count > 0) {
|
||||
for (const auto &sticker_id : premium_sticker_ids) {
|
||||
LOG(INFO) << "Add premium sticker " << sticker_id << " from installed sticker set";
|
||||
@ -5010,14 +5012,15 @@ void StickersManager::on_update_dice_emojis() {
|
||||
return;
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
G()->set_option_empty("dice_emojis");
|
||||
td_->option_manager_->set_option_empty("dice_emojis");
|
||||
return;
|
||||
}
|
||||
if (!is_inited_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dice_emojis_str = G()->get_option_string("dice_emojis", "🎲\x01🎯\x01🏀\x01⚽\x01⚽️\x01🎰\x01🎳");
|
||||
auto dice_emojis_str =
|
||||
td_->option_manager_->get_option_string("dice_emojis", "🎲\x01🎯\x01🏀\x01⚽\x01⚽️\x01🎰\x01🎳");
|
||||
if (dice_emojis_str == dice_emojis_str_) {
|
||||
return;
|
||||
}
|
||||
@ -5049,14 +5052,15 @@ void StickersManager::on_update_dice_success_values() {
|
||||
return;
|
||||
}
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
G()->set_option_empty("dice_success_values");
|
||||
td_->option_manager_->set_option_empty("dice_success_values");
|
||||
return;
|
||||
}
|
||||
if (!is_inited_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto dice_success_values_str = G()->get_option_string("dice_success_values", "0,6:62,5:110,5:110,5:110,64:110,6:110");
|
||||
auto dice_success_values_str =
|
||||
td_->option_manager_->get_option_string("dice_success_values", "0,6:62,5:110,5:110,5:110,64:110,6:110");
|
||||
if (dice_success_values_str == dice_success_values_str_) {
|
||||
return;
|
||||
}
|
||||
@ -5074,7 +5078,7 @@ void StickersManager::on_update_emoji_sounds() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto emoji_sounds_str = G()->get_option_string("emoji_sounds");
|
||||
auto emoji_sounds_str = td_->option_manager_->get_option_string("emoji_sounds");
|
||||
if (emoji_sounds_str == emoji_sounds_str_) {
|
||||
return;
|
||||
}
|
||||
@ -5121,7 +5125,7 @@ void StickersManager::on_update_disable_animated_emojis() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto disable_animated_emojis = G()->get_option_boolean("disable_animated_emoji");
|
||||
auto disable_animated_emojis = td_->option_manager_->get_option_boolean("disable_animated_emoji");
|
||||
if (disable_animated_emojis == disable_animated_emojis_) {
|
||||
return;
|
||||
}
|
||||
@ -7902,11 +7906,13 @@ void StickersManager::save_recent_stickers_to_database(bool is_attached) {
|
||||
}
|
||||
|
||||
void StickersManager::on_update_animated_emoji_zoom() {
|
||||
animated_emoji_zoom_ = static_cast<double>(G()->get_option_integer("animated_emoji_zoom", 625000000)) * 1e-9;
|
||||
animated_emoji_zoom_ =
|
||||
static_cast<double>(td_->option_manager_->get_option_integer("animated_emoji_zoom", 625000000)) * 1e-9;
|
||||
}
|
||||
|
||||
void StickersManager::on_update_recent_stickers_limit() {
|
||||
auto recent_stickers_limit = narrow_cast<int32>(G()->get_option_integer("recent_stickers_limit", 200));
|
||||
auto recent_stickers_limit =
|
||||
narrow_cast<int32>(td_->option_manager_->get_option_integer("recent_stickers_limit", 200));
|
||||
if (recent_stickers_limit != recent_stickers_limit_) {
|
||||
if (recent_stickers_limit > 0) {
|
||||
LOG(INFO) << "Update recent stickers limit to " << recent_stickers_limit;
|
||||
@ -7924,7 +7930,8 @@ void StickersManager::on_update_recent_stickers_limit() {
|
||||
}
|
||||
|
||||
void StickersManager::on_update_favorite_stickers_limit() {
|
||||
auto favorite_stickers_limit = narrow_cast<int32>(G()->get_option_integer("favorite_stickers_limit", 5));
|
||||
auto favorite_stickers_limit =
|
||||
narrow_cast<int32>(td_->option_manager_->get_option_integer("favorite_stickers_limit", 5));
|
||||
if (favorite_stickers_limit != favorite_stickers_limit_) {
|
||||
if (favorite_stickers_limit > 0) {
|
||||
LOG(INFO) << "Update favorite stickers limit to " << favorite_stickers_limit;
|
||||
|
@ -3273,8 +3273,6 @@ void Td::dec_actor_refcnt() {
|
||||
LOG(DEBUG) << "NotificationManager was cleared" << timer;
|
||||
notification_settings_manager_.reset();
|
||||
LOG(DEBUG) << "NotificationSettingsManager was cleared" << timer;
|
||||
option_manager_.reset();
|
||||
LOG(DEBUG) << "OptionManager was cleared" << timer;
|
||||
poll_manager_.reset();
|
||||
LOG(DEBUG) << "PollManager was cleared" << timer;
|
||||
sponsored_message_manager_.reset();
|
||||
@ -3295,8 +3293,11 @@ void Td::dec_actor_refcnt() {
|
||||
LOG(DEBUG) << "VoiceNotesManager was cleared" << timer;
|
||||
web_pages_manager_.reset();
|
||||
LOG(DEBUG) << "WebPagesManager was cleared" << timer;
|
||||
Promise<> promise = PromiseCreator::lambda([actor_id = create_reference()](Unit) mutable { actor_id.reset(); });
|
||||
|
||||
option_manager_.reset();
|
||||
LOG(DEBUG) << "OptionManager was cleared" << timer;
|
||||
|
||||
Promise<> promise = PromiseCreator::lambda([actor_id = create_reference()](Unit) mutable { actor_id.reset(); });
|
||||
if (destroy_flag_) {
|
||||
G()->close_and_destroy_all(std::move(promise));
|
||||
} else {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/NotificationSettings.h"
|
||||
#include "td/telegram/NotificationSettingsManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/Payments.h"
|
||||
#include "td/telegram/PollId.h"
|
||||
#include "td/telegram/PollManager.h"
|
||||
@ -1552,7 +1553,7 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
|
||||
break;
|
||||
}
|
||||
case telegram_api::updates_differenceTooLong::ID: {
|
||||
if (G()->get_option_integer("session_count") <= 1) {
|
||||
if (td_->option_manager_->get_option_integer("session_count") <= 1) {
|
||||
LOG(ERROR) << "Receive differenceTooLong";
|
||||
}
|
||||
// TODO
|
||||
@ -2260,8 +2261,8 @@ void UpdatesManager::add_pending_pts_update(tl_object_ptr<telegram_api::Update>
|
||||
|
||||
if (old_pts > new_pts - pts_count) {
|
||||
LOG(WARNING) << "Have old_pts (= " << old_pts << ") + pts_count (= " << pts_count << ") > new_pts (= " << new_pts
|
||||
<< "). Logged in " << G()->get_option_integer("authorization_date") << ". Update from " << source
|
||||
<< " = " << oneline(to_string(update));
|
||||
<< "). Logged in " << td_->option_manager_->get_option_integer("authorization_date")
|
||||
<< ". Update from " << source << " = " << oneline(to_string(update));
|
||||
postpone_pts_update(std::move(update), new_pts, pts_count, receive_time, std::move(promise));
|
||||
set_pts_gap_timeout(0.001);
|
||||
return;
|
||||
@ -2275,8 +2276,9 @@ void UpdatesManager::add_pending_pts_update(tl_object_ptr<telegram_api::Update>
|
||||
if (old_pts > accumulated_pts_ - accumulated_pts_count_) {
|
||||
LOG(WARNING) << "Have old_pts (= " << old_pts << ") + accumulated_pts_count (= " << accumulated_pts_count_
|
||||
<< ") > accumulated_pts (= " << accumulated_pts_ << "). new_pts = " << new_pts
|
||||
<< ", pts_count = " << pts_count << ". Logged in " << G()->get_option_integer("authorization_date")
|
||||
<< ". Update from " << source << " = " << oneline(to_string(update));
|
||||
<< ", pts_count = " << pts_count << ". Logged in "
|
||||
<< td_->option_manager_->get_option_integer("authorization_date") << ". Update from " << source
|
||||
<< " = " << oneline(to_string(update));
|
||||
postpone_pts_update(std::move(update), new_pts, pts_count, receive_time, std::move(promise));
|
||||
set_pts_gap_timeout(0.001);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user