tdlight/td/telegram/StarSubscription.cpp

39 lines
1.7 KiB
C++
Raw Normal View History

2024-07-25 19:06:29 +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)
//
#include "td/telegram/StarSubscription.h"
#include "td/telegram/DialogManager.h"
#include "td/telegram/Td.h"
namespace td {
StarSubscription::StarSubscription(telegram_api::object_ptr<telegram_api::starsSubscription> &&subscription)
: id_(std::move(subscription->id_))
, dialog_id_(subscription->peer_)
, until_date_(subscription->until_date_)
2024-07-29 20:48:36 +02:00
, can_reuse_(subscription->can_refulfill_)
2024-07-25 19:06:29 +02:00
, is_canceled_(subscription->canceled_)
2024-08-05 08:28:11 +02:00
, missing_balance_(subscription->missing_balance_)
2024-07-25 19:06:29 +02:00
, pricing_(std::move(subscription->pricing_)) {
}
td_api::object_ptr<td_api::starSubscription> StarSubscription::get_star_subscription_object(Td *td) const {
td->dialog_manager_->force_create_dialog(dialog_id_, "starSubscription", true);
return td_api::make_object<td_api::starSubscription>(
2024-07-29 20:48:36 +02:00
id_, td->dialog_manager_->get_chat_id_object(dialog_id_, "starSubscription"), until_date_, can_reuse_,
2024-08-05 08:28:11 +02:00
is_canceled_, missing_balance_, pricing_.get_star_subscription_pricing_object());
2024-07-25 19:06:29 +02:00
}
StringBuilder &operator<<(StringBuilder &string_builder, const StarSubscription &subscription) {
2024-08-05 08:28:11 +02:00
return string_builder << (subscription.is_canceled_ ? "canceled " : "")
<< (subscription.missing_balance_ ? "expiring " : "") << "subscription " << subscription.id_
2024-07-25 19:06:29 +02:00
<< " to " << subscription.dialog_id_ << " until " << subscription.until_date_ << " for "
<< subscription.pricing_;
}
} // namespace td