2
0
mirror of https://github.com/tdlib/telegram-bot-api synced 2025-08-22 18:08:31 +00:00

Add Message.suggested_post_paid.

This commit is contained in:
levlam 2025-08-02 23:38:09 +03:00
parent 481791f4bd
commit b142642208
2 changed files with 51 additions and 19 deletions

View File

@ -1398,6 +1398,22 @@ class Client::JsonUniqueGift final : public td::Jsonable {
const Client *client_;
};
class Client::JsonStarAmount final : public td::Jsonable {
public:
explicit JsonStarAmount(const td_api::starAmount *amount) : amount_(amount) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("amount", amount_->star_count_);
if (amount_->nanostar_count_ != 0) {
object("nanostar_amount", amount_->nanostar_count_);
}
}
private:
const td_api::starAmount *amount_;
};
class Client::JsonSuggestedPostPrice final : public td::Jsonable {
public:
explicit JsonSuggestedPostPrice(const td_api::SuggestedPostPrice *suggested_post_price)
@ -2269,6 +2285,36 @@ class Client::JsonSuggestedPostDeclined final : public td::Jsonable {
const Client *client_;
};
class Client::JsonSuggestedPostPaid final : public td::Jsonable {
public:
JsonSuggestedPostPaid(const td_api::messageSuggestedPostPaid *suggested_post_paid, int64 chat_id,
const Client *client)
: suggested_post_paid_(suggested_post_paid), chat_id_(chat_id), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
const MessageInfo *suggested_post_message =
client_->get_message(chat_id_, suggested_post_paid_->suggested_post_message_id_, true);
if (suggested_post_message != nullptr) {
object("suggested_post_message",
JsonMessage(suggested_post_message, false, "suggested post approval added", client_));
}
if (suggested_post_paid_->star_amount_->star_count_ != 0 ||
suggested_post_paid_->star_amount_->nanostar_count_ != 0) {
object("currency", "XTR");
object("star_amount", JsonStarAmount(suggested_post_paid_->star_amount_.get()));
} else {
object("currency", "TON");
object("amount", suggested_post_paid_->ton_amount_);
}
}
private:
const td_api::messageSuggestedPostPaid *suggested_post_paid_;
int64 chat_id_;
const Client *client_;
};
class Client::JsonStory final : public td::Jsonable {
public:
JsonStory(int64 chat_id, int32 story_id, const Client *client)
@ -4014,8 +4060,11 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
object("suggested_post_declined", JsonSuggestedPostDeclined(content, message_->chat_id, client_));
break;
}
case td_api::messageSuggestedPostPaid::ID:
case td_api::messageSuggestedPostPaid::ID: {
auto content = static_cast<const td_api::messageSuggestedPostPaid *>(message_->content.get());
object("suggested_post_paid", JsonSuggestedPostPaid(content, message_->chat_id, client_));
break;
}
case td_api::messageSuggestedPostRefunded::ID:
break;
default:
@ -4866,22 +4915,6 @@ class Client::JsonBusinessMessagesDeleted final : public td::Jsonable {
const Client *client_;
};
class Client::JsonStarAmount final : public td::Jsonable {
public:
explicit JsonStarAmount(const td_api::starAmount *amount) : amount_(amount) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("amount", amount_->star_count_);
if (amount_->nanostar_count_ != 0) {
object("nanostar_amount", amount_->nanostar_count_);
}
}
private:
const td_api::starAmount *amount_;
};
class Client::JsonReceivedGift final : public td::Jsonable {
public:
JsonReceivedGift(const td_api::receivedGift *received_gift, const Client *client)
@ -15966,8 +15999,6 @@ bool Client::need_skip_update_message(int64 chat_id, const object_ptr<td_api::me
return true;
case td_api::messageGiftedTon::ID:
return true;
case td_api::messageSuggestedPostPaid::ID:
return true;
case td_api::messageSuggestedPostRefunded::ID:
return true;
default:

View File

@ -140,6 +140,7 @@ class Client final : public WebhookActor::Callback {
class JsonSuggestedPostApprovalFailed;
class JsonSuggestedPostApproved;
class JsonSuggestedPostDeclined;
class JsonSuggestedPostPaid;
class JsonEntity;
class JsonVectorEntities;
class JsonWebAppInfo;