| 1 | package slides |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | // Models is every model the schema generator manages. Keep it in step |
| 6 | // with the structs below: `rastrillo migration generate` reads |
| 7 | // it to work out what the database should look like, and |
| 8 | // `rastrillo migration check` fails CI when it and the |
| 9 | // migrations disagree. |
| 10 | var Models = []any{ |
| 11 | &User{}, |
| 12 | &Deck{}, |
| 13 | &DeckUpdate{}, |
| 14 | &DeckSnapshot{}, |
| 15 | &DeckAsset{}, |
| 16 | &AssetUpload{}, |
| 17 | &DeckGrant{}, |
| 18 | &ShareLink{}, |
| 19 | &Presentation{}, |
| 20 | &PresentationPress{}, |
| 21 | &PresentationLink{}, |
| 22 | &Agent{}, |
| 23 | &LibraryFont{}, |
| 24 | &DeckFont{}, |
| 25 | &SceneBundle{}, |
| 26 | } |
| 27 | |
| 28 | // User is a person who has signed in here — spec §6.1's |
| 29 | // `users(id, email, name, colour)`, created on first sign-in by |
| 30 | // auth.go's ensureUser. |
| 31 | // |
| 32 | // It exists because under rastrillo/auth the session Subject is the |
| 33 | // verified email address, not a numeric id (SKILL.md §5's warning: |
| 34 | // sessions.UserID answers (0, false) and would scope every owned query |
| 35 | // to user_id = 0). Every later model's owner column points at User.ID, |
| 36 | // so the address has to become a row before anything can be scoped. |
| 37 | // |
| 38 | // Email carries the unique index because the address is the identity: |
| 39 | // two rows for one address would mean one person owning two disjoint |
| 40 | // sets of decks depending on which row a request happened to find. |
| 41 | // Stored normalized (auth.go's normalizeAddress) so "Paul@Example.test" |
| 42 | // and "paul@example.test" are the same person, which is what the |
| 43 | // allowlist already assumes. |
| 44 | type User struct { |
| 45 | ID int64 |
| 46 | Email string `gorm:"uniqueIndex"` |
| 47 | // Name is what other people see beside this person's cursor and in |
| 48 | // a deck's activity list. Empty until there is a screen to set it; |
| 49 | // callers fall back to Email. |
| 50 | Name string |
| 51 | // Colour is this person's presence colour (spec §3.2's coloured |
| 52 | // outline and cursor label). Assigned at creation from a fixed |
| 53 | // palette so two people in one deck are told apart by more than |
| 54 | // their name — and never by colour alone, per the app's own WCAG |
| 55 | // commitment. |
| 56 | Colour string |
| 57 | CreatedAt time.Time |
| 58 | |
| 59 | // team is this request's roster standing for the person, in team |
| 60 | // mode only (team_access.go). Never a column, never stored: a user |
| 61 | // read without it has no team standing until a request asks. |
| 62 | team *teamAccess `gorm:"-"` |
| 63 | } |
| 64 | |
| 65 | // Deck is one presentation: the row that owns a Y.Doc, not the document |
| 66 | // itself. The content lives in DeckUpdate's log (spec §2.1); what is on |
| 67 | // this row is everything a list, a link or a permission check needs |
| 68 | // without opening the document at all. |
| 69 | // |
| 70 | // Sqid is the deck's public name — ten random characters, unique, |
| 71 | // minted at creation and never derived from ID (decks.go's newSqid). It |
| 72 | // is also the Y.Doc's guid, so a document and its URL cannot drift |
| 73 | // apart. |
| 74 | // |
| 75 | // Title and Theme are duplicated: they are meta.title and meta.theme |
| 76 | // inside the document too, and both move together on every write. The |
| 77 | // copy exists so the deck list can render fifty rows without |
| 78 | // instantiating fifty wasm modules. |
| 79 | // |
| 80 | // Seq is the log's high-water mark and the optimistic lock every write |
| 81 | // takes: an insert at Seq+1 lands only if the row still reads Seq (see |
| 82 | // decks.go's applyOps). It is not a version anybody sees. |
| 83 | type Deck struct { |
| 84 | ID int64 |
| 85 | Sqid string `gorm:"uniqueIndex"` |
| 86 | // Title is the deck's name, and the only free text on this row. |
| 87 | Title string |
| 88 | // OwnerID is the creator — spec §5's private rung, and the one |
| 89 | // person who may change settings or delete. |
| 90 | OwnerID int64 `gorm:"index"` |
| 91 | // Rung is who may open this deck: "private", "granted" or "team" |
| 92 | // (suite ruling 15, spec §5). Every deck starts private. This |
| 93 | // slice's UI offers private and team only; granted needs a screen |
| 94 | // for naming people, which has not been built — but DeckGrant and |
| 95 | // decks.go's visibleDecks already honour it. |
| 96 | Rung string |
| 97 | // Theme is the theme id (spec §2.1's meta.theme). |
| 98 | Theme string |
| 99 | Seq int64 |
| 100 | CreatedAt time.Time |
| 101 | UpdatedAt time.Time |
| 102 | } |
| 103 | |
| 104 | // DeckUpdate is one entry in a deck's update log: the Yjs update bytes |
| 105 | // one write produced. Replaying every row of a deck in Seq order |
| 106 | // reproduces the document exactly (decks.go's openDeck) — there are no |
| 107 | // snapshots yet. |
| 108 | // |
| 109 | // Actor is spec §6.2's actor string, "person:<user id>" or |
| 110 | // "agent:<agent id>". It lives on this row rather than in the CRDT |
| 111 | // deliberately: the document is what every peer converges on, and who |
| 112 | // wrote which byte of it is this instance's bookkeeping, not shared |
| 113 | // content. |
| 114 | type DeckUpdate struct { |
| 115 | ID int64 |
| 116 | // DeckID and Seq carry one composite unique index rather than an |
| 117 | // index each. That index is what makes "the update after seq n" a |
| 118 | // single insert that either lands or violates, with no |
| 119 | // read-then-write window; and being leftmost in it, DeckID alone is |
| 120 | // still indexed, so a second index on DeckID would only cost |
| 121 | // writes. |
| 122 | DeckID int64 `gorm:"uniqueIndex:idx_deck_updates_deck_seq"` |
| 123 | Seq int64 `gorm:"uniqueIndex:idx_deck_updates_deck_seq"` |
| 124 | Actor string |
| 125 | Bytes []byte |
| 126 | CreatedAt time.Time |
| 127 | } |
| 128 | |
| 129 | // DeckSnapshot is one deck's whole document at one seq, stored as a |
| 130 | // single Yjs update (core.Handle.State) so a later open can start from |
| 131 | // it instead of from the first row of the log. |
| 132 | // |
| 133 | // It is DERIVED DATA, and every decision here follows from that (Docs' |
| 134 | // snapshots ruling, adopted). The log is what the deck is: delete every |
| 135 | // row of this table and nothing is lost but time. So a snapshot is |
| 136 | // written best-effort AFTER the update that crossed the boundary has |
| 137 | // committed (snapshot.go's maybeSnapshot), a failure to write one is |
| 138 | // logged and never fails the request, and a snapshot that cannot be |
| 139 | // read is skipped in favour of replaying the plain log. |
| 140 | // |
| 141 | // Seq is the highest seq the bytes contain, and openDeck trusts it: it |
| 142 | // replays the rows at seq > Seq and no others. Nothing here can check |
| 143 | // that claim, so the ONE caller allowed to write a row is the one |
| 144 | // holding a handle it knows the seq of. |
| 145 | // |
| 146 | // Bytes rather than a path: a deck's state is kilobytes, this is one |
| 147 | // row per two hundred updates, and superseded rows are deleted as each |
| 148 | // new one lands, so the table holds one row per deck in the steady |
| 149 | // state. |
| 150 | // |
| 151 | // (deck_id, seq) is deliberately NOT unique. Two writers crossing the |
| 152 | // boundary together produce equivalent rows at the same seq, and that |
| 153 | // is an ordinary outcome rather than a collision to resolve. |
| 154 | type DeckSnapshot struct { |
| 155 | ID int64 |
| 156 | DeckID int64 `gorm:"index"` |
| 157 | Seq int64 |
| 158 | Bytes []byte |
| 159 | // CreatedAt is when the snapshot was taken, not when the deck last |
| 160 | // moved: a snapshot is bookkeeping, and the deck's own UpdatedAt is |
| 161 | // the column anything user-facing reads. |
| 162 | CreatedAt time.Time |
| 163 | } |
| 164 | |
| 165 | // DeckAsset records that one ref was VERIFIED for one deck: read back |
| 166 | // out of the store, sniffed as an image, sanitised if an SVG |
| 167 | // (assets.go's registerAsset). It is the half of the asset gate the |
| 168 | // document cannot carry. |
| 169 | // |
| 170 | // The deck's own `assets` map says which refs a deck refers to, and |
| 171 | // serveAsset checks it before serving a byte. But that map is written |
| 172 | // by `register_asset`, an op any member can apply with any ref — and a |
| 173 | // presigned PUT lands whatever bytes the browser sent under whatever |
| 174 | // hash it named, with nothing in between looking at them. So a member |
| 175 | // could PUT an unsanitised SVG and name its ref in an op, and the deck |
| 176 | // would refer to it and this app would serve it under its own origin. |
| 177 | // A row here is written only by registerAsset, after the bytes were |
| 178 | // checked, so serveAsset requiring one (as well as the map) means the |
| 179 | // map alone can never make an unverified object servable. |
| 180 | // |
| 181 | // Ref is the store's content address, which is what the served bytes |
| 182 | // are named by; (deck_id, ref) is unique because verifying the same |
| 183 | // bytes for the same deck twice is one fact, not two. Deleting the deck |
| 184 | // deletes its rows (decks.go's deleteDeck): a verification is about a |
| 185 | // deck, and nothing else ever reads one. |
| 186 | type DeckAsset struct { |
| 187 | ID int64 |
| 188 | DeckID int64 `gorm:"uniqueIndex:idx_deck_assets_deck_ref"` |
| 189 | Ref string `gorm:"uniqueIndex:idx_deck_assets_deck_ref"` |
| 190 | CreatedAt time.Time |
| 191 | } |
| 192 | |
| 193 | // SceneBundle is DeckAsset's twin for a scene's code (scenes.go): |
| 194 | // registerAsset writes one after reading the bytes back and finding one |
| 195 | // HTML document of at most 2 MiB. A table of its own rather than a row |
| 196 | // in deck_assets, so a bundle is never a picture: the picture routes, |
| 197 | // thumbnails and the PDF read deck_assets and never see one, and the |
| 198 | // sealed scene routes read this and never see a picture. Deleting the |
| 199 | // deck deletes its rows. |
| 200 | type SceneBundle struct { |
| 201 | ID int64 |
| 202 | DeckID int64 `gorm:"uniqueIndex:idx_scene_bundles_deck_ref"` |
| 203 | Ref string `gorm:"uniqueIndex:idx_scene_bundles_deck_ref"` |
| 204 | CreatedAt time.Time |
| 205 | } |
| 206 | |
| 207 | // AssetUpload is the RECEIPT for one upload this app itself signed — |
| 208 | // spec §2.7 as amended by codex 1 and codex 2. It is what makes an |
| 209 | // upload a thing that happened rather than a ref somebody knows. |
| 210 | // |
| 211 | // Before it existed, `POST /d/{sqid}/uploads` signed a PUT for whatever |
| 212 | // address the browser named and `POST /d/{sqid}/assets` verified |
| 213 | // whatever address the browser named. Two consequences, each a hole: |
| 214 | // a member could sign a PUT for an address another deck's picture was |
| 215 | // already served from and replace the bytes under it (codex 1), and a |
| 216 | // member who merely KNEW another deck's ref could register it into a |
| 217 | // deck of their own and pass both of serveAsset's checks (codex 2) — |
| 218 | // which defeated the whole "a content address is not an authorisation" |
| 219 | // rule the asset routes are built on. |
| 220 | // |
| 221 | // So the browser never names an address again. signUpload mints a |
| 222 | // STAGING key — a hash of this deck, this actor and 32 fresh random |
| 223 | // bytes, so the address is a function of the principal and is not |
| 224 | // guessable or reachable from outside — writes this row, and signs a PUT |
| 225 | // for that key alone. Registration will only look at bytes a row here |
| 226 | // says THIS principal staged for THIS deck; it then reads them, hashes |
| 227 | // what it actually read, and promotes them to a final object keyed by |
| 228 | // that hash. Nothing ever signs a PUT for a final address, so a |
| 229 | // verified object is immutable by construction rather than by nobody |
| 230 | // having tried. |
| 231 | // |
| 232 | // StagingKey carries the unique index because it is what a PUT and a |
| 233 | // registration are both resolved by. ObjectKey is where the bytes |
| 234 | // actually are: the staging key itself on a presigning store (the |
| 235 | // browser wrote them there), or the content address blobs.Dir chose in |
| 236 | // development, where the PUT comes through this app and the store is |
| 237 | // content-addressed with no way to write a caller's key. ConsumedAt |
| 238 | // makes a receipt single-use, so one signed upload is one registration. |
| 239 | type AssetUpload struct { |
| 240 | ID int64 |
| 241 | DeckID int64 `gorm:"index"` |
| 242 | // Actor is who asked for the URL, in DeckUpdate.Actor's form. Half |
| 243 | // of the pair registration matches on: an upload one member staged |
| 244 | // is not another member's to register, and an upload staged for one |
| 245 | // deck is not registrable into another. |
| 246 | Actor string |
| 247 | // StagingKey is the address this app told the browser to write to, |
| 248 | // and the only address it will ever sign a PUT for. |
| 249 | StagingKey string `gorm:"uniqueIndex"` |
| 250 | // ObjectKey is where the staged bytes really are once the PUT has |
| 251 | // landed. Empty until then on the development path. |
| 252 | ObjectKey string |
| 253 | // DeclaredHash is the SHA-256 the browser said the file has. Never |
| 254 | // trusted for anything — the final address comes from bytes this |
| 255 | // app read — but checked against what landed on the development |
| 256 | // path, where this app does the hashing anyway. |
| 257 | DeclaredHash string |
| 258 | // ContentType is what the browser said it was uploading, kept so |
| 259 | // the PUT can be signed with the header the bucket will store. |
| 260 | ContentType string |
| 261 | Size int64 |
| 262 | CreatedAt time.Time |
| 263 | ConsumedAt *time.Time |
| 264 | } |
| 265 | |
| 266 | // DeckGrant names one person who may open one deck — spec §5's |
| 267 | // `granted` rung. |
| 268 | // |
| 269 | // No screen creates one yet. The model and visibleDecks' join exist |
| 270 | // from the start anyway, because the alternative is a visibility seam |
| 271 | // that quietly means "owner-or-team" long after grants land: the day |
| 272 | // the screen arrives, nothing about who can read what has to be |
| 273 | // rewritten. |
| 274 | type DeckGrant struct { |
| 275 | ID int64 |
| 276 | DeckID int64 `gorm:"index"` |
| 277 | UserID int64 `gorm:"index"` |
| 278 | // Actor is who granted it, in DeckUpdate.Actor's form. |
| 279 | Actor string |
| 280 | CreatedAt time.Time |
| 281 | } |
| 282 | |
| 283 | // ShareLink is one read-only capability for one deck — spec §5's share |
| 284 | // link, calendar's feed pattern (its calendar design §6). |
| 285 | // |
| 286 | // Only the hash is stored. A plaintext token in this table would be a |
| 287 | // live, unauthenticated read capability for somebody's whole deck, |
| 288 | // sitting in a file the platform replicates to object storage. The |
| 289 | // consequence is that the URL cannot be shown again, so the share page |
| 290 | // shows it at the moment of minting and says so. |
| 291 | // |
| 292 | // TokenHash carries the unique index because it is what a request is |
| 293 | // resolved by: a single indexed read on /s/{token}, and no two rows |
| 294 | // can ever claim one URL. |
| 295 | // |
| 296 | // Views is the honest part, calendar's reason: a link that has been |
| 297 | // opened four hundred times is a different thing to hold than one |
| 298 | // nobody has ever used, and the share page can only say so if the |
| 299 | // number is kept. |
| 300 | // |
| 301 | // RevokedAt rather than a delete, also calendar's: the share page keeps |
| 302 | // showing that the link existed and that it is off, and a URL still |
| 303 | // pasted in somebody's chat window stops working rather than silently |
| 304 | // matching a later link that happened to reuse the row. |
| 305 | type ShareLink struct { |
| 306 | ID int64 |
| 307 | DeckID int64 `gorm:"index"` |
| 308 | // TokenHash is the SHA-256 hex of the token (share.go's |
| 309 | // hashShareToken). This table never holds the token itself, and a |
| 310 | // link made from the share page is not written anywhere else. An |
| 311 | // Audience link is: its follow address, token included, is the |
| 312 | // props.url of the follow-along code it was made for, in the deck's |
| 313 | // document, where members can read it (qrlink.go). |
| 314 | TokenHash string `gorm:"uniqueIndex"` |
| 315 | // Actor is who minted it, in DeckUpdate.Actor's form. |
| 316 | Actor string |
| 317 | // Audience marks a link a follow-along code was made with |
| 318 | // (qrlink.go): the share page names it, in the catalog's words |
| 319 | // (slides.share.audience.name), so the person can tell which row |
| 320 | // the code on their slide opens. A link has no other name. |
| 321 | Audience bool |
| 322 | Views int64 |
| 323 | CreatedAt time.Time |
| 324 | RevokedAt *time.Time |
| 325 | } |
| 326 | |
| 327 | // Presentation is one live talk: which deck, who is presenting, which |
| 328 | // slide is on the screen, and the two capabilities that reach it — |
| 329 | // spec §3.4's session row, and ruling 5's "presenting is a server-side |
| 330 | // presentation session". |
| 331 | // |
| 332 | // It is the one record the presenter view, the phone remote and every |
| 333 | // following audience member all read and write, which is what makes |
| 334 | // them agree: there is no second place where "the deck is on slide |
| 335 | // four" is written down, so there is nothing for them to disagree |
| 336 | // about. |
| 337 | // |
| 338 | // Sqid is the session's public name and a VIEWING capability: anybody |
| 339 | // who has it may watch the fullscreen surface, exactly as a share link |
| 340 | // works. It is not a driving capability — that is RemoteTokenHash. |
| 341 | // |
| 342 | // Code is the six characters a person reads aloud or types into a |
| 343 | // phone, from an alphabet with no O/0 and no I/1 for the same reason |
| 344 | // the deck sqid's has none. It is unique among LIVE sessions only, and |
| 345 | // enforced in Go rather than by an index, because a code that could |
| 346 | // never be reused would make a long-lived instance run out of the |
| 347 | // short, sayable ones. It is not a capability on its own: pairing |
| 348 | // needs the code AND the token (presentation.go's remotePair). |
| 349 | // |
| 350 | // RemoteTokenHash is the SHA-256 hex of the remote's capability, the |
| 351 | // share link's construction and the share link's reason (share.go): |
| 352 | // only the hash is stored, so the URL can be shown exactly once, and |
| 353 | // resolving one is a constant-time compare rather than a lookup. |
| 354 | // |
| 355 | // Slide is a 0-based index into the deck's slides. Every URL and every |
| 356 | // stream event carries the 1-based number a person sees instead |
| 357 | // (presentation.go's eventFor) — the two are one conversion in one |
| 358 | // place, and this column is the index because that is what indexes |
| 359 | // into the document. |
| 360 | // |
| 361 | // EndedAt rather than a delete, and StartedAt read as a 12-hour |
| 362 | // deadline: a session is over when it is ended or when it is old, and |
| 363 | // both answers are 410 rather than 404, because a talk that finished |
| 364 | // is a different thing from a link that was never real. |
| 365 | type Presentation struct { |
| 366 | ID int64 |
| 367 | Sqid string `gorm:"uniqueIndex"` |
| 368 | DeckID int64 `gorm:"index"` |
| 369 | // Actor is who is presenting, in DeckUpdate.Actor's form. |
| 370 | Actor string |
| 371 | Slide int |
| 372 | Blackout bool |
| 373 | Code string `gorm:"index"` |
| 374 | RemoteTokenHash string |
| 375 | StartedAt time.Time |
| 376 | EndedAt *time.Time |
| 377 | |
| 378 | // The talk's absolute position (deck.Position), for a session that |
| 379 | // is Positional: the slide by id, the press on it, and the mode. |
| 380 | // Slide above stays in step with SlideID, as the slide's index in |
| 381 | // the full talk (deck.TalkOrder), so the 1-based number every URL |
| 382 | // and stream event carries still means the same slide. |
| 383 | SlideID string |
| 384 | Step int |
| 385 | Mode string |
| 386 | // Seq counts the presses the server has applied. A window compares |
| 387 | // the seq of a position it hears with the newest it has applied, so |
| 388 | // a late answer can never move it backwards. |
| 389 | Seq int64 |
| 390 | // Positional is false for a session begun before positions existed |
| 391 | // (and NULL in its row, which reads as false). Such a session keeps |
| 392 | // moving by Slide alone for its remaining hours. |
| 393 | Positional bool |
| 394 | // TimerAt is when the talk's timer started: the first move, not the |
| 395 | // session opening. Nil until then and after a timer-reset. |
| 396 | TimerAt *time.Time |
| 397 | } |
| 398 | |
| 399 | // PresentationPress is one press id a session has applied, so that a |
| 400 | // press sent twice (a window that did not hear its answer) counts once. |
| 401 | // Only the newest 64 per session are kept (presenting_position.go). |
| 402 | type PresentationPress struct { |
| 403 | PresentationID int64 `gorm:"uniqueIndex:idx_presentation_presses_press"` |
| 404 | PressID string `gorm:"uniqueIndex:idx_presentation_presses_press"` |
| 405 | CreatedAt time.Time |
| 406 | } |
| 407 | |
| 408 | // PresentationLink is the newest command a window's link has had |
| 409 | // applied to a session. A presenting window numbers every command it |
| 410 | // sends (N, rising); once the server has applied one, a command of that |
| 411 | // link numbered at or below it is not applied. So a press the window |
| 412 | // gave up on, and replaced with a resume, cannot reach the talk after |
| 413 | // the resume and move it twice. Commands without a link (the phone's |
| 414 | // forms, sessions begun before positions) are not numbered. Every link |
| 415 | // is kept for the session's life, and deleted with its row. |
| 416 | type PresentationLink struct { |
| 417 | PresentationID int64 `gorm:"uniqueIndex:idx_presentation_links_link"` |
| 418 | LinkID string `gorm:"uniqueIndex:idx_presentation_links_link"` |
| 419 | N int64 |
| 420 | UpdatedAt time.Time |
| 421 | } |
| 422 | |
| 423 | // Agent is one non-human principal that may drive this instance's |
| 424 | // decks — spec §7.1, and suite ruling 9 as this app reads it: an agent |
| 425 | // is its OWN principal with an operator behind it, never a borrowed |
| 426 | // session belonging to the person who minted it. |
| 427 | // |
| 428 | // The consequence lands on DeckUpdate.Actor. A write an agent makes is |
| 429 | // recorded "agent:<id>", so a deck's history says which agent wrote a |
| 430 | // slide and, through OperatorID, on whose authority — two facts a |
| 431 | // shared session would have collapsed into one wrong one. |
| 432 | // |
| 433 | // Name is the short half of the principal (`claude`, `codex`), held to |
| 434 | // lowercase letters, digits and hyphens so the principal string |
| 435 | // `<name>~<operator email>` has exactly one separator in it and reads |
| 436 | // the same everywhere it is shown. It is unique among one person's |
| 437 | // LIVE agents, enforced in Go rather than by an index, because a name |
| 438 | // that could never be reused would mean revoking `claude` costs you |
| 439 | // the name forever. |
| 440 | // |
| 441 | // TokenHash is the SHA-256 hex of the token and carries the unique |
| 442 | // index — share.go's construction and share.go's reason: only the |
| 443 | // fingerprint is stored, so a bearer resolves in one indexed read and |
| 444 | // the token itself can be shown exactly once. The screen that mints |
| 445 | // one says so at the moment it shows it. |
| 446 | // |
| 447 | // RevokedAt rather than a delete, ShareLink's reason again: the page |
| 448 | // keeps showing that the agent existed and that it is off, the actor |
| 449 | // strings already written into deck histories still resolve to a name, |
| 450 | // and a token still sitting in some machine's environment stops |
| 451 | // working rather than silently matching a later agent that happened to |
| 452 | // reuse the row. |
| 453 | type Agent struct { |
| 454 | ID int64 |
| 455 | Name string |
| 456 | // OperatorID is the person who minted this agent and whose |
| 457 | // visibility it borrows: an agent reads and writes exactly the |
| 458 | // decks its operator can, never more. |
| 459 | OperatorID int64 `gorm:"index"` |
| 460 | TokenHash string `gorm:"uniqueIndex"` |
| 461 | CreatedAt time.Time |
| 462 | RevokedAt *time.Time |
| 463 | } |
| 464 | |
| 465 | // LibraryFont is one face a person has uploaded to their own font |
| 466 | // library (library.go): a row per file, grouped on screen by Family. |
| 467 | // |
| 468 | // Owner is the person's actor string (actorFor), the form a deck's |
| 469 | // history already names them by, and Ref is the typeface package's |
| 470 | // SHA-256 of the file, which is also the key the bytes live under in |
| 471 | // the object store. A person cannot hold one file twice; two people |
| 472 | // holding the same file share one object, which is why deleting a row |
| 473 | // deletes the object only when no other row names it. |
| 474 | // |
| 475 | // CSSName is the family as a font-family name a stylesheet can carry |
| 476 | // (cssFamilyName), kept apart from Family, which is what the font's own |
| 477 | // name table says and may hold anything. |
| 478 | type LibraryFont struct { |
| 479 | ID uint |
| 480 | Owner string `gorm:"index;uniqueIndex:idx_library_fonts_owner_ref"` |
| 481 | Family string |
| 482 | CSSName string |
| 483 | Ref string `gorm:"uniqueIndex:idx_library_fonts_owner_ref"` |
| 484 | Format string |
| 485 | Outline string |
| 486 | Style string |
| 487 | Weight int |
| 488 | WeightMin int |
| 489 | WeightMax int |
| 490 | Italic bool |
| 491 | Variable bool |
| 492 | Pictures bool |
| 493 | Size int64 |
| 494 | CreatedAt time.Time |
| 495 | } |
| 496 | |
| 497 | // DeckFont records that one font file was put to use in one deck |
| 498 | // (deckfonts.go): written when a person picks a family from their own |
| 499 | // library, one row per face. It is DeckAsset's twin for fonts. The |
| 500 | // deck's meta.fontFiles is a list any member, or an agent, can write |
| 501 | // with any ref, so the three font routes and the font loader serve a |
| 502 | // ref only when this row says the deck took it from a library as well. |
| 503 | // |
| 504 | // A row outlives the library entry it came from: deleting a family |
| 505 | // from a library leaves the bytes in the store while any row here still |
| 506 | // names them (library.go's dropFontObject), so the decks using it keep |
| 507 | // it. Deleting the deck deletes its rows. |
| 508 | type DeckFont struct { |
| 509 | ID int64 |
| 510 | DeckID int64 `gorm:"uniqueIndex:idx_deck_fonts_deck_ref"` |
| 511 | Ref string `gorm:"uniqueIndex:idx_deck_fonts_deck_ref"` |
| 512 | } |
| 513 | |