Allow to change "archive_all_stories" option.
This commit is contained in:
parent
cebea14b03
commit
25bfb761d4
@ -2126,7 +2126,9 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
options.set_option_empty("gift_premium_from_input_field");
|
options.set_option_empty("gift_premium_from_input_field");
|
||||||
}
|
}
|
||||||
|
|
||||||
options.set_option_boolean("archive_all_stories", archive_all_stories);
|
if (!options.get_option_boolean("need_synchronize_archive_all_stories")) {
|
||||||
|
options.set_option_boolean("archive_all_stories", archive_all_stories);
|
||||||
|
}
|
||||||
|
|
||||||
options.set_option_integer("stickers_premium_by_emoji_num", stickers_premium_by_emoji_num);
|
options.set_option_integer("stickers_premium_by_emoji_num", stickers_premium_by_emoji_num);
|
||||||
options.set_option_integer("stickers_normal_by_emoji_per_premium_num", stickers_normal_by_emoji_per_premium_num);
|
options.set_option_integer("stickers_normal_by_emoji_per_premium_num", stickers_normal_by_emoji_per_premium_num);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "td/telegram/StateManager.h"
|
#include "td/telegram/StateManager.h"
|
||||||
#include "td/telegram/StickersManager.h"
|
#include "td/telegram/StickersManager.h"
|
||||||
#include "td/telegram/StorageManager.h"
|
#include "td/telegram/StorageManager.h"
|
||||||
|
#include "td/telegram/StoryManager.h"
|
||||||
#include "td/telegram/SuggestedAction.h"
|
#include "td/telegram/SuggestedAction.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
#include "td/telegram/TdDb.h"
|
#include "td/telegram/TdDb.h"
|
||||||
@ -277,7 +278,8 @@ bool OptionManager::is_internal_option(Slice name) {
|
|||||||
case 'm':
|
case 'm':
|
||||||
return name == "my_phone_number";
|
return name == "my_phone_number";
|
||||||
case 'n':
|
case 'n':
|
||||||
return name == "notification_cloud_delay_ms" || name == "notification_default_delay_ms";
|
return name == "need_synchronize_archive_all_stories" || name == "notification_cloud_delay_ms" ||
|
||||||
|
name == "notification_default_delay_ms";
|
||||||
case 'o':
|
case 'o':
|
||||||
return name == "online_cloud_timeout_ms" || name == "online_update_period_ms" || name == "otherwise_relogin_days";
|
return name == "online_cloud_timeout_ms" || name == "online_update_period_ms" || name == "otherwise_relogin_days";
|
||||||
case 'p':
|
case 'p':
|
||||||
@ -408,6 +410,9 @@ void OptionManager::on_option_updated(Slice name) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if (name == "need_synchronize_archive_all_stories") {
|
||||||
|
send_closure(td_->story_manager_actor_, &StoryManager::try_synchronize_archive_all_stories);
|
||||||
|
}
|
||||||
if (name == "notification_cloud_delay_ms") {
|
if (name == "notification_cloud_delay_ms") {
|
||||||
send_closure(td_->notification_manager_actor_, &NotificationManager::on_notification_cloud_delay_changed);
|
send_closure(td_->notification_manager_actor_, &NotificationManager::on_notification_cloud_delay_changed);
|
||||||
}
|
}
|
||||||
@ -619,6 +624,10 @@ void OptionManager::set_option(const string &name, td_api::object_ptr<td_api::Op
|
|||||||
if (set_boolean_option("always_parse_markdown")) {
|
if (set_boolean_option("always_parse_markdown")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!is_bot && set_boolean_option("archive_all_stories")) {
|
||||||
|
set_option_boolean("need_synchronize_archive_all_stories", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!is_bot && name == "archive_and_mute_new_chats_from_unknown_users") {
|
if (!is_bot && name == "archive_and_mute_new_chats_from_unknown_users") {
|
||||||
if (value_constructor_id != td_api::optionValueBoolean::ID &&
|
if (value_constructor_id != td_api::optionValueBoolean::ID &&
|
||||||
value_constructor_id != td_api::optionValueEmpty::ID) {
|
value_constructor_id != td_api::optionValueEmpty::ID) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "td/telegram/StoryManager.h"
|
#include "td/telegram/StoryManager.h"
|
||||||
|
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
|
#include "td/telegram/ConfigManager.h"
|
||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
#include "td/telegram/FileReferenceManager.h"
|
#include "td/telegram/FileReferenceManager.h"
|
||||||
#include "td/telegram/files/FileManager.h"
|
#include "td/telegram/files/FileManager.h"
|
||||||
@ -72,6 +73,33 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ToggleAllStoriesHiddenQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ToggleAllStoriesHiddenQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(bool all_stories_hidden) {
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::stories_toggleAllStoriesHidden(all_stories_hidden)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::stories_toggleAllStoriesHidden>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = result_ptr.move_as_ok();
|
||||||
|
LOG(DEBUG) << "Receive result for ToggleAllStoriesHiddenQuery: " << result;
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class IncrementStoryViewsQuery final : public Td::ResultHandler {
|
class IncrementStoryViewsQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
@ -559,6 +587,10 @@ StoryManager::~StoryManager() {
|
|||||||
active_stories_, max_read_story_ids_);
|
active_stories_, max_read_story_ids_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StoryManager::start_up() {
|
||||||
|
try_synchronize_archive_all_stories();
|
||||||
|
}
|
||||||
|
|
||||||
void StoryManager::tear_down() {
|
void StoryManager::tear_down() {
|
||||||
parent_.reset();
|
parent_.reset();
|
||||||
}
|
}
|
||||||
@ -587,6 +619,44 @@ const StoryManager::ActiveStories *StoryManager::get_active_stories(DialogId own
|
|||||||
return active_stories_.get_pointer(owner_dialog_id);
|
return active_stories_.get_pointer(owner_dialog_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StoryManager::try_synchronize_archive_all_stories() {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (has_active_synchronize_archive_all_stories_query_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!td_->option_manager_->get_option_boolean("need_synchronize_archive_all_stories")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
has_active_synchronize_archive_all_stories_query_ = true;
|
||||||
|
auto archive_all_stories = td_->option_manager_->get_option_boolean("archive_all_stories");
|
||||||
|
|
||||||
|
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), archive_all_stories](Result<Unit> result) {
|
||||||
|
send_closure(actor_id, &StoryManager::on_synchronized_archive_all_stories, archive_all_stories, std::move(result));
|
||||||
|
});
|
||||||
|
td_->create_handler<ToggleAllStoriesHiddenQuery>(std::move(promise))->send(archive_all_stories);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StoryManager::on_synchronized_archive_all_stories(bool set_archive_all_stories, Result<Unit> result) {
|
||||||
|
if (G()->close_flag()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CHECK(has_active_synchronize_archive_all_stories_query_);
|
||||||
|
has_active_synchronize_archive_all_stories_query_ = false;
|
||||||
|
|
||||||
|
auto archive_all_stories = td_->option_manager_->get_option_boolean("archive_all_stories");
|
||||||
|
if (archive_all_stories != set_archive_all_stories) {
|
||||||
|
return try_synchronize_archive_all_stories();
|
||||||
|
}
|
||||||
|
td_->option_manager_->set_option_empty("need_synchronize_archive_all_stories");
|
||||||
|
|
||||||
|
if (result.is_error()) {
|
||||||
|
send_closure(G()->config_manager(), &ConfigManager::reget_app_config, Promise<Unit>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise) {
|
void StoryManager::toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise) {
|
||||||
if (!td_->messages_manager_->have_dialog_info_force(dialog_id)) {
|
if (!td_->messages_manager_->have_dialog_info_force(dialog_id)) {
|
||||||
return promise.set_error(Status::Error(400, "Story sender not found"));
|
return promise.set_error(Status::Error(400, "Story sender not found"));
|
||||||
|
@ -156,6 +156,8 @@ class StoryManager final : public Actor {
|
|||||||
|
|
||||||
void reload_story(StoryFullId story_full_id, Promise<Unit> &&promise);
|
void reload_story(StoryFullId story_full_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void try_synchronize_archive_all_stories();
|
||||||
|
|
||||||
void on_binlog_events(vector<BinlogEvent> &&events);
|
void on_binlog_events(vector<BinlogEvent> &&events);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -167,6 +169,8 @@ class StoryManager final : public Actor {
|
|||||||
class DeleteStoryOnServerLogEvent;
|
class DeleteStoryOnServerLogEvent;
|
||||||
class ReadStoriesOnServerLogEvent;
|
class ReadStoriesOnServerLogEvent;
|
||||||
|
|
||||||
|
void start_up() final;
|
||||||
|
|
||||||
void tear_down() final;
|
void tear_down() final;
|
||||||
|
|
||||||
bool is_story_owned(DialogId owner_dialog_id) const;
|
bool is_story_owned(DialogId owner_dialog_id) const;
|
||||||
@ -256,6 +260,8 @@ class StoryManager final : public Actor {
|
|||||||
|
|
||||||
void update_interaction_info();
|
void update_interaction_info();
|
||||||
|
|
||||||
|
void on_synchronized_archive_all_stories(bool set_archive_all_stories, Result<Unit> result);
|
||||||
|
|
||||||
std::shared_ptr<UploadMediaCallback> upload_media_callback_;
|
std::shared_ptr<UploadMediaCallback> upload_media_callback_;
|
||||||
|
|
||||||
WaitFreeHashMap<StoryFullId, FileSourceId, StoryFullIdHash> story_full_id_to_file_source_id_;
|
WaitFreeHashMap<StoryFullId, FileSourceId, StoryFullIdHash> story_full_id_to_file_source_id_;
|
||||||
@ -280,6 +286,8 @@ class StoryManager final : public Actor {
|
|||||||
|
|
||||||
uint32 send_story_count_ = 0;
|
uint32 send_story_count_ = 0;
|
||||||
|
|
||||||
|
bool has_active_synchronize_archive_all_stories_query_ = false;
|
||||||
|
|
||||||
FlatHashMap<FileId, unique_ptr<PendingStory>, FileIdHash> being_uploaded_files_;
|
FlatHashMap<FileId, unique_ptr<PendingStory>, FileIdHash> being_uploaded_files_;
|
||||||
|
|
||||||
Timeout interaction_info_update_timeout_;
|
Timeout interaction_info_update_timeout_;
|
||||||
|
Loading…
Reference in New Issue
Block a user