Add internalLinkTypeInvoice.
This commit is contained in:
parent
7cd74e2660
commit
464ef38806
@ -3465,6 +3465,9 @@ internalLinkTypeFilterSettings = InternalLinkType;
|
||||
//@bot_username Username of the bot that owns the game @game_short_name Short name of the game
|
||||
internalLinkTypeGame bot_username:string game_short_name:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to an invoice. Call getPaymentForm with the given invoice name to process the link @invoice_name Name of the invoice
|
||||
internalLinkTypeInvoice invoice_name:string = InternalLinkType;
|
||||
|
||||
//@description The link is a link to a language pack. Call getLanguagePackInfo with the given language pack identifier to process the link @language_pack_id Language pack identifier
|
||||
internalLinkTypeLanguagePack language_pack_id:string = InternalLinkType;
|
||||
|
||||
|
@ -297,6 +297,18 @@ class LinkManager::InternalLinkGame final : public InternalLink {
|
||||
}
|
||||
};
|
||||
|
||||
class LinkManager::InternalLinkInvoice final : public InternalLink {
|
||||
string invoice_name_;
|
||||
|
||||
td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
|
||||
return td_api::make_object<td_api::internalLinkTypeInvoice>(invoice_name_);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit InternalLinkInvoice(string invoice_name) : invoice_name_(std::move(invoice_name)) {
|
||||
}
|
||||
};
|
||||
|
||||
class LinkManager::InternalLinkLanguage final : public InternalLink {
|
||||
string language_pack_id_;
|
||||
|
||||
@ -1099,6 +1111,11 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
|
||||
<< pass_arg("slug") << copy_arg("mode") << copy_arg("intensity")
|
||||
<< copy_arg("bg_color") << copy_arg("rotation"));
|
||||
}
|
||||
} else if (path.size() == 1 && path[0] == "invoice") {
|
||||
// invoice?slug=<invoice_name>
|
||||
if (has_arg("slug")) {
|
||||
return td::make_unique<InternalLinkInvoice>(url_query.get_arg("slug").str());
|
||||
}
|
||||
} else if (path.size() == 1 && (path[0] == "share" || path[0] == "msg" || path[0] == "msg_url")) {
|
||||
// msg_url?url=<url>
|
||||
// msg_url?url=<url>&text=<text>
|
||||
@ -1220,6 +1237,11 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_t_me_link_query(Slice q
|
||||
<< url_encode(path[1]) << copy_arg("mode") << copy_arg("intensity")
|
||||
<< copy_arg("bg_color") << copy_arg("rotation"));
|
||||
}
|
||||
} else if (path[0] == "invoice") {
|
||||
if (path.size() >= 2 && !path[1].empty()) {
|
||||
// /invoice/<name>
|
||||
return td::make_unique<InternalLinkInvoice>(path[1]);
|
||||
}
|
||||
} else if (path[0] == "share" || path[0] == "msg") {
|
||||
if (!(path.size() > 1 && (path[1] == "bookmarklet" || path[1] == "embed"))) {
|
||||
// /share?url=<url>
|
||||
|
@ -96,6 +96,7 @@ class LinkManager final : public Actor {
|
||||
class InternalLinkDialogInvite;
|
||||
class InternalLinkFilterSettings;
|
||||
class InternalLinkGame;
|
||||
class InternalLinkInvoice;
|
||||
class InternalLinkLanguage;
|
||||
class InternalLinkLanguageSettings;
|
||||
class InternalLinkMessage;
|
||||
|
@ -134,6 +134,9 @@ TEST(Link, parse_internal_link) {
|
||||
auto game = [](const td::string &bot_username, const td::string &game_short_name) {
|
||||
return td::td_api::make_object<td::td_api::internalLinkTypeGame>(bot_username, game_short_name);
|
||||
};
|
||||
auto invoice = [](const td::string &invoice_name) {
|
||||
return td::td_api::make_object<td::td_api::internalLinkTypeInvoice>(invoice_name);
|
||||
};
|
||||
auto language_pack = [](const td::string &language_pack_name) {
|
||||
return td::td_api::make_object<td::td_api::internalLinkTypeLanguagePack>(language_pack_name);
|
||||
};
|
||||
@ -368,6 +371,24 @@ TEST(Link, parse_internal_link) {
|
||||
parse_internal_link("t.me/bg/%20/", background("%20"));
|
||||
parse_internal_link("t.me/bg/", nullptr);
|
||||
|
||||
parse_internal_link("t.me/invoice?slug=abcdef", nullptr);
|
||||
parse_internal_link("t.me/invoice", nullptr);
|
||||
parse_internal_link("t.me/invoice/", nullptr);
|
||||
parse_internal_link("t.me/invoice//abcdef", nullptr);
|
||||
parse_internal_link("t.me/invoice?/abcdef", nullptr);
|
||||
parse_internal_link("t.me/invoice/?abcdef", nullptr);
|
||||
parse_internal_link("t.me/invoice/#abcdef", nullptr);
|
||||
parse_internal_link("t.me/invoice/abacaba", invoice("abacaba"));
|
||||
parse_internal_link("t.me/invoice/aba%20aba", invoice("aba aba"));
|
||||
parse_internal_link("t.me/invoice/123456a", invoice("123456a"));
|
||||
parse_internal_link("t.me/invoice/12345678901", invoice("12345678901"));
|
||||
parse_internal_link("t.me/invoice/123456", invoice("123456"));
|
||||
parse_internal_link("t.me/invoice/123456/123123/12/31/a/s//21w/?asdas#test", invoice("123456"));
|
||||
|
||||
parse_internal_link("tg:invoice?slug=abcdef", invoice("abcdef"));
|
||||
parse_internal_link("tg:invoice?slug=abc%30ef", invoice("abc0ef"));
|
||||
parse_internal_link("tg://invoice?slug=", unknown_deep_link("tg://invoice?slug="));
|
||||
|
||||
parse_internal_link("tg:share?url=google.com&text=text#asdasd", message_draft("google.com\ntext", true));
|
||||
parse_internal_link("tg:share?url=google.com&text=", message_draft("google.com", false));
|
||||
parse_internal_link("tg:share?url=&text=google.com", message_draft("google.com", false));
|
||||
|
Loading…
Reference in New Issue
Block a user