Skip to main content

Module account

Module account 

Source
Expand description

Account data, tags, filters, and public-room listing. Profile nick lookup and any restricted user directory are product concerns, not in this crate.

Structs§

DirectoryMatch
One ranked, labeled match — [rank_directory_candidates]’s own output row, carrying public_id along so the route handler can crate::store::ensure_matrix_user it into an mxid without a second identity-database round trip.
PublicRoomsFilter
PublicRoomsQuery
PublicRoomsRequestBody
TagBody
UserDirectoryResult
UserDirectorySearchRequest
UserDirectorySearchResponse

Constants§

DEFAULT_DIRECTORY_RESULTS
limit’s default when the client omits it — matches routes::dm::lookup_recipients’s own MAX_LOOKUP_RESULTS.
DEFAULT_PUBLIC_ROOMS_LIMIT
FILTER_MAX_BYTES
Ceiling on a stored Filter JSON object (P8 brief item 4).
MAX_DIRECTORY_RESULTS
Ceiling a client-supplied limit is clamped to — the DM lookup has no client-facing limit at all (always 10); the Matrix endpoint’s own spec shape does take one, so this is the abuse-prevention ceiling on it.
MAX_PUBLIC_ROOMS_LIMIT
MAX_SEARCH_TERM_LEN
A trimmed, lowercased search_term longer than this is truncated rather than refused — matches routes::dm::lookup_recipients’s own MAX_LOOKUP_QUERY_LEN.
MAX_TAGS_PER_ROOM
MAX_TAG_NAME_BYTES

Functions§

apply_tag_delete
DELETE .../tags/{tag} — idempotent: removing an absent tag is a silent no-op, matching Matrix’s own DELETE semantics.
apply_tag_put
PUT .../tags/{tag}’s whole DB-side decision: validate the tag name and order, refuse growing past MAX_TAGS_PER_ROOM on a genuinely NEW tag (re-setting an existing tag’s order never counts against the cap), then upsert. Membership is checked by the route handler, not here (this function takes no caller/room-membership context at all — the “testable cores” convention this module states).
check_account_data_type_allowed
m.fully_read is refused on both the global and per-room account-data endpoints (P8 brief items 1/2): it belongs to room account data via POST .../read_markers (crate::ephemeral::apply_read_markers), which is the only writer this server ever lets touch it — a raw PUT here would let a client desync it from the receipt bookkeeping that route also updates in the same call.
check_caller_owns_user_id
Every /user/{userId}/... route in this module: the path’s userId (a full mxid) must be the caller’s own — this server has no notion of one account managing another’s account data/tags/filters.
clamp_public_rooms_limit
list_public_rooms
One page of public rooms from the messenger database alone.
public_room_json
One chunk entry’s wire shape (P8 brief item 7) — name/topic are omitted entirely (not null) when the room never set them, matching Matrix’s own convention of omitting rather than nulling absent profile fields.
read_tags
{"tags": {...}}’s tags object, or empty when the room has no m.tag account-data row yet.
require_member
require_member_or_invited
The tags gate (P8 brief item 3): joined OR invited, unlike plain per-room account data (item 2), which requires a full join.
search_users_by_localpart
Match an mxid localpart stored in this database. No nick index and no restricted directory: a product owns both of those.
validate_account_data_content
PUT account-data content must be a JSON object (Matrix’s own shape for every account-data type) within crate::store::MATRIX_EVENT_CONTENT_MAX_BYTES once serialized — same ceiling routes::matrix::rooms::put_state applies to state-event content. Returns the serialized string ready to store.
validate_filter_definition
A Filter must be a JSON object within FILTER_MAX_BYTES once serialized — stored verbatim, opaque, interpreted only by a later /sync piece. Returns the serialized string ready to store.
validate_tag_name
validate_tag_order
order (P8 brief item 3): when present, must be in [0, 1].
whoami_response
GET /account/whoami’s wire shape: the caller’s own mxid and the device this credential resolved to (minting it on first use — see [auth::device_id_for]’s own doc). This is how a client with no /login flow (this server has none — plan §1) learns its own device id. is_guest is always false: this server has no guest accounts.
write_tags