From 846e96579d82ed4d201dc8f31398b4c718f9bb01 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 25 Sep 2023 17:53:02 +0400 Subject: [PATCH] Fix direct story links for channels. --- Telegram/SourceFiles/apiwrap.cpp | 7 +++---- Telegram/SourceFiles/data/data_story.cpp | 3 +-- Telegram/SourceFiles/window/window_session_controller.cpp | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 75f4047b3..441653784 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -776,10 +776,9 @@ QString ApiWrap::exportDirectMessageLink( QString ApiWrap::exportDirectStoryLink(not_null story) { const auto storyId = story->fullId(); - const auto user = story->peer()->asUser(); - Assert(user != nullptr); + const auto peer = story->peer(); const auto fallback = [&] { - const auto base = user->username(); + const auto base = peer->userName(); const auto story = QString::number(storyId.story); const auto query = base + "/s/" + story; return session().createInternalLinkFull(query); @@ -789,7 +788,7 @@ QString ApiWrap::exportDirectStoryLink(not_null story) { ? i->second : fallback(); request(MTPstories_ExportStoryLink( - story->peer()->input, + peer->input, MTP_int(story->id()) )).done([=](const MTPExportedStoryLink &result) { const auto link = qs(result.data().vlink()); diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp index 7500071c5..237c3323d 100644 --- a/Telegram/SourceFiles/data/data_story.cpp +++ b/Telegram/SourceFiles/data/data_story.cpp @@ -370,8 +370,7 @@ bool Story::hasDirectLink() const { if (!_privacyPublic || (!_pinned && expired())) { return false; } - const auto user = _peer->asUser(); - return user && !user->username().isEmpty(); + return !_peer->userName().isEmpty(); } std::optional Story::errorTextForForward( diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 4b69e4f2e..6f1526f4b 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -502,7 +502,7 @@ void SessionNavigation::showPeerByLinkResolved( info.messageId, callback); } - } else if (peer->isUser() && info.storyId) { + } else if (info.storyId) { const auto storyId = FullStoryId{ peer->id, info.storyId }; peer->owner().stories().resolve(storyId, crl::guard(this, [=] { if (peer->owner().stories().lookup(storyId)) {