hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Board workflows: the roster gates the REST surface drives, and the |
| 2 | //! atomic-union insert that replaced the old process-wide roster lock. The |
| 3 | //! queries live in [`crate::db::board`]; the room's WebSocket keeps its |
| 4 | //! own binding policy in [`crate::web::board_ws`], reading through here. |
| 5 | |
| 6 | use crateMAX_BOARD_PARTICIPANTS; |
| 7 | use crateDatabase; |
| 8 | use crateboard; |
| 9 | use crate; |
| 10 | use crateRole; |
| 11 | use crate; |
| 12 | use crate; |
| 13 | |
| 14 | /// The board, or a 404 — including the deliberate 404 for a caller who is not |
| 15 | /// on it. Every route starts here, so existence never leaks. |
| 16 | /// |
| 17 | /// A `parent` is treated as an outsider rather than refused with a 403: the |
| 18 | /// role is barred from the whiteboard entirely, and a 403 would confirm the |
| 19 | /// board exists. [`resolve_participants`] keeps parents off every roster, so |
| 20 | /// this arm only ever fires for a row written before that rule. |
| 21 | pub async |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | /// The creator-only gate. A 403, never a 404: the caller reached it through |
| 32 | /// [`board_for`], so they are a participant and the board's existence is |
| 33 | /// already theirs to see. |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | /// The invite list off the wire: deduped, capped, and every id resolved against |
| 44 | /// a real user. The cap is applied *before* the lookup (the domain caps too, but |
| 45 | /// only after the read would already have run), and an unknown id is a 400 |
| 46 | /// rather than a silently dropped invitation. |
| 47 | /// |
| 48 | /// The eligible set is fetched in **one** read, not one per id. That was a |
| 49 | /// per-id loop while a roster could only be typed by hand and so was a handful |
| 50 | /// of ids; bulk invite made a full board an ordinary thing to own, and a |
| 51 | /// read-modify-write PATCH of one — read the board, drop a name, send the rest |
| 52 | /// back — is the common client shape, so the loop had become |
| 53 | /// `max_participants` sequential round trips on a routine edit. |
| 54 | /// |
| 55 | /// A `parent` is refused here, and that is the cut that keeps the role off the |
| 56 | /// whiteboard: never on a roster means [`board_for`] and the room's door already |
| 57 | /// answer 404 on every id-scoped route, and no socket can ever open. |
| 58 | /// |
| 59 | /// The creator is a participant by construction, so they are neither injected |
| 60 | /// into the list nor rejected from it. |
| 61 | /// |
| 62 | /// `current` is the board's roster as it stands (empty when a board is being |
| 63 | /// created), and it is what makes a read-modify-write PATCH survive: an id |
| 64 | /// *already* on the board that no longer qualifies — demoted, or deleted |
| 65 | /// outright — is dropped silently instead of failing the whole call, so a |
| 66 | /// creator echoing back the roster they were just served gets a 200 and a |
| 67 | /// cleaned list. An id that is **new** to the board still 400s; without that |
| 68 | /// split the drop would be a hole letting a caller seed a roster with anyone. |
| 69 | pub async |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | /// Union a bulk-invite source's resolved ids into a board's roster: everyone |
| 113 | /// the source names who still resolves to an eligible user is **added**, |
| 114 | /// nobody is ever removed by it. The filters are silent on purpose — a source |
| 115 | /// is a whole group, and one member who has left or was never eligible must |
| 116 | /// not fail the invite for the other twenty-nine. The cap is |
| 117 | /// **all-or-nothing**: an over-full union is refused with a `409` naming the |
| 118 | /// two numbers and the roster is left exactly as it was. |
| 119 | /// |
| 120 | /// The merge itself is one serialized union ([`board::invite_group`]): the |
| 121 | /// board row is locked first, so of two concurrent invites the second |
| 122 | /// waits, counts against the first's committed roster and the cap refuses |
| 123 | /// it — neither can drop the other's group, the property the old |
| 124 | /// process-wide roster lock existed to provide, now enforced by the row |
| 125 | /// itself. Nothing else here writes between the read and the write, so |
| 126 | /// there is no lock left to hold. |
| 127 | pub async |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | pub async |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | pub async |
| 177 | |
| 178 | |
| 179 | |
| 180 | pub async |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | pub async |
| 192 | |
| 193 | |
| 194 | |
| 195 | pub async |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | pub async |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | pub async |
| 213 | |
| 214 | |
| 215 | |
| 216 | /// Delete the board and its whole stroke history; also frees the creator's |
| 217 | /// board seat. |
| 218 | pub async |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 |