diff options
| author | levlam <levlam@telegram.org> | 2024-12-23 20:17:11 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2024-12-23 20:17:11 +0300 |
| commit | a41f8d606abc4aba99feeae2abb2f603411074ab (patch) | |
| tree | 2f53848e6ebb5e9e37c8e72a531c01dd65a626aa /td/telegram/StarGiftAttribute.cpp | |
| parent | 4b146b34811f8c724b82529fc0ba67df84c975cd (diff) | |
Add td_api::upgradedGiftModel.
Diffstat (limited to 'td/telegram/StarGiftAttribute.cpp')
| -rw-r--r-- | td/telegram/StarGiftAttribute.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/td/telegram/StarGiftAttribute.cpp b/td/telegram/StarGiftAttribute.cpp new file mode 100644 index 000000000..43bccbde2 --- /dev/null +++ b/td/telegram/StarGiftAttribute.cpp @@ -0,0 +1,37 @@ +// +// 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/StarGiftAttribute.h" + +#include "td/telegram/StickerFormat.h" +#include "td/telegram/StickersManager.h" +#include "td/telegram/Td.h" + +namespace td { + +StarGiftAttributeModel::StarGiftAttributeModel( + Td *td, telegram_api::object_ptr<telegram_api::starGiftAttributeModel> &&attribute) + : name_(std::move(attribute->name_)) + , sticker_file_id_(td->stickers_manager_ + ->on_get_sticker_document(std::move(attribute->document_), StickerFormat::Unknown, + "StarGiftAttributeModel") + .second) + , rarity_permille_(attribute->rarity_permille_) { +} + +td_api::object_ptr<td_api::upgradedGiftModel> StarGiftAttributeModel::get_upgraded_gift_model_object( + const Td *td) const { + CHECK(is_valid()); + return td_api::make_object<td_api::upgradedGiftModel>( + name_, td->stickers_manager_->get_sticker_object(sticker_file_id_), rarity_permille_); +} + +bool operator==(const StarGiftAttributeModel &lhs, const StarGiftAttributeModel &rhs) { + return lhs.name_ == rhs.name_ && lhs.sticker_file_id_ == rhs.sticker_file_id_ && + lhs.rarity_permille_ == rhs.rarity_permille_; +} + +} // namespace td |
