Move get_months_by_star_count to StarManager.
This commit is contained in:
parent
f2d5a2e3bf
commit
de8dbf00b4
@ -5798,10 +5798,6 @@ static bool need_register_message_content_for_bots(MessageContentType content_ty
|
||||
return content_type == MessageContentType::Poll;
|
||||
}
|
||||
|
||||
static int32 get_months_by_star_count(int64 star_count) {
|
||||
return star_count <= 1000 ? 3 : (star_count < 2500 ? 6 : 12);
|
||||
}
|
||||
|
||||
void register_message_content(Td *td, const MessageContent *content, MessageFullId message_full_id,
|
||||
const char *source) {
|
||||
auto content_type = content->get_type();
|
||||
@ -5849,8 +5845,8 @@ void register_message_content(Td *td, const MessageContent *content, MessageFull
|
||||
message_full_id, {}, source);
|
||||
case MessageContentType::GiftStars: {
|
||||
auto star_count = static_cast<const MessageGiftStars *>(content)->star_count;
|
||||
return td->stickers_manager_->register_premium_gift(get_months_by_star_count(star_count), message_full_id,
|
||||
source);
|
||||
return td->stickers_manager_->register_premium_gift(StarManager::get_months_by_star_count(star_count),
|
||||
message_full_id, source);
|
||||
}
|
||||
default:
|
||||
return;
|
||||
@ -5984,8 +5980,8 @@ void unregister_message_content(Td *td, const MessageContent *content, MessageFu
|
||||
message_full_id, {}, source);
|
||||
case MessageContentType::GiftStars: {
|
||||
auto star_count = static_cast<const MessageGiftStars *>(content)->star_count;
|
||||
return td->stickers_manager_->unregister_premium_gift(get_months_by_star_count(star_count), message_full_id,
|
||||
source);
|
||||
return td->stickers_manager_->unregister_premium_gift(StarManager::get_months_by_star_count(star_count),
|
||||
message_full_id, source);
|
||||
}
|
||||
default:
|
||||
return;
|
||||
@ -7960,7 +7956,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
return td_api::make_object<td_api::messageGiftedStars>(
|
||||
gifter_user_id, receiver_user_id, m->currency, m->amount, m->crypto_currency, m->crypto_amount, m->star_count,
|
||||
m->transaction_id,
|
||||
td->stickers_manager_->get_premium_gift_sticker_object(get_months_by_star_count(m->star_count)));
|
||||
td->stickers_manager_->get_premium_gift_sticker_object(StarManager::get_months_by_star_count(m->star_count)));
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -666,4 +666,8 @@ int64 StarManager::get_star_count(int64 amount, bool allow_negative) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
int32 StarManager::get_months_by_star_count(int64 star_count) {
|
||||
return star_count <= 1000 ? 3 : (star_count < 2500 ? 6 : 12);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -54,6 +54,8 @@ class StarManager final : public Actor {
|
||||
|
||||
static int64 get_star_count(int64 amount, bool allow_negative = false);
|
||||
|
||||
static int32 get_months_by_star_count(int64 star_count);
|
||||
|
||||
private:
|
||||
void tear_down() final;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user