// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 // // 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/FileSourceId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/telegram/UserId.h" #include "td/actor/actor.h" #include "td/utils/common.h" #include "td/utils/FlatHashMap.h" #include "td/utils/Promise.h" #include "td/utils/Status.h" namespace td { class Td; class StarManager final : public Actor { public: StarManager(Td *td, ActorShared<> parent); void on_update_owned_star_count(int64 star_count); void add_owned_star_count(int64 star_count); void get_star_payment_options(Promise> &&promise); void get_star_gift_payment_options(UserId user_id, Promise> &&promise); void get_star_transactions(td_api::object_ptr owner_id, const string &subscription_id, const string &offset, int32 limit, td_api::object_ptr &&direction, Promise> &&promise); void get_star_subscriptions(bool only_expiring, const string &offset, Promise> &&promise); void edit_star_subscriptions(const string &subscription_id, bool is_canceled, Promise &&promise); void reuse_star_subscriptions(const string &subscription_id, Promise &&promise); void refund_star_payment(UserId user_id, const string &telegram_payment_charge_id, Promise &&promise); void get_star_revenue_statistics(const td_api::object_ptr &owner_id, bool is_dark, Promise> &&promise); void get_star_withdrawal_url(const td_api::object_ptr &owner_id, int64 star_count, const string &password, Promise &&promise); void get_star_ad_account_url(const td_api::object_ptr &owner_id, Promise &&promise); void reload_star_transaction(DialogId dialog_id, const string &transaction_id, bool is_refund, Promise &&promise); void on_update_stars_revenue_status(telegram_api::object_ptr &&update); FileSourceId get_star_transaction_file_source_id(DialogId dialog_id, const string &transaction_id, bool is_refund); static int64 get_star_count(int64 amount, bool allow_negative = false); static int32 get_months_by_star_count(int64 star_count); void get_current_state(vector> &updates) const; private: void tear_down() final; Status can_manage_stars(DialogId dialog_id, bool allow_self = false) const; void do_get_star_transactions(DialogId dialog_id, const string &subscription_id, const string &offset, int32 limit, td_api::object_ptr &&direction, Promise> &&promise); void send_get_star_withdrawal_url_query( DialogId dialog_id, int64 star_count, telegram_api::object_ptr input_check_password, Promise &&promise); td_api::object_ptr get_update_owned_star_count_object() const; Td *td_; ActorShared<> parent_; bool is_owned_star_count_inited_ = false; int64 owned_star_count_ = 0; FlatHashMap, DialogIdHash> star_transaction_file_source_ids_[2]; }; } // namespace td