Support message viewers-related config options.

This commit is contained in:
levlam 2021-09-03 19:06:24 +03:00
parent 623633bb35
commit f197d61c66
3 changed files with 25 additions and 3 deletions

View File

@ -1488,6 +1488,8 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
string animation_search_emojis;
vector<SuggestedAction> suggested_actions;
bool can_archive_and_mute_new_chats_from_unknown_users = false;
int64 chat_read_mark_expire_period = 0;
int64 chat_read_mark_size_threshold = 0;
if (config->get_id() == telegram_api::jsonObject::ID) {
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
Slice key = key_value->key_;
@ -1677,6 +1679,15 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
}
continue;
}
if (key == "chat_read_mark_expire_period") {
chat_read_mark_expire_period = get_json_value_int(std::move(key_value->value_), "chat_read_mark_expire_period");
continue;
}
if (key == "chat_read_mark_size_threshold") {
chat_read_mark_size_threshold =
get_json_value_int(std::move(key_value->value_), "chat_read_mark_size_threshold");
continue;
}
new_values.push_back(std::move(key_value));
}
@ -1733,6 +1744,16 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
shared_config.set_option_boolean("can_archive_and_mute_new_chats_from_unknown_users",
can_archive_and_mute_new_chats_from_unknown_users);
}
if (chat_read_mark_expire_period <= 0) {
shared_config.set_option_empty("chat_read_mark_expire_period");
} else {
shared_config.set_option_integer("chat_read_mark_expire_period", chat_read_mark_expire_period);
}
if (chat_read_mark_size_threshold <= 0) {
shared_config.set_option_empty("chat_read_mark_size_threshold");
} else {
shared_config.set_option_integer("chat_read_mark_size_threshold", chat_read_mark_size_threshold);
}
shared_config.set_option_empty("default_ton_blockchain_config");
shared_config.set_option_empty("default_ton_blockchain_name");

View File

@ -17117,7 +17117,7 @@ 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 (m->date < G()->unix_time() - 7 * 86400) {
if (G()->unix_time() - m->date > G()->shared_config().get_option_integer("chat_read_mark_expire_period", 7 * 86400)) {
return Status::Error(400, "Message is too old");
}
if (td_->auth_manager_->is_bot()) {
@ -17153,7 +17153,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 > 50) {
if (participant_count > G()->shared_config().get_option_integer("chat_read_mark_size_threshold", 50)) {
return Status::Error(400, "Chat is too big");
}

View File

@ -3405,7 +3405,8 @@ bool Td::is_internal_config_option(Slice name) {
return name == "base_language_pack_version";
case 'c':
return name == "call_ring_timeout_ms" || name == "call_receive_timeout_ms" ||
name == "channels_read_media_period";
name == "channels_read_media_period" || name == "chat_read_mark_expire_period" ||
name == "chat_read_mark_size_threshold";
case 'd':
return name == "dc_txt_domain_name" || name == "dice_emojis" || name == "dice_success_values";
case 'e':