diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index e7ed66ebd..95eb60933 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -2173,6 +2173,7 @@ void StoryManager::on_delete_story(StoryFullId story_full_id) { const Story *story = get_story(story_full_id); if (story == nullptr) { + delete_story_from_database(story_full_id); return; } auto owner_dialog_id = story_full_id.get_dialog_id(); @@ -2202,6 +2203,15 @@ void StoryManager::on_delete_story(StoryFullId story_full_id) { td::remove(story_ids, story_id); on_update_active_stories(owner_dialog_id, active_stories->max_read_story_id_, std::move(story_ids)); } + + delete_story_from_database(story_full_id); +} + +void StoryManager::delete_story_from_database(StoryFullId story_full_id) { + if (G()->use_message_database()) { + LOG(INFO) << "Delete " << story_full_id << " from database"; + G()->td_db()->get_story_db_async()->delete_story(story_full_id, Promise()); + } } void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed, @@ -3145,8 +3155,6 @@ void StoryManager::delete_story(StoryId story_id, Promise &&promise) { } delete_story_on_server(story_full_id, 0, std::move(promise)); - - on_delete_story(story_full_id); } class StoryManager::DeleteStoryOnServerLogEvent { @@ -3183,6 +3191,8 @@ void StoryManager::delete_story_on_server(StoryFullId story_full_id, uint64 log_ deleted_story_full_ids_.insert(story_full_id); td_->create_handler(std::move(promise))->send({story_full_id.get_story_id()}); + + on_delete_story(story_full_id); } telegram_api::object_ptr StoryManager::get_input_media(StoryFullId story_full_id) const { diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 6105d1ffc..8958c7de3 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -358,6 +358,8 @@ class StoryManager final : public Actor { void delete_story_on_server(StoryFullId story_full_id, uint64 log_event_id, Promise &&promise); + void delete_story_from_database(StoryFullId story_full_id); + void delete_story_files(const Story *story) const; void change_story_files(StoryFullId story_full_id, const Story *story, const vector &old_file_ids);