Avoid restoring of deleted stories.

This commit is contained in:
levlam 2023-06-02 16:46:10 +03:00
parent ede8911f05
commit dfeeaf8f87
2 changed files with 8 additions and 0 deletions

View File

@ -598,6 +598,9 @@ StoryId StoryManager::on_get_story(DialogId owner_dialog_id,
LOG(ERROR) << "Receive " << to_string(story_item); LOG(ERROR) << "Receive " << to_string(story_item);
return StoryId(); return StoryId();
} }
if (deleted_story_full_ids_.count({owner_dialog_id, story_id}) > 0) {
return StoryId();
}
StoryFullId story_full_id{owner_dialog_id, story_id}; StoryFullId story_full_id{owner_dialog_id, story_id};
auto story = get_story_editable(story_full_id); auto story = get_story_editable(story_full_id);
@ -1106,6 +1109,8 @@ void StoryManager::delete_story_on_server(DialogId dialog_id, StoryId story_id,
auto new_promise = get_erase_log_event_promise(log_event_id, std::move(promise)); auto new_promise = get_erase_log_event_promise(log_event_id, std::move(promise));
promise = std::move(new_promise); // to prevent self-move promise = std::move(new_promise); // to prevent self-move
deleted_story_full_ids_.insert({dialog_id, story_id});
td_->create_handler<DeleteStoriesQuery>(std::move(promise))->send({story_id.get()}); td_->create_handler<DeleteStoriesQuery>(std::move(promise))->send({story_id.get()});
} }

View File

@ -22,6 +22,7 @@
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/Promise.h" #include "td/utils/Promise.h"
#include "td/utils/WaitFreeHashMap.h" #include "td/utils/WaitFreeHashMap.h"
#include "td/utils/WaitFreeHashSet.h"
#include <utility> #include <utility>
@ -176,6 +177,8 @@ class StoryManager final : public Actor {
WaitFreeHashMap<StoryFullId, unique_ptr<Story>, StoryFullIdHash> stories_; WaitFreeHashMap<StoryFullId, unique_ptr<Story>, StoryFullIdHash> stories_;
WaitFreeHashSet<StoryFullId, StoryFullIdHash> deleted_story_full_ids_;
FlatHashMap<StoryFullId, unique_ptr<BeingEditedStory>, StoryFullIdHash> being_edited_stories_; FlatHashMap<StoryFullId, unique_ptr<BeingEditedStory>, StoryFullIdHash> being_edited_stories_;
uint32 send_story_count_ = 0; uint32 send_story_count_ = 0;