Process story stealth mode updates.
This commit is contained in:
parent
3448c6f4ab
commit
a9f6f897c6
@ -1520,6 +1520,7 @@ void StoryManager::on_load_active_stories_from_server(
|
||||
story_list.state_ = std::move(stories->state_);
|
||||
save_story_list(story_list_id, story_list.state_, story_list.server_total_count_, story_list.server_has_more_);
|
||||
}
|
||||
on_update_story_stealth_mode(std::move(stories->stealth_mode_));
|
||||
break;
|
||||
}
|
||||
case telegram_api::stories_allStories::ID: {
|
||||
@ -1603,6 +1604,8 @@ void StoryManager::on_load_active_stories_from_server(
|
||||
update_story_list_sent_total_count(story_list_id, story_list);
|
||||
|
||||
lock.set_value(Unit());
|
||||
|
||||
on_update_story_stealth_mode(std::move(stories->stealth_mode_));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -3202,6 +3205,28 @@ bool StoryManager::on_update_read_stories(DialogId owner_dialog_id, StoryId max_
|
||||
return false;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateStoryStealthMode> StoryManager::get_update_story_stealth_mode() const {
|
||||
return stealth_mode_.get_update_story_stealth_mode_object();
|
||||
}
|
||||
|
||||
void StoryManager::send_update_story_stealth_mode() const {
|
||||
send_closure(G()->td(), &Td::send_update, get_update_story_stealth_mode());
|
||||
}
|
||||
|
||||
void StoryManager::on_update_story_stealth_mode(
|
||||
telegram_api::object_ptr<telegram_api::storiesStealthMode> &&stealth_mode) {
|
||||
set_story_stealth_mode(StoryStealthMode(std::move(stealth_mode)));
|
||||
}
|
||||
|
||||
void StoryManager::set_story_stealth_mode(StoryStealthMode stealth_mode) {
|
||||
if (stealth_mode == stealth_mode_) {
|
||||
return;
|
||||
}
|
||||
|
||||
stealth_mode_ = stealth_mode;
|
||||
send_update_story_stealth_mode();
|
||||
}
|
||||
|
||||
DialogId StoryManager::get_changelog_story_dialog_id() const {
|
||||
return DialogId(UserId(td_->option_manager_->get_option_integer(
|
||||
"stories_changelog_user_id", ContactsManager::get_service_notifications_user_id().get())));
|
||||
@ -3963,6 +3988,8 @@ void StoryManager::get_current_state(vector<td_api::object_ptr<td_api::Update>>
|
||||
updates.push_back(get_update_story_list_chat_count_object(story_list_id, story_list));
|
||||
}
|
||||
}
|
||||
|
||||
updates.push_back(get_update_story_stealth_mode());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "td/telegram/StoryId.h"
|
||||
#include "td/telegram/StoryInteractionInfo.h"
|
||||
#include "td/telegram/StoryListId.h"
|
||||
#include "td/telegram/StoryStealthMode.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/UserId.h"
|
||||
@ -261,6 +262,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
bool on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id);
|
||||
|
||||
void on_update_story_stealth_mode(telegram_api::object_ptr<telegram_api::storiesStealthMode> &&stealth_mode);
|
||||
|
||||
void on_dialog_active_stories_order_updated(DialogId owner_dialog_id, const char *source);
|
||||
|
||||
Status can_get_story_viewers(StoryFullId story_full_id, const Story *story) const;
|
||||
@ -506,6 +509,12 @@ class StoryManager final : public Actor {
|
||||
|
||||
void on_synchronized_archive_all_stories(bool set_archive_all_stories, Result<Unit> result);
|
||||
|
||||
td_api::object_ptr<td_api::updateStoryStealthMode> get_update_story_stealth_mode() const;
|
||||
|
||||
void send_update_story_stealth_mode() const;
|
||||
|
||||
void set_story_stealth_mode(StoryStealthMode stealth_mode);
|
||||
|
||||
void on_get_story_viewers(StoryId story_id, MessageViewer offset,
|
||||
Result<telegram_api::object_ptr<telegram_api::stories_storyViewsList>> r_view_list,
|
||||
Promise<td_api::object_ptr<td_api::messageViewers>> &&promise);
|
||||
@ -560,6 +569,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
StoryList story_lists_[2];
|
||||
|
||||
StoryStealthMode stealth_mode_;
|
||||
|
||||
uint32 send_story_count_ = 0;
|
||||
|
||||
int64 max_story_global_id_ = 0;
|
||||
|
@ -29,9 +29,7 @@ bool StoryStealthMode::update() {
|
||||
return result;
|
||||
}
|
||||
|
||||
int32 StoryStealthMode::get_update_date() {
|
||||
update();
|
||||
|
||||
int32 StoryStealthMode::get_update_date() const {
|
||||
if (active_until_date_ > 0) {
|
||||
if (cooldown_until_date_ > 0) {
|
||||
return min(active_until_date_, cooldown_until_date_);
|
||||
|
@ -31,7 +31,7 @@ class StoryStealthMode {
|
||||
return active_until_date_ == 0 && cooldown_until_date_ == 0;
|
||||
}
|
||||
|
||||
int32 get_update_date();
|
||||
int32 get_update_date() const;
|
||||
|
||||
bool update();
|
||||
|
||||
|
@ -4311,6 +4311,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateReadStories> up
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStoriesStealthMode> update, Promise<Unit> &&promise) {
|
||||
td_->story_manager_->on_update_story_stealth_mode(std::move(update->stealth_mode_));
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
// unsupported updates
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateSentStoryReaction> update, Promise<Unit> &&promise) {
|
||||
@ -4321,8 +4326,4 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStoryID> update
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStoriesStealthMode> update, Promise<Unit> &&promise) {
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -624,13 +624,13 @@ class UpdatesManager final : public Actor {
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateReadStories> update, Promise<Unit> &&promise);
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateStoriesStealthMode> update, Promise<Unit> &&promise);
|
||||
|
||||
// unsupported updates
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateSentStoryReaction> update, Promise<Unit> &&promise);
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateStoryID> update, Promise<Unit> &&promise);
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateStoriesStealthMode> update, Promise<Unit> &&promise);
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user