Skip to content

Commit b9e29ad

Browse files
committed
Add messageGift.upgrade_star_count.
1 parent aa5aae2 commit b9e29ad

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

td/generate/scheme/td_api.tl

+2-1
Original file line numberDiff line numberDiff line change
@@ -3982,12 +3982,13 @@ messageGiveawayPrizeStars star_count:int53 transaction_id:string boosted_chat_id
39823982
//@gift The gift
39833983
//@text Message added to the gift
39843984
//@sell_star_count Number of Telegram Stars that can be claimed by the receiver instead of the gift; 0 if the gift can't be sold by the receiver
3985+
//@upgrade_star_count Number of Telegram Stars that must be paid to upgrade the gift; only for the receiver of the gift
39853986
//@is_private True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them
39863987
//@is_saved True, if the gift is displayed on the user's profile page; only for the receiver of the gift
39873988
//@can_be_upgraded True, if the gift can be upgraded to a unique gift; only for the receiver of the gift
39883989
//@was_converted True, if the gift was converted to Telegram Stars; only for the receiver of the gift
39893990
//@was_upgraded True, if the gift was upgraded to a unique gift; only for the receiver of the gift
3990-
messageGift gift:gift text:formattedText sell_star_count:int53 is_private:Bool is_saved:Bool can_be_upgraded:Bool was_converted:Bool was_upgraded:Bool = MessageContent;
3991+
messageGift gift:gift text:formattedText sell_star_count:int53 upgrade_star_count:int53 is_private:Bool is_saved:Bool can_be_upgraded:Bool was_converted:Bool was_upgraded:Bool = MessageContent;
39913992

39923993
//@description A contact has registered with Telegram
39933994
messageContactRegistered = MessageContent;

td/telegram/MessageContent.cpp

+22-8
Original file line numberDiff line numberDiff line change
@@ -1249,18 +1249,20 @@ class MessageStarGift final : public MessageContent {
12491249
StarGift star_gift;
12501250
FormattedText text;
12511251
int64 convert_star_count = 0;
1252+
int64 upgrade_star_count = 0;
12521253
bool name_hidden = false;
12531254
bool is_saved = false;
12541255
bool can_upgrade = false;
12551256
bool was_converted = false;
12561257
bool was_upgraded = false;
12571258

12581259
MessageStarGift() = default;
1259-
MessageStarGift(StarGift &&star_gift, FormattedText &&text, int64 convert_star_count, bool name_hidden, bool is_saved,
1260-
bool can_upgrade, bool was_converted, bool was_upgraded)
1260+
MessageStarGift(StarGift &&star_gift, FormattedText &&text, int64 convert_star_count, int64 upgrade_star_count,
1261+
bool name_hidden, bool is_saved, bool can_upgrade, bool was_converted, bool was_upgraded)
12611262
: star_gift(std::move(star_gift))
12621263
, text(std::move(text))
12631264
, convert_star_count(convert_star_count)
1265+
, upgrade_star_count(upgrade_star_count)
12641266
, name_hidden(name_hidden)
12651267
, is_saved(is_saved)
12661268
, can_upgrade(can_upgrade)
@@ -1956,19 +1958,24 @@ static void store(const MessageContent *content, StorerT &storer) {
19561958
case MessageContentType::StarGift: {
19571959
const auto *m = static_cast<const MessageStarGift *>(content);
19581960
bool has_text = !m->text.text.empty();
1961+
bool has_upgrade_star_count = m->upgrade_star_count != 0;
19591962
BEGIN_STORE_FLAGS();
19601963
STORE_FLAG(m->name_hidden);
19611964
STORE_FLAG(m->is_saved);
19621965
STORE_FLAG(m->was_converted);
19631966
STORE_FLAG(has_text);
19641967
STORE_FLAG(m->was_upgraded);
19651968
STORE_FLAG(m->can_upgrade);
1969+
STORE_FLAG(has_upgrade_star_count);
19661970
END_STORE_FLAGS();
19671971
store(m->star_gift, storer);
19681972
if (has_text) {
19691973
store(m->text, storer);
19701974
}
19711975
store(m->convert_star_count, storer);
1976+
if (has_upgrade_star_count) {
1977+
store(m->upgrade_star_count, storer);
1978+
}
19721979
break;
19731980
}
19741981
default:
@@ -2866,19 +2873,24 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
28662873
case MessageContentType::StarGift: {
28672874
auto m = make_unique<MessageStarGift>();
28682875
bool has_text;
2876+
bool has_upgrade_star_count;
28692877
BEGIN_PARSE_FLAGS();
28702878
PARSE_FLAG(m->name_hidden);
28712879
PARSE_FLAG(m->is_saved);
28722880
PARSE_FLAG(m->was_converted);
28732881
PARSE_FLAG(has_text);
28742882
PARSE_FLAG(m->was_upgraded);
28752883
PARSE_FLAG(m->can_upgrade);
2884+
PARSE_FLAG(has_upgrade_star_count);
28762885
END_PARSE_FLAGS();
28772886
parse(m->star_gift, parser);
28782887
if (has_text) {
28792888
parse(m->text, parser);
28802889
}
28812890
parse(m->convert_star_count, parser);
2891+
if (has_upgrade_star_count) {
2892+
parse(m->upgrade_star_count, parser);
2893+
}
28822894
if (!m->star_gift.is_valid()) {
28832895
is_bad = true;
28842896
break;
@@ -6103,9 +6115,10 @@ void compare_message_contents(Td *td, const MessageContent *old_content, const M
61036115
const auto *lhs = static_cast<const MessageStarGift *>(old_content);
61046116
const auto *rhs = static_cast<const MessageStarGift *>(new_content);
61056117
if (lhs->star_gift != rhs->star_gift || lhs->text != rhs->text ||
6106-
lhs->convert_star_count != rhs->convert_star_count || lhs->name_hidden != rhs->name_hidden ||
6107-
lhs->is_saved != rhs->is_saved || lhs->can_upgrade != rhs->can_upgrade ||
6108-
lhs->was_converted != rhs->was_converted || lhs->was_upgraded != rhs->was_upgraded) {
6118+
lhs->convert_star_count != rhs->convert_star_count || lhs->upgrade_star_count != rhs->upgrade_star_count ||
6119+
lhs->name_hidden != rhs->name_hidden || lhs->is_saved != rhs->is_saved ||
6120+
lhs->can_upgrade != rhs->can_upgrade || lhs->was_converted != rhs->was_converted ||
6121+
lhs->was_upgraded != rhs->was_upgraded) {
61096122
need_update = true;
61106123
}
61116124
break;
@@ -7897,7 +7910,8 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
78977910
"messageActionStarGift");
78987911
return td::make_unique<MessageStarGift>(
78997912
std::move(star_gift), std::move(text), StarManager::get_star_count(action->convert_stars_),
7900-
action->name_hidden_, action->saved_, action->can_upgrade_, action->converted_, action->upgraded_);
7913+
StarManager::get_star_count(action->upgrade_stars_), action->name_hidden_, action->saved_,
7914+
action->can_upgrade_, action->converted_, action->upgraded_);
79017915
}
79027916
case telegram_api::messageActionStarGiftUnique::ID:
79037917
return td::make_unique<MessageUnsupported>();
@@ -8388,8 +8402,8 @@ td_api::object_ptr<td_api::MessageContent> get_message_content_object(const Mess
83888402
case MessageContentType::StarGift: {
83898403
const auto *m = static_cast<const MessageStarGift *>(content);
83908404
return td_api::make_object<td_api::messageGift>(m->star_gift.get_gift_object(td), get_text_object(m->text),
8391-
m->convert_star_count, m->name_hidden, m->is_saved,
8392-
m->can_upgrade, m->was_converted, m->was_upgraded);
8405+
m->convert_star_count, m->upgrade_star_count, m->name_hidden,
8406+
m->is_saved, m->can_upgrade, m->was_converted, m->was_upgraded);
83938407
}
83948408
default:
83958409
UNREACHABLE();

0 commit comments

Comments
 (0)