2023-10-12 16:05:03 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2023-10-12 16:05:03 +02:00
|
|
|
//
|
|
|
|
// 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/ChannelId.h"
|
|
|
|
#include "td/telegram/DialogId.h"
|
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class Dependencies;
|
|
|
|
|
|
|
|
class Td;
|
|
|
|
|
|
|
|
class GiveawayParameters {
|
|
|
|
ChannelId boosted_channel_id_;
|
|
|
|
vector<ChannelId> additional_channel_ids_;
|
|
|
|
bool only_new_subscribers_ = false;
|
2023-12-05 11:45:32 +01:00
|
|
|
bool winners_are_visible_ = false;
|
2023-10-12 16:05:03 +02:00
|
|
|
int32 date_ = 0;
|
2023-10-12 17:58:40 +02:00
|
|
|
vector<string> country_codes_;
|
2023-12-05 11:45:32 +01:00
|
|
|
string prize_description_;
|
2023-10-12 16:05:03 +02:00
|
|
|
|
|
|
|
static Result<ChannelId> get_boosted_channel_id(Td *td, DialogId dialog_id);
|
|
|
|
|
|
|
|
friend bool operator==(const GiveawayParameters &lhs, const GiveawayParameters &rhs);
|
|
|
|
friend bool operator!=(const GiveawayParameters &lhs, const GiveawayParameters &rhs);
|
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const GiveawayParameters &giveaway_parameters);
|
|
|
|
|
|
|
|
public:
|
|
|
|
GiveawayParameters() = default;
|
|
|
|
|
|
|
|
GiveawayParameters(ChannelId boosted_channel_id, vector<ChannelId> &&additional_channel_ids,
|
2023-12-05 11:45:32 +01:00
|
|
|
bool only_new_subscribers, bool winners_are_visible, int32 date, vector<string> &&country_codes,
|
|
|
|
string &&prize_description)
|
2023-10-12 16:05:03 +02:00
|
|
|
: boosted_channel_id_(boosted_channel_id)
|
|
|
|
, additional_channel_ids_(std::move(additional_channel_ids))
|
|
|
|
, only_new_subscribers_(only_new_subscribers)
|
2023-12-05 11:45:32 +01:00
|
|
|
, winners_are_visible_(winners_are_visible)
|
2023-10-12 17:58:40 +02:00
|
|
|
, date_(date)
|
2023-12-05 11:45:32 +01:00
|
|
|
, country_codes_(std::move(country_codes))
|
|
|
|
, prize_description_(std::move(prize_description)) {
|
2023-10-12 16:05:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static Result<GiveawayParameters> get_giveaway_parameters(Td *td,
|
|
|
|
const td_api::premiumGiveawayParameters *parameters);
|
|
|
|
|
|
|
|
bool is_valid() const {
|
|
|
|
for (auto channel_id : additional_channel_ids_) {
|
|
|
|
if (!channel_id.is_valid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return boosted_channel_id_.is_valid() && date_ > 0;
|
|
|
|
}
|
|
|
|
|
2023-10-12 17:19:08 +02:00
|
|
|
DialogId get_boosted_dialog_id() const {
|
|
|
|
return DialogId(boosted_channel_id_);
|
|
|
|
}
|
|
|
|
|
2023-10-26 23:34:33 +02:00
|
|
|
vector<ChannelId> get_channel_ids() const;
|
|
|
|
|
2023-10-12 16:05:03 +02:00
|
|
|
void add_dependencies(Dependencies &dependencies) const;
|
|
|
|
|
|
|
|
telegram_api::object_ptr<telegram_api::inputStorePaymentPremiumGiveaway> get_input_store_payment_premium_giveaway(
|
|
|
|
Td *td, const string ¤cy, int64 amount) const;
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::premiumGiveawayParameters> get_premium_giveaway_parameters_object(Td *td) const;
|
|
|
|
|
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const;
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser);
|
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const GiveawayParameters &lhs, const GiveawayParameters &rhs);
|
|
|
|
bool operator!=(const GiveawayParameters &lhs, const GiveawayParameters &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const GiveawayParameters &giveaway_parameters);
|
|
|
|
|
|
|
|
} // namespace td
|