directory: show knocking status in listings, trigger re-review on knocking change (#6695)

* directory: show knocking status in listings, trigger re-review on knocking change

- fix sameProfile to include memberAdmission so toggling knocking triggers re-review and regenerates the web listing JSON
- show "Knocking: enabled" in bot search results and /list output
- show "Knocking: enabled" in web directory UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* directory: rename "Knocking: enabled" to "Member admission: enabled"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* directory: member admission must trigger review

* update text, refactor

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
Narasimha-sc
2026-03-24 20:01:58 +00:00
committed by GitHub
parent 779dd38257
commit 427ce1b3ff
2 changed files with 21 additions and 10 deletions
@@ -326,6 +326,10 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
notifyAdminUsers msg
logError msg
groupInfoText p@GroupProfile {description = d} = groupNameDescr p <> maybe "" ("\nWelcome message:\n" <>) d
knockingStr :: Maybe GroupMemberAdmission -> [Text]
knockingStr = \case
Just GroupMemberAdmission {review = Just MCAll} -> ["New members are reviewed by admins"]
_ -> []
groupNameDescr GroupProfile {displayName = n, fullName = fn, shortDescr = sd_} =
n <> maybe "" (\d' -> " (" <> d' <> ")") descr
where
@@ -485,9 +489,9 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
GroupInfo {groupId, groupProfile = p} = fromGroup
GroupInfo {groupProfile = p'} = toGroup
sameProfile
GroupProfile {displayName = n, fullName = fn, shortDescr = sd, image = i, description = d}
GroupProfile {displayName = n', fullName = fn', shortDescr = sd', image = i', description = d'} =
n == n' && fn == fn' && i == i' && sd == sd' && (T.words <$> d) == (T.words <$> d')
GroupProfile {displayName = n, fullName = fn, shortDescr = sd, image = i, description = d, memberAdmission = ma}
GroupProfile {displayName = n', fullName = fn', shortDescr = sd', image = i', description = d', memberAdmission = ma'} =
n == n' && fn == fn' && i == i' && sd == sd' && (T.words <$> d) == (T.words <$> d') && ma == ma'
groupLinkAdded gr byMember =
getDuplicateGroup toGroup >>= \case
Left e -> notifyOwner gr $ "Error: getDuplicateGroup. Please notify the developers.\n" <> T.pack e
@@ -532,9 +536,9 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
checkRolesSendToApprove gr' n'
where
onlyLinkChanged
GroupProfile {displayName = dn, fullName = fn, shortDescr = sd, image = i, description = d}
GroupProfile {displayName = dn', fullName = fn', shortDescr = sd', image = i', description = d'} =
dn == dn' && fn == fn' && i == i' && sd == sd' && (T.words . T.replace linkBefore "" <$> d) == (T.words . T.replace linkNow "" <$> d')
GroupProfile {displayName = dn, fullName = fn, shortDescr = sd, image = i, description = d, memberAdmission = ma}
GroupProfile {displayName = dn', fullName = fn', shortDescr = sd', image = i', description = d', memberAdmission = ma'} =
dn == dn' && fn == fn' && i == i' && sd == sd' && ma == ma' && (T.words . T.replace linkBefore "" <$> d) == (T.words . T.replace linkNow "" <$> d')
GPServiceLinkError -> logError $ "Error: no group link for " <> groupRef <> " pending approval."
groupProfileUpdate = profileUpdate <$> sendChatCmd cc (APIGetGroupLink groupId)
where
@@ -996,10 +1000,10 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
where
msgs = replyMsg :| map foundGroup gs <> [moreMsg | moreGroups > 0]
replyMsg = (Just ciId, MCText reply)
foundGroup (GroupInfo {groupId, groupProfile = p@GroupProfile {image = image_}, groupSummary = GroupSummary {currentMembers}}, _) =
foundGroup (GroupInfo {groupId, groupProfile = p@GroupProfile {image = image_, memberAdmission}, groupSummary = GroupSummary {currentMembers}}, _) =
let membersStr = "_" <> tshow currentMembers <> " members_"
showId = if isAdmin then tshow groupId <> ". " else ""
text = showId <> groupInfoText p <> "\n" <> membersStr
text = T.unlines $ [showId <> groupInfoText p, membersStr] ++ knockingStr memberAdmission
in (Nothing, maybe (MCText text) (\image -> MCImage {text, image}) image_)
moreMsg = (Nothing, MCText $ "Send /next for " <> tshow moreGroups <> " more result(s).")
@@ -1181,14 +1185,14 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName
sendComposedMessages_ cc (SRDirect $ contactId' ct) $ replyMsg :| map groupMessage gs'
where
groupMessage ((g, gr), ct_) =
let GroupInfo {groupId, groupProfile = p@GroupProfile {image = image_}, groupSummary} = g
let GroupInfo {groupId, groupProfile = p@GroupProfile {image = image_, memberAdmission}, groupSummary} = g
GroupReg {userGroupRegId, groupRegStatus} = gr
useGroupId = if isAdmin then groupId else userGroupRegId
statusStr = "Status: " <> groupRegStatusText groupRegStatus
membersStr = "_" <> tshow (currentMembers groupSummary) <> " members_"
cmds = "/'role " <> tshow useGroupId <> "', /'filter " <> tshow useGroupId <> "'"
ownerStr = maybe "" (("Owner: " <>) . either (("getContact error: " <>) . T.pack) localDisplayName') ct_
text = T.unlines $ [tshow useGroupId <> ". " <> groupInfoText p] ++ [ownerStr | isAdmin] ++ [membersStr, statusStr, cmds]
text = T.unlines $ [tshow useGroupId <> ". " <> groupInfoText p] ++ [ownerStr | isAdmin] ++ [membersStr, statusStr] ++ knockingStr memberAdmission ++ [cmds]
msg = maybe (MCText text) (\image -> MCImage {text, image}) image_
in (Nothing, msg)
+7
View File
@@ -246,6 +246,13 @@ function displayEntries(entries) {
textContainer.appendChild(memberCountElement);
}
if (entryType?.admission?.review === "all") {
const knockingElement = document.createElement('p');
knockingElement.textContent = 'New members are reviewed by admins';
knockingElement.className = 'text-sm';
textContainer.appendChild(knockingElement);
}
const imgLinkElement = document.createElement('a');
const groupLinkUri = groupLink.connShortLink ?? groupLink.connFullLink
try {