You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/user_directory.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,3 +10,40 @@ DB corruption) get stale or out of sync. If this happens, for now the
10
10
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)
11
11
and then restart synapse. This should then start a background task to
12
12
flush the current tables and regenerate the directory.
13
+
14
+
Data model
15
+
----------
16
+
17
+
There are five relevant tables that collectively form the "user directory".
18
+
Three of them track a master list of all the users we could search for.
19
+
The last two (collectively called the "search tables") track who can
20
+
see who.
21
+
22
+
From all of these tables we exclude three types of local user:
23
+
- support users
24
+
- appservice users
25
+
- deactivated users
26
+
27
+
*`user_directory`. This contains the user_id, display name and avatar we'll
28
+
return when you search the directory.
29
+
- Because there's only one directory entry per user, it's important that we only
30
+
ever put publicly visible names here. Otherwise we might leak a private
31
+
nickname or avatar used in a private room.
32
+
- Indexed on rooms. Indexed on users.
33
+
34
+
*`user_directory_search`. To be joined to `user_directory`. It contains an extra
35
+
column that enables full text search based on user ids and display names.
36
+
Different schemas for SQLite and Postgres with different code paths to match.
37
+
- Indexed on the full text search data. Indexed on users.
38
+
39
+
*`user_directory_stream_pos`. When the initial background update to populate
40
+
the directory is complete, we record a stream position here. This indicates
41
+
that synapse should now listen for room changes and incrementally update
42
+
the directory where necessary.
43
+
44
+
*`users_in_public_rooms`. Contains associations between users and the public rooms they're in.
45
+
Used to determine which users are in public rooms and should be publicly visible in the directory.
46
+
47
+
*`users_who_share_private_rooms`. Rows are triples `(L, M, room id)` where `L`
48
+
is a local user and `M` is a local or remote user. `L` and `M` should be
49
+
different, but this isn't enforced by a constraint.
0 commit comments