From ec8fe669c76a28ca5fa25d6a9cdc292c39736df2 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Mon, 29 Jun 2026 23:07:12 +0100 Subject: [PATCH] add api for setting public group access --- src/Simplex/Chat/Controller.hs | 1 + src/Simplex/Chat/Library/Commands.hs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 1ef866b11a..c018228b6f 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -443,6 +443,7 @@ data ChatCommand | APILeaveGroup {groupId :: GroupId} | APIListMembers {groupId :: GroupId} | APIUpdateGroupProfile {groupId :: GroupId, groupProfile :: GroupProfile} + | APISetPublicGroupAccess GroupId PublicGroupAccess | APICreateGroupLink {groupId :: GroupId, memberRole :: GroupMemberRole} | APIGroupLinkMemberRole {groupId :: GroupId, memberRole :: GroupMemberRole} | APIDeleteGroupLink {groupId :: GroupId} diff --git a/src/Simplex/Chat/Library/Commands.hs b/src/Simplex/Chat/Library/Commands.hs index d45019b94c..9ab1d38193 100644 --- a/src/Simplex/Chat/Library/Commands.hs +++ b/src/Simplex/Chat/Library/Commands.hs @@ -3134,9 +3134,8 @@ processChatCommand cxt nm = \case updateGroupProfileByName gName $ \p -> p {description} ShowGroupDescription gName -> withUser $ \user -> CRGroupDescription user <$> withFastStore (\db -> getGroupInfoByName db cxt user gName) - SetPublicGroupAccess gName access@PublicGroupAccess {simplexName} -> withUser $ \user -> do - gInfo@GroupInfo {groupProfile = p@GroupProfile {publicGroup}} <- withStore $ \db -> - getGroupIdByName db user gName >>= getGroupInfo db cxt user + APISetPublicGroupAccess gId access@PublicGroupAccess {simplexName} -> withUser $ \user -> do + gInfo@GroupInfo {groupProfile = p@GroupProfile {publicGroup}} <- withStore $ \db -> getGroupInfo db cxt user gId case publicGroup of Just pg@PublicGroupProfile {groupLink, publicGroupAccess = existingAccess} -> do forM_ (claimName <$> simplexName) $ \newName@SimplexNameInfo {nameDomain} -> @@ -3258,6 +3257,9 @@ processChatCommand cxt nm = \case sqSecured <- withAgent $ \a -> joinConnection a nm (aUserId user) (aConnId conn) True cReq dm PQSupportOff subMode let newStatus = if sqSecured then ConnSndReady else ConnJoined void $ withFastStore' $ \db -> updateConnectionStatusFromTo db conn ConnPrepared newStatus + SetPublicGroupAccess gName access -> withUser $ \user -> do + groupId <- withFastStore $ \db -> getGroupIdByName db user gName + processChatCommand cxt nm $ APISetPublicGroupAccess groupId access CreateGroupLink gName mRole -> withUser $ \user -> do groupId <- withFastStore $ \db -> getGroupIdByName db user gName processChatCommand cxt nm $ APICreateGroupLink groupId mRole @@ -5443,6 +5445,7 @@ chatCommandP = "/set welcome " *> char_ '#' *> (UpdateGroupDescription <$> displayNameP <* A.space <*> (Just <$> msgTextP)), "/delete welcome " *> char_ '#' *> (UpdateGroupDescription <$> displayNameP <*> pure Nothing), "/show welcome " *> char_ '#' *> (ShowGroupDescription <$> displayNameP), + "/_public group access #" *> (APISetPublicGroupAccess <$> A.decimal <* A.space <*> jsonP), "/_create link #" *> (APICreateGroupLink <$> A.decimal <*> (memberRole <|> pure GRMember)), "/_set link role #" *> (APIGroupLinkMemberRole <$> A.decimal <*> memberRole), "/_delete link #" *> (APIDeleteGroupLink <$> A.decimal),