directory service: fix deleting group registration (#5856)

This commit is contained in:
Evgeny 2025-04-27 15:55:49 +01:00 committed by GitHub
parent 7cac164b84
commit ca49167ec6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 8 deletions

View file

@ -699,11 +699,6 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
DCListUserGroups ->
getUserGroupRegs st (contactId' ct) >>= \grs -> do
sendReply $ tshow (length grs) <> " registered group(s)"
-- debug how it can be that user has 0 registered groups
when (length grs == 0) $ do
total <- length <$> readTVarIO (groupRegs st)
withSuperUsers $ \ctId -> sendMessage' cc ctId $
"0 registered groups for " <> localDisplayName' ct <> " (" <> tshow (contactId' ct) <> ") out of " <> tshow total <> " registrations"
void . forkIO $ forM_ (reverse grs) $ \gr@GroupReg {userGroupRegId} ->
sendGroupInfo ct gr userGroupRegId Nothing
DCDeleteGroup gId gName ->

View file

@ -212,7 +212,7 @@ delGroupReg st GroupReg {dbGroupId = gId, groupRegStatus} = do
logGDelete st gId
atomically $ writeTVar groupRegStatus GRSRemoved
atomically $ unlistGroup st gId
atomically $ modifyTVar' (groupRegs st) $ filter ((gId ==) . dbGroupId)
atomically $ modifyTVar' (groupRegs st) $ filter ((gId /=) . dbGroupId)
setGroupStatus :: DirectoryStore -> GroupReg -> GroupRegStatus -> IO ()
setGroupStatus st gr grStatus = do

View file

@ -299,10 +299,12 @@ testDeleteGroupAdmin ps =
superUser #> "@SimpleX-Directory /delete 2:security"
superUser <# "SimpleX-Directory> > /delete 2:security"
superUser <## " The group security is deleted from the directory"
groupFound bob "privacy"
groupFound cath "privacy"
listUserGroup bob "privacy" "Privacy"
groupNotFound bob "security"
sendListCommand cath 0
-- another user can register the group with the same name
registerGroupId superUser bob "security" "Security" 4 1
registerGroupId superUser bob "security" "Security" 4 2
testSetRole :: HasCallStack => TestParams -> IO ()
testSetRole ps =