From 2e5bab9c4849bb4d7cb797fc1bcba7ae389dcd56 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 3 Apr 2023 21:20:41 +0300 Subject: [PATCH] Add messageGiftedPremium.gifter_user_id. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/MessageContent.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 55f89f00b..9efdf3899 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2600,13 +2600,14 @@ messagePaymentSuccessful invoice_chat_id:int53 invoice_message_id:int53 currency messagePaymentSuccessfulBot currency:string total_amount:int53 is_recurring:Bool is_first_recurring:Bool invoice_payload:bytes shipping_option_id:string order_info:orderInfo telegram_payment_charge_id:string provider_payment_charge_id:string = MessageContent; //@description Telegram Premium was gifted to the user +//@gifter_user_id The identifier of a user that gifted Telegram Premium; 0 if the gift was anonymous //@currency Currency for the paid amount //@amount The paid amount, in the smallest units of the currency //@cryptocurrency Cryptocurrency used to pay for the gift; may be empty if none //@cryptocurrency_amount The paid amount, in the smallest units of the cryptocurrency //@month_count Number of month the Telegram Premium subscription will be active //@sticker A sticker to be shown in the message; may be null if unknown -messageGiftedPremium currency:string amount:int53 cryptocurrency:string cryptocurrency_amount:int64 month_count:int32 sticker:sticker = MessageContent; +messageGiftedPremium gifter_user_id:int53 currency:string amount:int53 cryptocurrency:string cryptocurrency_amount:int64 month_count:int32 sticker:sticker = MessageContent; //@description A contact has registered with Telegram messageContactRegistered = MessageContent; diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 5e5a22b9f..cdfbead86 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5736,8 +5736,16 @@ tl_object_ptr get_message_content_object(const MessageCo } case MessageContentType::GiftPremium: { const auto *m = static_cast(content); + int64 gifter_user_id = 0; + if (dialog_id.get_type() == DialogType::User) { + auto user_id = dialog_id.get_user_id(); + if (user_id != ContactsManager::get_service_notifications_user_id() && + !td->contacts_manager_->is_user_bot(user_id) && !td->contacts_manager_->is_user_support(user_id)) { + gifter_user_id = td->contacts_manager_->get_user_id_object(user_id, "MessageGiftPremium"); + } + } return make_tl_object( - m->currency, m->amount, m->crypto_currency, m->crypto_amount, m->months, + gifter_user_id, m->currency, m->amount, m->crypto_currency, m->crypto_amount, m->months, td->stickers_manager_->get_premium_gift_sticker_object(m->months)); } case MessageContentType::TopicCreate: {