From ec73a31cb5baabfcf3c62d9d86453ae61780702f Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:07:01 +0400 Subject: [PATCH] directory: fix double logic inversion on roles check, incorrect error message (#3944) --- apps/simplex-directory-service/src/Directory/Service.hs | 8 ++++---- tests/Bots/DirectoryTests.hs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/simplex-directory-service/src/Directory/Service.hs b/apps/simplex-directory-service/src/Directory/Service.hs index ea79dabb10..c1428881b9 100644 --- a/apps/simplex-directory-service/src/Directory/Service.hs +++ b/apps/simplex-directory-service/src/Directory/Service.hs @@ -177,8 +177,8 @@ directoryService st DirectoryOpts {superUsers, serviceName, searchResults, testi badRolesMsg :: GroupRolesStatus -> Maybe String badRolesMsg = \case GRSOk -> Nothing - GRSServiceNotAdmin -> Just "You must have a group *owner* role to register the group" - GRSContactNotOwner -> Just "You must grant directory service *admin* role to register the group" + GRSServiceNotAdmin -> Just "You must grant directory service *admin* role to register the group" + GRSContactNotOwner -> Just "You must have a group *owner* role to register the group" GRSBadRoles -> Just "You must have a group *owner* role and you must grant directory service *admin* role to register the group" getGroupRolesStatus :: GroupInfo -> GroupReg -> IO (Maybe GroupRolesStatus) @@ -190,8 +190,8 @@ directoryService st DirectoryOpts {superUsers, serviceName, searchResults, testi groupRolesStatus :: GroupMemberRole -> GroupMemberRole -> GroupRolesStatus groupRolesStatus contactRole serviceRole = case (contactRole, serviceRole) of (GROwner, GRAdmin) -> GRSOk - (_, GRAdmin) -> GRSServiceNotAdmin - (GROwner, _) -> GRSContactNotOwner + (_, GRAdmin) -> GRSContactNotOwner + (GROwner, _) -> GRSServiceNotAdmin _ -> GRSBadRoles getGroupMember :: GroupReg -> IO (Maybe GroupMember) diff --git a/tests/Bots/DirectoryTests.hs b/tests/Bots/DirectoryTests.hs index 1054a1d8eb..b78d36f489 100644 --- a/tests/Bots/DirectoryTests.hs +++ b/tests/Bots/DirectoryTests.hs @@ -522,7 +522,7 @@ testNotApprovedBadRoles tmp = let approve = "/approve 1:privacy 1" superUser #> ("@SimpleX-Directory " <> approve) superUser <# ("SimpleX-Directory> > " <> approve) - superUser <## " Group is not approved: user is not an owner." + superUser <## " Group is not approved: SimpleX-Directory is not an admin." groupNotFound cath "privacy" bob ##> "/mr privacy SimpleX-Directory admin" bob <## "#privacy: you changed the role of SimpleX-Directory from member to admin"