2023-05-01 22:19:16 +03: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-09-14 18:59:30 +03:00
|
|
|
#include "td/telegram/ChannelId.h"
|
2023-06-30 16:05:08 +03:00
|
|
|
#include "td/telegram/DialogDate.h"
|
2023-05-08 20:09:01 +03:00
|
|
|
#include "td/telegram/DialogId.h"
|
2023-05-19 17:00:33 +03:00
|
|
|
#include "td/telegram/files/FileId.h"
|
2023-05-20 01:23:33 +03:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2023-08-01 16:15:30 +03:00
|
|
|
#include "td/telegram/MediaArea.h"
|
2023-05-18 17:20:22 +03:00
|
|
|
#include "td/telegram/MessageEntity.h"
|
2023-09-21 19:11:17 +03:00
|
|
|
#include "td/telegram/MessageFullId.h"
|
2023-08-04 18:56:53 +03:00
|
|
|
#include "td/telegram/ReactionType.h"
|
2023-07-17 15:50:27 +03:00
|
|
|
#include "td/telegram/StoryDb.h"
|
2023-05-18 19:57:50 +03:00
|
|
|
#include "td/telegram/StoryFullId.h"
|
2023-05-08 20:09:01 +03:00
|
|
|
#include "td/telegram/StoryId.h"
|
2023-05-18 18:41:07 +03:00
|
|
|
#include "td/telegram/StoryInteractionInfo.h"
|
2023-07-08 15:42:23 +03:00
|
|
|
#include "td/telegram/StoryListId.h"
|
2023-08-04 14:51:39 +03:00
|
|
|
#include "td/telegram/StoryStealthMode.h"
|
2023-05-19 13:41:15 +03:00
|
|
|
#include "td/telegram/td_api.h"
|
2023-07-01 14:53:04 +03:00
|
|
|
#include "td/telegram/telegram_api.h"
|
2023-07-13 19:32:54 +03:00
|
|
|
#include "td/telegram/UserId.h"
|
2023-05-08 20:09:01 +03:00
|
|
|
#include "td/telegram/UserPrivacySettingRule.h"
|
|
|
|
|
2023-05-01 22:19:16 +03:00
|
|
|
#include "td/actor/actor.h"
|
2023-06-19 20:45:58 +03:00
|
|
|
#include "td/actor/MultiTimeout.h"
|
2023-06-15 20:07:40 +03:00
|
|
|
#include "td/actor/Timeout.h"
|
2023-05-01 22:19:16 +03:00
|
|
|
|
2023-07-13 19:32:54 +03:00
|
|
|
#include "td/utils/buffer.h"
|
2023-05-01 22:19:16 +03:00
|
|
|
#include "td/utils/common.h"
|
2023-07-01 16:22:01 +03:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
|
|
|
#include "td/utils/FlatHashSet.h"
|
2023-05-19 23:34:08 +03:00
|
|
|
#include "td/utils/Promise.h"
|
2023-06-19 19:13:08 +03:00
|
|
|
#include "td/utils/Status.h"
|
2023-05-08 20:09:01 +03:00
|
|
|
#include "td/utils/WaitFreeHashMap.h"
|
2023-06-02 16:46:10 +03:00
|
|
|
#include "td/utils/WaitFreeHashSet.h"
|
2023-05-01 22:19:16 +03:00
|
|
|
|
2023-07-01 16:22:01 +03:00
|
|
|
#include <memory>
|
|
|
|
#include <set>
|
2023-05-19 23:25:52 +03:00
|
|
|
#include <utility>
|
|
|
|
|
2023-05-01 22:19:16 +03:00
|
|
|
namespace td {
|
|
|
|
|
2023-06-01 17:41:46 +03:00
|
|
|
struct BinlogEvent;
|
2023-07-03 20:03:26 +03:00
|
|
|
class Dependencies;
|
2023-06-21 23:23:19 +03:00
|
|
|
class ReportReason;
|
2023-05-18 17:20:22 +03:00
|
|
|
class StoryContent;
|
2023-07-10 19:43:26 +03:00
|
|
|
struct StoryDbStory;
|
2023-05-01 22:19:16 +03:00
|
|
|
class Td;
|
|
|
|
|
|
|
|
class StoryManager final : public Actor {
|
2023-05-25 15:46:04 +03:00
|
|
|
struct Story {
|
|
|
|
int32 date_ = 0;
|
|
|
|
int32 expire_date_ = 0;
|
2023-06-22 21:40:34 +03:00
|
|
|
int32 receive_date_ = 0;
|
2023-06-29 15:15:12 +03:00
|
|
|
bool is_edited_ = false;
|
2023-05-25 15:46:04 +03:00
|
|
|
bool is_pinned_ = false;
|
|
|
|
bool is_public_ = false;
|
|
|
|
bool is_for_close_friends_ = false;
|
2023-07-18 16:19:11 +03:00
|
|
|
bool is_for_contacts_ = false;
|
|
|
|
bool is_for_selected_contacts_ = false;
|
2023-09-05 13:50:16 +03:00
|
|
|
bool is_outgoing_ = false;
|
2023-06-27 17:16:22 +03:00
|
|
|
bool noforwards_ = false;
|
2023-06-01 13:55:11 +03:00
|
|
|
mutable bool is_update_sent_ = false; // whether the story is known to the app
|
2023-05-25 15:46:04 +03:00
|
|
|
StoryInteractionInfo interaction_info_;
|
2023-08-04 18:56:53 +03:00
|
|
|
ReactionType chosen_reaction_type_;
|
2023-05-25 15:46:04 +03:00
|
|
|
UserPrivacySettingRules privacy_rules_;
|
|
|
|
unique_ptr<StoryContent> content_;
|
2023-08-01 16:15:30 +03:00
|
|
|
vector<MediaArea> areas_;
|
2023-05-25 15:46:04 +03:00
|
|
|
FormattedText caption_;
|
2023-06-19 20:13:44 +03:00
|
|
|
int64 global_id_ = 0;
|
2023-07-03 16:03:28 +03:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2023-05-30 14:41:36 +03:00
|
|
|
};
|
|
|
|
|
2023-07-15 02:16:48 +03:00
|
|
|
struct StoryInfo {
|
|
|
|
StoryId story_id_;
|
|
|
|
int32 date_ = 0;
|
|
|
|
int32 expire_date_ = 0;
|
|
|
|
bool is_for_close_friends_ = false;
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
2023-05-30 14:41:36 +03:00
|
|
|
struct BeingEditedStory {
|
|
|
|
unique_ptr<StoryContent> content_;
|
2023-08-01 20:37:37 +03:00
|
|
|
vector<MediaArea> areas_;
|
2023-05-30 14:41:36 +03:00
|
|
|
FormattedText caption_;
|
2023-08-01 20:37:37 +03:00
|
|
|
bool edit_media_areas_ = false;
|
2023-05-30 14:41:36 +03:00
|
|
|
bool edit_caption_ = false;
|
|
|
|
vector<Promise<Unit>> promises_;
|
2023-07-04 18:42:43 +03:00
|
|
|
int64 log_event_id_ = 0;
|
2023-05-25 15:46:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PendingStory {
|
|
|
|
DialogId dialog_id_;
|
|
|
|
StoryId story_id_;
|
|
|
|
uint64 log_event_id_ = 0;
|
|
|
|
uint32 send_story_num_ = 0;
|
|
|
|
int64 random_id_ = 0;
|
2023-05-25 21:21:10 +03:00
|
|
|
bool was_reuploaded_ = false;
|
2023-05-25 15:46:04 +03:00
|
|
|
unique_ptr<Story> story_;
|
|
|
|
|
2023-07-03 20:39:42 +03:00
|
|
|
PendingStory() = default;
|
|
|
|
|
2023-07-03 22:03:29 +03:00
|
|
|
PendingStory(DialogId dialog_id, StoryId story_id, uint32 send_story_num, int64 random_id,
|
2023-05-25 15:46:04 +03:00
|
|
|
unique_ptr<Story> &&story);
|
2023-07-03 20:39:42 +03:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2023-05-25 15:46:04 +03:00
|
|
|
};
|
|
|
|
|
2023-07-09 16:01:14 +03:00
|
|
|
struct ReadyToSendStory {
|
|
|
|
FileId file_id_;
|
|
|
|
unique_ptr<PendingStory> pending_story_;
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> input_file_;
|
|
|
|
|
|
|
|
ReadyToSendStory(FileId file_id, unique_ptr<PendingStory> &&pending_story,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> &&input_file);
|
|
|
|
};
|
|
|
|
|
2023-06-14 16:06:48 +03:00
|
|
|
struct PendingStoryViews {
|
|
|
|
FlatHashSet<StoryId, StoryIdHash> story_ids_;
|
|
|
|
bool has_query_ = false;
|
|
|
|
};
|
|
|
|
|
2023-06-14 19:27:08 +03:00
|
|
|
struct ActiveStories {
|
|
|
|
StoryId max_read_story_id_;
|
|
|
|
vector<StoryId> story_ids_;
|
2023-07-08 15:42:23 +03:00
|
|
|
StoryListId story_list_id_;
|
2023-06-29 14:22:50 +03:00
|
|
|
int64 private_order_ = 0;
|
|
|
|
int64 public_order_ = 0;
|
2023-07-15 02:25:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SavedActiveStories {
|
|
|
|
StoryId max_read_story_id_;
|
|
|
|
vector<StoryInfo> story_infos_;
|
2023-07-14 17:42:59 +03:00
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
2023-06-14 19:27:08 +03:00
|
|
|
};
|
|
|
|
|
2023-06-29 14:22:50 +03:00
|
|
|
struct StoryList {
|
|
|
|
int32 server_total_count_ = -1;
|
2023-07-08 18:50:58 +03:00
|
|
|
int32 sent_total_count_ = -1;
|
2023-06-29 14:22:50 +03:00
|
|
|
string state_;
|
|
|
|
|
2023-08-07 00:02:30 +03:00
|
|
|
bool is_reloaded_server_total_count_ = false;
|
2023-07-16 17:52:08 +03:00
|
|
|
bool server_has_more_ = true;
|
2023-07-17 15:50:27 +03:00
|
|
|
bool database_has_more_ = false;
|
2023-07-16 17:52:08 +03:00
|
|
|
|
2023-07-17 14:40:01 +03:00
|
|
|
vector<Promise<Unit>> load_list_from_server_queries_;
|
2023-07-17 15:50:27 +03:00
|
|
|
vector<Promise<Unit>> load_list_from_database_queries_;
|
2023-06-30 16:05:08 +03:00
|
|
|
|
2023-06-30 17:12:19 +03:00
|
|
|
std::set<DialogDate> ordered_stories_; // all known active stories from the story list
|
|
|
|
|
2023-07-17 15:50:27 +03:00
|
|
|
DialogDate last_loaded_database_dialog_date_ = MIN_DIALOG_DATE; // in memory
|
|
|
|
DialogDate list_last_story_date_ = MIN_DIALOG_DATE; // in memory
|
2023-06-29 14:22:50 +03:00
|
|
|
};
|
|
|
|
|
2023-07-16 17:52:08 +03:00
|
|
|
struct SavedStoryList {
|
|
|
|
string state_;
|
|
|
|
int32 total_count_ = -1;
|
|
|
|
bool has_more_ = true;
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
2023-05-01 22:19:16 +03:00
|
|
|
public:
|
|
|
|
StoryManager(Td *td, ActorShared<> parent);
|
2023-05-18 17:20:22 +03:00
|
|
|
StoryManager(const StoryManager &) = delete;
|
|
|
|
StoryManager &operator=(const StoryManager &) = delete;
|
|
|
|
StoryManager(StoryManager &&) = delete;
|
|
|
|
StoryManager &operator=(StoryManager &&) = delete;
|
|
|
|
~StoryManager() final;
|
2023-05-01 22:19:16 +03:00
|
|
|
|
2023-07-11 12:29:10 +03:00
|
|
|
void get_story(DialogId owner_dialog_id, StoryId story_id, bool only_local,
|
|
|
|
Promise<td_api::object_ptr<td_api::story>> &&promise);
|
2023-06-05 16:55:06 +03:00
|
|
|
|
2023-09-14 18:59:30 +03:00
|
|
|
void get_dialogs_to_send_stories(Promise<td_api::object_ptr<td_api::chats>> &&promise);
|
|
|
|
|
|
|
|
void reload_dialogs_to_send_stories(Promise<td_api::object_ptr<td_api::chats>> &&promise);
|
|
|
|
|
|
|
|
void on_get_dialogs_to_send_stories(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
|
|
|
|
2023-09-20 19:07:51 +03:00
|
|
|
void update_dialogs_to_send_stories(ChannelId channel_id, bool can_send_stories);
|
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void can_send_story(DialogId dialog_id, Promise<td_api::object_ptr<td_api::CanSendStoryResult>> &&promise);
|
2023-08-11 19:43:26 +03:00
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void send_story(DialogId dialog_id, td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
|
2023-08-01 19:07:13 +03:00
|
|
|
td_api::object_ptr<td_api::inputStoryAreas> &&input_areas,
|
2023-05-25 15:03:29 +03:00
|
|
|
td_api::object_ptr<td_api::formattedText> &&input_caption,
|
2023-07-18 16:00:06 +03:00
|
|
|
td_api::object_ptr<td_api::StoryPrivacySettings> &&settings, int32 active_period, bool is_pinned,
|
2023-06-27 17:19:10 +03:00
|
|
|
bool protect_content, Promise<td_api::object_ptr<td_api::story>> &&promise);
|
2023-05-25 15:03:29 +03:00
|
|
|
|
2023-07-05 10:55:16 +03:00
|
|
|
void on_send_story_file_parts_missing(unique_ptr<PendingStory> &&pending_story, vector<int> &&bad_parts);
|
2023-05-25 15:46:04 +03:00
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void edit_story(DialogId owner_dialog_id, StoryId story_id,
|
|
|
|
td_api::object_ptr<td_api::InputStoryContent> &&input_story_content,
|
2023-08-01 20:37:37 +03:00
|
|
|
td_api::object_ptr<td_api::inputStoryAreas> &&input_areas,
|
2023-05-30 14:41:36 +03:00
|
|
|
td_api::object_ptr<td_api::formattedText> &&input_caption, Promise<Unit> &&promise);
|
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void set_story_privacy_settings(DialogId owner_dialog_id, StoryId story_id,
|
|
|
|
td_api::object_ptr<td_api::StoryPrivacySettings> &&settings, Promise<Unit> &&promise);
|
2023-05-25 18:18:28 +03:00
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void toggle_story_is_pinned(DialogId owner_dialog_id, StoryId story_id, bool is_pinned, Promise<Unit> &&promise);
|
2023-05-26 14:21:36 +03:00
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void delete_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise);
|
2023-06-01 17:28:49 +03:00
|
|
|
|
2023-07-08 15:42:23 +03:00
|
|
|
void load_active_stories(StoryListId story_list_id, Promise<Unit> &&promise);
|
2023-06-29 14:22:50 +03:00
|
|
|
|
2023-07-06 18:22:20 +03:00
|
|
|
void reload_active_stories();
|
|
|
|
|
2023-07-07 17:41:30 +03:00
|
|
|
void reload_all_read_stories();
|
|
|
|
|
2023-07-08 16:53:29 +03:00
|
|
|
void toggle_dialog_stories_hidden(DialogId dialog_id, StoryListId story_list_id, Promise<Unit> &&promise);
|
2023-06-05 16:07:44 +03:00
|
|
|
|
2023-05-20 23:24:36 +03:00
|
|
|
void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void get_story_archive(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
|
|
|
|
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
2023-06-09 17:21:34 +03:00
|
|
|
|
2023-06-14 19:27:08 +03:00
|
|
|
void get_dialog_expiring_stories(DialogId owner_dialog_id,
|
2023-07-07 16:52:56 +03:00
|
|
|
Promise<td_api::object_ptr<td_api::chatActiveStories>> &&promise);
|
2023-05-21 12:39:53 +03:00
|
|
|
|
2023-08-07 23:04:23 +03:00
|
|
|
void reload_dialog_expiring_stories(DialogId dialog_id);
|
|
|
|
|
2023-06-14 15:17:24 +03:00
|
|
|
void open_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise);
|
|
|
|
|
2023-06-15 18:34:05 +03:00
|
|
|
void close_story(DialogId owner_dialog_id, StoryId story_id, Promise<Unit> &&promise);
|
|
|
|
|
2023-06-23 13:40:59 +03:00
|
|
|
void view_story_message(StoryFullId story_full_id);
|
|
|
|
|
2023-07-02 19:10:40 +03:00
|
|
|
void on_story_replied(StoryFullId story_full_id, UserId replier_user_id);
|
|
|
|
|
2023-08-06 23:28:00 +03:00
|
|
|
void set_story_reaction(StoryFullId story_full_id, ReactionType reaction_type, bool add_to_recent,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2023-08-07 19:56:55 +03:00
|
|
|
void get_story_viewers(StoryId story_id, const string &query, bool only_contacts, bool prefer_with_reaction,
|
|
|
|
const string &offset, int32 limit,
|
2023-08-07 16:03:10 +03:00
|
|
|
Promise<td_api::object_ptr<td_api::storyViewers>> &&promise);
|
2023-06-18 23:25:50 +03:00
|
|
|
|
2023-06-21 23:23:19 +03:00
|
|
|
void report_story(StoryFullId story_full_id, ReportReason &&reason, Promise<Unit> &&promise);
|
|
|
|
|
2023-08-04 15:23:51 +03:00
|
|
|
void activate_stealth_mode(Promise<Unit> &&promise);
|
|
|
|
|
2023-06-22 15:56:34 +03:00
|
|
|
void remove_story_notifications_by_story_ids(DialogId dialog_id, const vector<StoryId> &story_ids);
|
|
|
|
|
2023-06-12 19:23:58 +03:00
|
|
|
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::StoryItem> &&story_item_ptr);
|
2023-05-08 20:09:01 +03:00
|
|
|
|
2023-06-15 18:57:12 +03:00
|
|
|
std::pair<int32, vector<StoryId>> on_get_stories(DialogId owner_dialog_id, vector<StoryId> &&expected_story_ids,
|
2023-05-19 23:25:52 +03:00
|
|
|
telegram_api::object_ptr<telegram_api::stories_stories> &&stories);
|
|
|
|
|
2023-08-15 22:45:37 +03:00
|
|
|
DialogId on_get_dialog_stories(DialogId owner_dialog_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::peerStories> &&peer_stories,
|
|
|
|
Promise<Unit> &&promise);
|
2023-06-15 13:22:36 +03:00
|
|
|
|
2023-08-11 14:07:13 +03:00
|
|
|
void on_update_story_id(int64 random_id, StoryId new_story_id, const char *source);
|
|
|
|
|
2023-06-15 14:51:41 +03:00
|
|
|
bool on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id);
|
2023-06-15 13:16:31 +03:00
|
|
|
|
2023-08-04 14:51:39 +03:00
|
|
|
void on_update_story_stealth_mode(telegram_api::object_ptr<telegram_api::storiesStealthMode> &&stealth_mode);
|
|
|
|
|
2023-08-04 19:18:27 +03:00
|
|
|
void on_update_story_chosen_reaction_type(DialogId owner_dialog_id, StoryId story_id,
|
|
|
|
ReactionType chosen_reaction_type);
|
|
|
|
|
2023-09-02 23:23:38 +03:00
|
|
|
void on_update_dialog_stories_hidden(DialogId owner_dialog_id, bool stories_hidden);
|
|
|
|
|
2023-07-07 15:52:55 +03:00
|
|
|
void on_dialog_active_stories_order_updated(DialogId owner_dialog_id, const char *source);
|
2023-06-28 16:09:44 +03:00
|
|
|
|
2023-10-04 11:28:56 +03:00
|
|
|
Status can_get_story_viewers(StoryFullId story_full_id, const Story *story, int32 unix_time) const;
|
2023-09-28 16:31:17 +03:00
|
|
|
|
|
|
|
bool has_unexpired_viewers(StoryFullId story_full_id, const Story *story) const;
|
2023-06-19 19:13:08 +03:00
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void on_get_story_views(DialogId owner_dialog_id, const vector<StoryId> &story_ids,
|
2023-06-15 19:30:28 +03:00
|
|
|
telegram_api::object_ptr<telegram_api::stories_storyViews> &&story_views);
|
|
|
|
|
2023-06-06 15:58:27 +03:00
|
|
|
bool have_story(StoryFullId story_full_id) const;
|
|
|
|
|
2023-07-10 14:56:39 +03:00
|
|
|
bool have_story_force(StoryFullId story_full_id);
|
2023-06-13 15:45:10 +03:00
|
|
|
|
2023-06-06 16:11:12 +03:00
|
|
|
bool is_inaccessible_story(StoryFullId story_full_id) const;
|
|
|
|
|
2023-06-06 16:07:29 +03:00
|
|
|
int32 get_story_duration(StoryFullId story_full_id) const;
|
|
|
|
|
2023-09-21 19:11:17 +03:00
|
|
|
void register_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source);
|
2023-06-13 18:20:26 +03:00
|
|
|
|
2023-09-21 19:11:17 +03:00
|
|
|
void unregister_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source);
|
2023-06-13 18:20:26 +03:00
|
|
|
|
2023-05-19 13:41:15 +03:00
|
|
|
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id) const;
|
|
|
|
|
2023-05-20 23:24:36 +03:00
|
|
|
td_api::object_ptr<td_api::stories> get_stories_object(int32 total_count,
|
|
|
|
const vector<StoryFullId> &story_full_ids) const;
|
|
|
|
|
2023-05-20 01:23:33 +03:00
|
|
|
FileSourceId get_story_file_source_id(StoryFullId story_full_id);
|
|
|
|
|
2023-06-12 19:23:58 +03:00
|
|
|
telegram_api::object_ptr<telegram_api::InputMedia> get_input_media(StoryFullId story_full_id) const;
|
|
|
|
|
2023-07-13 16:39:19 +03:00
|
|
|
void reload_story(StoryFullId story_full_id, Promise<Unit> &&promise, const char *source);
|
2023-05-19 23:34:08 +03:00
|
|
|
|
2023-06-16 17:55:54 +03:00
|
|
|
void try_synchronize_archive_all_stories();
|
|
|
|
|
2023-07-07 16:18:18 +03:00
|
|
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
|
|
|
|
2023-06-01 17:41:46 +03:00
|
|
|
void on_binlog_events(vector<BinlogEvent> &&events);
|
|
|
|
|
2023-05-01 22:19:16 +03:00
|
|
|
private:
|
2023-05-25 15:03:29 +03:00
|
|
|
class UploadMediaCallback;
|
|
|
|
|
|
|
|
class SendStoryQuery;
|
2023-05-30 14:41:36 +03:00
|
|
|
class EditStoryQuery;
|
2023-05-25 15:03:29 +03:00
|
|
|
|
2023-06-01 17:41:46 +03:00
|
|
|
class DeleteStoryOnServerLogEvent;
|
2023-06-15 15:25:32 +03:00
|
|
|
class ReadStoriesOnServerLogEvent;
|
2023-06-28 17:52:33 +03:00
|
|
|
class LoadDialogExpiringStoriesLogEvent;
|
2023-07-03 22:03:29 +03:00
|
|
|
class SendStoryLogEvent;
|
2023-07-04 18:42:43 +03:00
|
|
|
class EditStoryLogEvent;
|
2023-06-01 17:41:46 +03:00
|
|
|
|
2023-06-22 21:40:34 +03:00
|
|
|
static constexpr int32 OPENED_STORY_POLL_PERIOD = 60;
|
2023-06-23 13:40:59 +03:00
|
|
|
static constexpr int32 VIEWED_STORY_POLL_PERIOD = 300;
|
2023-06-22 21:40:34 +03:00
|
|
|
|
2023-07-10 19:43:26 +03:00
|
|
|
static constexpr int32 DEFAULT_LOADED_EXPIRED_STORIES = 50;
|
|
|
|
|
2023-06-16 17:55:54 +03:00
|
|
|
void start_up() final;
|
|
|
|
|
2023-07-10 19:43:26 +03:00
|
|
|
void timeout_expired() final;
|
|
|
|
|
2023-06-22 21:53:03 +03:00
|
|
|
void hangup() final;
|
|
|
|
|
2023-05-01 22:19:16 +03:00
|
|
|
void tear_down() final;
|
|
|
|
|
2023-06-22 22:23:24 +03:00
|
|
|
static void on_story_reload_timeout_callback(void *story_manager_ptr, int64 story_global_id);
|
|
|
|
|
|
|
|
void on_story_reload_timeout(int64 story_global_id);
|
|
|
|
|
2023-06-19 20:45:58 +03:00
|
|
|
static void on_story_expire_timeout_callback(void *story_manager_ptr, int64 story_global_id);
|
|
|
|
|
|
|
|
void on_story_expire_timeout(int64 story_global_id);
|
|
|
|
|
2023-06-20 00:05:19 +03:00
|
|
|
static void on_story_can_get_viewers_timeout_callback(void *story_manager_ptr, int64 story_global_id);
|
|
|
|
|
|
|
|
void on_story_can_get_viewers_timeout(int64 story_global_id);
|
|
|
|
|
2023-09-04 21:34:17 +03:00
|
|
|
bool is_my_story(DialogId owner_dialog_id) const;
|
|
|
|
|
2023-09-04 21:52:05 +03:00
|
|
|
bool can_access_expired_story(DialogId owner_dialog_id, const Story *story) const;
|
|
|
|
|
2023-09-04 22:19:42 +03:00
|
|
|
bool can_get_story_view_count(DialogId owner_dialog_id);
|
|
|
|
|
2023-09-04 21:45:16 +03:00
|
|
|
bool can_post_stories(DialogId owner_dialog_id) const;
|
|
|
|
|
|
|
|
bool can_edit_stories(DialogId owner_dialog_id) const;
|
|
|
|
|
|
|
|
bool can_delete_stories(DialogId owner_dialog_id) const;
|
|
|
|
|
2023-09-05 15:50:38 +03:00
|
|
|
bool can_edit_story(StoryFullId story_full_id, const Story *story) const;
|
2023-09-04 23:49:17 +03:00
|
|
|
|
2023-09-05 15:50:38 +03:00
|
|
|
bool can_toggle_story_is_pinned(StoryFullId story_full_id, const Story *story) const;
|
2023-09-04 23:49:17 +03:00
|
|
|
|
2023-09-05 15:50:38 +03:00
|
|
|
bool can_delete_story(StoryFullId story_full_id, const Story *story) const;
|
2023-09-04 23:49:17 +03:00
|
|
|
|
2023-06-20 00:05:19 +03:00
|
|
|
int32 get_story_viewers_expire_date(const Story *story) const;
|
|
|
|
|
|
|
|
static bool is_active_story(const Story *story);
|
2023-06-15 12:00:19 +03:00
|
|
|
|
2023-06-28 18:23:40 +03:00
|
|
|
DialogId get_changelog_story_dialog_id() const;
|
|
|
|
|
2023-06-28 16:56:17 +03:00
|
|
|
bool is_subscribed_to_dialog_stories(DialogId owner_dialog_id) const;
|
|
|
|
|
2023-07-08 15:42:23 +03:00
|
|
|
StoryListId get_dialog_story_list_id(DialogId owner_dialog_id) const;
|
2023-06-30 16:05:08 +03:00
|
|
|
|
2023-07-03 20:03:26 +03:00
|
|
|
void add_story_dependencies(Dependencies &dependencies, const Story *story);
|
|
|
|
|
|
|
|
void add_pending_story_dependencies(Dependencies &dependencies, const PendingStory *pending_story);
|
|
|
|
|
2023-05-18 19:57:50 +03:00
|
|
|
const Story *get_story(StoryFullId story_full_id) const;
|
2023-05-08 20:09:01 +03:00
|
|
|
|
2023-05-18 19:57:50 +03:00
|
|
|
Story *get_story_editable(StoryFullId story_full_id);
|
2023-05-08 20:09:01 +03:00
|
|
|
|
2023-07-10 14:56:39 +03:00
|
|
|
Story *get_story_force(StoryFullId story_full_id, const char *source);
|
|
|
|
|
|
|
|
unique_ptr<Story> parse_story(StoryFullId story_full_id, const BufferSlice &value);
|
|
|
|
|
|
|
|
Story *on_get_story_from_database(StoryFullId story_full_id, const BufferSlice &value, const char *source);
|
|
|
|
|
2023-06-15 13:49:23 +03:00
|
|
|
const ActiveStories *get_active_stories(DialogId owner_dialog_id) const;
|
|
|
|
|
2023-06-30 14:10:42 +03:00
|
|
|
ActiveStories *get_active_stories_editable(DialogId owner_dialog_id);
|
|
|
|
|
2023-07-15 03:36:18 +03:00
|
|
|
ActiveStories *get_active_stories_force(DialogId owner_dialog_id, const char *source);
|
|
|
|
|
2023-08-07 00:02:30 +03:00
|
|
|
ActiveStories *on_get_active_stories_from_database(StoryListId story_list_id, DialogId owner_dialog_id,
|
|
|
|
const BufferSlice &value, const char *source);
|
2023-07-15 03:36:18 +03:00
|
|
|
|
2023-09-27 15:31:34 +03:00
|
|
|
void set_story_expire_timeout(const Story *story);
|
|
|
|
|
|
|
|
void set_story_can_get_viewers_timeout(const Story *story);
|
|
|
|
|
2023-07-10 14:56:39 +03:00
|
|
|
void on_story_changed(StoryFullId story_full_id, const Story *story, bool is_changed, bool need_save_to_database,
|
|
|
|
bool from_database = false);
|
2023-05-26 14:21:36 +03:00
|
|
|
|
2023-06-19 20:13:44 +03:00
|
|
|
void register_story_global_id(StoryFullId story_full_id, Story *story);
|
|
|
|
|
|
|
|
void unregister_story_global_id(const Story *story);
|
|
|
|
|
2023-07-15 02:46:50 +03:00
|
|
|
StoryId on_get_story_info(DialogId owner_dialog_id, StoryInfo &&story_info);
|
|
|
|
|
2023-07-15 02:16:48 +03:00
|
|
|
StoryInfo get_story_info(StoryFullId story_full_id) const;
|
2023-06-14 19:27:08 +03:00
|
|
|
|
2023-07-15 02:16:48 +03:00
|
|
|
td_api::object_ptr<td_api::storyInfo> get_story_info_object(StoryFullId story_full_id) const;
|
2023-06-14 19:27:08 +03:00
|
|
|
|
2023-05-19 13:41:15 +03:00
|
|
|
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id, const Story *story) const;
|
2023-06-01 16:27:00 +03:00
|
|
|
|
2023-07-14 16:27:03 +03:00
|
|
|
td_api::object_ptr<td_api::chatActiveStories> get_chat_active_stories_object(
|
|
|
|
DialogId owner_dialog_id, const ActiveStories *active_stories) const;
|
|
|
|
|
2023-06-28 16:38:33 +03:00
|
|
|
StoryId on_get_new_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::storyItem> &&story_item);
|
2023-06-01 16:27:00 +03:00
|
|
|
|
2023-06-14 20:10:57 +03:00
|
|
|
StoryId on_get_skipped_story(DialogId owner_dialog_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::storyItemSkipped> &&story_item);
|
|
|
|
|
2023-06-14 20:17:40 +03:00
|
|
|
StoryId on_get_deleted_story(DialogId owner_dialog_id,
|
|
|
|
telegram_api::object_ptr<telegram_api::storyItemDeleted> &&story_item);
|
|
|
|
|
2023-06-25 00:37:52 +03:00
|
|
|
void on_delete_story(StoryFullId story_full_id);
|
2023-05-19 13:41:15 +03:00
|
|
|
|
2023-09-14 18:59:30 +03:00
|
|
|
void return_dialogs_to_send_stories(Promise<td_api::object_ptr<td_api::chats>> &&promise,
|
|
|
|
const vector<ChannelId> &channel_ids);
|
|
|
|
|
|
|
|
void finish_get_dialogs_to_send_stories(Result<Unit> &&result);
|
|
|
|
|
2023-09-20 19:07:51 +03:00
|
|
|
void save_channels_to_send_stories();
|
|
|
|
|
2023-05-20 23:24:36 +03:00
|
|
|
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);
|
|
|
|
|
2023-08-15 22:45:37 +03:00
|
|
|
void on_get_story_archive(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
|
2023-06-09 17:21:34 +03:00
|
|
|
Promise<td_api::object_ptr<td_api::stories>> &&promise);
|
|
|
|
|
2023-05-21 12:39:53 +03:00
|
|
|
void on_get_dialog_expiring_stories(DialogId owner_dialog_id,
|
2023-08-15 22:45:37 +03:00
|
|
|
telegram_api::object_ptr<telegram_api::stories_peerStories> &&stories,
|
2023-07-07 16:52:56 +03:00
|
|
|
Promise<td_api::object_ptr<td_api::chatActiveStories>> &&promise);
|
2023-05-21 12:39:53 +03:00
|
|
|
|
2023-06-28 17:52:33 +03:00
|
|
|
static uint64 save_load_dialog_expiring_stories_log_event(DialogId owner_dialog_id);
|
|
|
|
|
2023-06-30 16:20:09 +03:00
|
|
|
void load_dialog_expiring_stories(DialogId owner_dialog_id, uint64 log_event_id, const char *source);
|
2023-06-28 17:52:33 +03:00
|
|
|
|
|
|
|
void on_load_dialog_expiring_stories(DialogId owner_dialog_id);
|
2023-06-28 17:10:14 +03:00
|
|
|
|
2023-07-17 15:50:27 +03:00
|
|
|
void on_load_active_stories_from_database(StoryListId story_list_id, Result<StoryDbGetActiveStoryListResult> result);
|
|
|
|
|
2023-07-17 14:40:01 +03:00
|
|
|
void load_active_stories_from_server(StoryListId story_list_id, StoryList &story_list, bool is_next,
|
|
|
|
Promise<Unit> &&promise);
|
2023-07-06 18:22:20 +03:00
|
|
|
|
2023-07-17 14:40:01 +03:00
|
|
|
void on_load_active_stories_from_server(
|
|
|
|
StoryListId story_list_id, bool is_next, string old_state,
|
|
|
|
Result<telegram_api::object_ptr<telegram_api::stories_AllStories>> r_all_stories);
|
2023-06-29 14:22:50 +03:00
|
|
|
|
2023-07-16 17:52:08 +03:00
|
|
|
void save_story_list(StoryListId story_list_id, string state, int32 total_count, bool has_more);
|
|
|
|
|
2023-07-13 15:53:40 +03:00
|
|
|
StoryList &get_story_list(StoryListId story_list_id);
|
|
|
|
|
|
|
|
const StoryList &get_story_list(StoryListId story_list_id) const;
|
|
|
|
|
2023-07-08 18:50:58 +03:00
|
|
|
td_api::object_ptr<td_api::updateStoryListChatCount> get_update_story_list_chat_count_object(
|
|
|
|
StoryListId story_list_id, const StoryList &story_list) const;
|
|
|
|
|
2023-09-27 00:40:36 +03:00
|
|
|
void update_story_list_sent_total_count(StoryListId story_list_id, const char *source);
|
2023-07-13 15:37:11 +03:00
|
|
|
|
2023-09-27 00:40:36 +03:00
|
|
|
void update_story_list_sent_total_count(StoryListId story_list_id, StoryList &story_list, const char *source);
|
2023-07-08 18:50:58 +03:00
|
|
|
|
2023-05-19 17:00:33 +03:00
|
|
|
vector<FileId> get_story_file_ids(const Story *story) const;
|
|
|
|
|
2023-06-25 00:37:52 +03:00
|
|
|
static uint64 save_delete_story_on_server_log_event(StoryFullId story_full_id);
|
2023-06-01 17:41:46 +03:00
|
|
|
|
2023-06-25 00:37:52 +03:00
|
|
|
void delete_story_on_server(StoryFullId story_full_id, uint64 log_event_id, Promise<Unit> &&promise);
|
2023-06-01 17:28:49 +03:00
|
|
|
|
2023-07-10 13:52:42 +03:00
|
|
|
void delete_story_from_database(StoryFullId story_full_id);
|
|
|
|
|
2023-05-19 17:00:33 +03:00
|
|
|
void delete_story_files(const Story *story) const;
|
|
|
|
|
2023-05-20 01:23:33 +03:00
|
|
|
void change_story_files(StoryFullId story_full_id, const Story *story, const vector<FileId> &old_file_ids);
|
|
|
|
|
2023-06-05 16:55:06 +03:00
|
|
|
void do_get_story(StoryFullId story_full_id, Result<Unit> &&result,
|
|
|
|
Promise<td_api::object_ptr<td_api::story>> &&promise);
|
|
|
|
|
2023-06-22 21:53:03 +03:00
|
|
|
void on_reload_story(StoryFullId story_full_id, Result<Unit> &&result);
|
|
|
|
|
2023-07-03 22:03:29 +03:00
|
|
|
int64 save_send_story_log_event(const PendingStory *pending_story);
|
|
|
|
|
2023-07-03 22:54:42 +03:00
|
|
|
void delete_pending_story(FileId file_id, unique_ptr<PendingStory> &&pending_story, Status status);
|
2023-07-03 18:01:25 +03:00
|
|
|
|
2023-08-11 15:16:24 +03:00
|
|
|
Result<StoryId> get_next_yet_unsent_story_id(DialogId dialog_id);
|
|
|
|
|
2023-05-25 21:09:31 +03:00
|
|
|
void do_send_story(unique_ptr<PendingStory> &&pending_story, vector<int> bad_parts);
|
2023-05-25 15:03:29 +03:00
|
|
|
|
|
|
|
void on_upload_story(FileId file_id, telegram_api::object_ptr<telegram_api::InputFile> input_file);
|
|
|
|
|
|
|
|
void on_upload_story_error(FileId file_id, Status status);
|
|
|
|
|
2023-08-10 23:29:48 +03:00
|
|
|
void try_send_story(DialogId dialog_id);
|
2023-07-09 16:01:14 +03:00
|
|
|
|
2023-05-30 14:41:36 +03:00
|
|
|
void do_edit_story(FileId file_id, unique_ptr<PendingStory> &&pending_story,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputFile> input_file);
|
|
|
|
|
2023-09-04 23:49:17 +03:00
|
|
|
void on_toggle_story_is_pinned(StoryFullId story_full_id, bool is_pinned, Promise<Unit> &&promise);
|
2023-05-26 14:21:36 +03:00
|
|
|
|
2023-09-02 23:06:24 +03:00
|
|
|
void on_update_dialog_max_story_ids(DialogId owner_dialog_id, StoryId max_story_id, StoryId max_read_story_id);
|
|
|
|
|
2023-09-02 23:13:52 +03:00
|
|
|
void on_update_dialog_max_read_story_id(DialogId owner_dialog_id, StoryId max_read_story_id);
|
|
|
|
|
2023-09-02 23:23:38 +03:00
|
|
|
void on_update_dialog_has_pinned_stories(DialogId owner_dialog_id, bool has_pinned_stories);
|
|
|
|
|
2023-09-27 16:15:18 +03:00
|
|
|
void update_active_stories(DialogId owner_dialog_id);
|
|
|
|
|
2023-07-16 15:39:55 +03:00
|
|
|
void on_update_active_stories(DialogId owner_dialog_id, StoryId max_read_story_id, vector<StoryId> &&story_ids,
|
2023-07-23 09:50:26 +03:00
|
|
|
Promise<Unit> &&promise, const char *source, bool from_database = false);
|
2023-06-15 12:42:42 +03:00
|
|
|
|
2023-07-14 17:26:09 +03:00
|
|
|
bool update_active_stories_order(DialogId owner_dialog_id, ActiveStories *active_stories,
|
|
|
|
bool *need_save_to_database);
|
2023-06-30 14:10:42 +03:00
|
|
|
|
2023-07-07 15:49:46 +03:00
|
|
|
void delete_active_stories_from_story_list(DialogId owner_dialog_id, const ActiveStories *active_stories);
|
|
|
|
|
2023-07-12 16:16:55 +03:00
|
|
|
void send_update_story(StoryFullId story_full_id, const Story *story);
|
|
|
|
|
2023-08-16 17:34:36 +03:00
|
|
|
td_api::object_ptr<td_api::updateChatActiveStories> get_update_chat_active_stories_object(
|
2023-07-14 16:30:49 +03:00
|
|
|
DialogId owner_dialog_id, const ActiveStories *active_stories) const;
|
2023-07-07 16:13:12 +03:00
|
|
|
|
2023-08-16 17:57:16 +03:00
|
|
|
void send_update_chat_active_stories(DialogId owner_dialog_id, const ActiveStories *active_stories,
|
|
|
|
const char *source);
|
2023-06-15 12:42:42 +03:00
|
|
|
|
2023-07-22 18:19:05 +03:00
|
|
|
void save_active_stories(DialogId owner_dialog_id, const ActiveStories *active_stories, Promise<Unit> &&promise,
|
|
|
|
const char *source) const;
|
2023-07-14 17:42:59 +03:00
|
|
|
|
2023-06-14 16:06:48 +03:00
|
|
|
void increment_story_views(DialogId owner_dialog_id, PendingStoryViews &story_views);
|
|
|
|
|
|
|
|
void on_increment_story_views(DialogId owner_dialog_id);
|
|
|
|
|
2023-06-15 15:25:32 +03:00
|
|
|
static uint64 save_read_stories_on_server_log_event(DialogId dialog_id, StoryId max_story_id);
|
|
|
|
|
|
|
|
void read_stories_on_server(DialogId owner_dialog_id, StoryId story_id, uint64 log_event_id);
|
2023-06-15 14:51:41 +03:00
|
|
|
|
2023-09-19 13:42:13 +03:00
|
|
|
static bool has_suggested_reaction(const Story *story, const ReactionType &reaction_type);
|
|
|
|
|
2023-08-25 19:11:24 +03:00
|
|
|
bool can_use_story_reaction(const Story *story, const ReactionType &reaction_type) const;
|
2023-08-06 23:28:00 +03:00
|
|
|
|
2023-09-19 14:41:31 +03:00
|
|
|
void on_story_chosen_reaction_changed(StoryFullId story_full_id, Story *story, const ReactionType &reaction_type);
|
|
|
|
|
2023-06-15 20:07:40 +03:00
|
|
|
void schedule_interaction_info_update();
|
|
|
|
|
|
|
|
static void update_interaction_info_static(void *story_manager);
|
|
|
|
|
|
|
|
void update_interaction_info();
|
|
|
|
|
2023-06-16 17:55:54 +03:00
|
|
|
void on_synchronized_archive_all_stories(bool set_archive_all_stories, Result<Unit> result);
|
|
|
|
|
2023-08-04 14:51:39 +03:00
|
|
|
td_api::object_ptr<td_api::updateStoryStealthMode> get_update_story_stealth_mode() const;
|
|
|
|
|
|
|
|
void send_update_story_stealth_mode() const;
|
|
|
|
|
2023-08-08 01:18:33 +03:00
|
|
|
void schedule_stealth_mode_update();
|
|
|
|
|
|
|
|
static void update_stealth_mode_static(void *story_manager);
|
|
|
|
|
|
|
|
void update_stealth_mode();
|
|
|
|
|
2023-08-08 01:04:08 +03:00
|
|
|
static string get_story_stealth_mode_key();
|
|
|
|
|
2023-08-04 14:51:39 +03:00
|
|
|
void set_story_stealth_mode(StoryStealthMode stealth_mode);
|
|
|
|
|
2023-08-07 20:04:06 +03:00
|
|
|
void on_get_story_viewers(StoryId story_id, bool is_full, bool is_first,
|
2023-06-18 23:25:50 +03:00
|
|
|
Result<telegram_api::object_ptr<telegram_api::stories_storyViewsList>> r_view_list,
|
2023-08-07 16:03:10 +03:00
|
|
|
Promise<td_api::object_ptr<td_api::storyViewers>> &&promise);
|
2023-06-18 23:25:50 +03:00
|
|
|
|
2023-08-06 23:28:00 +03:00
|
|
|
void on_set_story_reaction(StoryFullId story_full_id, Result<Unit> &&result, Promise<Unit> &&promise);
|
|
|
|
|
2023-07-10 19:43:26 +03:00
|
|
|
void load_expired_database_stories();
|
|
|
|
|
|
|
|
void on_load_expired_database_stories(vector<StoryDbStory> stories);
|
|
|
|
|
2023-05-25 15:03:29 +03:00
|
|
|
std::shared_ptr<UploadMediaCallback> upload_media_callback_;
|
|
|
|
|
2023-05-20 01:23:33 +03:00
|
|
|
WaitFreeHashMap<StoryFullId, FileSourceId, StoryFullIdHash> story_full_id_to_file_source_id_;
|
|
|
|
|
2023-05-18 19:57:50 +03:00
|
|
|
WaitFreeHashMap<StoryFullId, unique_ptr<Story>, StoryFullIdHash> stories_;
|
2023-05-08 20:09:01 +03:00
|
|
|
|
2023-06-19 20:13:44 +03:00
|
|
|
WaitFreeHashMap<int64, StoryFullId> stories_by_global_id_;
|
|
|
|
|
2023-07-16 00:52:52 +03:00
|
|
|
WaitFreeHashMap<StoryFullId, double, StoryFullIdHash> inaccessible_story_full_ids_;
|
2023-06-06 16:11:12 +03:00
|
|
|
|
2023-06-02 16:46:10 +03:00
|
|
|
WaitFreeHashSet<StoryFullId, StoryFullIdHash> deleted_story_full_ids_;
|
|
|
|
|
2023-07-15 23:35:05 +03:00
|
|
|
WaitFreeHashSet<StoryFullId, StoryFullIdHash> failed_to_load_story_full_ids_;
|
|
|
|
|
2023-09-21 19:11:17 +03:00
|
|
|
WaitFreeHashMap<StoryFullId, WaitFreeHashSet<MessageFullId, MessageFullIdHash>, StoryFullIdHash> story_messages_;
|
2023-06-13 18:20:26 +03:00
|
|
|
|
2023-06-15 12:42:42 +03:00
|
|
|
WaitFreeHashMap<DialogId, unique_ptr<ActiveStories>, DialogIdHash> active_stories_;
|
|
|
|
|
2023-08-16 17:34:36 +03:00
|
|
|
WaitFreeHashSet<DialogId, DialogIdHash> updated_active_stories_;
|
|
|
|
|
2023-06-15 14:10:48 +03:00
|
|
|
WaitFreeHashMap<DialogId, StoryId, DialogIdHash> max_read_story_ids_;
|
|
|
|
|
2023-07-16 13:35:35 +03:00
|
|
|
WaitFreeHashSet<DialogId, DialogIdHash> failed_to_load_active_stories_;
|
|
|
|
|
2023-06-28 17:52:33 +03:00
|
|
|
FlatHashMap<DialogId, uint64, DialogIdHash> load_expiring_stories_log_event_ids_;
|
|
|
|
|
2023-05-30 14:41:36 +03:00
|
|
|
FlatHashMap<StoryFullId, unique_ptr<BeingEditedStory>, StoryFullIdHash> being_edited_stories_;
|
|
|
|
|
2023-07-10 17:45:16 +03:00
|
|
|
FlatHashMap<StoryFullId, int64, StoryFullIdHash> edit_generations_;
|
|
|
|
|
2023-06-14 16:06:48 +03:00
|
|
|
FlatHashMap<DialogId, PendingStoryViews, DialogIdHash> pending_story_views_;
|
|
|
|
|
2023-09-04 22:19:42 +03:00
|
|
|
FlatHashMap<StoryFullId, uint32, StoryFullIdHash> opened_stories_with_view_count_;
|
2023-06-15 18:34:05 +03:00
|
|
|
|
2023-06-22 22:23:24 +03:00
|
|
|
FlatHashMap<StoryFullId, uint32, StoryFullIdHash> opened_stories_;
|
|
|
|
|
2023-06-22 21:53:03 +03:00
|
|
|
FlatHashMap<StoryFullId, vector<Promise<Unit>>, StoryFullIdHash> reload_story_queries_;
|
|
|
|
|
2023-07-04 13:42:03 +03:00
|
|
|
FlatHashMap<FileId, unique_ptr<PendingStory>, FileIdHash> being_uploaded_files_;
|
|
|
|
|
2023-08-10 23:29:48 +03:00
|
|
|
FlatHashMap<DialogId, std::set<uint32>, DialogIdHash> yet_unsent_stories_;
|
2023-07-09 16:01:14 +03:00
|
|
|
|
2023-08-16 16:06:16 +03:00
|
|
|
FlatHashMap<DialogId, vector<StoryId>, DialogIdHash> yet_unsent_story_ids_;
|
|
|
|
|
2023-08-11 14:07:13 +03:00
|
|
|
FlatHashMap<int64, StoryFullId> being_sent_stories_;
|
|
|
|
|
2023-08-16 15:10:41 +03:00
|
|
|
FlatHashMap<StoryFullId, int64, StoryFullIdHash> being_sent_story_random_ids_;
|
|
|
|
|
|
|
|
FlatHashMap<StoryFullId, FileId, StoryFullIdHash> being_uploaded_file_ids_;
|
|
|
|
|
2023-08-11 14:07:13 +03:00
|
|
|
FlatHashMap<StoryFullId, StoryId, StoryFullIdHash> update_story_ids_;
|
|
|
|
|
2023-08-16 15:10:41 +03:00
|
|
|
FlatHashMap<int64, vector<Promise<Unit>>> delete_yet_unsent_story_queries_;
|
|
|
|
|
2023-07-09 16:01:14 +03:00
|
|
|
FlatHashMap<uint32, unique_ptr<ReadyToSendStory>> ready_to_send_stories_;
|
|
|
|
|
2023-09-14 18:59:30 +03:00
|
|
|
bool channels_to_send_stories_inited_ = false;
|
|
|
|
vector<ChannelId> channels_to_send_stories_;
|
|
|
|
vector<Promise<td_api::object_ptr<td_api::chats>>> get_dialogs_to_send_stories_queries_;
|
2023-09-27 13:31:09 +03:00
|
|
|
double next_reload_channels_to_send_stories_time_ = 0.0;
|
2023-09-14 18:59:30 +03:00
|
|
|
|
2023-09-19 18:40:15 +03:00
|
|
|
FlatHashMap<StoryFullId, int32, StoryFullIdHash> being_set_story_reactions_;
|
|
|
|
|
2023-06-29 14:22:50 +03:00
|
|
|
StoryList story_lists_[2];
|
|
|
|
|
2023-08-04 14:51:39 +03:00
|
|
|
StoryStealthMode stealth_mode_;
|
|
|
|
|
2023-05-25 15:03:29 +03:00
|
|
|
uint32 send_story_count_ = 0;
|
|
|
|
|
2023-06-19 20:13:44 +03:00
|
|
|
int64 max_story_global_id_ = 0;
|
|
|
|
|
2023-08-11 15:16:24 +03:00
|
|
|
FlatHashMap<DialogId, int32, DialogIdHash> current_yet_unsent_story_ids_;
|
|
|
|
|
2023-06-16 17:55:54 +03:00
|
|
|
bool has_active_synchronize_archive_all_stories_query_ = false;
|
|
|
|
|
2023-08-08 01:18:33 +03:00
|
|
|
Timeout stealth_mode_update_timeout_;
|
|
|
|
|
2023-06-15 20:07:40 +03:00
|
|
|
Timeout interaction_info_update_timeout_;
|
|
|
|
|
2023-07-10 19:43:26 +03:00
|
|
|
int32 load_expired_database_stories_next_limit_ = DEFAULT_LOADED_EXPIRED_STORIES;
|
|
|
|
|
2023-06-22 22:23:24 +03:00
|
|
|
MultiTimeout story_reload_timeout_{"StoryReloadTimeout"};
|
2023-06-19 20:45:58 +03:00
|
|
|
MultiTimeout story_expire_timeout_{"StoryExpireTimeout"};
|
2023-06-20 00:05:19 +03:00
|
|
|
MultiTimeout story_can_get_viewers_timeout_{"StoryCanGetViewersTimeout"};
|
2023-06-19 20:45:58 +03:00
|
|
|
|
2023-05-01 22:19:16 +03:00
|
|
|
Td *td_;
|
|
|
|
ActorShared<> parent_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|