Support stories_changelog_user_id option.

This commit is contained in:
levlam 2023-06-27 17:26:17 +03:00
parent 47d30cc7dc
commit 09a30a4b3c
4 changed files with 16 additions and 4 deletions

View File

@ -8,6 +8,7 @@
#include "td/telegram/AuthManager.h" #include "td/telegram/AuthManager.h"
#include "td/telegram/ConnectionState.h" #include "td/telegram/ConnectionState.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/JsonValue.h" #include "td/telegram/JsonValue.h"
#include "td/telegram/LinkManager.h" #include "td/telegram/LinkManager.h"
@ -1561,6 +1562,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
int32 dialog_filter_update_period = 300; int32 dialog_filter_update_period = 300;
bool archive_all_stories = false; bool archive_all_stories = false;
int32 story_viewers_expire_period = 86400; int32 story_viewers_expire_period = 86400;
int64 stories_changelog_user_id = ContactsManager::get_service_notifications_user_id().get();
if (config->get_id() == telegram_api::jsonObject::ID) { if (config->get_id() == telegram_api::jsonObject::ID) {
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) { for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
Slice key = key_value->key_; Slice key = key_value->key_;
@ -1965,6 +1967,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
story_viewers_expire_period = get_json_value_int(std::move(key_value->value_), key); story_viewers_expire_period = get_json_value_int(std::move(key_value->value_), key);
continue; continue;
} }
if (key == "stories_changelog_user_id") {
stories_changelog_user_id = get_json_value_long(std::move(key_value->value_), key);
continue;
}
new_values.push_back(std::move(key_value)); new_values.push_back(std::move(key_value));
} }
@ -2130,6 +2136,11 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
} else { } else {
options.set_option_empty("gift_premium_from_input_field"); options.set_option_empty("gift_premium_from_input_field");
} }
if (stories_changelog_user_id != ContactsManager::get_service_notifications_user_id().get()) {
options.set_option_integer("stories_changelog_user_id", stories_changelog_user_id);
} else {
options.set_option_empty("stories_changelog_user_id");
}
if (story_viewers_expire_period >= 0) { if (story_viewers_expire_period >= 0) {
options.set_option_integer("story_viewers_expire_period", story_viewers_expire_period); options.set_option_integer("story_viewers_expire_period", story_viewers_expire_period);

View File

@ -106,7 +106,7 @@ class ConfigManager final : public NetQueryCallback {
private: private:
struct AppConfig { struct AppConfig {
static constexpr int32 CURRENT_VERSION = 5; static constexpr int32 CURRENT_VERSION = 6;
int32 version_ = 0; int32 version_ = 0;
int32 hash_ = 0; int32 hash_ = 0;
telegram_api::object_ptr<telegram_api::JSONValue> config_; telegram_api::object_ptr<telegram_api::JSONValue> config_;

View File

@ -293,7 +293,7 @@ bool OptionManager::is_internal_option(Slice name) {
name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" || name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" ||
name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" || name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" ||
name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num" || name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num" ||
name == "story_viewers_expire_period"; name == "stories_changelog_user_id" || name == "story_viewers_expire_period";
case 'v': case 'v':
return name == "video_note_size_max"; return name == "video_note_size_max";
case 'w': case 'w':

View File

@ -1410,8 +1410,9 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
} }
auto story_id = story_full_id.get_story_id(); auto story_id = story_full_id.get_story_id();
bool is_visible_only_for_self = !story_id.is_server() || auto changelog_user_id = td_->option_manager_->get_option_integer(
dialog_id == DialogId(ContactsManager::get_service_notifications_user_id()) || "stories_changelog_user_id", ContactsManager::get_service_notifications_user_id().get());
bool is_visible_only_for_self = !story_id.is_server() || dialog_id == DialogId(changelog_user_id) ||
(!story->is_pinned_ && !is_active_story(story)); (!story->is_pinned_ && !is_active_story(story));
bool can_be_forwarded = !story->noforwards_ && story_id.is_server() && privacy_rules != nullptr && bool can_be_forwarded = !story->noforwards_ && story_id.is_server() && privacy_rules != nullptr &&
privacy_rules->rules_.size() == 1u && privacy_rules->rules_.size() == 1u &&