summary refs log tree commit diff
path: root/docs/user_directory.md
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-09-14 11:02:37 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-09-14 11:02:37 +0100
commit003c2ab629ac23e5a789b8152f45f999a21dcfb2 (patch)
tree389f4e154384a4aea61aff018c0027f89b5179d0 /docs/user_directory.md
parentMerge remote-tracking branch 'origin/develop' into matrix-org-hotfixes (diff)
parentUse direct references for some configuration variables (#10798) (diff)
downloadsynapse-003c2ab629ac23e5a789b8152f45f999a21dcfb2.tar.xz
Merge branch 'release-v1.43' of github.com:matrix-org/synapse into matrix-org-hotfixes
Diffstat (limited to 'docs/user_directory.md')
-rw-r--r--docs/user_directory.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/user_directory.md b/docs/user_directory.md

index d4f38d2cf1..07fe954891 100644 --- a/docs/user_directory.md +++ b/docs/user_directory.md
@@ -10,3 +10,40 @@ DB corruption) get stale or out of sync. If this happens, for now the solution to fix it is to execute the SQL [here](https://github.com/matrix-org/synapse/blob/master/synapse/storage/schema/main/delta/53/user_dir_populate.sql) and then restart synapse. This should then start a background task to flush the current tables and regenerate the directory. + +Data model +---------- + +There are five relevant tables that collectively form the "user directory". +Three of them track a master list of all the users we could search for. +The last two (collectively called the "search tables") track who can +see who. + +From all of these tables we exclude three types of local user: + - support users + - appservice users + - deactivated users + +* `user_directory`. This contains the user_id, display name and avatar we'll + return when you search the directory. + - Because there's only one directory entry per user, it's important that we only + ever put publicly visible names here. Otherwise we might leak a private + nickname or avatar used in a private room. + - Indexed on rooms. Indexed on users. + +* `user_directory_search`. To be joined to `user_directory`. It contains an extra + column that enables full text search based on user ids and display names. + Different schemas for SQLite and Postgres with different code paths to match. + - Indexed on the full text search data. Indexed on users. + +* `user_directory_stream_pos`. When the initial background update to populate + the directory is complete, we record a stream position here. This indicates + that synapse should now listen for room changes and incrementally update + the directory where necessary. + +* `users_in_public_rooms`. Contains associations between users and the public rooms they're in. + Used to determine which users are in public rooms and should be publicly visible in the directory. + +* `users_who_share_private_rooms`. Rows are triples `(L, M, room id)` where `L` + is a local user and `M` is a local or remote user. `L` and `M` should be + different, but this isn't enforced by a constraint.