Add td_api::internalLinkTypeBuyStars.
This commit is contained in:
parent
076528a99f
commit
e90d8621fb
@ -6493,7 +6493,7 @@ internalLinkTypeActiveSessions = InternalLinkType;
|
||||
|
||||
//@description The link is a link to an attachment menu bot to be opened in the specified or a chosen chat. Process given target_chat to open the chat.
|
||||
//-Then, call searchPublicChat with the given bot username, check that the user is a bot and can be added to attachment menu. Then, use getAttachmentMenuBot to receive information about the bot.
|
||||
//-If the bot isn't added to attachment menu, then show a disclaimer about Mini Apps being third-party apps, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu.
|
||||
//-If the bot isn't added to attachment menu, then show a disclaimer about Mini Apps being third-party applications, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu.
|
||||
//-If the user accept the terms and confirms adding, then use toggleBotIsAddedToAttachmentMenu to add the bot.
|
||||
//-If the attachment menu bot can't be used in the opened chat, show an error to the user. If the bot is added to attachment menu and can be used in the chat, then use openWebApp with the given URL
|
||||
//@target_chat Target chat to be opened
|
||||
@ -6539,7 +6539,10 @@ internalLinkTypeBotStartInGroup bot_username:string start_parameter:string admin
|
||||
//@link_name Name of the link
|
||||
internalLinkTypeBusinessChat link_name:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the change phone number section of the app
|
||||
//@description The link is a link to the Telegram Star purchase section of the application @star_count The number of Telegram Stars that must be purchased by the user
|
||||
internalLinkTypeBuyStars star_count:int53 = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the change phone number section of the application
|
||||
internalLinkTypeChangePhoneNumber = InternalLinkType;
|
||||
|
||||
//@description The link is a link to boost a Telegram chat. Call getChatBoostLinkInfo with the given URL to process the link.
|
||||
@ -6553,7 +6556,7 @@ internalLinkTypeChatBoost url:string = InternalLinkType;
|
||||
//@invite_link Internal representation of the invite link
|
||||
internalLinkTypeChatFolderInvite invite_link:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the folder section of the app settings
|
||||
//@description The link is a link to the folder section of the application settings
|
||||
internalLinkTypeChatFolderSettings = InternalLinkType;
|
||||
|
||||
//@description The link is a chat invite link. Call checkChatInviteLink with the given invite link to process the link.
|
||||
@ -6561,10 +6564,10 @@ internalLinkTypeChatFolderSettings = InternalLinkType;
|
||||
//@invite_link Internal representation of the invite link
|
||||
internalLinkTypeChatInvite invite_link:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the default message auto-delete timer settings section of the app settings
|
||||
//@description The link is a link to the default message auto-delete timer settings section of the application settings
|
||||
internalLinkTypeDefaultMessageAutoDeleteTimerSettings = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the edit profile section of the app settings
|
||||
//@description The link is a link to the edit profile section of the application settings
|
||||
internalLinkTypeEditProfileSettings = InternalLinkType;
|
||||
|
||||
//@description The link is a link to a game. Call searchPublicChat with the given bot username, check that the user is a bot,
|
||||
@ -6587,12 +6590,12 @@ internalLinkTypeInvoice invoice_name:string = InternalLinkType;
|
||||
//@language_pack_id Language pack identifier
|
||||
internalLinkTypeLanguagePack language_pack_id:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the language section of the app settings
|
||||
//@description The link is a link to the language section of the application settings
|
||||
internalLinkTypeLanguageSettings = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the main Web App of a bot. Call searchPublicChat with the given bot username, check that the user is a bot and has the main Web App.
|
||||
//-If the bot can be added to attachment menu, then use getAttachmentMenuBot to receive information about the bot, then if the bot isn't added to side menu,
|
||||
//-show a disclaimer about Mini Apps being third-party apps, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu,
|
||||
//-show a disclaimer about Mini Apps being third-party applications, ask the user to accept their Terms of service and confirm adding the bot to side and attachment menu,
|
||||
//-then if the user accepts the terms and confirms adding, use toggleBotIsAddedToAttachmentMenu to add the bot.
|
||||
//-Then, use getMainWebApp with the given start parameter and open the returned URL as a Web App
|
||||
//@bot_username Username of the bot
|
||||
@ -6637,7 +6640,7 @@ internalLinkTypePremiumGift referrer:string = InternalLinkType;
|
||||
//@code The Telegram Premium gift code
|
||||
internalLinkTypePremiumGiftCode code:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the privacy and security section of the app settings
|
||||
//@description The link is a link to the privacy and security section of the application settings
|
||||
internalLinkTypePrivacyAndSecuritySettings = InternalLinkType;
|
||||
|
||||
//@description The link is a link to a proxy. Call addProxy with the given parameters to process the link and add the proxy
|
||||
@ -6678,7 +6681,7 @@ internalLinkTypeStory story_sender_username:string story_id:int32 = InternalLink
|
||||
//@description The link is a link to a cloud theme. TDLib has no theme support yet @theme_name Name of the theme
|
||||
internalLinkTypeTheme theme_name:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to the theme section of the app settings
|
||||
//@description The link is a link to the theme section of the application settings
|
||||
internalLinkTypeThemeSettings = InternalLinkType;
|
||||
|
||||
//@description The link is an unknown tg: link. Call getDeepLinkInfo to process the link @link Link to be passed to getDeepLinkInfo
|
||||
@ -6706,7 +6709,7 @@ internalLinkTypeUserToken token:string = InternalLinkType;
|
||||
internalLinkTypeVideoChat chat_username:string invite_hash:string is_live_stream:Bool = InternalLinkType;
|
||||
|
||||
//@description The link is a link to a Web App. Call searchPublicChat with the given bot username, check that the user is a bot, then call searchWebApp with the received bot and the given web_app_short_name.
|
||||
//-Process received foundWebApp by showing a confirmation dialog if needed. If the bot can be added to attachment or side menu, but isn't added yet, then show a disclaimer about Mini Apps being third-party apps
|
||||
//-Process received foundWebApp by showing a confirmation dialog if needed. If the bot can be added to attachment or side menu, but isn't added yet, then show a disclaimer about Mini Apps being third-party applications
|
||||
//-instead of the dialog and ask the user to accept their Terms of service. If the user accept the terms and confirms adding, then use toggleBotIsAddedToAttachmentMenu to add the bot.
|
||||
//-Then, call getWebAppLinkUrl and open the returned URL as a Web App
|
||||
//@bot_username Username of the bot that owns the Web App
|
||||
|
@ -397,6 +397,19 @@ class LinkManager::InternalLinkBusinessChat final : public InternalLink {
|
||||
}
|
||||
};
|
||||
|
||||
class LinkManager::InternalLinkBuyStars final : public InternalLink {
|
||||
int64 star_count_;
|
||||
|
||||
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
|
||||
return td_api::make_object<td_api::internalLinkTypeBuyStars>(star_count_);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit InternalLinkBuyStars(int64 star_count)
|
||||
: star_count_(clamp(star_count, static_cast<int64>(1), static_cast<int64>(1000000000000))) {
|
||||
}
|
||||
};
|
||||
|
||||
class LinkManager::InternalLinkChangePhoneNumber final : public InternalLink {
|
||||
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
|
||||
return td_api::make_object<td_api::internalLinkTypeChangePhoneNumber>();
|
||||
@ -1545,6 +1558,11 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
|
||||
// msg_url?url=<url>
|
||||
// msg_url?url=<url>&text=<text>
|
||||
return get_internal_link_message_draft(get_arg("url"), get_arg("text"));
|
||||
} else if (path.size() == 1 && path[0] == "stars_topup") {
|
||||
// stars_topup?amount=<star_count>
|
||||
if (has_arg("amount")) {
|
||||
return td::make_unique<InternalLinkBuyStars>(to_integer<int64>(url_query.get_arg("amount")));
|
||||
}
|
||||
}
|
||||
if (!path.empty() && !path[0].empty()) {
|
||||
return td::make_unique<InternalLinkUnknownDeepLink>(PSTRING() << "tg://" << query);
|
||||
@ -2095,6 +2113,16 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp
|
||||
return PSTRING() << get_t_me_url() << "m/" << url_encode(link->link_name_);
|
||||
}
|
||||
}
|
||||
case td_api::internalLinkTypeBuyStars::ID: {
|
||||
auto link = static_cast<const td_api::internalLinkTypeBuyStars *>(type_ptr);
|
||||
if (!is_internal) {
|
||||
return Status::Error("HTTP link is unavailable for the link type");
|
||||
}
|
||||
if (link->star_count_ <= 0) {
|
||||
return Status::Error(400, "Invalid Telegram Star number provided");
|
||||
}
|
||||
return PSTRING() << "tg://stars_topup?amount=" << link->star_count_;
|
||||
}
|
||||
case td_api::internalLinkTypeChangePhoneNumber::ID:
|
||||
if (!is_internal) {
|
||||
return Status::Error("HTTP link is unavailable for the link type");
|
||||
|
@ -125,6 +125,7 @@ class LinkManager final : public Actor {
|
||||
class InternalLinkBotStart;
|
||||
class InternalLinkBotStartInGroup;
|
||||
class InternalLinkBusinessChat;
|
||||
class InternalLinkBuyStars;
|
||||
class InternalLinkChangePhoneNumber;
|
||||
class InternalLinkConfirmPhone;
|
||||
class InternalLinkDefaultMessageAutoDeleteTimerSettings;
|
||||
|
@ -224,6 +224,10 @@ static auto business_chat(const td::string &link_name) {
|
||||
return td::td_api::make_object<td::td_api::internalLinkTypeBusinessChat>(link_name);
|
||||
}
|
||||
|
||||
static auto buy_stars(td::int64 star_count) {
|
||||
return td::td_api::make_object<td::td_api::internalLinkTypeBuyStars>(star_count);
|
||||
}
|
||||
|
||||
static auto change_phone_number() {
|
||||
return td::td_api::make_object<td::td_api::internalLinkTypeChangePhoneNumber>();
|
||||
}
|
||||
@ -1327,6 +1331,12 @@ TEST(Link, parse_internal_link_part4) {
|
||||
parse_internal_link("tg://settings/language", language_settings());
|
||||
parse_internal_link("tg://settings/privacy", privacy_and_security_settings());
|
||||
|
||||
parse_internal_link("tg://stars_topup", unknown_deep_link("tg://stars_topup"));
|
||||
parse_internal_link("tg://stars_topup?amount=", unknown_deep_link("tg://stars_topup?amount="));
|
||||
parse_internal_link("tg://stars_topup?amount=test", buy_stars(1));
|
||||
parse_internal_link("tg://stars_topup?amount=10", buy_stars(10));
|
||||
parse_internal_link("tg://stars_topup?amount=100000000000", buy_stars(100000000000));
|
||||
|
||||
parse_internal_link("username.t.me////0/a//s/as?start=", bot_start("username", ""));
|
||||
parse_internal_link("username.t.me?start=as", bot_start("username", "as"));
|
||||
parse_internal_link("username.t.me", public_chat("username"));
|
||||
|
Loading…
Reference in New Issue
Block a user