From 9707d8486b6ec230acbe9580b7364293bf59bbb3 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 1 Dec 2024 11:50:32 +0300 Subject: [PATCH] Add "affiliate_program" Star transaction type. --- telegram-bot-api/Client.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index ef3942e..be7cd97 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -4344,7 +4344,20 @@ class Client::JsonStarTransactionType final : public td::Jsonable { object("gift", JsonGift(type->gift_.get(), client_)); break; } - case td_api::starTransactionTypeAffiliateProgramCommission::ID: + case td_api::starTransactionTypeAffiliateProgramCommission::ID: { + auto type = static_cast(type_); + object("type", "affiliate_program"); + auto chat_info = client_->get_chat(type->chat_id_); + CHECK(chat_info != nullptr); + if (chat_info->type == ChatInfo::Type::Private) { + object("sponsor_user", JsonUser(chat_info->user_id, client_)); + } else { + LOG(ERROR) << "Receive chat " << type->chat_id_ << " as an affiliate program sponsor"; + object("sponsor_chat", JsonChat(type->chat_id_, client_)); + } + object("commission_per_mille", type->commission_per_mille_); + break; + } case td_api::starTransactionTypeUnsupported::ID: object("type", "other"); break;