From 78b4431dea3b6465ad5fc9c84d3dd13639017c72 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 25 Aug 2025 07:51:53 +0100 Subject: [PATCH] directory: use bot commands and menu in SimpleX Directory (#6219) * directory: use bot commands and menu in SimpleX Directory * rename (remove hyphen), fix test --- .../src/Directory/Options.hs | 4 +- .../src/Directory/Service.hs | 97 ++- tests/Bots/DirectoryTests.hs | 584 +++++++++--------- tests/ChatTests/Utils.hs | 3 +- 4 files changed, 363 insertions(+), 325 deletions(-) diff --git a/apps/simplex-directory-service/src/Directory/Options.hs b/apps/simplex-directory-service/src/Directory/Options.hs index 2eba633609..7ad3512fe9 100644 --- a/apps/simplex-directory-service/src/Directory/Options.hs +++ b/apps/simplex-directory-service/src/Directory/Options.hs @@ -116,8 +116,8 @@ directoryOpts appDir defaultDbName = do strOption ( long "service-name" <> metavar "SERVICE_NAME" - <> help "The display name of the directory service bot, without *'s and spaces (SimpleX-Directory)" - <> value "SimpleX-Directory" + <> help "The display name of the directory service bot, without *'s and spaces (SimpleX Directory)" + <> value "SimpleX Directory" ) runCLI <- switch diff --git a/apps/simplex-directory-service/src/Directory/Service.hs b/apps/simplex-directory-service/src/Directory/Service.hs index 1cbf419f41..f95b04dee1 100644 --- a/apps/simplex-directory-service/src/Directory/Service.hs +++ b/apps/simplex-directory-service/src/Directory/Service.hs @@ -8,6 +8,7 @@ {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -fno-warn-ambiguous-fields #-} module Directory.Service ( welcomeGetOpts, @@ -59,6 +60,7 @@ import Simplex.Chat.Store.Shared (StoreError (..)) import Simplex.Chat.Terminal (terminalChatConfig) import Simplex.Chat.Terminal.Main (simplexChatCLI') import Simplex.Chat.Types +import Simplex.Chat.Types.Preferences import Simplex.Chat.Types.Shared import Simplex.Chat.View (serializeChatError, serializeChatResponse, simplexChatContact, viewContactName, viewGroupName) import Simplex.Messaging.Agent.Protocol (AConnectionLink (..), ConnectionLink (..), CreatedConnLink (..)) @@ -70,6 +72,7 @@ import Simplex.Messaging.TMap (TMap) import qualified Simplex.Messaging.TMap as TM import Simplex.Messaging.Util (safeDecodeUtf8, tshow, ($>>=), (<$$>)) import System.Directory (getAppUserDataDirectory) +import System.Exit (exitFailure) import System.Process (readProcess) data GroupProfileUpdate @@ -144,7 +147,7 @@ directoryServiceCLI st opts = do env <- newServiceState opts eventQ <- newTQueueIO let eventHook cc resp = atomically $ resp <$ writeTQueue eventQ (cc, resp) - chatHooks = defaultChatHooks {eventHook = Just eventHook, acceptMember = Just $ acceptMemberHook opts env} + chatHooks = defaultChatHooks {postStartHook = Just postStartHook, eventHook = Just eventHook, acceptMember = Just $ acceptMemberHook opts env} race_ (simplexChatCLI' terminalChatConfig {chatHooks} (mkChatOpts opts) Nothing) (processEvents eventQ env) @@ -153,6 +156,34 @@ directoryServiceCLI st opts = do (cc, resp) <- atomically $ readTQueue eventQ u_ <- readTVarIO (currentUser cc) forM_ u_ $ \user -> directoryServiceEvent st opts env user cc resp + postStartHook cc = + readTVarIO (currentUser cc) >>= \case + Nothing -> putStrLn "No current user" >> exitFailure + Just User {userId, profile = p@LocalProfile {preferences}} -> do + let cmds = fromMaybe [] $ preferences >>= commands_ + unless (cmds == directoryCommands) $ do + let prefs = (fromMaybe emptyChatPrefs preferences) {files = Just FilesPreference {allow = FANo}, commands = Just directoryCommands} :: Preferences + p' = (fromLocalProfile p) {displayName = serviceName opts, peerType = Just CPTBot, preferences = Just prefs} :: Profile + liftIO $ sendChatCmd cc (APIUpdateProfile userId p') >>= \case + Right CRUserProfileUpdated {} -> putStrLn "Updated directory commands" + Right r -> putStrLn ("Error: unexpected response " <> show r) >> exitFailure + Left e -> putStrLn ("Error: " <> show e) >> exitFailure + +directoryCommands :: [ChatBotCommand] +directoryCommands = + [ CBCCommand "new" "New groups" Nothing, + CBCCommand "help" "How to submit your group" Nothing, + CBCCommand "list" "Your own groups" Nothing, + CBCMenu + "Group settings" + [ CBCCommand "role" "View new member role" idParam, + CBCCommand "filter" "Anti-spam filter" idParam, + CBCCommand "link" "View and upgrade group link" idParam, + CBCCommand "delete" "Remove a group from directory" (Just ":''") + ] + ] + where + idParam = Just "" directoryService :: DirectoryStore -> DirectoryOpts -> ServiceState -> User -> ChatController -> IO () directoryService st opts@DirectoryOpts {testing} env user cc = do @@ -299,11 +330,11 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName deContactConnected ct = when (contactDirect ct) $ do logInfo $ (viewContactName ct) <> " connected" sendMessage cc ct $ - ("Welcome to " <> serviceName <> " service!\n") - <> "Send a search string to find groups or */help* to learn how to add groups to directory.\n\n\ - \For example, send _privacy_ to find groups about privacy.\n\ - \Or send */all* or */new* to list groups.\n\n\ - \Content and privacy policy: https://simplex.chat/docs/directory.html" + ("Welcome to " <> serviceName <> "!\n\n") + <> "šŸ” Send search string to find groups - try _security_.\n\ + \/help - how to submit your group.\n\ + \/new - recent groups.\n\n\ + \[Directory rules](https://simplex.chat/docs/directory.html)." deGroupInvitation :: Contact -> GroupInfo -> GroupMemberRole -> GroupMemberRole -> IO () deGroupInvitation ct g@GroupInfo {groupProfile = p@GroupProfile {displayName}} fromMemberRole memberRole = do @@ -674,24 +705,22 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName deUserCommand ct ciId = \case DCHelp DHSRegistration -> sendMessage cc ct $ - "You must be the owner to add the group to the directory:\n\ - \1. Invite " + "You must be the group owner to add it to the directory:\n\n\ + \1ļøāƒ£ *Invite* " <> serviceName - <> " bot to your group as *admin* (you can send `/list` to see all groups you submitted).\n\ - \2. " - <> serviceName - <> " bot will create a public group link for the new members to join even when you are offline.\n\ - \3. You will then need to add this link to the group welcome message.\n\ - \4. Once the link is added, service admins will approve the group (it can take up to 48 hours), and everybody will be able to find it in directory.\n\n\ - \Start from inviting the bot to your group as admin - it will guide you through the process." + <> " bot to your group as *admin* - it will create a link for new members to join.\n\ + \2ļøāƒ£ *Add* this link to the group's welcome message.\n\ + \3ļøāƒ£ We *review* your group. Once *approved*, anybody can find it.\n\n\ + \_We usually approve within a day, except holidays_. [More details](https://simplex.chat/docs/directory.html#adding-groups-to-the-directory)." DCHelp DHSCommands -> sendMessage cc ct $ - "*/help commands* - receive this help message.\n\ - \*/help* - how to register your group to be added to directory.\n\ - \*/list* - list the groups you registered.\n\ - \*/delete :* - remove the group you submitted from directory, with _ID_ and _name_ as shown by */list* command.\n\ - \*/role * - view and set default member role for your group.\n\ - \*/filter * - view and set spam filter settings for group.\n\n\ + "/'help commands' - receive this help message.\n\ + \/help - how to register your group to be added to directory.\n\ + \/list - list the groups you registered.\n\ + \`/role ` - view and set default member role for your group.\n\ + \`/filter ` - view and set spam filter settings for group.\n\ + \`/link ` - view and upgrade group link.\n\ + \`/delete :` - remove the group you submitted from directory, with _ID_ and _name_ as shown by /list command.\n\n\ \To search for groups, send the search text." DCSearchGroup s -> withFoundListedGroups (Just s) $ sendSearchResults s DCSearchNext -> @@ -741,7 +770,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName let anotherRole = case acceptMemberRole of GRObserver -> GRMember; _ -> GRObserver sendReply $ initialRole n acceptMemberRole - <> ("Send */role " <> tshow gId <> " " <> strEncodeTxt anotherRole <> "* to change it.\n\n") + <> ("Send /'role " <> tshow gId <> " " <> strEncodeTxt anotherRole <> "' to change it.\n\n") <> onlyViaLink gLink Nothing -> sendReply $ "Error: failed reading the initial member role for the group " <> n Just mRole -> do @@ -765,16 +794,19 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName where sendSettigns n a setTo = sendReply $ - T.unlines + T.unlines $ [ "Spam filter settings for group " <> n <> setTo <> ":", "- reject long/inappropriate names: " <> showCondition (rejectNames a), "- pass captcha to join: " <> showCondition (passCaptcha a), -- "- make observer: " <> showCondition (makeObserver a) <> (if isJust (makeObserver a) then "" else " (use default set with /role command)"), - "", + "" -- "Use */filter " <> tshow gId <> " * to change spam filter level: no (disable), basic, moderate, strong.", -- "Or use */filter " <> tshow gId <> " [name[=noimage]] [captcha[=noimage]] [observer[=noimage]]* for advanced filter configuration." - "Use */filter " <> tshow gId <> " [name] [captcha]* to enable and */filter " <> tshow gId <> " off* to disable filter." ] + <> ["/'filter " <> tshow gId <> " name' - enable name filter" | isNothing (rejectNames a)] + <> ["/'filter " <> tshow gId <> " captcha' - enable captcha challenge" | isNothing (passCaptcha a)] + <> ["/'filter " <> tshow gId <> " name captcha' - enable both" | isNothing (rejectNames a) || isNothing (passCaptcha a)] + <> ["/'filter " <> tshow gId <> " off' - disable filter" | isJust (rejectNames a) || isJust (passCaptcha a)] showCondition = \case Nothing -> "_disabled_" Just PCAll -> "_enabled_" @@ -887,7 +919,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName showId = if isAdmin then tshow groupId <> ". " else "" text = showId <> groupInfoText p <> "\n" <> membersStr in (Nothing, maybe (MCText text) (\image -> MCImage {text, image}) image_) - moreMsg = (Nothing, MCText $ "Send */next* or just *.* for " <> tshow moreGroups <> " more result(s).") + moreMsg = (Nothing, MCText $ "Send /next for " <> tshow moreGroups <> " more result(s).") deAdminCommand :: Contact -> ChatItemId -> DirectoryCmd 'DRAdmin -> IO () deAdminCommand ct ciId cmd @@ -907,11 +939,11 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName let approved = "The group " <> userGroupReference' gr n <> " is approved" notifyOwner gr $ (approved <> " and listed in directory - please moderate it!\n") - <> "Please note: if you change the group profile it will be hidden from directory until it is re-approved.\n\n" + <> "_Please note_: if you change the group profile it will be hidden from directory until it is re-approved.\n\n" <> "Supported commands:\n" - <> ("- */filter " <> tshow ugrId <> "* - to configure anti-spam filter.\n") - <> ("- */role " <> tshow ugrId <> "* - to set default member role.\n") - <> "- */help commands* - other commands." + <> ("/'filter " <> tshow ugrId <> "' - to configure anti-spam filter.\n") + <> ("/'role " <> tshow ugrId <> "' - to set default member role.\n") + <> ("/'link " <> tshow ugrId <> "' - to view/upgrade group link.") invited <- forM ownersGroup $ \og@KnownGroup {localDisplayName = ogName} -> do inviteToOwnersGroup og gr $ \case @@ -920,7 +952,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName pure $ "Invited " <> owner <> " to owners' group " <> viewName ogName Left err -> pure err sendReply $ "Group approved!" <> maybe "" ("\n" <>) invited - notifyOtherSuperUsers $ approved <> " by " <> viewName (localDisplayName' ct) <> fromMaybe "" invited + notifyOtherSuperUsers $ approved <> " by " <> viewName (localDisplayName' ct) <> maybe "" ("\n" <>) invited Just GRSServiceNotAdmin -> replyNotApproved serviceNotAdmin Just GRSContactNotOwner -> replyNotApproved "user is not an owner." Just GRSBadRoles -> replyNotApproved $ "user is not an owner, " <> serviceNotAdmin @@ -1062,7 +1094,8 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName getGroupAndSummary cc user dbGroupId >>= \case Just (GroupInfo {groupProfile = p@GroupProfile {image = image_}}, GroupSummary {currentMembers}) -> do let membersStr = "_" <> tshow currentMembers <> " members_" - text = T.unlines $ [tshow useGroupId <> ". " <> groupInfoText p] <> maybeToList ownerStr_ <> [membersStr, statusStr] + cmds = "/'role " <> tshow useGroupId <> "', /'filter " <> tshow useGroupId <> "'" + text = T.unlines $ [tshow useGroupId <> ". " <> groupInfoText p] <> maybeToList ownerStr_ <> [membersStr, statusStr, cmds] msg = maybe (MCText text) (\image -> MCImage {text, image}) image_ sendComposedMessage cc ct Nothing msg Nothing -> do diff --git a/tests/Bots/DirectoryTests.hs b/tests/Bots/DirectoryTests.hs index a69f57cfca..3f59863f25 100644 --- a/tests/Bots/DirectoryTests.hs +++ b/tests/Bots/DirectoryTests.hs @@ -75,7 +75,7 @@ directoryServiceTests = do it "should accept some incorrect spellings" testCaptcha directoryProfile :: Profile -directoryProfile = Profile {displayName = "SimpleX-Directory", fullName = "", shortDescr = Nothing, image = Nothing, contactLink = Nothing, peerType = Just CPTBot, preferences = Nothing} +directoryProfile = Profile {displayName = "SimpleX Directory", fullName = "", shortDescr = Nothing, image = Nothing, contactLink = Nothing, peerType = Just CPTBot, preferences = Nothing} mkDirectoryOpts :: TestParams -> [KnownContact] -> Maybe KnownGroup -> DirectoryOpts mkDirectoryOpts TestParams {tmpPath = ps} superUsers ownersGroup = @@ -101,7 +101,7 @@ mkDirectoryOpts TestParams {tmpPath = ps} superUsers ownersGroup = profileNameLimit = maxBound, captchaGenerator = Nothing, directoryLog = Just $ ps "directory_service.log", - serviceName = "SimpleX-Directory", + serviceName = "SimpleX Directory", runCLI = False, searchResults = 3, testing = True @@ -119,101 +119,102 @@ testDirectoryService ps = withNewTestChat ps "bob" bobProfile $ \bob -> withNewTestChat ps "cath" cathProfile $ \cath -> do bob `connectVia` dsLink - bob #> "@SimpleX-Directory privacy" - bob <# "SimpleX-Directory> > privacy" + bob #> "@'SimpleX Directory' privacy" + bob <# "'SimpleX Directory'> > privacy" bob <## " No groups found" -- putStrLn "*** create a group" bob ##> "/g PSA Privacy, Security & Anonymity" bob <## "group #PSA (Privacy, Security & Anonymity) is created" bob <## "to add members use /a PSA or /create link #PSA" - bob ##> "/a PSA SimpleX-Directory member" - bob <## "invitation to join the group #PSA sent to SimpleX-Directory" - bob <# "SimpleX-Directory> You must grant directory service admin role to register the group" - bob ##> "/mr PSA SimpleX-Directory admin" + bob ##> "/a PSA 'SimpleX Directory' member" + bob <## "invitation to join the group #PSA sent to 'SimpleX Directory'" + bob <# "'SimpleX Directory'> You must grant directory service admin role to register the group" + bob ##> "/mr PSA 'SimpleX Directory' admin" -- putStrLn "*** discover service joins group and creates the link for profile" - bob <## "#PSA: you changed the role of SimpleX-Directory to admin" - bob <# "SimpleX-Directory> Joining the group PSA…" - bob <## "#PSA: SimpleX-Directory joined the group" - bob <# "SimpleX-Directory> Joined the group PSA, creating the link…" - bob <# "SimpleX-Directory> Created the public link to join the group via this directory service that is always online." + bob <## "#PSA: you changed the role of 'SimpleX Directory' to admin" + bob <# "'SimpleX Directory'> Joining the group PSA…" + bob <## "#PSA: 'SimpleX Directory' joined the group" + bob <# "'SimpleX Directory'> Joined the group PSA, creating the link…" + bob <# "'SimpleX Directory'> Created the public link to join the group via this directory service that is always online." bob <## "" bob <## "Please add it to the group welcome message." bob <## "For example, add:" - welcomeWithLink <- dropStrPrefix "SimpleX-Directory> " . dropTime <$> getTermLine bob + welcomeWithLink <- dropStrPrefix "'SimpleX Directory'> " . dropTime <$> getTermLine bob -- putStrLn "*** update profile without link" updateGroupProfile bob "Welcome!" - bob <# "SimpleX-Directory> The profile updated for ID 1 (PSA), but the group link is not added to the welcome message." + bob <# "'SimpleX Directory'> The profile updated for ID 1 (PSA), but the group link is not added to the welcome message." (superUser Thank you! The group link for ID 1 (PSA) is added to the welcome message." + bob <# "'SimpleX Directory'> Thank you! The group link for ID 1 (PSA) is added to the welcome message." bob <## "You will be notified once the group is added to the directory - it may take up to 48 hours." approvalRequested superUser welcomeWithLink (1 :: Int) -- putStrLn "*** update profile so that it still has link" let welcomeWithLink' = "Welcome! " <> welcomeWithLink updateGroupProfile bob welcomeWithLink' - bob <# "SimpleX-Directory> The group ID 1 (PSA) is updated!" + bob <# "'SimpleX Directory'> The group ID 1 (PSA) is updated!" bob <## "It is hidden from the directory until approved." - superUser <# "SimpleX-Directory> The group ID 1 (PSA) is updated." + superUser <# "'SimpleX Directory'> The group ID 1 (PSA) is updated." approvalRequested superUser welcomeWithLink' (2 :: Int) -- putStrLn "*** try approving with the old registration code" - bob #> "@SimpleX-Directory /approve 1:PSA 1" - bob <# "SimpleX-Directory> > /approve 1:PSA 1" + bob #> "@'SimpleX Directory' /approve 1:PSA 1" + bob <# "'SimpleX Directory'> > /approve 1:PSA 1" bob <## " You are not allowed to use this command" - superUser #> "@SimpleX-Directory /approve 1:PSA 1" - superUser <# "SimpleX-Directory> > /approve 1:PSA 1" + superUser #> "@'SimpleX Directory' /approve 1:PSA 1" + superUser <# "'SimpleX Directory'> > /approve 1:PSA 1" superUser <## " Incorrect approval code" -- putStrLn "*** update profile so that it has no link" updateGroupProfile bob "Welcome!" - bob <# "SimpleX-Directory> The group link for ID 1 (PSA) is removed from the welcome message." + bob <# "'SimpleX Directory'> The group link for ID 1 (PSA) is removed from the welcome message." bob <## "" bob <## "The group is hidden from the directory until the group link is added and the group is re-approved." - superUser <# "SimpleX-Directory> The group link is removed from ID 1 (PSA), de-listed." - superUser #> "@SimpleX-Directory /approve 1:PSA 2" - superUser <# "SimpleX-Directory> > /approve 1:PSA 2" + superUser <# "'SimpleX Directory'> The group link is removed from ID 1 (PSA), de-listed." + superUser #> "@'SimpleX Directory' /approve 1:PSA 2" + superUser <# "'SimpleX Directory'> > /approve 1:PSA 2" superUser <## " Error: the group ID 1 (PSA) is not pending approval." -- putStrLn "*** update profile so that it has link again" updateGroupProfile bob welcomeWithLink' - bob <# "SimpleX-Directory> Thank you! The group link for ID 1 (PSA) is added to the welcome message." + bob <# "'SimpleX Directory'> Thank you! The group link for ID 1 (PSA) is added to the welcome message." bob <## "You will be notified once the group is added to the directory - it may take up to 48 hours." approvalRequested superUser welcomeWithLink' (1 :: Int) - superUser #> "@SimpleX-Directory /pending" - superUser <# "SimpleX-Directory> > /pending" + superUser #> "@'SimpleX Directory' /pending" + superUser <# "'SimpleX Directory'> > /pending" superUser <## " 1 registered group(s)" - superUser <# "SimpleX-Directory> 1. PSA (Privacy, Security & Anonymity)" + superUser <# "'SimpleX Directory'> 1. PSA (Privacy, Security & Anonymity)" superUser <## "Welcome message:" superUser <##. "Welcome! Link to join the group PSA: " superUser <## "Owner: bob" superUser <## "2 members" superUser <## "Status: pending admin approval" - superUser #> "@SimpleX-Directory /approve 1:PSA 1" - superUser <# "SimpleX-Directory> > /approve 1:PSA 1" + superUser <## "/'role 1', /'filter 1'" + superUser #> "@'SimpleX Directory' /approve 1:PSA 1" + superUser <# "'SimpleX Directory'> > /approve 1:PSA 1" superUser <## " Group approved!" - bob <# "SimpleX-Directory> The group ID 1 (PSA) is approved and listed in directory - please moderate it!" + bob <# "'SimpleX Directory'> The group ID 1 (PSA) is approved and listed in directory - please moderate it!" bob <## "Please note: if you change the group profile it will be hidden from directory until it is re-approved." bob <## "" bob <## "Supported commands:" - bob <## "- /filter 1 - to configure anti-spam filter." - bob <## "- /role 1 - to set default member role." - bob <## "- /help commands - other commands." + bob <## "/'filter 1' - to configure anti-spam filter." + bob <## "/'role 1' - to set default member role." + bob <## "/'link 1' - to view/upgrade group link." search bob "privacy" welcomeWithLink' search bob "security" welcomeWithLink' cath `connectVia` dsLink search cath "privacy" welcomeWithLink' - bob #> "@SimpleX-Directory /exec /contacts" - bob <# "SimpleX-Directory> > /exec /contacts" + bob #> "@'SimpleX Directory' /exec /contacts" + bob <# "'SimpleX Directory'> > /exec /contacts" bob <## " You are not allowed to use this command" - superUser #> "@SimpleX-Directory /exec /contacts" - superUser <# "SimpleX-Directory> > /exec /contacts" + superUser #> "@'SimpleX Directory' /exec /contacts" + superUser <# "'SimpleX Directory'> > /exec /contacts" superUser <## " alice (Alice)" superUser <## "bob (Bob)" superUser <## "cath (Catherine)" where search u s welcome = do - u #> ("@SimpleX-Directory " <> s) - u <# ("SimpleX-Directory> > " <> s) + u #> ("@'SimpleX Directory' " <> s) + u <# ("'SimpleX Directory'> > " <> s) u <## " Found 1 group(s)." - u <# "SimpleX-Directory> PSA (Privacy, Security & Anonymity)" + u <# "'SimpleX Directory'> PSA (Privacy, Security & Anonymity)" u <## "Welcome message:" u <## welcome u <## "2 members" @@ -222,14 +223,14 @@ testDirectoryService ps = u <## "welcome message changed to:" u <## welcome approvalRequested su welcome grId = do - su <# "SimpleX-Directory> bob submitted the group ID 1:" + su <# "'SimpleX Directory'> bob submitted the group ID 1:" su <## "PSA (Privacy, Security & Anonymity)" su <## "Welcome message:" su <## welcome su <## "2 members" su <## "" su <## "To approve send:" - su <# ("SimpleX-Directory> /approve 1:PSA " <> show grId) + su <# ("'SimpleX Directory'> /approve 1:PSA " <> show grId) testSuspendResume :: HasCallStack => TestParams -> IO () testSuspendResume ps = @@ -238,26 +239,26 @@ testSuspendResume ps = bob `connectVia` dsLink registerGroup superUser bob "privacy" "Privacy" groupFound bob "privacy" - superUser #> "@SimpleX-Directory /suspend 1:privacy" - superUser <# "SimpleX-Directory> > /suspend 1:privacy" + superUser #> "@'SimpleX Directory' /suspend 1:privacy" + superUser <# "'SimpleX Directory'> > /suspend 1:privacy" superUser <## " Group suspended!" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is suspended and hidden from directory. Please contact the administrators." + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is suspended and hidden from directory. Please contact the administrators." groupNotFound bob "privacy" - superUser #> "@SimpleX-Directory /resume 1:privacy" - superUser <# "SimpleX-Directory> > /resume 1:privacy" + superUser #> "@'SimpleX Directory' /resume 1:privacy" + superUser <# "'SimpleX Directory'> > /resume 1:privacy" superUser <## " Group listing resumed!" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is listed in the directory again!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is listed in the directory again!" groupFound bob "privacy" - superUser #> "@SimpleX-Directory privacy" + superUser #> "@'SimpleX Directory' privacy" groupFoundN_ "" (Just 1) 2 superUser "privacy" - superUser #> "@SimpleX-Directory /link 1:privacy" - superUser <# "SimpleX-Directory> > /link 1:privacy" + superUser #> "@'SimpleX Directory' /link 1:privacy" + superUser <# "'SimpleX Directory'> > /link 1:privacy" superUser <## " The link to join the group ID 1 (privacy):" superUser <##. "https://localhost/g#" superUser <## "New member role: member" -- get and change the link to the equivalent - should not ask to re-approve - bob #> "@SimpleX-Directory /link 1" - bob <# "SimpleX-Directory> > /link 1" + bob #> "@'SimpleX Directory' /link 1" + bob <# "'SimpleX Directory'> > /link 1" bob <## " The link to join the group ID 1 (privacy):" gLink <- getTermLine bob gLink `shouldStartWith` "https://localhost/g#" @@ -268,38 +269,38 @@ testSuspendResume ps = bob ##> ("/set welcome #privacy Link to join the group privacy: " <> gLink <> "?same_link=true") bob <## "welcome message changed to:" bob <## ("Link to join the group privacy: " <> gLink <> "?same_link=true") - bob <# "SimpleX-Directory> The group ID 1 (privacy) is updated!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is updated!" bob <## "The group is listed in directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is updated - only link or whitespace changes." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is updated - only link or whitespace changes." superUser <## "The group remained listed in directory." -- upgrade link -- make it upgradeable first - superUser #> "@SimpleX-Directory /x /sql chat UPDATE user_contact_links SET short_link_contact = NULL" - superUser <# "SimpleX-Directory> > /x /sql chat UPDATE user_contact_links SET short_link_contact = NULL" + superUser #> "@'SimpleX Directory' /x /sql chat UPDATE user_contact_links SET short_link_contact = NULL" + superUser <# "'SimpleX Directory'> > /x /sql chat UPDATE user_contact_links SET short_link_contact = NULL" superUser <## "" - bob #> "@SimpleX-Directory /link 1" - bob <# "SimpleX-Directory> > /link 1" + bob #> "@'SimpleX Directory' /link 1" + bob <# "'SimpleX Directory'> > /link 1" bob <## " The link to join the group ID 1 (privacy):" bob <##. "https://simplex.chat/contact#/" bob <## "New member role: member" bob <## "The link is being upgraded..." - bob <# "SimpleX-Directory> Please replace the old link in welcome message of your group ID 1 (privacy)" + bob <# "'SimpleX Directory'> Please replace the old link in welcome message of your group ID 1 (privacy)" bob <## "If this is the only change, the group will remain listed in directory without re-approval." bob <## "" bob <## "The new link:" - gLink' <- dropStrPrefix "SimpleX-Directory> " . dropTime <$> getTermLine bob + gLink' <- dropStrPrefix "'SimpleX Directory'> " . dropTime <$> getTermLine bob bob ##> ("/set welcome #privacy Link to join the group privacy: " <> gLink') bob <## "welcome message changed to:" bob <## ("Link to join the group privacy: " <> gLink') - bob <# "SimpleX-Directory> The group ID 1 (privacy) is updated!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is updated!" bob <## "The group is listed in directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is updated - only link or whitespace changes." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is updated - only link or whitespace changes." superUser <## "The group remained listed in directory." -- send message to group owner - superUser #> "@SimpleX-Directory /owner 1:privacy hello there" - superUser <# "SimpleX-Directory> > /owner 1:privacy hello there" + superUser #> "@'SimpleX Directory' /owner 1:privacy hello there" + superUser <# "'SimpleX Directory'> > /owner 1:privacy hello there" superUser <## " Forwarded to @bob, the owner of the group ID 1 (privacy)" - bob <# "SimpleX-Directory> hello there" + bob <# "'SimpleX Directory'> hello there" testDeleteGroup :: HasCallStack => TestParams -> IO () testDeleteGroup ps = @@ -308,8 +309,8 @@ testDeleteGroup ps = bob `connectVia` dsLink registerGroup superUser bob "privacy" "Privacy" groupFound bob "privacy" - bob #> "@SimpleX-Directory /delete 1:privacy" - bob <# "SimpleX-Directory> > /delete 1:privacy" + bob #> "@'SimpleX Directory' /delete 1:privacy" + bob <# "'SimpleX Directory'> > /delete 1:privacy" bob <## " Your group privacy is deleted from the directory" groupNotFound bob "privacy" @@ -326,19 +327,19 @@ testDeleteGroupAdmin ps = groupFound bob "security" listUserGroup bob "privacy" "Privacy" listUserGroup cath "security" "Security" - superUser #> "@SimpleX-Directory /last" - superUser <# "SimpleX-Directory> > /last" + superUser #> "@'SimpleX Directory' /last" + superUser <# "'SimpleX Directory'> > /last" superUser <## " 2 registered group(s)" memberGroupListing superUser bob 1 "privacy" "Privacy" 2 "active" memberGroupListing superUser cath 2 "security" "Security" 2 "active" -- trying to register group with the same name submitGroup bob "security" "Security" - bob <# "SimpleX-Directory> The group security (Security) is already listed in the directory, please choose another name." + bob <# "'SimpleX Directory'> The group security (Security) is already listed in the directory, please choose another name." bob ##> "/d #security" bob <## "#security: you deleted the group" -- admin can delete the group - superUser #> "@SimpleX-Directory /delete 2:security" - superUser <# "SimpleX-Directory> > /delete 2:security" + superUser #> "@'SimpleX Directory' /delete 2:security" + superUser <# "'SimpleX Directory'> > /delete 2:security" superUser <## " The group security is deleted from the directory" groupFound cath "privacy" listUserGroup bob "privacy" "Privacy" @@ -355,8 +356,8 @@ testSetRole ps = bob `connectVia` dsLink registerGroup superUser bob "privacy" "Privacy" groupFound bob "privacy" - bob #> "@SimpleX-Directory /role 1:privacy observer" - bob <# "SimpleX-Directory> > /role 1:privacy observer" + bob #> "@'SimpleX Directory' /role 1:privacy observer" + bob <# "'SimpleX Directory'> > /role 1:privacy observer" bob <## " The initial member role for the group privacy is set to observer" bob <## "" note <- getTermLine bob @@ -365,13 +366,13 @@ testSetRole ps = cath <## "connection request sent!" cath <## "#privacy: joining the group..." cath <## "#privacy: you joined the group" - cath <#. "#privacy SimpleX-Directory> Link to join the group privacy: https://localhost/g#" + cath <#. "#privacy 'SimpleX Directory'> Link to join the group privacy: https://localhost/g#" cath <## "#privacy: member bob (Bob) is connected" - bob <## "#privacy: SimpleX-Directory added cath (Catherine) to the group (connecting...)" + bob <## "#privacy: 'SimpleX Directory' added cath (Catherine) to the group (connecting...)" bob <## "#privacy: new member cath is connected" bob ##> "/ms #privacy" bob <## "bob (Bob): owner, you, created group" - bob <## "SimpleX-Directory: admin, invited, connected" + bob <## "'SimpleX Directory': admin, invited, connected" bob <## "cath (Catherine): observer, connected" cath ##> "#privacy hello" cath <## "#privacy: you don't have permission to send messages" @@ -385,10 +386,10 @@ testJoinGroup ps = bob `connectVia` dsLink registerGroup superUser bob "privacy" "Privacy" cath `connectVia` dsLink - cath #> "@SimpleX-Directory privacy" - cath <# "SimpleX-Directory> > privacy" + cath #> "@'SimpleX Directory' privacy" + cath <# "'SimpleX Directory'> > privacy" cath <## " Found 1 group(s)." - cath <# "SimpleX-Directory> privacy (Privacy)" + cath <# "'SimpleX Directory'> privacy (Privacy)" cath <## "Welcome message:" welcomeMsg <- getTermLine cath let groupLink = dropStrPrefix "Link to join the group privacy: " welcomeMsg @@ -397,11 +398,11 @@ testJoinGroup ps = cath <## "connection request sent!" cath <## "#privacy: joining the group..." cath <## "#privacy: you joined the group" - cath <## "contact and member are merged: SimpleX-Directory, #privacy SimpleX-Directory_1" - cath <## "use @SimpleX-Directory to send messages" - cath <# ("#privacy SimpleX-Directory> " <> welcomeMsg) + cath <## "contact and member are merged: 'SimpleX Directory', #privacy 'SimpleX Directory_1'" + cath <## "use @'SimpleX Directory' to send messages" + cath <# ("#privacy 'SimpleX Directory'> " <> welcomeMsg) cath <## "#privacy: member bob (Bob) is connected" - bob <## "#privacy: SimpleX-Directory added cath (Catherine) to the group (connecting...)" + bob <## "#privacy: 'SimpleX Directory' added cath (Catherine) to the group (connecting...)" bob <## "#privacy: new member cath is connected" bob ##> "/create link #privacy" bobLink <- getGroupLink bob "privacy" GRMember True @@ -416,7 +417,7 @@ testJoinGroup ps = dan <## "#privacy: you joined the group" dan <# ("#privacy bob> " <> welcomeMsg) dan - <### [ "#privacy: member SimpleX-Directory is connected", + <### [ "#privacy: member 'SimpleX Directory' is connected", "#privacy: member cath (Catherine) is connected" ], do @@ -431,15 +432,15 @@ testGroupNameWithSpaces ps = bob `connectVia` dsLink registerGroup superUser bob "Privacy & Security" "" groupFound bob "Privacy & Security" - superUser #> "@SimpleX-Directory /suspend 1:'Privacy & Security'" - superUser <# "SimpleX-Directory> > /suspend 1:'Privacy & Security'" + superUser #> "@'SimpleX Directory' /suspend 1:'Privacy & Security'" + superUser <# "'SimpleX Directory'> > /suspend 1:'Privacy & Security'" superUser <## " Group suspended!" - bob <# "SimpleX-Directory> The group ID 1 (Privacy & Security) is suspended and hidden from directory. Please contact the administrators." + bob <# "'SimpleX Directory'> The group ID 1 (Privacy & Security) is suspended and hidden from directory. Please contact the administrators." groupNotFound bob "privacy" - superUser #> "@SimpleX-Directory /resume 1:'Privacy & Security'" - superUser <# "SimpleX-Directory> > /resume 1:'Privacy & Security'" + superUser #> "@'SimpleX Directory' /resume 1:'Privacy & Security'" + superUser <# "'SimpleX Directory'> > /resume 1:'Privacy & Security'" superUser <## " Group listing resumed!" - bob <# "SimpleX-Directory> The group ID 1 (Privacy & Security) is listed in the directory again!" + bob <# "'SimpleX Directory'> The group ID 1 (Privacy & Security) is listed in the directory again!" groupFound bob "Privacy & Security" testSearchGroups :: HasCallStack => TestParams -> IO () @@ -453,58 +454,58 @@ testSearchGroups ps = connectUsers bob cath fullAddMember "MyGroup" "" bob cath GRMember joinGroup "MyGroup" cath bob - cath <## "#MyGroup: member SimpleX-Directory_1 is connected" - cath <## "contact and member are merged: SimpleX-Directory, #MyGroup SimpleX-Directory_1" - cath <## "use @SimpleX-Directory to send messages" - cath #> "@SimpleX-Directory MyGroup" - cath <# "SimpleX-Directory> > MyGroup" + cath <## "#MyGroup: member 'SimpleX Directory_1' is connected" + cath <## "contact and member are merged: 'SimpleX Directory', #MyGroup 'SimpleX Directory_1'" + cath <## "use @'SimpleX Directory' to send messages" + cath #> "@'SimpleX Directory' MyGroup" + cath <# "'SimpleX Directory'> > MyGroup" cath <## " Found 7 group(s), sending top 3." receivedGroup cath 0 3 receivedGroup cath 1 2 receivedGroup cath 2 2 - cath <# "SimpleX-Directory> Send /next or just . for 4 more result(s)." - cath #> "@SimpleX-Directory /next" - cath <# "SimpleX-Directory> > /next" + cath <# "'SimpleX Directory'> Send /next for 4 more result(s)." + cath #> "@'SimpleX Directory' /next" + cath <# "'SimpleX Directory'> > /next" cath <## " Sending 3 more group(s)." receivedGroup cath 3 2 receivedGroup cath 4 2 receivedGroup cath 5 2 - cath <# "SimpleX-Directory> Send /next or just . for 1 more result(s)." + cath <# "'SimpleX Directory'> Send /next for 1 more result(s)." -- search of another user does not affect the search of the first user groupFound bob "Another" - cath #> "@SimpleX-Directory ." - cath <# "SimpleX-Directory> > ." + cath #> "@'SimpleX Directory' ." + cath <# "'SimpleX Directory'> > ." cath <## " Sending 1 more group(s)." receivedGroup cath 6 2 - cath #> "@SimpleX-Directory /all" - cath <# "SimpleX-Directory> > /all" + cath #> "@'SimpleX Directory' /all" + cath <# "'SimpleX Directory'> > /all" cath <## " 8 group(s) listed, sending top 3." receivedGroup cath 0 3 receivedGroup cath 1 2 receivedGroup cath 2 2 - cath <# "SimpleX-Directory> Send /next or just . for 5 more result(s)." - cath #> "@SimpleX-Directory /new" - cath <# "SimpleX-Directory> > /new" + cath <# "'SimpleX Directory'> Send /next for 5 more result(s)." + cath #> "@'SimpleX Directory' /new" + cath <# "'SimpleX Directory'> > /new" cath <## " 8 group(s) listed, sending the most recent 3." receivedGroup cath 7 2 receivedGroup cath 6 2 receivedGroup cath 5 2 - cath <# "SimpleX-Directory> Send /next or just . for 5 more result(s)." - cath #> "@SimpleX-Directory term3" - cath <# "SimpleX-Directory> > term3" + cath <# "'SimpleX Directory'> Send /next for 5 more result(s)." + cath #> "@'SimpleX Directory' term3" + cath <# "'SimpleX Directory'> > term3" cath <## " Found 3 group(s)." receivedGroup cath 4 2 receivedGroup cath 5 2 receivedGroup cath 6 2 - cath #> "@SimpleX-Directory term1" - cath <# "SimpleX-Directory> > term1" + cath #> "@'SimpleX Directory' term1" + cath <# "'SimpleX Directory'> > term1" cath <## " Found 6 group(s), sending top 3." receivedGroup cath 1 2 receivedGroup cath 2 2 receivedGroup cath 3 2 - cath <# "SimpleX-Directory> Send /next or just . for 3 more result(s)." - cath #> "@SimpleX-Directory ." - cath <# "SimpleX-Directory> > ." + cath <# "'SimpleX Directory'> Send /next for 3 more result(s)." + cath #> "@'SimpleX Directory' ." + cath <# "'SimpleX Directory'> > ." cath <## " Sending 3 more group(s)." receivedGroup cath 4 2 receivedGroup cath 5 2 @@ -523,7 +524,7 @@ testSearchGroups ps = ] receivedGroup :: TestCC -> Int -> Int -> IO () receivedGroup u ix count = do - u <#. ("SimpleX-Directory> " <> groups !! ix) + u <#. ("'SimpleX Directory'> " <> groups !! ix) u <## "Welcome message:" u <##. "Link to join the group " u <## (show count <> " members") @@ -534,13 +535,13 @@ testInviteToOwnersGroup ps = withNewTestChatCfg ps testCfg "bob" bobProfile $ \bob -> do bob `connectVia` dsLink registerGroupId superUser bob "privacy" "Privacy" 2 1 - bob <## "#owners: SimpleX-Directory invites you to join the group as member" + bob <## "#owners: 'SimpleX Directory' invites you to join the group as member" bob <## "use /j owners to accept" superUser <## "Invited @bob, the owner of the group ID 2 (privacy) to owners' group owners" bob ##> "/j owners" bob <## "#owners: you joined the group" bob <## "#owners: member alice (Alice) is connected" - superUser <## "#owners: SimpleX-Directory added bob (Bob) to the group (connecting...)" + superUser <## "#owners: 'SimpleX Directory' added bob (Bob) to the group (connecting...)" superUser <## "#owners: new member bob is connected" -- second group registerGroupId superUser bob "security" "Security" 3 2 @@ -556,13 +557,13 @@ testDelistedOwnerLeaves ps = addCathAsOwner bob cath leaveGroup "privacy" bob cath <## "#privacy: bob left the group" - bob <# "SimpleX-Directory> You left the group ID 1 (privacy)." + bob <# "'SimpleX Directory'> You left the group ID 1 (privacy)." bob <## "" bob <## "The group is no longer listed in the directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is de-listed (group owner left)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is de-listed (group owner left)." cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" groupNotFound cath "privacy" testDelistedOwnerRemoved :: HasCallStack => TestParams -> IO () @@ -574,13 +575,13 @@ testDelistedOwnerRemoved ps = registerGroup superUser bob "privacy" "Privacy" addCathAsOwner bob cath removeMember "privacy" cath bob - bob <# "SimpleX-Directory> You are removed from the group ID 1 (privacy)." + bob <# "'SimpleX Directory'> You are removed from the group ID 1 (privacy)." bob <## "" bob <## "The group is no longer listed in the directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is de-listed (group owner is removed)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is de-listed (group owner is removed)." cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" groupNotFound cath "privacy" testNotDelistedMemberLeaves :: HasCallStack => TestParams -> IO () @@ -595,7 +596,7 @@ testNotDelistedMemberLeaves ps = bob <## "#privacy: cath left the group" (superUser "@SimpleX-Directory_1 privacy" + cath #> "@'SimpleX Directory_1' privacy" groupFoundN_ "_1" Nothing 2 cath "privacy" testNotDelistedMemberRemoved :: HasCallStack => TestParams -> IO () @@ -609,7 +610,7 @@ testNotDelistedMemberRemoved ps = removeMember "privacy" bob cath (superUser "@SimpleX-Directory_1 privacy" + cath #> "@'SimpleX Directory_1' privacy" groupFoundN_ "_1" Nothing 2 cath "privacy" testDelistedServiceRemoved :: HasCallStack => TestParams -> IO () @@ -620,13 +621,13 @@ testDelistedServiceRemoved ps = bob `connectVia` dsLink registerGroup superUser bob "privacy" "Privacy" addCathAsOwner bob cath - bob ##> "/rm #privacy SimpleX-Directory" - bob <## "#privacy: you removed SimpleX-Directory from the group" - cath <## "#privacy: bob removed SimpleX-Directory from the group" - bob <# "SimpleX-Directory> SimpleX-Directory is removed from the group ID 1 (privacy)." + bob ##> "/rm #privacy 'SimpleX Directory'" + bob <## "#privacy: you removed 'SimpleX Directory' from the group" + cath <## "#privacy: bob removed 'SimpleX Directory' from the group" + bob <# "'SimpleX Directory'> SimpleX Directory is removed from the group ID 1 (privacy)." bob <## "" bob <## "The group is no longer listed in the directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is de-listed (directory service is removed)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is de-listed (directory service is removed)." cath `connectVia` dsLink groupNotFound_ "_1" cath "privacy" @@ -641,17 +642,17 @@ testDelistedGroupDeleted ps = connectUsers bob cath fullAddMember "privacy" "Privacy" bob cath GROwner joinGroup "privacy" cath bob - cath <## "#privacy: member SimpleX-Directory_1 is connected" - cath <## "contact and member are merged: SimpleX-Directory, #privacy SimpleX-Directory_1" - cath <## "use @SimpleX-Directory to send messages" + cath <## "#privacy: member 'SimpleX Directory_1' is connected" + cath <## "contact and member are merged: 'SimpleX Directory', #privacy 'SimpleX Directory_1'" + cath <## "use @'SimpleX Directory' to send messages" bob ##> "/d #privacy" bob <## "#privacy: you deleted the group" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is deleted." + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is deleted." bob <## "" bob <## "The group is no longer listed in the directory." cath <## "#privacy: bob deleted the group" cath <## "use /d #privacy to delete the local copy of the group" - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is de-listed (group is deleted)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is de-listed (group is deleted)." groupNotFound cath "privacy" testDelistedRoleChanges :: HasCallStack => TestParams -> IO () @@ -663,44 +664,44 @@ testDelistedRoleChanges ps = registerGroup superUser bob "privacy" "Privacy" addCathAsOwner bob cath cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" groupFoundN 3 cath "privacy" -- de-listed if service role changed - bob ##> "/mr privacy SimpleX-Directory member" - bob <## "#privacy: you changed the role of SimpleX-Directory to member" - cath <## "#privacy: bob changed the role of SimpleX-Directory from admin to member" - bob <# "SimpleX-Directory> SimpleX-Directory role in the group ID 1 (privacy) is changed to member." + bob ##> "/mr privacy 'SimpleX Directory' member" + bob <## "#privacy: you changed the role of 'SimpleX Directory' to member" + cath <## "#privacy: bob changed the role of 'SimpleX Directory' from admin to member" + bob <# "'SimpleX Directory'> SimpleX Directory role in the group ID 1 (privacy) is changed to member." bob <## "" bob <## "The group is no longer listed in the directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is de-listed (SimpleX-Directory role is changed to member)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is de-listed (SimpleX Directory role is changed to member)." groupNotFound cath "privacy" -- re-listed if service role changed back without profile changes - cath ##> "/mr privacy SimpleX-Directory admin" - cath <## "#privacy: you changed the role of SimpleX-Directory to admin" - bob <## "#privacy: cath changed the role of SimpleX-Directory from member to admin" - bob <# "SimpleX-Directory> SimpleX-Directory role in the group ID 1 (privacy) is changed to admin." + cath ##> "/mr privacy 'SimpleX Directory' admin" + cath <## "#privacy: you changed the role of 'SimpleX Directory' to admin" + bob <## "#privacy: cath changed the role of 'SimpleX Directory' from member to admin" + bob <# "'SimpleX Directory'> SimpleX Directory role in the group ID 1 (privacy) is changed to admin." bob <## "" bob <## "The group is listed in the directory again." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is listed (SimpleX-Directory role is changed to admin)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is listed (SimpleX Directory role is changed to admin)." groupFoundN 3 cath "privacy" -- de-listed if owner role changed cath ##> "/mr privacy bob admin" cath <## "#privacy: you changed the role of bob to admin" bob <## "#privacy: cath changed your role from owner to admin" - bob <# "SimpleX-Directory> Your role in the group ID 1 (privacy) is changed to admin." + bob <# "'SimpleX Directory'> Your role in the group ID 1 (privacy) is changed to admin." bob <## "" bob <## "The group is no longer listed in the directory." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is de-listed (user role is set to admin)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is de-listed (user role is set to admin)." groupNotFound cath "privacy" -- re-listed if owner role changed back without profile changes cath ##> "/mr privacy bob owner" cath <## "#privacy: you changed the role of bob to owner" bob <## "#privacy: cath changed your role from admin to owner" - bob <# "SimpleX-Directory> Your role in the group ID 1 (privacy) is changed to owner." + bob <# "'SimpleX Directory'> Your role in the group ID 1 (privacy) is changed to owner." bob <## "" bob <## "The group is listed in the directory again." - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is listed (user role is set to owner)." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is listed (user role is set to owner)." groupFoundN 3 cath "privacy" testNotDelistedMemberRoleChanged :: HasCallStack => TestParams -> IO () @@ -712,8 +713,8 @@ testNotDelistedMemberRoleChanged ps = registerGroup superUser bob "privacy" "Privacy" addCathAsOwner bob cath cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" groupFoundN 3 cath "privacy" bob ##> "/mr privacy cath member" bob <## "#privacy: you changed the role of cath to member" @@ -729,13 +730,13 @@ testNotSentApprovalBadRoles ps = cath `connectVia` dsLink submitGroup bob "privacy" "Privacy" welcomeWithLink <- groupAccepted bob "privacy" - bob ##> "/mr privacy SimpleX-Directory member" - bob <## "#privacy: you changed the role of SimpleX-Directory to member" + bob ##> "/mr privacy 'SimpleX Directory' member" + bob <## "#privacy: you changed the role of 'SimpleX Directory' to member" updateProfileWithLink bob "privacy" welcomeWithLink 1 - bob <# "SimpleX-Directory> You must grant directory service admin role to register the group" - bob ##> "/mr privacy SimpleX-Directory admin" - bob <## "#privacy: you changed the role of SimpleX-Directory to admin" - bob <# "SimpleX-Directory> SimpleX-Directory role in the group ID 1 (privacy) is changed to admin." + bob <# "'SimpleX Directory'> You must grant directory service admin role to register the group" + bob ##> "/mr privacy 'SimpleX Directory' admin" + bob <## "#privacy: you changed the role of 'SimpleX Directory' to admin" + bob <# "'SimpleX Directory'> SimpleX Directory role in the group ID 1 (privacy) is changed to admin." bob <## "" bob <## "The group is submitted for approval." notifySuperUser superUser bob "privacy" "Privacy" welcomeWithLink 1 @@ -754,16 +755,16 @@ testNotApprovedBadRoles ps = welcomeWithLink <- groupAccepted bob "privacy" updateProfileWithLink bob "privacy" welcomeWithLink 1 notifySuperUser superUser bob "privacy" "Privacy" welcomeWithLink 1 - bob ##> "/mr privacy SimpleX-Directory member" - bob <## "#privacy: you changed the role of SimpleX-Directory to member" + bob ##> "/mr privacy 'SimpleX Directory' member" + bob <## "#privacy: you changed the role of 'SimpleX Directory' to member" let approve = "/approve 1:privacy 1" - superUser #> ("@SimpleX-Directory " <> approve) - superUser <# ("SimpleX-Directory> > " <> approve) - superUser <## " Group is not approved: SimpleX-Directory is not an admin." + superUser #> ("@'SimpleX Directory' " <> approve) + superUser <# ("'SimpleX Directory'> > " <> approve) + 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 to admin" - bob <# "SimpleX-Directory> SimpleX-Directory role in the group ID 1 (privacy) is changed to admin." + bob ##> "/mr privacy 'SimpleX Directory' admin" + bob <## "#privacy: you changed the role of 'SimpleX Directory' to admin" + bob <# "'SimpleX Directory'> SimpleX Directory role in the group ID 1 (privacy) is changed to admin." bob <## "" bob <## "The group is submitted for approval." notifySuperUser superUser bob "privacy" "Privacy" welcomeWithLink 1 @@ -780,15 +781,15 @@ testRegOwnerChangedProfile ps = addCathAsOwner bob cath bob ##> "/gp privacy privacy Privacy and Security" bob <## "description changed to: Privacy and Security" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is updated!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is updated!" bob <## "It is hidden from the directory until approved." cath <## "bob updated group #privacy:" cath <## "description changed to: Privacy and Security" cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" groupNotFound cath "privacy" - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is updated." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is updated." reapproveGroup 3 superUser bob groupFoundN 3 cath "privacy" @@ -801,16 +802,16 @@ testAnotherOwnerChangedProfile ps = registerGroup superUser bob "privacy" "Privacy" addCathAsOwner bob cath cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" cath ##> "/gp privacy privacy Privacy and Security" cath <## "description changed to: Privacy and Security" bob <## "cath updated group #privacy:" bob <## "description changed to: Privacy and Security" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is updated by cath!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is updated by cath!" bob <## "It is hidden from the directory until approved." groupNotFound cath "privacy" - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is updated by cath." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is updated by cath." reapproveGroup 3 superUser bob groupFoundN 3 cath "privacy" @@ -828,10 +829,10 @@ testNotConnectedOwnerChangedProfile ps = cath <## "description changed to: Privacy and Security" bob <## "cath updated group #privacy:" bob <## "description changed to: Privacy and Security" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is updated by cath!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is updated by cath!" bob <## "It is hidden from the directory until approved." groupNotFound dan "privacy" - superUser <# "SimpleX-Directory> The group ID 1 (privacy) is updated by cath." + superUser <# "'SimpleX Directory'> The group ID 1 (privacy) is updated by cath." reapproveGroup 3 superUser bob groupFoundN 3 dan "privacy" @@ -849,22 +850,22 @@ testRegOwnerRemovedLink ps = bob ##> "/set welcome #privacy Welcome!" bob <## "welcome message changed to:" bob <## "Welcome!" - bob <# "SimpleX-Directory> The group link for ID 1 (privacy) is removed from the welcome message." + bob <# "'SimpleX Directory'> The group link for ID 1 (privacy) is removed from the welcome message." bob <## "" bob <## "The group is hidden from the directory until the group link is added and the group is re-approved." cath <## "bob updated group #privacy:" cath <## "welcome message changed to:" cath <## "Welcome!" - superUser <# "SimpleX-Directory> The group link is removed from ID 1 (privacy), de-listed." + superUser <# "'SimpleX Directory'> The group link is removed from ID 1 (privacy), de-listed." cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" groupNotFound cath "privacy" let withChangedLink = T.unpack $ T.replace "contact#/?v=2-7&" "contact#/?v=3-7&" $ T.pack welcomeWithLink bob ##> ("/set welcome #privacy " <> withChangedLink) bob <## "welcome message changed to:" bob <## withChangedLink - bob <# "SimpleX-Directory> Thank you! The group link for ID 1 (privacy) is added to the welcome message." + bob <# "'SimpleX Directory'> Thank you! The group link for ID 1 (privacy) is added to the welcome message." bob <## "You will be notified once the group is added to the directory - it may take up to 48 hours." cath <## "bob updated group #privacy:" cath <## "welcome message changed to:" @@ -881,8 +882,8 @@ testAnotherOwnerRemovedLink ps = registerGroup superUser bob "privacy" "Privacy" addCathAsOwner bob cath cath `connectVia` dsLink - cath <## "contact and member are merged: SimpleX-Directory_1, #privacy SimpleX-Directory" - cath <## "use @SimpleX-Directory to send messages" + cath <## "contact and member are merged: 'SimpleX Directory_1', #privacy 'SimpleX Directory'" + cath <## "use @'SimpleX Directory' to send messages" bob ##> "/show welcome #privacy" bob <## "Welcome message:" welcomeWithLink <- getTermLine bob @@ -892,10 +893,10 @@ testAnotherOwnerRemovedLink ps = bob <## "cath updated group #privacy:" bob <## "welcome message changed to:" bob <## "Welcome!" - bob <# "SimpleX-Directory> The group link for ID 1 (privacy) is removed from the welcome message by cath." + bob <# "'SimpleX Directory'> The group link for ID 1 (privacy) is removed from the welcome message by cath." bob <## "" bob <## "The group is hidden from the directory until the group link is added and the group is re-approved." - superUser <# "SimpleX-Directory> The group link is removed from ID 1 (privacy), de-listed." + superUser <# "'SimpleX Directory'> The group link is removed from ID 1 (privacy), de-listed." groupNotFound cath "privacy" cath ##> ("/set welcome #privacy " <> welcomeWithLink) cath <## "welcome message changed to:" @@ -903,7 +904,7 @@ testAnotherOwnerRemovedLink ps = bob <## "cath updated group #privacy:" bob <## "welcome message changed to:" bob <## welcomeWithLink - bob <# "SimpleX-Directory> Thank you! The group link for ID 1 (privacy) is added to the welcome message by cath." + bob <# "'SimpleX Directory'> Thank you! The group link for ID 1 (privacy) is added to the welcome message by cath." bob <## "You will be notified once the group is added to the directory - it may take up to 48 hours." reapproveGroup 3 superUser bob groupFoundN 3 cath "privacy" @@ -927,10 +928,10 @@ testNotConnectedOwnerRemovedLink ps = bob <## "cath updated group #privacy:" bob <## "welcome message changed to:" bob <## "Welcome!" - bob <# "SimpleX-Directory> The group link for ID 1 (privacy) is removed from the welcome message by cath." + bob <# "'SimpleX Directory'> The group link for ID 1 (privacy) is removed from the welcome message by cath." bob <## "" bob <## "The group is hidden from the directory until the group link is added and the group is re-approved." - superUser <# "SimpleX-Directory> The group link is removed from ID 1 (privacy), de-listed." + superUser <# "'SimpleX Directory'> The group link is removed from ID 1 (privacy), de-listed." groupNotFound dan "privacy" cath ##> ("/set welcome #privacy " <> welcomeWithLink) cath <## "welcome message changed to:" @@ -938,13 +939,13 @@ testNotConnectedOwnerRemovedLink ps = bob <## "cath updated group #privacy:" bob <## "welcome message changed to:" bob <## welcomeWithLink - -- bob <# "SimpleX-Directory> The group link is added by another group member, your registration will not be processed." + -- bob <# "'SimpleX Directory'> The group link is added by another group member, your registration will not be processed." -- bob <## "" -- bob <## "Please update the group profile yourself." -- bob ##> ("/set welcome #privacy " <> welcomeWithLink <> " - welcome!") -- bob <## "welcome message changed to:" -- bob <## (welcomeWithLink <> " - welcome!") - bob <# "SimpleX-Directory> Thank you! The group link for ID 1 (privacy) is added to the welcome message by cath." + bob <# "'SimpleX Directory'> Thank you! The group link for ID 1 (privacy) is added to the welcome message by cath." bob <## "You will be notified once the group is added to the directory - it may take up to 48 hours." -- cath <## "bob updated group #privacy:" -- cath <## "welcome message changed to:" @@ -962,10 +963,10 @@ testDuplicateAskConfirmation ps = _ <- groupAccepted bob "privacy" cath `connectVia` dsLink submitGroup cath "privacy" "Privacy" - cath <# "SimpleX-Directory> The group privacy (Privacy) is already submitted to the directory." + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already submitted to the directory." cath <## "To confirm the registration, please send:" - cath <# "SimpleX-Directory> /confirm 1:privacy" - cath #> "@SimpleX-Directory /confirm 1:privacy" + cath <# "'SimpleX Directory'> /confirm 1:privacy" + cath #> "@'SimpleX Directory' /confirm 1:privacy" welcomeWithLink <- groupAccepted cath "privacy" groupNotFound bob "privacy" completeRegistration superUser cath "privacy" "Privacy" welcomeWithLink 2 @@ -981,7 +982,7 @@ testDuplicateProhibitRegistration ps = cath `connectVia` dsLink groupFound cath "privacy" _ <- submitGroup cath "privacy" "Privacy" - cath <# "SimpleX-Directory> The group privacy (Privacy) is already listed in the directory, please choose another name." + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already listed in the directory, please choose another name." testDuplicateProhibitConfirmation :: HasCallStack => TestParams -> IO () testDuplicateProhibitConfirmation ps = @@ -993,14 +994,14 @@ testDuplicateProhibitConfirmation ps = welcomeWithLink <- groupAccepted bob "privacy" cath `connectVia` dsLink submitGroup cath "privacy" "Privacy" - cath <# "SimpleX-Directory> The group privacy (Privacy) is already submitted to the directory." + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already submitted to the directory." cath <## "To confirm the registration, please send:" - cath <# "SimpleX-Directory> /confirm 1:privacy" + cath <# "'SimpleX Directory'> /confirm 1:privacy" groupNotFound cath "privacy" completeRegistration superUser bob "privacy" "Privacy" welcomeWithLink 1 groupFound cath "privacy" - cath #> "@SimpleX-Directory /confirm 1:privacy" - cath <# "SimpleX-Directory> The group privacy (Privacy) is already listed in the directory, please choose another name." + cath #> "@'SimpleX Directory' /confirm 1:privacy" + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already listed in the directory, please choose another name." testDuplicateProhibitWhenUpdated :: HasCallStack => TestParams -> IO () testDuplicateProhibitWhenUpdated ps = @@ -1012,10 +1013,10 @@ testDuplicateProhibitWhenUpdated ps = welcomeWithLink <- groupAccepted bob "privacy" cath `connectVia` dsLink submitGroup cath "privacy" "Privacy" - cath <# "SimpleX-Directory> The group privacy (Privacy) is already submitted to the directory." + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already submitted to the directory." cath <## "To confirm the registration, please send:" - cath <# "SimpleX-Directory> /confirm 1:privacy" - cath #> "@SimpleX-Directory /confirm 1:privacy" + cath <# "'SimpleX Directory'> /confirm 1:privacy" + cath #> "@'SimpleX Directory' /confirm 1:privacy" welcomeWithLink' <- groupAccepted cath "privacy" groupNotFound cath "privacy" completeRegistration superUser bob "privacy" "Privacy" welcomeWithLink 1 @@ -1023,10 +1024,10 @@ testDuplicateProhibitWhenUpdated ps = cath ##> ("/set welcome privacy " <> welcomeWithLink') cath <## "welcome message changed to:" cath <## welcomeWithLink' - cath <# "SimpleX-Directory> The group privacy (Privacy) is already listed in the directory, please choose another name." + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already listed in the directory, please choose another name." cath ##> "/gp privacy security Security" cath <## "changed to #security (Security)" - cath <# "SimpleX-Directory> Thank you! The group link for ID 2 (security) is added to the welcome message." + cath <# "'SimpleX Directory'> Thank you! The group link for ID 2 (security) is added to the welcome message." cath <## "You will be notified once the group is added to the directory - it may take up to 48 hours." notifySuperUser superUser cath "security" "Security" welcomeWithLink' 2 approveRegistration superUser cath "security" 2 @@ -1043,10 +1044,10 @@ testDuplicateProhibitApproval ps = welcomeWithLink <- groupAccepted bob "privacy" cath `connectVia` dsLink submitGroup cath "privacy" "Privacy" - cath <# "SimpleX-Directory> The group privacy (Privacy) is already submitted to the directory." + cath <# "'SimpleX Directory'> The group privacy (Privacy) is already submitted to the directory." cath <## "To confirm the registration, please send:" - cath <# "SimpleX-Directory> /confirm 1:privacy" - cath #> "@SimpleX-Directory /confirm 1:privacy" + cath <# "'SimpleX Directory'> /confirm 1:privacy" + cath #> "@'SimpleX Directory' /confirm 1:privacy" welcomeWithLink' <- groupAccepted cath "privacy" updateProfileWithLink cath "privacy" welcomeWithLink' 2 notifySuperUser superUser cath "privacy" "Privacy" welcomeWithLink' 2 @@ -1055,8 +1056,8 @@ testDuplicateProhibitApproval ps = groupFound cath "privacy" -- fails at approval, as already listed let approve = "/approve 2:privacy 1" - superUser #> ("@SimpleX-Directory " <> approve) - superUser <# ("SimpleX-Directory> > " <> approve) + superUser #> ("@'SimpleX Directory' " <> approve) + superUser <# ("'SimpleX Directory'> > " <> approve) superUser <## " The group ID 2 (privacy) is already listed in the directory." testListUserGroups :: HasCallStack => TestParams -> IO () @@ -1070,20 +1071,20 @@ testListUserGroups ps = connectUsers bob cath fullAddMember "privacy" "Privacy" bob cath GRMember joinGroup "privacy" cath bob - cath <## "#privacy: member SimpleX-Directory_1 is connected" - cath <## "contact and member are merged: SimpleX-Directory, #privacy SimpleX-Directory_1" - cath <## "use @SimpleX-Directory to send messages" + cath <## "#privacy: member 'SimpleX Directory_1' is connected" + cath <## "contact and member are merged: 'SimpleX Directory', #privacy 'SimpleX Directory_1'" + cath <## "use @'SimpleX Directory' to send messages" registerGroupId superUser bob "security" "Security" 2 2 registerGroupId superUser cath "anonymity" "Anonymity" 3 1 listUserGroup cath "anonymity" "Anonymity" -- with de-listed group groupFound cath "anonymity" - cath ##> "/mr anonymity SimpleX-Directory member" - cath <## "#anonymity: you changed the role of SimpleX-Directory to member" - cath <# "SimpleX-Directory> SimpleX-Directory role in the group ID 1 (anonymity) is changed to member." + cath ##> "/mr anonymity 'SimpleX Directory' member" + cath <## "#anonymity: you changed the role of 'SimpleX Directory' to member" + cath <# "'SimpleX Directory'> SimpleX Directory role in the group ID 1 (anonymity) is changed to member." cath <## "" cath <## "The group is no longer listed in the directory." - superUser <# "SimpleX-Directory> The group ID 3 (anonymity) is de-listed (SimpleX-Directory role is changed to member)." + superUser <# "'SimpleX Directory'> The group ID 3 (anonymity) is de-listed (SimpleX Directory role is changed to member)." groupNotFound cath "anonymity" listGroups superUser bob cath @@ -1095,32 +1096,34 @@ testCapthaScreening ps = bob `connectVia` dsLink registerGroup superUser bob "privacy" "Privacy" -- check default role - bob #> "@SimpleX-Directory /role 1" - bob <# "SimpleX-Directory> > /role 1" + bob #> "@'SimpleX Directory' /role 1" + bob <# "'SimpleX Directory'> > /role 1" bob <## " The initial member role for the group privacy is set to member" - bob <## "Send /role 1 observer to change it." + bob <## "Send /'role 1 observer' to change it." bob <## "" note <- getTermLine bob let groupLink = dropStrPrefix "Please note: it applies only to members joining via this link: " note -- enable captcha - bob #> "@SimpleX-Directory /filter 1 captcha" - bob <# "SimpleX-Directory> > /filter 1 captcha" + bob #> "@'SimpleX Directory' /filter 1 captcha" + bob <# "'SimpleX Directory'> > /filter 1 captcha" bob <## " Spam filter settings for group privacy set to:" bob <## "- reject long/inappropriate names: disabled" bob <## "- pass captcha to join: enabled" bob <## "" - bob <## "Use /filter 1 [name] [captcha] to enable and /filter 1 off to disable filter." + bob <## "/'filter 1 name' - enable name filter" + bob <## "/'filter 1 name captcha' - enable both" + bob <## "/'filter 1 off' - disable filter" -- connect with captcha screen _ <- join cath groupLink cath ##> "/_send #1(_support) text 123" -- sending incorrect captcha cath <# "#privacy (support) 123" - cath <# "#privacy (support) SimpleX-Directory!> > cath 123" + cath <# "#privacy (support) 'SimpleX Directory'!> > cath 123" cath <## " Incorrect text, please try again." - captcha <- dropStrPrefix "#privacy (support) SimpleX-Directory> " . dropTime <$> getTermLine cath + captcha <- dropStrPrefix "#privacy (support) 'SimpleX Directory'> " . dropTime <$> getTermLine cath sendCaptcha cath captcha - cath <#. "#privacy SimpleX-Directory> Link to join the group privacy: https://" + cath <#. "#privacy 'SimpleX Directory'> Link to join the group privacy: https://" cath <## "#privacy: member bob (Bob) is connected" - bob <## "#privacy: SimpleX-Directory added cath (Catherine) to the group (connecting...)" + bob <## "#privacy: 'SimpleX Directory' added cath (Catherine) to the group (connecting...)" bob <## "#privacy: new member cath is connected" cath #> "#privacy hello" bob <# "#privacy cath> hello" @@ -1131,8 +1134,8 @@ testCapthaScreening ps = cath ##> "/d #privacy" cath <## "#privacy: you deleted the group" -- change default role to observer - bob #> "@SimpleX-Directory /role 1 observer" - bob <# "SimpleX-Directory> > /role 1 observer" + bob #> "@'SimpleX Directory' /role 1 observer" + bob <# "'SimpleX Directory'> > /role 1 observer" bob <## " The initial member role for the group privacy is set to observer" bob <## "" bob <##. "Please note: it applies only to members joining via this link: https://" @@ -1140,18 +1143,18 @@ testCapthaScreening ps = captcha' <- join cath groupLink sendCaptcha cath captcha' -- message from cath that left - pastMember <- dropStrPrefix "#privacy: SimpleX-Directory forwarded a message from an unknown member, creating unknown member record " <$> getTermLine cath + pastMember <- dropStrPrefix "#privacy: 'SimpleX Directory' forwarded a message from an unknown member, creating unknown member record " <$> getTermLine cath cath <# ("#privacy " <> pastMember <> "> hello [>>]") - cath <#. "#privacy SimpleX-Directory> Link to join the group privacy: https://" + cath <#. "#privacy 'SimpleX Directory'> Link to join the group privacy: https://" cath <## "#privacy: member bob (Bob) is connected" - bob <## "#privacy: SimpleX-Directory added cath_1 (Catherine) to the group (connecting...)" + bob <## "#privacy: 'SimpleX Directory' added cath_1 (Catherine) to the group (connecting...)" bob <## "#privacy: new member cath_1 is connected" cath ##> "#privacy hello" cath <## "#privacy: you don't have permission to send messages" (bob "/ms privacy" cath <## "cath (Catherine): observer, you, connected" - cath <## "SimpleX-Directory: admin, host, connected" + cath <## "'SimpleX Directory': admin, host, connected" cath <## "bob (Bob): owner, connected" cath <## (pastMember <> ": author, status unknown") where @@ -1160,14 +1163,14 @@ testCapthaScreening ps = cath <## "connection request sent!" cath <## "#privacy: joining the group..." cath <## "#privacy: you joined the group, pending approval" - cath <# "#privacy (support) SimpleX-Directory> Captcha is generated by SimpleX Directory service." + cath <# "#privacy (support) 'SimpleX Directory'> Captcha is generated by SimpleX Directory service." cath <## "" cath <## "Send captcha text to join the group privacy." - dropStrPrefix "#privacy (support) SimpleX-Directory> " . dropTime <$> getTermLine cath + dropStrPrefix "#privacy (support) 'SimpleX Directory'> " . dropTime <$> getTermLine cath sendCaptcha cath captcha = do cath ##> ("/_send #1(_support) text " <> captcha) cath <# ("#privacy (support) " <> captcha) - cath <# ("#privacy (support) SimpleX-Directory!> > cath " <> captcha) + cath <# ("#privacy (support) 'SimpleX Directory'!> > cath " <> captcha) cath <## " Correct, you joined the group privacy" cath <## "#privacy: you joined the group" @@ -1191,7 +1194,7 @@ testRestoreDirectory ps = do groupFoundN 3 bob "privacy" groupFound bob "security" groupFoundN 3 cath "privacy" - cath #> "@SimpleX-Directory security" + cath #> "@'SimpleX Directory' security" groupFoundN' 2 cath "security" testCaptcha :: HasCallStack => TestParams -> IO () @@ -1215,18 +1218,18 @@ listGroups superUser bob cath = do sendListCommand cath 1 groupListing cath 1 "anonymity" "Anonymity" 2 "suspended because roles changed" -- superuser lists all groups - bob #> "@SimpleX-Directory /last" - bob <# "SimpleX-Directory> > /last" + bob #> "@'SimpleX Directory' /last" + bob <# "'SimpleX Directory'> > /last" bob <## " You are not allowed to use this command" - superUser #> "@SimpleX-Directory /last" - superUser <# "SimpleX-Directory> > /last" + superUser #> "@'SimpleX Directory' /last" + superUser <# "'SimpleX Directory'> > /last" superUser <## " 3 registered group(s)" memberGroupListing superUser bob 1 "privacy" "Privacy" 3 "active" memberGroupListing superUser bob 2 "security" "Security" 2 "active" memberGroupListing superUser cath 3 "anonymity" "Anonymity" 2 "suspended because roles changed" -- showing last 1 group - superUser #> "@SimpleX-Directory /last 1" - superUser <# "SimpleX-Directory> > /last 1" + superUser #> "@'SimpleX Directory' /last 1" + superUser <# "'SimpleX Directory'> > /last 1" superUser <## " 3 registered group(s), showing the last 1" memberGroupListing superUser cath 3 "anonymity" "Anonymity" 2 "suspended because roles changed" @@ -1237,8 +1240,8 @@ listUserGroup u n fn = do sendListCommand :: HasCallStack => TestCC -> Int -> IO () sendListCommand u count = do - u #> "@SimpleX-Directory /list" - u <# "SimpleX-Directory> > /list" + u #> "@'SimpleX Directory' /list" + u <# "'SimpleX Directory'> > /list" u <## (" " <> show count <> " registered group(s)") groupListing :: HasCallStack => TestCC -> Int -> String -> String -> Int -> String -> IO () @@ -1249,7 +1252,7 @@ memberGroupListing su owner = groupListing_ su (Just owner) groupListing_ :: HasCallStack => TestCC -> Maybe TestCC -> Int -> String -> String -> Int -> String -> IO () groupListing_ su owner_ gId n fn count status = do - su <# ("SimpleX-Directory> " <> show gId <> ". " <> n <> " (" <> fn <> ")") + su <# ("'SimpleX Directory'> " <> show gId <> ". " <> n <> " (" <> fn <> ")") su <## "Welcome message:" su <##. ("Link to join the group " <> n <> ": ") forM_ owner_ $ \owner -> do @@ -1257,34 +1260,35 @@ groupListing_ su owner_ gId n fn count status = do su <## ("Owner: " <> ownerName) su <## (show count <> " members") su <## ("Status: " <> status) + su <## ("/'role " <> show gId <> "', /'filter " <> show gId <> "'") reapproveGroup :: HasCallStack => Int -> TestCC -> TestCC -> IO () reapproveGroup count superUser bob = do - superUser <# "SimpleX-Directory> bob submitted the group ID 1:" + superUser <# "'SimpleX Directory'> bob submitted the group ID 1:" superUser <##. "privacy (" superUser <## "Welcome message:" superUser <##. "Link to join the group privacy: " superUser <## (show count <> " members") superUser <## "" superUser <## "To approve send:" - superUser <# "SimpleX-Directory> /approve 1:privacy 1" - superUser #> "@SimpleX-Directory /approve 1:privacy 1" - superUser <# "SimpleX-Directory> > /approve 1:privacy 1" + superUser <# "'SimpleX Directory'> /approve 1:privacy 1" + superUser #> "@'SimpleX Directory' /approve 1:privacy 1" + superUser <# "'SimpleX Directory'> > /approve 1:privacy 1" superUser <## " Group approved!" - bob <# "SimpleX-Directory> The group ID 1 (privacy) is approved and listed in directory - please moderate it!" + bob <# "'SimpleX Directory'> The group ID 1 (privacy) is approved and listed in directory - please moderate it!" bob <## "Please note: if you change the group profile it will be hidden from directory until it is re-approved." bob <## "" bob <## "Supported commands:" - bob <## "- /filter 1 - to configure anti-spam filter." - bob <## "- /role 1 - to set default member role." - bob <## "- /help commands - other commands." + bob <## "/'filter 1' - to configure anti-spam filter." + bob <## "/'role 1' - to set default member role." + bob <## "/'link 1' - to view/upgrade group link." addCathAsOwner :: HasCallStack => TestCC -> TestCC -> IO () addCathAsOwner bob cath = do connectUsers bob cath fullAddMember "privacy" "Privacy" bob cath GROwner joinGroup "privacy" cath bob - cath <## "#privacy: member SimpleX-Directory is connected" + cath <## "#privacy: member 'SimpleX Directory' is connected" withDirectoryService :: HasCallStack => TestParams -> (TestCC -> String -> IO ()) -> IO () withDirectoryService ps = withDirectoryServiceCfg ps testCfg @@ -1302,13 +1306,13 @@ withDirectoryServiceCfgOwnersGroup ps cfg createOwnersGroup test = do superUser ##> "/g owners" superUser <## "group #owners is created" superUser <## "to add members use /a owners or /create link #owners" - superUser ##> "/a owners SimpleX-Directory admin" - superUser <## "invitation to join the group #owners sent to SimpleX-Directory" + superUser ##> "/a owners 'SimpleX Directory' admin" + superUser <## "invitation to join the group #owners sent to 'SimpleX Directory'" ds <## "#owners: alice invites you to join the group as admin" ds <## "use /j owners to accept" ds ##> "/j owners" ds <## "#owners: you joined the group" - superUser <## "#owners: SimpleX-Directory joined the group" + superUser <## "#owners: 'SimpleX Directory' joined the group" ds ##> "/ad" getContactLink ds True withDirectoryOwnersGroup ps cfg dsLink createOwnersGroup test @@ -1366,19 +1370,19 @@ submitGroup u n fn = do u ##> ("/g " <> viewName n <> if null fn then "" else " " <> fn) u <## ("group #" <> viewName n <> (if null fn then "" else " (" <> fn <> ")") <> " is created") u <## ("to add members use /a " <> viewName n <> " or /create link #" <> viewName n) - u ##> ("/a " <> viewName n <> " SimpleX-Directory admin") - u <## ("invitation to join the group #" <> viewName n <> " sent to SimpleX-Directory") + u ##> ("/a " <> viewName n <> " 'SimpleX Directory' admin") + u <## ("invitation to join the group #" <> viewName n <> " sent to 'SimpleX Directory'") groupAccepted :: TestCC -> String -> IO String groupAccepted u n = do - u <# ("SimpleX-Directory> Joining the group " <> n <> "…") - u <## ("#" <> viewName n <> ": SimpleX-Directory joined the group") - u <# ("SimpleX-Directory> Joined the group " <> n <> ", creating the link…") - u <# "SimpleX-Directory> Created the public link to join the group via this directory service that is always online." + u <# ("'SimpleX Directory'> Joining the group " <> n <> "…") + u <## ("#" <> viewName n <> ": 'SimpleX Directory' joined the group") + u <# ("'SimpleX Directory'> Joined the group " <> n <> ", creating the link…") + u <# "'SimpleX Directory'> Created the public link to join the group via this directory service that is always online." u <## "" u <## "Please add it to the group welcome message." u <## "For example, add:" - dropStrPrefix "SimpleX-Directory> " . dropTime <$> getTermLine u -- welcome message with link + dropStrPrefix "'SimpleX Directory'> " . dropTime <$> getTermLine u -- welcome message with link completeRegistration :: TestCC -> TestCC -> String -> String -> String -> Int -> IO () completeRegistration su u n fn welcomeWithLink gId = @@ -1395,13 +1399,13 @@ updateProfileWithLink u n welcomeWithLink ugId = do u ##> ("/set welcome " <> viewName n <> " " <> welcomeWithLink) u <## "welcome message changed to:" u <## welcomeWithLink - u <# ("SimpleX-Directory> Thank you! The group link for ID " <> show ugId <> " (" <> n <> ") is added to the welcome message.") + u <# ("'SimpleX Directory'> Thank you! The group link for ID " <> show ugId <> " (" <> n <> ") is added to the welcome message.") u <## "You will be notified once the group is added to the directory - it may take up to 48 hours." notifySuperUser :: TestCC -> TestCC -> String -> String -> String -> Int -> IO () notifySuperUser su u n fn welcomeWithLink gId = do uName <- userName u - su <# ("SimpleX-Directory> " <> uName <> " submitted the group ID " <> show gId <> ":") + su <# ("'SimpleX Directory'> " <> uName <> " submitted the group ID " <> show gId <> ":") su <## (n <> if null fn then "" else " (" <> fn <> ")") su <## "Welcome message:" su <## welcomeWithLink @@ -1409,7 +1413,7 @@ notifySuperUser su u n fn welcomeWithLink gId = do su <## "" su <## "To approve send:" let approve = "/approve " <> show gId <> ":" <> viewName n <> " 1" - su <# ("SimpleX-Directory> " <> approve) + su <# ("'SimpleX Directory'> " <> approve) approveRegistration :: TestCC -> TestCC -> String -> Int -> IO () approveRegistration su u n gId = @@ -1418,29 +1422,29 @@ approveRegistration su u n gId = approveRegistrationId :: TestCC -> TestCC -> String -> Int -> Int -> IO () approveRegistrationId su u n gId ugId = do let approve = "/approve " <> show gId <> ":" <> viewName n <> " 1" - su #> ("@SimpleX-Directory " <> approve) - su <# ("SimpleX-Directory> > " <> approve) + su #> ("@'SimpleX Directory' " <> approve) + su <# ("'SimpleX Directory'> > " <> approve) su <## " Group approved!" - u <# ("SimpleX-Directory> The group ID " <> show ugId <> " (" <> n <> ") is approved and listed in directory - please moderate it!") + u <# ("'SimpleX Directory'> The group ID " <> show ugId <> " (" <> n <> ") is approved and listed in directory - please moderate it!") u <## "Please note: if you change the group profile it will be hidden from directory until it is re-approved." u <## "" u <## "Supported commands:" - u <## ("- /filter " <> show ugId <> " - to configure anti-spam filter.") - u <## ("- /role " <> show ugId <> " - to set default member role.") - u <## "- /help commands - other commands." + u <## ("/'filter " <> show ugId <> "' - to configure anti-spam filter.") + u <## ("/'role " <> show ugId <> "' - to set default member role.") + u <## ("/'link " <> show ugId <> "' - to view/upgrade group link.") connectVia :: TestCC -> String -> IO () u `connectVia` dsLink = do u ##> ("/c " <> dsLink) u <## "connection request sent!" u .<## ": contact is connected" - u .<# "> Welcome to SimpleX-Directory service!" - u <## "Send a search string to find groups or /help to learn how to add groups to directory." + u .<# "> Welcome to SimpleX Directory!" u <## "" - u <## "For example, send privacy to find groups about privacy." - u <## "Or send /all or /new to list groups." + u <## "šŸ” Send search string to find groups - try security." + u <## "/help - how to submit your group." + u <## "/new - recent groups." u <## "" - u <## "Content and privacy policy: https://simplex.chat/docs/directory.html" + u <## "[Directory rules](https://simplex.chat/docs/directory.html)." joinGroup :: String -> TestCC -> TestCC -> IO () joinGroup gName member host = do @@ -1474,7 +1478,7 @@ groupFound = groupFoundN 2 groupFoundN :: Int -> TestCC -> String -> IO () groupFoundN count u name = do - u #> ("@SimpleX-Directory " <> name) + u #> ("@'SimpleX Directory' " <> name) groupFoundN' count u name groupFoundN' :: Int -> TestCC -> String -> IO () @@ -1482,9 +1486,9 @@ groupFoundN' = groupFoundN_ "" Nothing groupFoundN_ :: String -> Maybe Int -> Int -> TestCC -> String -> IO () groupFoundN_ suffix shownId_ count u name = do - u <# ("SimpleX-Directory" <> suffix <> "> > " <> name) + u <# ("'SimpleX Directory" <> suffix <> "'> > " <> name) u <## " Found 1 group(s)." - u <#. ("SimpleX-Directory" <> suffix <> "> " <> maybe "" (\gId -> show gId <> ". ") shownId_ <> name) + u <#. ("'SimpleX Directory" <> suffix <> "'> " <> maybe "" (\gId -> show gId <> ". ") shownId_ <> name) u <## "Welcome message:" u <##. "Link to join the group " u <## (show count <> " members") @@ -1494,6 +1498,6 @@ groupNotFound = groupNotFound_ "" groupNotFound_ :: String -> TestCC -> String -> IO () groupNotFound_ suffix u s = do - u #> ("@SimpleX-Directory" <> suffix <> " " <> s) - u <# ("SimpleX-Directory" <> suffix <> "> > " <> s) + u #> ("@'SimpleX Directory" <> suffix <> "' " <> s) + u <# ("'SimpleX Directory" <> suffix <> "'> > " <> s) u <## " No groups found" diff --git a/tests/ChatTests/Utils.hs b/tests/ChatTests/Utils.hs index 8650b80b06..dfb0aece74 100644 --- a/tests/ChatTests/Utils.hs +++ b/tests/ChatTests/Utils.hs @@ -24,6 +24,7 @@ import Data.Maybe (fromMaybe) import Data.String import qualified Data.Text as T import Simplex.Chat.Controller (ChatConfig (..), ChatController (..)) +import Simplex.Chat.Markdown (viewName) import Simplex.Chat.Messages.CIContent (e2eInfoNoPQText, e2eInfoPQText) import Simplex.Chat.Protocol import Simplex.Chat.Store.Direct (getContact) @@ -723,7 +724,7 @@ connectUsers_ cc1 cc2 noShortLink = do showName :: TestCC -> IO String showName (TestCC ChatController {currentUser} _ _ _ _ _) = do Just User {localDisplayName, profile = LocalProfile {fullName, shortDescr}} <- readTVarIO currentUser - pure . T.unpack $ localDisplayName <> optionalFullName localDisplayName fullName shortDescr + pure . T.unpack $ viewName localDisplayName <> optionalFullName localDisplayName fullName shortDescr createGroup2 :: HasCallStack => String -> TestCC -> TestCC -> IO () createGroup2 gName cc1 cc2 = createGroup2' gName cc1 (cc2, GRAdmin) True