Update active stories from UserFull.

This commit is contained in:
levlam 2023-06-15 13:22:36 +03:00
parent 56df91b265
commit 966eee8a07
3 changed files with 14 additions and 4 deletions

View File

@ -46,6 +46,7 @@
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/StickerPhotoSize.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/StoryManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/telegram_api.hpp"
@ -12498,6 +12499,8 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
td_->messages_manager_->on_update_dialog_is_translatable(DialogId(user_id), !user->translations_disabled_);
td_->story_manager_->on_get_user_stories(DialogId(user_id), std::move(user->stories_));
UserFull *user_full = add_user_full(user_id);
user_full->expires_at = Time::now() + USER_FULL_EXPIRE_TIME;

View File

@ -1157,7 +1157,10 @@ std::pair<int32, vector<StoryId>> StoryManager::on_get_stories(
DialogId StoryManager::on_get_user_stories(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::userStories> &&user_stories) {
CHECK(user_stories != nullptr);
if (user_stories == nullptr) {
on_update_active_stories(owner_dialog_id, StoryId(), {});
return owner_dialog_id;
}
DialogId story_dialog_id(UserId(user_stories->user_id_));
if (owner_dialog_id.is_valid() && owner_dialog_id != story_dialog_id) {
@ -1211,6 +1214,10 @@ void StoryManager::on_update_active_stories(DialogId owner_dialog_id, StoryId ma
max_read_story_id = StoryId();
}
if (owner_dialog_id.get_type() == DialogType::User) {
td_->contacts_manager_->on_update_user_has_stories(owner_dialog_id.get_user_id(), !story_ids.empty());
}
if (max_read_story_id == StoryId() && story_ids.empty()) {
if (active_stories_.erase(owner_dialog_id) > 0) {
send_update_active_stories(owner_dialog_id);

View File

@ -122,6 +122,9 @@ class StoryManager final : public Actor {
std::pair<int32, vector<StoryId>> on_get_stories(DialogId owner_dialog_id, vector<int32> &&expected_story_ids,
telegram_api::object_ptr<telegram_api::stories_stories> &&stories);
DialogId on_get_user_stories(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::userStories> &&user_stories);
void on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id);
bool have_story(StoryFullId story_full_id) const;
@ -189,9 +192,6 @@ class StoryManager final : public Actor {
void on_delete_story(DialogId owner_dialog_id, StoryId story_id);
DialogId on_get_user_stories(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::userStories> &&user_stories);
void on_get_dialog_pinned_stories(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
Promise<td_api::object_ptr<td_api::stories>> &&promise);