From 6a1a0c15b0c98df1c97ef00540a2965393802178 Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Sat, 11 Jul 2026 17:04:11 +0000 Subject: [PATCH] remove duplicate verification --- .../src/Directory/Service.hs | 23 ++++++++++--------- .../src/Directory/Store.hs | 2 -- src/Simplex/Chat/Library/Internal.hs | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/apps/simplex-directory-service/src/Directory/Service.hs b/apps/simplex-directory-service/src/Directory/Service.hs index 90c656cd5e..76c6b76f72 100644 --- a/apps/simplex-directory-service/src/Directory/Service.hs +++ b/apps/simplex-directory-service/src/Directory/Service.hs @@ -570,7 +570,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName ("The " <> gt <> " " <> userGroupRef <> " is updated" <> byMember) <> ".\nIt is hidden from the directory until approved." notifyAdminUsers $ "The " <> gt <> " " <> groupRef <> " is updated" <> byMember <> "." - sendToApprove g' gr' n' + verifyAndSendToApprove g' gr' n' sendChatCmd cc (APIConnectPlan userId (Just (aConnectTarget link)) PRMAllGroups Nothing) >>= \case Right (CRConnectionPlan _ _ _ _ (CPGroupLink (GLPKnown {groupInfo = g'}))) -> case dbOwnerMemberId gr of @@ -657,7 +657,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName (badRolesMsg <$$> getGroupRolesStatus toGroup gr) >>= \case Left e -> notifyOwner gr $ "Error: getGroupRolesStatus. Please notify the developers.\n" <> T.pack e Right (Just msg) -> notifyOwner gr msg - Right Nothing -> sendToApprove toGroup gr gaId + Right Nothing -> verifyAndSendToApprove toGroup gr gaId dePendingMember :: GroupInfo -> GroupMember -> IO () dePendingMember g@GroupInfo {groupProfile = GroupProfile {displayName}} m @@ -811,10 +811,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName alwaysCaptcha || useMemberFilter image (passCaptcha a) sendToApprove :: GroupInfo -> GroupReg -> GroupApprovalId -> IO () - sendToApprove g0 GroupReg {dbContactId, promoted} gaId = do - -- verify the claimed name first, so admins see its actual state - g@GroupInfo {groupId, groupProfile = p@GroupProfile {displayName, image = image', publicGroup = pg_}, groupSummary} <- - if groupDomainVerified g0 /= Just True then verifyGroupDomain_ g0 else pure g0 + sendToApprove g@GroupInfo {groupId, groupProfile = p@GroupProfile {displayName, image = image', publicGroup = pg_}, groupSummary} GroupReg {dbContactId, promoted} gaId = do ct_ <- getContact' cc user dbContactId let gt = maybe "group" groupTypeStr' pg_ -- admins see an unverified claim, marked; users never do @@ -828,6 +825,10 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName let approveCmd = MCText $ "/approve " <> tshow groupId <> ":" <> viewName displayName <> " " <> tshow gaId <> if promoted then " promote=on" else "" sendComposedMessages cc (SRDirect cId) [msg, approveCmd] + -- the link-check reapproval path verifies before it reaches sendToApprove, so it uses sendToApprove directly + verifyAndSendToApprove :: GroupInfo -> GroupReg -> GroupApprovalId -> IO () + verifyAndSendToApprove g gr gaId = verifyGroupDomain_ g >>= \g' -> sendToApprove g' gr gaId + deGroupLinkCheck :: GroupInfo -> IO () deGroupLinkCheck gInfo@GroupInfo {groupId, groupProfile = GroupProfile {publicGroup = pg_}, groupSummary = summary} = withGroupReg gInfo "link check" $ \gr@GroupReg {groupRegStatus, dbOwnerMemberId} -> @@ -885,7 +886,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName notifyOwner gr' $ uCtRole <> ".\n\nThe group is listed in the directory again." notifyAdminUsers $ "The group " <> groupRef <> " is listed " <> suCtRole GRSPendingApproval gaId | rStatus == GRSOk -> do - sendToApprove g gr gaId + verifyAndSendToApprove g gr gaId notifyOwner gr $ uCtRole <> ".\n\nThe group is submitted for approval." GRSActive | rStatus /= GRSOk -> setGroupStatus notifyAdminUsers st env cc groupId GRSSuspendedBadRoles $ \gr' -> do @@ -912,7 +913,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName notifyAdminUsers $ "The group " <> groupRef <> " is listed " <> suSrvRole GRSPendingApproval gaId | serviceRole == GRAdmin -> whenContactIsOwner gr $ do - sendToApprove g gr gaId + verifyAndSendToApprove g gr gaId notifyOwner gr $ uSrvRole <> ".\n\nThe group is submitted for approval." GRSActive | serviceRole /= GRAdmin -> setGroupStatus notifyAdminUsers st env cc groupId GRSSuspendedBadRoles $ \gr' -> do @@ -1049,7 +1050,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName Left _ -> addGroupReg notifyAdminUsers st cc user ct g (GRSPendingApproval 1) $ \gr -> do void $ setGroupRegOwner cc groupId ownerMember - sendToApprove g gr 1 + verifyAndSendToApprove g gr 1 | role < GROwner -> sendMessage cc ct $ "You must be the " <> gt <> " owner to register it." | otherwise -> sendMessage cc ct $ "Waiting for the owner member to be connected to the " <> gt <> "." Left _ -> sendMessage cc ct $ "Error: could not verify " <> gt <> " ownership. Please report it to directory admins." @@ -1072,7 +1073,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName setGroupStatus notifyAdminUsers st env cc groupId (GRSPendingApproval n) $ \gr' -> do notifyOwner gr' $ "The " <> gt <> " " <> userGroupRef <> " is submitted for approval.\nIt is hidden from the directory until approved." - sendToApprove g gr' n + verifyAndSendToApprove g gr' n deReregistration ct _ _ _ = sendMessage cc ct "Error: could not verify ownership. Please report it to directory admins." @@ -1086,7 +1087,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName then setGroupStatus notifyAdminUsers st env cc groupId (GRSPendingApproval 1) $ \gr' -> do notifyOwner gr' $ "Joined the " <> gt <> " " <> displayName <> ". Registration is pending approval — it may take up to 48 hours." notifyOwner gr' $ recommendedSettingsNotice (userGroupRegId gr') - sendToApprove g gr' 1 + verifyAndSendToApprove g gr' 1 else do setGroupStatus notifyAdminUsers st env cc groupId GRSRemoved $ \_ -> pure () sendMessage' cc (dbContactId gr) "The signing key does not belong to a current owner. Registration cancelled." diff --git a/apps/simplex-directory-service/src/Directory/Store.hs b/apps/simplex-directory-service/src/Directory/Store.hs index 7cd730f746..bdb812276f 100644 --- a/apps/simplex-directory-service/src/Directory/Store.hs +++ b/apps/simplex-directory-service/src/Directory/Store.hs @@ -225,8 +225,6 @@ grDirectoryStatus = \case GRSRemoved -> DSRemoved _ -> DSRegistered --- the group's claimed SimpleX name, only when its verification status is recorded as --- verified - the display criterion for all user-facing directory surfaces verifiedGroupDomain :: GroupInfo -> Maybe SimplexDomain verifiedGroupDomain GroupInfo {groupProfile = GroupProfile {publicGroup}, groupDomainVerified} | groupDomainVerified == Just True = claimDomain <$> (publicGroup >>= publicGroupAccess >>= groupDomainClaim) diff --git a/src/Simplex/Chat/Library/Internal.hs b/src/Simplex/Chat/Library/Internal.hs index 27e5530a5f..7ad44bfa3c 100644 --- a/src/Simplex/Chat/Library/Internal.hs +++ b/src/Simplex/Chat/Library/Internal.hs @@ -1476,8 +1476,6 @@ updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = G Just PublicGroupData {publicMemberCount} | countChanged -> setPublicMemberCount db cxt user g publicMemberCount _ -> pure g - -- the claim is marked verified only when the caller resolved this name to reach this link - -- data; updateGroupProfile above clears verification on a claim change, so set it afterwards g'' <- if verifyResolved then liftIO $ setGroupDomainVerified db user g' True else pure g' pure (g'', profileChanged) | otherwise = pure (gInfo, False)