Expand description
Saved notecards and saved renders: scope/destination types, permission helpers, and the orphan-file sweeper.
Every handler that mutates or reads a saved item funnels through one of
the assert_can_* helpers here so the permission rules live in exactly
one place.
Structs§
- GlwData
Row - Raw row fields for a saved GLW event as fetched from the DB.
- GlwData
View - Public, serializable record of a saved GLW event. Excludes the raw
payload_jsonblob (which is large and only the render worker needs it) so the library list stays small over the wire. - LogoRow
- Raw row fields for a saved logo as fetched from the DB.
- Logo
View - Public, serializable record of a saved logo. Excludes the raw bytes
(downloaded separately via
GET /api/logos/{id}/image). - Notecard
Row - Raw row fields for a saved notecard as fetched from the DB.
- Notecard
View - Public, serializable record of a saved notecard.
- Render
Row - Raw row fields for a saved render as fetched from the DB.
- Render
View - Public, serializable record of a saved render.
- Theme
Row - Raw row fields for a saved theme as fetched from the DB.
Enums§
- Destination
- Owner scope of a saved notecard or saved render. Exactly one of the two variants is set; the schema CHECK constraint mirrors this at the DB.
- GlwData
Source Kind - Where a saved GLW row originally came from. Persisted as the
source_kindtext column. Surfaced in the library list so the user can tell pasted JSON from a real id/key fetch.
Constants§
- MAX_
DISPLAY_ NAME_ LEN - Maximum length, in unicode codepoints, of a user-supplied display
name. Applies to
groups.nameandsaved_notecards.name.
Functions§
- assert_
can_ delete_ glw_ data - Permission gate for deleting a GLW data row. Personal: must be the owner. Group: must be an owner of the group.
- assert_
can_ delete_ logo - Permission gate for deleting a logo. Personal: must be the owner. Group: must be an owner of the group.
- assert_
can_ delete_ notecard - Permission gate for deleting a notecard (same rule as renders).
- assert_
can_ delete_ render - Permission gate for deleting a render. Personal: must be the owner. Group: must be an owner of the group.
- assert_
can_ modify_ theme - Permission gate for modifying (renaming / overwriting / deleting) a
theme. Personal: must be the owner. Group: must be an owner of the
group. Mirrors
assert_can_delete_glw_data. - assert_
can_ read_ glw_ data - Permission gate for reading a GLW data row. Personal: must be the owner. Group: must be a member of the owning group.
- assert_
can_ read_ logo - Permission gate for reading a logo. Personal: must be the owner. Group: must be a member of the owning group.
- assert_
can_ read_ notecard - Permission gate for reading a notecard. Personal: must be the owner. Group: must be a member.
- assert_
can_ read_ render - Permission gate for reading a render. Personal: must be the owner.
Group: must be a member; members may not see
in_progressorfailedrenders. - assert_
can_ read_ theme - Permission gate for reading a theme. Personal: must be the owner. Group: must be a member of the owning group.
- assert_
can_ view - Resolve a destination to whether the current user can view its
contents and (for groups) what role they have. Personal scope means the
user is the owner; otherwise
Error::Forbiddenis returned. - assert_
can_ write - Verify that the calling user is allowed to write to the given destination. Personal scope is always allowed; group scope requires owner membership.
- destination_
from_ columns - Convert a
(owner_user_id, owner_group_id)row pair (exactly one of the two is Some) into aDestination. - is_
canonical_ hex_ color - True if
sis canonical#rrggbb— exactly one leading#followed by exactly six ASCII hex digits (case-insensitive). Shared by every endpoint that validates a colour swatch on the way in (the route-colour preference, the saved-colour palette, and saved themes). - recover_
orphaned_ in_ progress - Mark every
saved_rendersrow still instatus = 'in_progress'asfailed. Run once at server startup, before the HTTP listener accepts connections: anything found inin_progressat that moment is orphaned by definition — the tokio task that could have transitioned it died with the previous process. Without this sweep each abandoned row would permanently count againstMAX_CONCURRENT_RENDERS_PER_USER. - run_
orphan_ sweeper - Run the orphan-file sweeper. Wakes every
periodseconds; if the dirty flag is unset, the tick is a cheap no-op. When the flag is set the sweeper scans<storage_dir>/renders/and unlinks any file whose UUID is not present insaved_renders. A scan failure re-raises the flag so the next tick retries. - sanitise_
display_ name - Trim a user-supplied display name and reject it if it is empty,
longer than
MAX_DISPLAY_NAME_LENcodepoints, contains any unicode control character (char::is_control— NUL, TAB, LF, CR, the C1 control block, DEL), or contains any unicodeCfFormat character (bidi overrides, zero-width joiners, the BOM, language-tag block, etc. — seeis_unicode_format).fieldis interpolated into the error message so the caller does not need to repeat the label.