hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB6d68754Ahmet Kaan Gümüş2 months ago566 commits
| 1 | //! Chatbot thread workflows: the create, rename and delete paths the |
| 2 | //! chatbot surface drives, all scoped to the owning user — a foreign id |
| 3 | //! reads as absent. The queries live in [`crate::db::chatbot_thread`]. |
| 4 | |
| 5 | use crateDatabase; |
| 6 | use cratechatbot_thread; |
| 7 | use crate; |
| 8 | use crateUserId; |
| 9 | use crateAppError; |
| 10 | |
| 11 | /// Start a thread unless `user` is already at the school's |
| 12 | /// `max_chatbot_threads` (409 at the cap — the cap is storage protection, |
| 13 | /// not a usage quota). The cap check and the row write are one atomic |
| 14 | /// conditional write, so two requests racing the same user's last slot |
| 15 | /// cannot both win. |
| 16 | pub async |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | /// The caller's own threads, most recently active first. |
| 25 | pub async |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | /// Read a thread only if `user` owns it — a foreign id reads as absent, so |
| 35 | /// the web layer answers 404 rather than leaking that it exists. |
| 36 | pub async |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | /// Rename the thread (`None` clears the name back to untitled), stamping |
| 45 | /// the edit as activity so the thread moves to the top of the list. |
| 46 | pub async |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | /// Delete the thread and every turn in it — one transaction, so a crash |
| 55 | /// can't orphan messages under a vanished thread — and give the owner's |
| 56 | /// cap slot back in the same transaction. |
| 57 | pub async |
| 58 | |
| 59 |