Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Option for user_directory to search all users on a server (whether they are publicly visible or not) #2720

Closed
ara4n opened this issue Nov 29, 2017 · 5 comments

Comments

@ara4n
Copy link
Member

ara4n commented Nov 29, 2017

I think something like:

diff --git a/synapse/storage/user_directory.py b/synapse/storage/user_directory.py
index 5dc5b958..7bce9e7e 100644
--- a/synapse/storage/user_directory.py
+++ b/synapse/storage/user_directory.py
@@ -647,7 +647,9 @@ class UserDirectoryStore(SQLBaseStore):
                     WHERE user_id = ? AND share_private
                 ) AS s USING (user_id)
                 WHERE
-                    (s.user_id IS NOT NULL OR p.user_id IS NOT NULL)
+                    (s.user_id IS NOT NULL OR
+                     p.user_id IS NOT NULL OR
+                     d.user_id LIKE '%:domain.com')
                     AND vector @@ to_tsquery('english', ?)
                 ORDER BY
                     (CASE WHEN s.user_id IS NOT NULL THEN 4.0 ELSE 1.0 END)
@@ -686,7 +688,9 @@ class UserDirectoryStore(SQLBaseStore):
                     WHERE user_id = ? AND share_private
                 ) AS s USING (user_id)
                 WHERE
-                    (s.user_id IS NOT NULL OR p.user_id IS NOT NULL)
+                    (s.user_id IS NOT NULL OR
+                     p.user_id IS NOT NULL OR
+                     d.user_id LIKE '%:domain.com')
                     AND value MATCH ?
                 ORDER BY
                     rank(matchinfo(user_directory_search)) DESC,

...would work, but it needs to be wrapped up nicely as a config option.

@ara4n
Copy link
Member Author

ara4n commented Nov 29, 2017

This doesn't actually work; it filters too aggressively (at least on sqlite) and haven't spotted why yet.

I've started a PR for this at 47d99a2 but it needs the filtering fixing, and also keeping all the user profiles synced into the user_directory_search table in order to actually work.

@ara4n
Copy link
Member Author

ara4n commented Nov 29, 2017

so much for this being an easy fix; turns out that the user_directory has no way of tracking users who are not yet in a room...

@markwooff
Copy link

Good effort though @ara4n ! Does it seem like something that could be done? Wondering how large of an effort it would be.

@ara4n ara4n changed the title Option for user_directory to search all uses on a server (whether they are publicly visible or not) Option for user_directory to search all users on a server (whether they are publicly visible or not) Nov 29, 2017
@ara4n
Copy link
Member Author

ara4n commented Nov 30, 2017

@markwooff np. the PR ended up being about 3-4 hours of work. I'm pretty rusty though and don't normally hack on synapse; just wanted to drop this in as it's something I want myself. The PR's now up for review with @erikjohnston.

@ara4n
Copy link
Member Author

ara4n commented Dec 6, 2017

this PR landed ftr on develop (cc @markwooff)

@ara4n ara4n closed this as completed Dec 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants