[PR #2167] [MERGED] Mod registry: 1-5 star ratings, one per GitHub account #4065

Closed
opened 2026-11-03 04:14:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2167
Author: @ludovic111
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: feat/mod-ratings-api


📝 Commits (1)

  • 4558172 Mod registry: 1-5 star ratings, one per GitHub account

📊 Changes

8 files changed (+577 additions, -66 deletions)

View changed files

📝 crates/horizon-mod-registry/Cargo.lock (+79 -5)
📝 crates/horizon-mod-registry/Cargo.toml (+2 -0)
📝 crates/horizon-mod-registry/Dockerfile (+4 -2)
📝 crates/horizon-mod-registry/README.md (+16 -8)
📝 crates/horizon-mod-registry/src/lib.rs (+231 -41)
📝 crates/horizon-mod-registry/src/main.rs (+3 -2)
➕ crates/horizon-mod-registry/src/ratings.rs (+129 -0)
📝 crates/horizon-mod-registry/tests/submit.rs (+113 -8)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What and why

Ludovic asked for star ratings in the mod browser. This is the service side. The launcher and website UI come in their own PRs.

The registry service (crates/horizon-mod-registry) now keeps players' ratings of published projects, 1 to 5 stars, in one SQLite file (REGISTRY_DB, default /data/registry.sqlite3):

Route
GET /api/mods/ratings {projects: {<id>: {average, count}}}: totals only, never who rated. Cached a minute in memory and by clients.
GET /api/mods/{id}/rating The signed-in account's own {stars} (null when it hasn't rated), else 401
POST /api/mods/{id}/rating {"stars": 1..5}: sets or changes the rating. Answers {stars, average, count}.
  • One rating per GitHub account and project. The key is the account's numeric id, so a renamed account keeps its rating. Rating again replaces the old one.
  • Checked like a submission. The request must come from the site's origin, with a session and the session's CSRF token. Limits: 30 per account and 600 in all per hour.
  • Only published projects. The project must be mods/<id>.toml on the registry's main. Its owners can't rate it.
  • Sign-in comes back to the page. The sign-in takes ?back=/mods/<id> (or /mods), so a project's page brings the player back after GitHub. Any other value falls back to /mods/submit.
  • Docker image. It now starts as root only to chown the volume (Railway mounts volumes owned by root), then runs as nobody through setpriv, which util-linux ships in Debian.

Deploy

I created the volume registry-data (500 MB, /data) on the service horizon-mod-registry before this PR, so the first deploy finds it. No new secrets. Once this merges, I'll check that the Railway build and the health check pass.

Self-check

  • cargo test in crates/horizon-mod-registry: 2 unit tests + 3 integration tests pass. The new ratings test covers: signed out; wrong CSRF; 0 and 6 stars; rate, then change; own rating; own project refused; unpublished project refused; a second account; totals; the hourly limit; back accepted and refused.
  • cargo clippy --all-targets -- -D warnings in the crate: clean. cargo fmt: clean.
  • tools/pr_ready.py --quick: public tree check, rustfmt and clippy passed. The game workspace doesn't build this crate (CI's mod-registry.yml does).

Needs Ludovic

Nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2167 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/mod-ratings-api` --- ### 📝 Commits (1) - [`4558172`](https://github.com/horizon-rust/horizon/commit/455817204f21983955e1e83ef57026caa89d55d9) Mod registry: 1-5 star ratings, one per GitHub account ### 📊 Changes **8 files changed** (+577 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-mod-registry/Cargo.lock` (+79 -5) 📝 `crates/horizon-mod-registry/Cargo.toml` (+2 -0) 📝 `crates/horizon-mod-registry/Dockerfile` (+4 -2) 📝 `crates/horizon-mod-registry/README.md` (+16 -8) 📝 `crates/horizon-mod-registry/src/lib.rs` (+231 -41) 📝 `crates/horizon-mod-registry/src/main.rs` (+3 -2) ➕ `crates/horizon-mod-registry/src/ratings.rs` (+129 -0) 📝 `crates/horizon-mod-registry/tests/submit.rs` (+113 -8) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Ludovic asked for star ratings in the mod browser. This is the service side. The launcher and website UI come in their own PRs. The registry service (`crates/horizon-mod-registry`) now keeps players' ratings of published projects, 1 to 5 stars, in one SQLite file (`REGISTRY_DB`, default `/data/registry.sqlite3`): | Route | | |---|---| | `GET /api/mods/ratings` | `{projects: {<id>: {average, count}}}`: totals only, never who rated. Cached a minute in memory and by clients. | | `GET /api/mods/{id}/rating` | The signed-in account's own `{stars}` (`null` when it hasn't rated), else 401 | | `POST /api/mods/{id}/rating` | `{"stars": 1..5}`: sets or changes the rating. Answers `{stars, average, count}`. | - **One rating per GitHub account and project.** The key is the account's numeric id, so a renamed account keeps its rating. Rating again replaces the old one. - **Checked like a submission.** The request must come from the site's origin, with a session and the session's CSRF token. Limits: 30 per account and 600 in all per hour. - **Only published projects.** The project must be `mods/<id>.toml` on the registry's `main`. Its `owners` can't rate it. - **Sign-in comes back to the page.** The sign-in takes `?back=/mods/<id>` (or `/mods`), so a project's page brings the player back after GitHub. Any other value falls back to `/mods/submit`. - **Docker image.** It now starts as root only to `chown` the volume (Railway mounts volumes owned by root), then runs as `nobody` through `setpriv`, which util-linux ships in Debian. ## Deploy I created the volume `registry-data` (500 MB, `/data`) on the service `horizon-mod-registry` before this PR, so the first deploy finds it. No new secrets. Once this merges, I'll check that the Railway build and the health check pass. ## Self-check - `cargo test` in `crates/horizon-mod-registry`: 2 unit tests + 3 integration tests pass. The new `ratings` test covers: signed out; wrong CSRF; 0 and 6 stars; rate, then change; own rating; own project refused; unpublished project refused; a second account; totals; the hourly limit; `back` accepted and refused. - `cargo clippy --all-targets -- -D warnings` in the crate: clean. `cargo fmt`: clean. - `tools/pr_ready.py --quick`: public tree check, rustfmt and clippy passed. The game workspace doesn't build this crate (CI's `mod-registry.yml` does). ## Needs Ludovic Nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:27 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4065
No description provided.