Add get_premium_payment_options_object fucntion.
This commit is contained in:
parent
472fdd248e
commit
9b87c2237a
@ -16850,18 +16850,14 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
|
||||
}
|
||||
bio_object = get_formatted_text_object(bio, true, 0);
|
||||
}
|
||||
auto base_premium_gift_it =
|
||||
std::min_element(user_full->premium_gift_options.begin(), user_full->premium_gift_options.end());
|
||||
auto premium_gift_options = transform(user_full->premium_gift_options, [&base_premium_gift_it](const auto &option) {
|
||||
return option.get_premium_payment_option_object(*base_premium_gift_it);
|
||||
});
|
||||
auto voice_messages_forbidden = is_premium ? user_full->voice_messages_forbidden : false;
|
||||
return make_tl_object<td_api::userFullInfo>(
|
||||
get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked,
|
||||
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
|
||||
!user_full->private_forward_name.empty(), voice_messages_forbidden,
|
||||
user_full->need_phone_number_privacy_exception, std::move(bio_object), std::move(premium_gift_options),
|
||||
user_full->common_chat_count, std::move(bot_info));
|
||||
return make_tl_object<td_api::userFullInfo>(get_chat_photo_object(td_->file_manager_.get(), user_full->photo),
|
||||
user_full->is_blocked, user_full->can_be_called,
|
||||
user_full->supports_video_calls, user_full->has_private_calls,
|
||||
!user_full->private_forward_name.empty(), voice_messages_forbidden,
|
||||
user_full->need_phone_number_privacy_exception, std::move(bio_object),
|
||||
get_premium_payment_options_object(user_full->premium_gift_options),
|
||||
user_full->common_chat_count, std::move(bot_info));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateBasicGroup> ContactsManager::get_update_unknown_basic_group_object(ChatId chat_id) {
|
||||
|
@ -157,12 +157,9 @@ class GetPremiumPromoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
auto period_options = get_premium_gift_options(std::move(promo->period_options_));
|
||||
auto base_premium_gift_it = std::min_element(period_options.begin(), period_options.end());
|
||||
auto payment_options = transform(period_options, [&base_premium_gift_it](const auto &option) {
|
||||
return option.get_premium_payment_option_object(*base_premium_gift_it);
|
||||
});
|
||||
promise_.set_value(td_api::make_object<td_api::premiumState>(get_formatted_text_object(state, true, 0),
|
||||
std::move(payment_options), std::move(animations)));
|
||||
get_premium_payment_options_object(period_options),
|
||||
std::move(animations)));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
|
||||
namespace td {
|
||||
@ -94,4 +95,15 @@ vector<PremiumGiftOption> get_premium_gift_options(
|
||||
return premium_gift_options;
|
||||
}
|
||||
|
||||
vector<td_api::object_ptr<td_api::premiumPaymentOption>> get_premium_payment_options_object(
|
||||
const vector<PremiumGiftOption> &options) {
|
||||
if (options.empty()) {
|
||||
return {};
|
||||
}
|
||||
auto base_premium_option_it = std::min_element(options.begin(), options.end());
|
||||
return transform(options, [&base_premium_option_it](const auto &option) {
|
||||
return option.get_premium_payment_option_object(*base_premium_option_it);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -52,4 +52,7 @@ vector<PremiumGiftOption> get_premium_gift_options(
|
||||
vector<PremiumGiftOption> get_premium_gift_options(
|
||||
vector<telegram_api::object_ptr<telegram_api::premiumSubscriptionOption>> &&options);
|
||||
|
||||
vector<td_api::object_ptr<td_api::premiumPaymentOption>> get_premium_payment_options_object(
|
||||
const vector<PremiumGiftOption> &options);
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user