Fix startchannel deeplink: add missing stories rights and bot defaults fallback.

ParseRequestedAdminRights was missing post_stories, edit_stories and
delete_stories identifiers, causing all admin rights to be discarded
when any of these appeared in the admin parameter. Also, startchannel
always used explicit URL rights even when empty, never falling back to
bot's default admin rights configured via BotFather (unlike iOS client).

Unknown admin right identifiers are now skipped instead of discarding
all already-parsed rights, improving forward-compatibility of deeplinks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
rdmcd
2026-04-03 14:35:32 +03:00
committed by John Preston
parent 13ddffd66a
commit a17199c7a9
2 changed files with 11 additions and 3 deletions
@@ -217,7 +217,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
controller->hideLayer();
controller->showPeerHistory(chat, Way::ClearStack, ShowAtUnreadMsgId);
};
const auto rights = requestedAddAdmin
const auto rights = (requestedAddAdmin && _requestedRights != 0)
? _requestedRights
: (chat->isBroadcast()
&& chat->asBroadcast()->canAddAdmins())
@@ -460,7 +460,9 @@ bool ShowWallPaper(
const QString &value) {
auto result = ChatAdminRights();
for (const auto &element : value.split(QRegularExpression(u"[+ ]"_q))) {
if (element == u"change_info"_q) {
if (element.isEmpty()) {
continue;
} else if (element == u"change_info"_q) {
result |= ChatAdminRight::ChangeInfo;
} else if (element == u"post_messages"_q) {
result |= ChatAdminRight::PostMessages;
@@ -478,6 +480,12 @@ bool ShowWallPaper(
result |= ChatAdminRight::PinMessages;
} else if (element == u"promote_members"_q) {
result |= ChatAdminRight::AddAdmins;
} else if (element == u"post_stories"_q) {
result |= ChatAdminRight::PostStories;
} else if (element == u"edit_stories"_q) {
result |= ChatAdminRight::EditStories;
} else if (element == u"delete_stories"_q) {
result |= ChatAdminRight::DeleteStories;
} else if (element == u"manage_video_chats"_q) {
result |= ChatAdminRight::ManageCall;
} else if (element == u"manage_direct_messages"_q) {
@@ -487,7 +495,7 @@ bool ShowWallPaper(
} else if (element == u"manage_chat"_q) {
result |= ChatAdminRight::Other;
} else {
return {};
continue;
}
}
return result;