aboutsummaryrefslogtreecommitdiff
path: root/scripts (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-10-01style.css: Switch the header to a grey themeRunxi Yu1-4/+8
2024-10-01style.css: Revert back to blue themeRunxi Yu1-3/+5
2024-10-01{ws,wsm}.go: Split message handlers into their own functionsRunxi Yu2-124/+182
2024-10-01lint.sh: Disable dogsled and unparamRunxi Yu1-1/+1
dogsled forbids patterns such as "_, _, _ = a, b, c" for no reason. unparam warns about unused parameters even when I'm assigning them to _ to indicate that it's fine for them to be unused.
2024-10-01{auth,ws}.go: Remove unnecessary TODOsRunxi Yu2-19/+2
2024-10-01ws.go: Allow deselecting coursesRunxi Yu1-0/+34
2024-10-01lint.sh: Disable yet another cyclomatic complexity checkerRunxi Yu1-1/+1
2024-10-01ws.go: Fix logic error when reaffirming a course choiceRunxi Yu1-2/+2
When a user has already chosen a course choice but sends a message to choose it again, a database error occurs as the uniqueness constraint is violated. In this case, we "reaffirm" the user's course choice, to hopefully get their client's state back in sync. However, we previously forgot to return back to the event loop after this reaffirmation, causing the control flow to fall into the course-increment and transaction-commit stage. The error is discovered at tx.Commit, where pgx raises a ErrTxCommitRollback, because in that case we're trying to commit a transaction that has already encountered an error.
2024-10-01{main,pw}.go, Makefile, index_login.html: Remove password auth stubRunxi Yu4-92/+1
I don't think password authentication is really useful, since Microsoft Entra ID is the "proper" way of doing authentication in our school system and there's just little reason to have a password login. I previously wanted to use password authentication for stress testing, but stress testing really could just use completely fake authentication and there's no need for any password whatsoever.
2024-10-01ws.go: protocolError instead of R on unexpected database errorsRunxi Yu1-23/+7
When an unknown database error is encoutered, the connection should be considered broken and the error should be reported as a fatal error to the end user. Rejecting the course choice unsets the checkbox and lets the page to be continued to be used, which is not intended.
2024-10-01index.go, ws.go: Fix race condition surrounding coursesRunxi Yu2-13/+21
handleIndex and handleConn used to access the courses map without RLock'ing coursesLock, which may cause issues if courses is being written to, by a function such as setupCourses.
2024-10-01courses.go: Propagate course.Selected when setting up coursesRunxi Yu1-2/+7
2024-10-01ws.go: Decrement course.Selected counter on commit failuresRunxi Yu1-0/+6
2024-10-01ws.go: Reaffirm course choice when duplicate is requestedRunxi Yu1-5/+13
Laggy clients, extremely fast clicks, or other conditions could cause duplicate course choices to be sent, which would violate the uniqueness constraint. In this case the fact that the user has already chosen the course should be reaffirmed, rather than making it look like their choice was rejected.
2024-10-01ws.go: propagateCouldFail -> propagateIgnoreFailuresRunxi Yu1-2/+2
I think the new name better reflects the fact that it just ignores failures when propagating to each channel. The old name sounds like "this function itself could fail".
2024-10-01ws.go, schema.sql: Enforce uniqueness of course choicesRunxi Yu2-43/+65
References: https://todo.sr.ht/~runxiyu/cca/1
2024-10-01lint.sh: Disable yet another cyclomatic complexity checkerRunxi Yu1-1/+1
2024-10-01ws.go, *.sql: Add course choices to the databaseRunxi Yu3-7/+47
Note that this naive implementation currently allows users to submit multiple requests for the same course. See the TODO comment below: /* * TODO: Ensure that the user is not already enrolled in this course * and pay attention to relevant race conditions. It might be useful * to restructure this part, to begin a transaction that adds the user * to the database (and check the (currently not existing) uniqueness) * constraint at that exact moment, and abort the transaction if the * course limit is exceeded. * Or perhaps choices should be also stored in an internal data * structure, though that requires extra attention on consistency * issues between the internal data structure and the database. * (Sometime I should really go fix the LMDB bindings...) */ References: https://todo.sr.ht/~runxiyu/cca/1
2024-10-01postgres_run.sh: Run in debug level 2Runxi Yu1-1/+1
This allows SQL statements to be logged which makes debugging much easier. Also "$@" is added so any extra arguments may be passed.
2024-10-01ws.go: propagate -> propagateCouldFailRunxi Yu1-3/+8
2024-10-01ws.go: propagate course number updates in another goroutineRunxi Yu1-1/+1
2024-10-01auth.go: Add TODO about INSERTRunxi Yu1-0/+7
2024-09-30admin_handbook: List configuration caveatsRunxi Yu1-3/+7
2024-09-30iadocs: cover_page.{html->htm}Runxi Yu2-353/+352
Cgit was kinda broken in serving HTML, it was a caching issue
2024-09-30docs, iadocs: RevampRunxi Yu6-352/+544
2024-09-30docs: TeXinfo kinda sucks, removingRunxi Yu3-57/+0
2024-09-30ws.go: Separate c.Write calls into writeText()Runxi Yu1-25/+17
2024-09-30utils.go, auth.go: Rename random to randomBytesRunxi Yu2-3/+3
2024-09-30main.go: Actually repsect config.Perf.ReadHeaderTimeoutRunxi Yu1-1/+1
2024-09-30style.css: Misc enhancementsRunxi Yu1-29/+25
2024-09-30style.css: Break element specifiers onto its own line when longRunxi Yu1-6/+12
2024-09-30style.css: Rename --boxbg to --boxRunxi Yu1-13/+11
2024-09-30style.css: Add a dark themeRunxi Yu1-8/+28
2024-09-30style.css: Remove poorly-framed comment on --x-contrast colorsRunxi Yu1-5/+0
2024-09-30ws.go, utils.go: Document some synchronization design choicesRunxi Yu2-1/+21
Also use TryLock in setupChanPool, and fail when not successful.
2024-09-30index.html: Disable checkbox initially when .Selected >= MaxRunxi Yu1-0/+4
2024-09-30main.js: Move connect(s) to the event listener directlyRunxi Yu1-6/+2
2024-09-30{config,index}.go, cca.scfg.example, style.css, *.html: Link to sourceRunxi Yu6-14/+17
2024-09-30*: Change license to AGPL-3.0-or-laterRunxi Yu13-238/+787
2024-09-30index.go: Correct typoRunxi Yu1-1/+1
2024-09-30auth.go, config.go, cca.scfg.example: Issue expiring cookiesRunxi Yu3-2/+13
2024-09-30{auth,index,ws}.go, schema.sql: Move session cookie into the user tableRunxi Yu4-55/+23
One user shall only have one session at a time. This reduces the possibility of strange race conditions and simplifies the code a lot. References: https://todo.sr.ht/~runxiyu/cca/4
2024-09-30utils.go: Better logging for wstr()Runxi Yu1-1/+1
2024-09-30main.js: Disable boxes when fullRunxi Yu1-0/+8
2024-09-30main.js: Fix the IRC-style message parserRunxi Yu1-0/+4
Previously, if it receives a message like "a b :c", it returns "["a", "b", "c "]" which is erroneous.
2024-09-30index.html, main.js, ws.go: Enhance course selection rejection messageRunxi Yu3-5/+9
2024-09-29main.js: Handle "Y" (course selection approved)Runxi Yu1-0/+4
2024-09-29style.css: Remove styling for preformatted textRunxi Yu1-9/+0
2024-09-29ws.go, config.go, config.scfg.example: Attempt to fix deadlockRunxi Yu3-4/+14
When propagate tries to propagate a message to a connection that actually called propagate, it deadlocks because the it tries to send to that connection's send channel in the same goroutine. This is an attempt at a fix.
2024-09-29main.js: Handle number updatesRunxi Yu1-0/+3