tdlight/td/telegram/StoryManager.h
2023-05-19 23:25:52 +03:00

83 lines
2.4 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/DialogId.h"
#include "td/telegram/files/FileId.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/StoryFullId.h"
#include "td/telegram/StoryId.h"
#include "td/telegram/StoryInteractionInfo.h"
#include "td/telegram/td_api.h"
#include "td/telegram/UserId.h"
#include "td/telegram/UserPrivacySettingRule.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/WaitFreeHashMap.h"
#include <utility>
namespace td {
class StoryContent;
class Td;
class StoryManager final : public Actor {
public:
StoryManager(Td *td, ActorShared<> parent);
StoryManager(const StoryManager &) = delete;
StoryManager &operator=(const StoryManager &) = delete;
StoryManager(StoryManager &&) = delete;
StoryManager &operator=(StoryManager &&) = delete;
~StoryManager() final;
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::storyItem> &&story_item);
std::pair<int32, vector<StoryId>> on_get_stories(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::stories_stories> &&stories);
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id) const;
private:
struct Story {
int32 date_ = 0;
int32 expire_date_ = 0;
bool is_pinned_ = false;
bool is_public_ = false;
bool is_for_close_friends_ = false;
StoryInteractionInfo interaction_info_;
UserPrivacySettingRules privacy_rules_;
unique_ptr<StoryContent> content_;
FormattedText caption_;
};
void tear_down() final;
bool is_story_owned(DialogId owner_dialog_id) const;
const Story *get_story(StoryFullId story_full_id) const;
Story *get_story_editable(StoryFullId story_full_id);
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id, const Story *story) const;
vector<FileId> get_story_file_ids(const Story *story) const;
void delete_story_files(const Story *story) const;
static bool is_local_story_id(StoryId story_id);
WaitFreeHashMap<StoryFullId, unique_ptr<Story>, StoryFullIdHash> stories_;
Td *td_;
ActorShared<> parent_;
};
} // namespace td