Fix direct story links for channels.

This commit is contained in:
John Preston 2023-09-25 17:53:02 +04:00
parent eaa491518e
commit 846e96579d
3 changed files with 5 additions and 7 deletions

View File

@ -776,10 +776,9 @@ QString ApiWrap::exportDirectMessageLink(
QString ApiWrap::exportDirectStoryLink(not_null<Data::Story*> 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<Data::Story*> 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());

View File

@ -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<QString> Story::errorTextForForward(

View File

@ -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)) {