mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-12 20:29:12 +00:00
remove comments
This commit is contained in:
@@ -362,8 +362,6 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
|
||||
let msg = "Error: " <> err <> ", group: " <> tshow groupId <> " " <> localDisplayName <> ", " <> T.pack e
|
||||
notifyAdminUsers msg
|
||||
logError msg
|
||||
-- validates that resolving the claimed name leads to the link in the group profile,
|
||||
-- updating the group's verification status; leaves it unchanged on network errors
|
||||
verifyGroupDomain_ :: GroupInfo -> IO GroupInfo
|
||||
verifyGroupDomain_ g@GroupInfo {groupId}
|
||||
| isJust (groupSimplexDomain g) =
|
||||
@@ -814,7 +812,6 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
|
||||
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
|
||||
nameStr_ = (\d -> simplexNameStr d <> (if groupDomainVerified g == Just True then "" else " (NOT verified - will not be shown)")) <$> groupSimplexDomain g
|
||||
membersStr = "_" <> membersCountStr p groupSummary <> "_\n"
|
||||
text =
|
||||
@@ -825,7 +822,6 @@ 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
|
||||
|
||||
@@ -838,8 +834,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
|
||||
sendChatCmd cc (APIConnectPlan userId (Just (aConnectTarget link)) PRMAllGroups Nothing) >>= \case
|
||||
Right (CRConnectionPlan _ _ _ _ (CPGroupLink (GLPKnown {groupInfo = g', groupUpdated, linkOwners = ListDef owners}))) ->
|
||||
checkValidOwner dbOwnerMemberId owners $ do
|
||||
-- re-verified every cycle: the directory re-publishes the name, so it must
|
||||
-- know the name still resolves to the link in the (just refreshed) profile
|
||||
-- re-verify every cycle: a name that stopped resolving to the link must lose verified status
|
||||
g'' <- verifyGroupDomain_ g'
|
||||
when groupUpdated $ reapprove pg gr groupRegStatus g''
|
||||
when (groupUpdated || summary /= groupSummary g'' || groupDomainVerified g'' /= groupDomainVerified gInfo) $ listingsUpdated env
|
||||
|
||||
@@ -402,8 +402,7 @@ searchListedGroups cc user@User {userId, userContactId} searchType lastGroup_ pa
|
||||
pure (gs, n)
|
||||
where
|
||||
s = T.toLower search
|
||||
-- names are searched without the # / @ prefix; "#" (empty after stripping) cannot
|
||||
-- match any stored domain, so a bare prefix does not match every named group
|
||||
-- a bare "#"/"@" maps to "#", matching no stored domain (domains are stored unprefixed)
|
||||
sDomain = case T.uncons s of
|
||||
Just (c, rest) | c == '#' || c == '@' -> if T.null rest then "#" else rest
|
||||
_ -> s
|
||||
|
||||
@@ -2311,9 +2311,7 @@ processChatCommand cxt nm = \case
|
||||
g@GroupInfo {groupProfile = GroupProfile {publicGroup}} <- withFastStore $ \db -> getGroupInfo db cxt user groupId
|
||||
PublicGroupProfile {groupLink, publicGroupAccess} <- maybe (throwCmdError "not a public group") pure publicGroup
|
||||
claim <- maybe (throwCmdError "group has no name to verify") pure $ publicGroupAccess >>= groupDomainClaim
|
||||
-- name <-> link consistency: resolving the claimed name must lead to the link in the group
|
||||
-- profile - the same check the owner's client runs when setting the name; the link used
|
||||
-- to join is not compared, links may rotate
|
||||
-- checks the profile link, not the link we joined through (which may have rotated)
|
||||
(verified, reason) <-
|
||||
tryAllErrors (withAgent $ \a -> resolveSimplexName a nm (aUserId user) (claimDomain claim)) >>= \case
|
||||
Right NameRecord {nrSimplexChannel}
|
||||
@@ -3167,7 +3165,6 @@ processChatCommand cxt nm = \case
|
||||
when domainChanged $ do
|
||||
NameRecord {nrSimplexChannel} <- withAgent $ \a -> resolveSimplexName a nm (aUserId user) newDomain
|
||||
unless (nameResolvesTo groupLink nrSimplexChannel) $ throwChatError $ CESimplexDomainNotReady newDomain SDENoValidLink
|
||||
-- the resolution above proved name <-> link consistency, so mark it verified in the update
|
||||
runUpdateGroupProfile user gInfo p {publicGroup = Just pg {publicGroupAccess = Just access}} (isJust newClaim && domainChanged)
|
||||
Nothing -> throwChatError $ CECommandError "not a public group"
|
||||
APICreateGroupLink groupId mRole -> withUser $ \user -> withGroupLock "createGroupLink" groupId $ do
|
||||
@@ -3930,8 +3927,7 @@ processChatCommand cxt nm = \case
|
||||
runUpdateGroupProfile user gInfo@GroupInfo {businessChat, groupProfile = p@GroupProfile {displayName = n}} p'@GroupProfile {displayName = n'} domainVerified = do
|
||||
assertUserGroupRole gInfo GROwner
|
||||
when (n /= n') $ checkValidName n'
|
||||
-- updateGroupProfile resets domain verification on a claim change; the caller sets domainVerified
|
||||
-- when it has already resolved the new name, so it stays verified
|
||||
-- updateGroupProfile clears domain verification; re-set it when the caller already re-resolved the name
|
||||
gInfo' <- withStore $ \db -> do
|
||||
g <- updateGroupProfile db user gInfo p'
|
||||
if domainVerified then liftIO $ setGroupDomainVerified db user g True else pure g
|
||||
|
||||
@@ -1469,9 +1469,7 @@ updatePublicGroupData user gInfo
|
||||
withStore $ \db -> updatePublicMemberCount db cxt user gInfo
|
||||
| otherwise = pure gInfo
|
||||
|
||||
-- resolvedDomain_ is the name the caller just resolved, by explicit user action, to reach
|
||||
-- this link data; a link-data refresh alone (resolvedDomain_ = Nothing) never marks a
|
||||
-- claim verified, and names are never resolved here.
|
||||
-- must not resolve names here: a background link-data refresh would leak channel membership to the resolver
|
||||
updateGroupFromLinkData :: User -> GroupInfo -> GroupShortLinkData -> Maybe SimplexDomain -> CM (GroupInfo, Bool)
|
||||
updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = GroupSummary {publicMemberCount = localCount}} GroupShortLinkData {groupProfile, publicGroupData} resolvedDomain_
|
||||
| profileChanged || countChanged || verifyResolved = do
|
||||
@@ -1492,8 +1490,6 @@ updateGroupFromLinkData user gInfo@GroupInfo {groupProfile = p, groupSummary = G
|
||||
_ -> False
|
||||
groupClaim GroupProfile {publicGroup} = claimDomain <$> (publicGroup >>= publicGroupAccess >>= groupDomainClaim)
|
||||
newClaim = groupClaim groupProfile
|
||||
-- mark verified whenever the caller resolved exactly this claim (connect-by-name); idempotent,
|
||||
-- so no need to special-case an already-verified status (which updateGroupProfile may just have reset)
|
||||
verifyResolved = isJust resolvedDomain_ && resolvedDomain_ == newClaim
|
||||
|
||||
updateContactFromLinkData :: User -> Contact -> Profile -> CM Contact
|
||||
|
||||
@@ -102,8 +102,7 @@ directoryServiceTests = do
|
||||
it "should handle re-registration when already listed" testReregistrationAlreadyListed
|
||||
it "should update subscriber count periodically" testLinkCheckUpdatesCount
|
||||
|
||||
-- these run under a names-enabled SMP server (withSmpServerAndNames), so they are a
|
||||
-- separate spec from directoryServiceTests (which runs under a plain SMP server)
|
||||
-- separate spec from directoryServiceTests: these need a names-enabled SMP server (withSmpServerAndNames)
|
||||
directoryNameTests :: SpecWith TestParams
|
||||
directoryNameTests = do
|
||||
it "should verify and show a channel's SimpleX name" testDirectoryChannelName
|
||||
@@ -2126,8 +2125,7 @@ testRegisterChannelViaCard ps =
|
||||
superUser <# "'SimpleX Directory'> The channel ID 1 (news) is de-listed (channel owner left)."
|
||||
relay <## "#news: 'SimpleX Directory' left the group (signed)"
|
||||
|
||||
-- the owner sets a SimpleX name on a channel; the directory verifies name<->link consistency
|
||||
-- against the resolver and shows the verified name in the admin approval message
|
||||
-- owner sets a name; directory verifies name<->link consistency and shows the verified name to the admin
|
||||
testDirectoryChannelName :: HasCallStack => TestParams -> IO ()
|
||||
testDirectoryChannelName ps = withSmpServerAndNames $ \reg ->
|
||||
withDirectoryServiceCfg ps testCfg $ \superUser dsLink ->
|
||||
@@ -2167,8 +2165,7 @@ testDirectoryChannelName ps = withSmpServerAndNames $ \reg ->
|
||||
where
|
||||
newsName = SimplexNameInfo NTPublicGroup (SimplexDomain TLDSimplex "news" [])
|
||||
|
||||
-- after the owner set the name, the registry entry is re-pointed to a different link; the
|
||||
-- directory's verification fails, so the admin sees the name marked as not verified
|
||||
-- registry re-pointed to a different link after the owner set the name: directory verification fails
|
||||
testDirectoryChannelNameNotVerified :: HasCallStack => TestParams -> IO ()
|
||||
testDirectoryChannelNameNotVerified ps = withSmpServerAndNames $ \reg ->
|
||||
withDirectoryServiceCfg ps testCfg $ \superUser dsLink ->
|
||||
|
||||
@@ -117,8 +117,7 @@ testSetNameNotOwnAddress ps = withSmpServerAndNames $ \reg ->
|
||||
alice ##> "/_set domain 1 alice.simplex"
|
||||
alice <## "SimpleX name alice.simplex has no valid connection link"
|
||||
|
||||
-- A member who joined via link does not get the claimed name verified, even after a link-data
|
||||
-- refresh - the group's self-claim is not proof of name ownership.
|
||||
-- a self-claimed name is never auto-verified from link data: the claim is not proof of ownership
|
||||
testChannelDomainLinkJoinUnverified :: HasCallStack => TestParams -> IO ()
|
||||
testChannelDomainLinkJoinUnverified ps = withSmpServerAndNames $ \reg ->
|
||||
withNewTestChat ps "alice" aliceProfile $ \alice ->
|
||||
@@ -138,8 +137,6 @@ testChannelDomainLinkJoinUnverified ps = withSmpServerAndNames $ \reg ->
|
||||
where
|
||||
teamName = SimplexNameInfo NTPublicGroup (SimplexDomain TLDSimplex "team" [])
|
||||
|
||||
-- A2 (verify by name<->profile-link consistency), A3 (owner verified on set), and A1 (a failed
|
||||
-- status is retained across a link-data refresh, not erased to verified).
|
||||
testChannelDomainVerify :: HasCallStack => TestParams -> IO ()
|
||||
testChannelDomainVerify ps = withSmpServerAndNames $ \reg ->
|
||||
withNewTestChat ps "alice" aliceProfile $ \alice ->
|
||||
@@ -151,18 +148,17 @@ testChannelDomainVerify ps = withSmpServerAndNames $ \reg ->
|
||||
alice <## "updated public group access: domain=team.simplex"
|
||||
cath <## "alice updated group #team: (signed)"
|
||||
cath <## "updated public group access: domain=team.simplex"
|
||||
-- A3: setting the name resolved it, so the owner's channel is verified
|
||||
-- setting the name resolved it, so the owner's channel is verified
|
||||
alice ##> "/_verify domain #1"
|
||||
alice <## "SimpleX name #team verified"
|
||||
memberJoinChannel "team" [cath] [alice] shortLink fullLink bob
|
||||
-- A2: resolving the name leads to the profile's link
|
||||
bob ##> "/_verify domain #1"
|
||||
bob <## "SimpleX name #team verified"
|
||||
-- the name is re-pointed to a different link: verification fails
|
||||
registerName reg teamName (channelNameRecord "team" "https://simplex.chat/other")
|
||||
bob ##> "/_verify domain #1"
|
||||
bob <## "SimpleX name #team not verified: the name does not resolve to the link in the group profile"
|
||||
-- A1: a link-data refresh keeps the failed status (it does not overwrite it with verified)
|
||||
-- a link-data refresh keeps the failed status, not overwritten with verified
|
||||
bob ##> ("/_connect plan 1 " <> shortLink <> " resolve=allGroups")
|
||||
bob <## "group link: known group #team"
|
||||
bob <## "SimpleX name: #team (verification failed)"
|
||||
|
||||
@@ -112,7 +112,6 @@ function filterEntries(mode, s) {
|
||||
);
|
||||
}
|
||||
|
||||
// matches '#team', 'team' and 'team.simplex' against an entry displaying '#team'
|
||||
function simplexNameIncludesQuery(name, query) {
|
||||
if (!name) return false;
|
||||
const q = normalizeSimplexName(query);
|
||||
|
||||
Reference in New Issue
Block a user