directory: add to website, send terms, sort search results (#2950)

* directory: add to website, send terms, sort search results

* corrections
This commit is contained in:
Evgeny Poberezkin 2023-08-18 14:31:42 +01:00 committed by GitHub
parent addace9faf
commit 41c68c82ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 8 deletions

View file

@ -17,12 +17,14 @@ import Control.Concurrent.Async
import Control.Concurrent.STM
import Control.Monad.Reader
import qualified Data.ByteString.Char8 as B
import Data.Time.Clock (getCurrentTime)
import Data.Time.LocalTime (getCurrentTimeZone)
import Data.List (sortOn)
import Data.Maybe (fromMaybe, maybeToList)
import Data.Ord (Down(..))
import qualified Data.Set as S
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time.Clock (getCurrentTime)
import Data.Time.LocalTime (getCurrentTimeZone)
import Directory.Events
import Directory.Options
import Directory.Store
@ -31,7 +33,6 @@ import Simplex.Chat.Bot.KnownContacts
import Simplex.Chat.Controller
import Simplex.Chat.Core
import Simplex.Chat.Messages
-- import Simplex.Chat.Messages.CIContent
import Simplex.Chat.Options
import Simplex.Chat.Protocol (MsgContent (..))
import Simplex.Chat.Types
@ -139,7 +140,8 @@ directoryService st DirectoryOpts {superUsers, serviceName, testing} user@User {
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."
\For example, send _privacy_ to find groups about privacy.\n\n\
\Content and privacy policy: https://simplex.chat/docs/directory.html"
deGroupInvitation :: Contact -> GroupInfo -> GroupMemberRole -> GroupMemberRole -> IO ()
deGroupInvitation ct g@GroupInfo {groupProfile = GroupProfile {displayName, fullName}} fromMemberRole memberRole = do
@ -382,7 +384,7 @@ directoryService st DirectoryOpts {superUsers, serviceName, testing} user@User {
DCHelp ->
sendMessage cc ct $
"You must be the owner to add the group to the directory:\n\
\1. Invite " <> serviceName <> " bot to your group as *admin*.\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 24 hours), and everybody will be able to find it in directory.\n\n\
@ -394,7 +396,7 @@ directoryService st DirectoryOpts {superUsers, serviceName, testing} user@User {
[] -> sendReply "No groups found"
gs -> do
sendReply $ "Found " <> show (length gs) <> " group(s)" <> if length gs > 10 then ", sending 10." else ""
void . forkIO $ forM_ (take 10 gs) $
void . forkIO $ forM_ (take 10 $ sortOn (Down . currentMembers . snd) gs) $
\(GroupInfo {groupProfile = p@GroupProfile {image = image_}}, GroupSummary {currentMembers}) -> do
let membersStr = "_" <> tshow currentMembers <> " members_"
text = groupInfoText p <> "\n" <> membersStr

View file

@ -1,3 +1,8 @@
---
title: SimpleX Directory Service
revision: 18.08.2023
---
# SimpleX Directory Service
You can use an experimental directory service to discover the groups created and registered by other users.
@ -10,9 +15,10 @@ Please note that your search queries can be kept by the bot as the conversation
## Adding groups to the directory
### How to add the group
To add the group you must be the owner of the group. Once you connect to the directory service and send `/help`, the service will guide you through the process.
### How to add a group
To add a group you must be its owner. Once you connect to the directory service and send `/help`, the service will guide you through the process.
1. Invite SimpleX Service Directory to the group as `admin` member. You can also set the role to `admin` after inviting the directory service.

View file

@ -905,6 +905,8 @@ u `connectVia` dsLink = do
u <## "Send a search string to find groups or /help to learn how to add groups to directory."
u <## ""
u <## "For example, send privacy to find groups about privacy."
u <## ""
u <## "Content and privacy policy: https://simplex.chat/docs/directory.html"
joinGroup :: String -> TestCC -> TestCC -> IO ()
joinGroup gName member host = do

View file

@ -227,6 +227,7 @@
"docs-dropdown-5": "Host XFTP Server",
"docs-dropdown-6": "WebRTC servers",
"docs-dropdown-7": "Translate SimpleX Chat",
"docs-dropdown-8": "SimpleX Directory Service",
"newer-version-of-eng-msg": "There is a newer version of this page in English.",
"click-to-see": "Click to see",
"menu": "Menu",

View file

@ -4,6 +4,10 @@
"title": "docs-dropdown-1",
"url": "/docs/simplex.html"
},
{
"title": "docs-dropdown-8",
"url": "/docs/directory.html"
},
{
"title": "docs-dropdown-2",
"url": "/docs/android.html"

View file

@ -18,6 +18,7 @@
"menu": "Reference",
"data": [
"SIMPLEX.md",
"DIRECTORY.md",
"ANDROID.md",
"CLI.md",
"SQL.md",