tdlight/td/telegram/StoryManager.h

66 lines
1.8 KiB
C
Raw Normal View History

2023-05-01 21:19:16 +02:00
//
// 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
2023-05-08 19:09:01 +02:00
#include "td/telegram/DialogId.h"
2023-05-18 16:20:22 +02:00
#include "td/telegram/MessageEntity.h"
2023-05-18 18:57:50 +02:00
#include "td/telegram/StoryFullId.h"
2023-05-08 19:09:01 +02:00
#include "td/telegram/StoryId.h"
2023-05-18 17:41:07 +02:00
#include "td/telegram/StoryInteractionInfo.h"
2023-05-08 19:09:01 +02:00
#include "td/telegram/UserId.h"
#include "td/telegram/UserPrivacySettingRule.h"
2023-05-01 21:19:16 +02:00
#include "td/actor/actor.h"
#include "td/utils/common.h"
2023-05-08 19:09:01 +02:00
#include "td/utils/WaitFreeHashMap.h"
2023-05-01 21:19:16 +02:00
namespace td {
2023-05-18 16:20:22 +02:00
class StoryContent;
2023-05-01 21:19:16 +02:00
class Td;
class StoryManager final : public Actor {
public:
StoryManager(Td *td, ActorShared<> parent);
2023-05-18 16:20:22 +02:00
StoryManager(const StoryManager &) = delete;
StoryManager &operator=(const StoryManager &) = delete;
StoryManager(StoryManager &&) = delete;
StoryManager &operator=(StoryManager &&) = delete;
~StoryManager() final;
2023-05-01 21:19:16 +02:00
2023-05-08 19:09:01 +02:00
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::storyItem> &&story_item);
2023-05-01 21:19:16 +02:00
private:
2023-05-08 19:09:01 +02:00
struct Story {
int32 date_ = 0;
int32 expire_date_ = 0;
bool is_pinned_ = false;
bool is_public_ = false;
bool is_for_close_friends_ = false;
2023-05-18 17:41:07 +02:00
StoryInteractionInfo interaction_info_;
2023-05-08 19:09:01 +02:00
UserPrivacySettingRules privacy_rules_;
2023-05-18 16:20:22 +02:00
unique_ptr<StoryContent> content_;
FormattedText caption_;
2023-05-08 19:09:01 +02:00
};
2023-05-01 21:19:16 +02:00
void tear_down() final;
2023-05-18 18:57:50 +02:00
const Story *get_story(StoryFullId story_full_id) const;
2023-05-08 19:09:01 +02:00
2023-05-18 18:57:50 +02:00
Story *get_story_editable(StoryFullId story_full_id);
2023-05-08 19:09:01 +02:00
static bool is_local_story_id(StoryId story_id);
2023-05-18 18:57:50 +02:00
WaitFreeHashMap<StoryFullId, unique_ptr<Story>, StoryFullIdHash> stories_;
2023-05-08 19:09:01 +02:00
2023-05-01 21:19:16 +02:00
Td *td_;
ActorShared<> parent_;
};
} // namespace td