core, ui: prohibit to invite contact to channel

This commit is contained in:
spaced4ndy
2026-03-30 18:47:57 +04:00
parent eddb42bd63
commit d51cc75f35
4 changed files with 6 additions and 3 deletions

View File

@@ -578,7 +578,7 @@ struct ChatView: View {
HStack {
contentFilterMenu(withLabel: false)
Menu {
if groupInfo.canAddMembers {
if groupInfo.canAddMembers && !groupInfo.useRelays {
if (chat.chatInfo.incognito) {
groupLinkButton()
.appSheet(isPresented: $showGroupLinkSheet) {

View File

@@ -1281,7 +1281,7 @@ fun BoxScope.ChatInfoToolbar(
}
is ChatInfo.Group -> {
// Add members / group link moved to menu
if (chatInfo.groupInfo.canAddMembers) {
if (chatInfo.groupInfo.canAddMembers && !chatInfo.groupInfo.useRelays) {
if (!chatInfo.incognito) {
menuItems.add {
ItemAction(stringResource(MR.strings.icon_descr_add_members), painterResource(MR.images.ic_person_add_500), onClick = {

View File

@@ -2425,9 +2425,10 @@ processChatCommand vr nm = \case
APIAddMember groupId contactId memRole -> withUser $ \user -> withGroupLock "addMember" groupId $ do
-- TODO for large groups: no need to load all members to determine if contact is a member
(group, contact) <- withFastStore $ \db -> (,) <$> getGroup db vr user groupId <*> getContact db vr user contactId
assertDirectAllowed user MDSnd contact XGrpInv_
let Group gInfo members = group
Contact {localDisplayName = cName} = contact
when (useRelays' gInfo) $ throwCmdError "can't invite contact to channel"
assertDirectAllowed user MDSnd contact XGrpInv_
assertUserGroupRole gInfo $ max GRAdmin memRole
-- [incognito] forbid to invite contact to whom user is connected incognito
when (contactConnIncognito contact) $ throwChatError CEContactIncognitoCantInvite

View File

@@ -2314,6 +2314,8 @@ processAgentMessageConn vr user@User {userId} corrId agentConnId agentMessage =
toView $ CEvtNewChatItems user [AChatItem SCTGroup (msgDirection @d) cInfo ci]
processGroupInvitation :: Contact -> GroupInvitation -> RcvMessage -> MsgMeta -> CM ()
processGroupInvitation _ct GroupInvitation {groupProfile = GroupProfile {groupLink = Just _}} _msg _msgMeta =
messageError "x.grp.inv: can't invite to channel"
processGroupInvitation ct inv msg msgMeta = do
let Contact {localDisplayName = c, activeConn} = ct
GroupInvitation {fromMember = (MemberIdRole fromMemId fromRole), invitedMember = (MemberIdRole memId memRole), connRequest, groupLinkId} = inv