diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index b1d4659fd..e1ee13559 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -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(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(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 get_message_content_object(const MessageCo return td_api::make_object( 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(); diff --git a/td/telegram/StarManager.cpp b/td/telegram/StarManager.cpp index d346bfae3..3ba120ccd 100644 --- a/td/telegram/StarManager.cpp +++ b/td/telegram/StarManager.cpp @@ -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 diff --git a/td/telegram/StarManager.h b/td/telegram/StarManager.h index 29da88361..9808e13c9 100644 --- a/td/telegram/StarManager.h +++ b/td/telegram/StarManager.h @@ -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;