aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-01-19 17:09:09 +0300
committerlevlam <levlam@telegram.org>2026-01-19 17:09:09 +0300
commit3c69fca9ed65bf9dcbbe898ba2d383a1222ae9ce (patch)
tree1f697c66c4b4b083f5fdfb9b67a9cdc0a6cb0072
parent1c37d20723720753c3fff4ab204fa5a7f6d7034d (diff)
Add td_api::internalLinkTypePostStory.
-rw-r--r--td/generate/scheme/td_api.tl18
-rw-r--r--td/telegram/LinkManager.cpp51
-rw-r--r--td/telegram/LinkManager.h1
-rw-r--r--test/link.cpp11
4 files changed, 81 insertions, 0 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl
index 2a57c934c..a2151b4c2 100644
--- a/td/generate/scheme/td_api.tl
+++ b/td/generate/scheme/td_api.tl
@@ -5791,6 +5791,21 @@ inputStoryAreas areas:vector<inputStoryArea> = InputStoryAreas;
storyVideo duration:double width:int32 height:int32 has_stickers:Bool is_animation:Bool minithumbnail:minithumbnail thumbnail:thumbnail preload_prefix_size:int32 cover_frame_timestamp:double video:file = StoryVideo;
+//@class StoryContentType @description Contains the type of the content of a story
+
+//@description A photo story
+storyContentTypePhoto = StoryContentType;
+
+//@description A video story
+storyContentTypeVideo = StoryContentType;
+
+//@description A live story
+storyContentTypeLive = StoryContentType;
+
+//@description A story of unknown content type
+storyContentTypeUnsupported = StoryContentType;
+
+
//@class StoryContent @description Contains the content of a story
//@description A photo story @photo The photo
@@ -8624,6 +8639,9 @@ internalLinkTypePassportDataRequest bot_user_id:int53 scope:string public_key:st
//@phone_number Phone number value from the link
internalLinkTypePhoneNumberConfirmation hash:string phone_number:string = InternalLinkType;
+//@description The link is a link to open the story posting interface @content_type The type of the content of the story to post; may be null if unspecified
+internalLinkTypePostStory content_type:StoryContentType = InternalLinkType;
+
//@description The link is a link to the Premium features screen of the application from which the user can subscribe to Telegram Premium. Call getPremiumFeatures with the given referrer to process the link
//@referrer Referrer specified in the link
internalLinkTypePremiumFeatures referrer:string = InternalLinkType;
diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp
index c16fe6589..bc647beaf 100644
--- a/td/telegram/LinkManager.cpp
+++ b/td/telegram/LinkManager.cpp
@@ -975,6 +975,33 @@ class LinkManager::InternalLinkPassportDataRequest final : public InternalLink {
}
};
+class LinkManager::InternalLinkPostStory final : public InternalLink {
+ string content_type_;
+
+ td_api::object_ptr<td_api::InternalLinkType> get_internal_link_type_object() const final {
+ auto content_type = [&]() -> td_api::object_ptr<td_api::StoryContentType> {
+ if (content_type_ == "photo") {
+ return td_api::make_object<td_api::storyContentTypePhoto>();
+ }
+ if (content_type_ == "video") {
+ return td_api::make_object<td_api::storyContentTypeVideo>();
+ }
+ if (content_type_ == "live") {
+ return td_api::make_object<td_api::storyContentTypeLive>();
+ }
+ if (!content_type_.empty()) {
+ return td_api::make_object<td_api::storyContentTypeUnsupported>();
+ }
+ return nullptr;
+ }();
+ return td_api::make_object<td_api::internalLinkTypePostStory>(std::move(content_type));
+ }
+
+ public:
+ explicit InternalLinkPostStory(string content_type) : content_type_(std::move(content_type)) {
+ }
+};
+
class LinkManager::InternalLinkPremiumFeatures final : public InternalLink {
string referrer_;
@@ -2121,6 +2148,9 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que
} else if (path.size() == 2 && path[0] == "new" && path[1] == "group") {
// new/group
return td::make_unique<InternalLinkNewGroupChat>();
+ } else if (path.size() <= 2 && path[0] == "post") {
+ // post[/content-type]
+ return td::make_unique<InternalLinkPostStory>(path.size() == 2 ? path[1] : string());
} else if (path.size() == 1 && path[0] == "restore_purchases") {
// restore_purchases
return td::make_unique<InternalLinkRestorePurchases>();
@@ -3262,6 +3292,27 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp
<< "&hash=" << url_encode(link->hash_);
}
}
+ case td_api::internalLinkTypePostStory::ID: {
+ auto link = static_cast<const td_api::internalLinkTypePostStory *>(type_ptr);
+ if (!is_internal) {
+ return Status::Error("HTTP link is unavailable for the link type");
+ }
+ if (link->content_type_ != nullptr) {
+ switch (link->content_type_->get_id()) {
+ case td_api::storyContentTypePhoto::ID:
+ return "tg://post/photo";
+ case td_api::storyContentTypeVideo::ID:
+ return "tg://post/video";
+ case td_api::storyContentTypeLive::ID:
+ return "tg://post/live";
+ case td_api::storyContentTypeUnsupported::ID:
+ return "tg://post/unsupported";
+ default:
+ UNREACHABLE();
+ }
+ }
+ return "tg://post";
+ }
case td_api::internalLinkTypePremiumFeatures::ID: {
auto link = static_cast<const td_api::internalLinkTypePremiumFeatures *>(type_ptr);
if (!is_internal) {
diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h
index 9086e358f..dc25b1fe5 100644
--- a/td/telegram/LinkManager.h
+++ b/td/telegram/LinkManager.h
@@ -158,6 +158,7 @@ class LinkManager final : public Actor {
class InternalLinkNewGroupChat;
class InternalLinkNewPrivateChat;
class InternalLinkPassportDataRequest;
+ class InternalLinkPostStory;
class InternalLinkPremiumFeatures;
class InternalLinkPremiumGift;
class InternalLinkPremiumGiftCode;
diff --git a/test/link.cpp b/test/link.cpp
index 5e3684730..1d7369b59 100644
--- a/test/link.cpp
+++ b/test/link.cpp
@@ -427,6 +427,10 @@ static auto phone_number_confirmation(const td::string &hash, const td::string &
return td::td_api::make_object<td::td_api::internalLinkTypePhoneNumberConfirmation>(hash, phone_number);
}
+static auto post_story(td::td_api::object_ptr<td::td_api::StoryContentType> content_type) {
+ return td::td_api::make_object<td::td_api::internalLinkTypePostStory>(std::move(content_type));
+}
+
static auto premium_features(const td::string &referrer) {
return td::td_api::make_object<td::td_api::internalLinkTypePremiumFeatures>(referrer);
}
@@ -1004,6 +1008,13 @@ TEST(Link, parse_internal_link_part2) {
parse_internal_link("tg://new/channel", new_channel_chat());
parse_internal_link("tg://new/channel/", new_channel_chat());
+ parse_internal_link("tg://post", post_story(nullptr));
+ parse_internal_link("tg://post/photo", post_story(td::td_api::make_object<td::td_api::storyContentTypePhoto>()));
+ parse_internal_link("tg://post/video", post_story(td::td_api::make_object<td::td_api::storyContentTypeVideo>()));
+ parse_internal_link("tg://post/live", post_story(td::td_api::make_object<td::td_api::storyContentTypeLive>()));
+ parse_internal_link("tg://post/photos",
+ post_story(td::td_api::make_object<td::td_api::storyContentTypeUnsupported>()));
+
parse_internal_link("t.me/joinchat?invite=abcdef", nullptr);
parse_internal_link("t.me/joinchat", nullptr);
parse_internal_link("t.me/joinchat/", nullptr);