hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Pool-question funnels: ask, the two listings, the approve with its |
| 2 | //! 409-vs-404 split, the pending-only image writes, and the delete whose |
| 3 | //! swept solutions and collected image blob keys ride back for the web |
| 4 | //! layer's blob cleanup. The queries and their transactions live in |
| 5 | //! [`crate::db::pool_question`]; the pure entity and newtypes in |
| 6 | //! [`crate::domain::pool_question`]. |
| 7 | |
| 8 | use crateDatabase; |
| 9 | use cratepool_question; |
| 10 | use crateFileContentType; |
| 11 | use crate; |
| 12 | use crateUserId; |
| 13 | use crateAppError; |
| 14 | |
| 15 | pub async |
| 16 | |
| 17 | |
| 18 | |
| 19 | pub async |
| 20 | |
| 21 | |
| 22 | |
| 23 | /// One page of the caller's question list — visibility gate and optional |
| 24 | /// status filter in one SQL `WHERE`, so `total` counts the filtered set. |
| 25 | /// `viewer = None` is the teacher+ view (everything); `Some(me)` the pool |
| 26 | /// plus the caller's own pending questions. |
| 27 | pub async |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | /// Approve a pending question, stamping `approver`. A `None` from the |
| 38 | /// guarded write is ambiguous — already approved, or gone — so this sorts it |
| 39 | /// out with a read: the question missing is a 404, anything else is the 409 |
| 40 | /// the route's second approve answers. |
| 41 | pub async |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | /// Point the question at a freshly written image blob; `None` means the |
| 60 | /// question was approved or deleted mid-upload (the fresh blob is the |
| 61 | /// caller's orphan to take back off disk). `Some(replaced)` names the blob |
| 62 | /// this upload displaced — the caller's to remove. |
| 63 | pub async |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | /// Detach the question's image (pending only, like [`set_image`]); `None` |
| 74 | /// means the question is no longer pending. `Some(detached)` names the |
| 75 | /// removed blob — `None` inside when there was no image. |
| 76 | pub async |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | /// Delete the question and cascade its solutions; the removed rows and the |
| 84 | /// image blob keys they named come back so the web layer can take every |
| 85 | /// blob off disk. |
| 86 | pub async |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 |