2024-06-13 21:31:51 +02:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2024-06-13 22:21:04 +02:00
|
|
|
#include "td/telegram/DialogId.h"
|
2024-06-28 13:05:25 +02:00
|
|
|
#include "td/telegram/files/FileSourceId.h"
|
2024-06-13 21:41:23 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
2024-06-13 22:21:04 +02:00
|
|
|
#include "td/telegram/telegram_api.h"
|
2024-06-13 21:41:23 +02:00
|
|
|
#include "td/telegram/UserId.h"
|
|
|
|
|
2024-06-13 21:31:51 +02:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2024-06-30 08:29:53 +02:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2024-06-13 21:41:23 +02:00
|
|
|
#include "td/utils/Promise.h"
|
2024-06-16 21:33:27 +02:00
|
|
|
#include "td/utils/Status.h"
|
2024-06-13 21:31:51 +02:00
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class Td;
|
|
|
|
|
|
|
|
class StarManager final : public Actor {
|
|
|
|
public:
|
|
|
|
StarManager(Td *td, ActorShared<> parent);
|
|
|
|
|
2024-06-13 21:41:23 +02:00
|
|
|
void get_star_payment_options(Promise<td_api::object_ptr<td_api::starPaymentOptions>> &&promise);
|
|
|
|
|
2024-07-10 16:19:43 +02:00
|
|
|
void get_star_gift_payment_options(UserId user_id, Promise<td_api::object_ptr<td_api::starPaymentOptions>> &&promise);
|
|
|
|
|
2024-06-14 13:09:02 +02:00
|
|
|
void get_star_transactions(td_api::object_ptr<td_api::MessageSender> owner_id, const string &offset, int32 limit,
|
2024-06-14 12:42:18 +02:00
|
|
|
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
2024-06-13 21:41:23 +02:00
|
|
|
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise);
|
|
|
|
|
|
|
|
void refund_star_payment(UserId user_id, const string &telegram_payment_charge_id, Promise<Unit> &&promise);
|
|
|
|
|
2024-06-14 16:06:26 +02:00
|
|
|
void get_star_revenue_statistics(const td_api::object_ptr<td_api::MessageSender> &owner_id, bool is_dark,
|
|
|
|
Promise<td_api::object_ptr<td_api::starRevenueStatistics>> &&promise);
|
|
|
|
|
2024-06-14 14:18:35 +02:00
|
|
|
void get_star_withdrawal_url(const td_api::object_ptr<td_api::MessageSender> &owner_id, int64 star_count,
|
|
|
|
const string &password, Promise<string> &&promise);
|
2024-06-13 22:21:04 +02:00
|
|
|
|
2024-06-24 19:45:55 +02:00
|
|
|
void get_star_ad_account_url(const td_api::object_ptr<td_api::MessageSender> &owner_id, Promise<string> &&promise);
|
|
|
|
|
2024-06-28 12:29:22 +02:00
|
|
|
void reload_star_transaction(DialogId dialog_id, const string &transaction_id, bool is_refund,
|
|
|
|
Promise<Unit> &&promise);
|
|
|
|
|
2024-06-14 17:06:20 +02:00
|
|
|
void on_update_stars_revenue_status(telegram_api::object_ptr<telegram_api::updateStarsRevenueStatus> &&update);
|
|
|
|
|
2024-06-28 13:05:25 +02:00
|
|
|
FileSourceId get_star_transaction_file_source_id(DialogId dialog_id, const string &transaction_id, bool is_refund);
|
|
|
|
|
2024-06-15 21:09:44 +02:00
|
|
|
static int64 get_star_count(int64 amount, bool allow_negative = false);
|
2024-06-14 16:23:13 +02:00
|
|
|
|
2024-07-30 12:51:53 +02:00
|
|
|
static int32 get_months_by_star_count(int64 star_count);
|
|
|
|
|
2024-06-13 21:31:51 +02:00
|
|
|
private:
|
|
|
|
void tear_down() final;
|
|
|
|
|
2024-06-14 22:31:13 +02:00
|
|
|
Status can_manage_stars(DialogId dialog_id, bool allow_self = false) const;
|
2024-06-14 13:09:02 +02:00
|
|
|
|
2024-07-30 14:18:06 +02:00
|
|
|
void do_get_star_transactions(DialogId dialog_id, const string &offset, int32 limit,
|
|
|
|
td_api::object_ptr<td_api::StarTransactionDirection> &&direction,
|
|
|
|
Promise<td_api::object_ptr<td_api::starTransactions>> &&promise);
|
|
|
|
|
2024-06-13 22:21:04 +02:00
|
|
|
void send_get_star_withdrawal_url_query(
|
|
|
|
DialogId dialog_id, int64 star_count,
|
|
|
|
telegram_api::object_ptr<telegram_api::InputCheckPasswordSRP> input_check_password, Promise<string> &&promise);
|
|
|
|
|
2024-06-13 21:31:51 +02:00
|
|
|
Td *td_;
|
|
|
|
ActorShared<> parent_;
|
2024-06-28 13:05:25 +02:00
|
|
|
|
|
|
|
FlatHashMap<DialogId, FlatHashMap<string, FileSourceId>, DialogIdHash> star_transaction_file_source_ids_[2];
|
2024-06-13 21:31:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|