Commit Graph

22 Commits

Author SHA1 Message Date
MingxuanGame
40da994ae8 refactor(database): use a new 'On-Demand' design (#86)
Technical Details: https://blog.mxgame.top/2025/11/22/An-On-Demand-Design-Within-SQLModel/
2025-11-23 21:41:02 +08:00
咕谷酱
a4dbb9a167 feat(matchmaking): support matchmaking (#48) 2025-10-19 00:05:06 +08:00
MingxuanGame
10caa82320 feat(user-preference): add user preference support (#55)
APIs:

- GET `/api/private/user/preferences`: Get current user's preferences.
- PATCH `/api/private/user/preferences`: Modify current user's preferences. (body: Preferences)
- PUT `/api/private/user/preferences`: Overwrite current user's preferences. (body: Preferences)
- DELETE `/api/private/user/preferences`: Reset current user's preferences. (body: list[str])
  - body specifies the content to be reset. If body is empty, reset all preferences.

User:

- `User.g0v0_playmode`: show the special ruleset like `OSURX`, and custom rulesets in the future.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-06 20:57:17 +08:00
MingxuanGame
febc1d761f feat(user): implement user restrictions
## APIs Restricted for Restricted Users

A restricted user is blocked from performing the following actions, and will typically receive a `403 Forbidden` error:

*   **Chat & Notifications:**
    *   Sending any chat messages (public or private).
    *   Joining or leaving chat channels.
    *   Creating new PM channels.
*   **User Profile & Content:**
    *   Uploading a new avatar.
    *   Uploading a new profile cover image.
    *   Changing their username.
    *   Updating their userpage content.
*   **Scores & Gameplay:**
    *   Submitting scores in multiplayer rooms.
    *   Deleting their own scores (to prevent hiding evidence of cheating).
*   **Beatmaps:**
    *   Rating beatmaps.
    *   Taging beatmaps.
*   **Relationship:**
    *   Adding friends or blocking users.
    *   Removing friends or unblocking users.
*   **Teams:**
    *   Creating, updating, or deleting a team.
    *   Requesting to join a team.
    *   Handling join requests for a team they manage.
    *   Kicking a member from a team they manage.
*   **Multiplayer:**
    *   Creating or deleting multiplayer rooms.
    *   Joining or leaving multiplayer rooms.

## What is Invisible to Normal Users

*   **Leaderboards:**
    *   Beatmap leaderboards.
    *   Multiplayer (playlist) room leaderboards.
*   **User Search/Lists:**
    *   Restricted users will not appear in the results of the `/api/v2/users` endpoint.
    *   They will not appear in the list of a team's members.
*   **Relationship:**
    *   They will not appear in a user's friend list (`/friends`).
*   **Profile & History:**
    *   Attempting to view a restricted user's profile, events, kudosu history, or score history will result in a `404 Not Found` error, effectively making their profile invisible (unless the user viewing the profile is the restricted user themselves).
*   **Chat:**
    *   Normal users cannot start a new PM with a restricted user (they will get a `404 Not Found` error).
*   **Ranking:**
    *   Restricted users are excluded from any rankings.

### How to Restrict a User

Insert into `user_account_history` with `type=restriction`.

```sql
-- length is in seconds
INSERT INTO user_account_history (`description`, `length`, `permanent`, `timestamp`, `type`, `user_id`) VALUE ('some description', 86400, 0, '2025-10-05 01:00:00', 'RESTRICTION', 1);
```

---

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-06 11:10:25 +08:00
MingxuanGame
1163a93053 refactor(scores): rename models of score to match with filename 2025-10-04 08:01:38 +00:00
MingxuanGame
ca7c74f709 refactor(project): remove useless getattr 2025-10-04 06:43:55 +00:00
MingxuanGame
d490239f46 chore(linter): update ruff rules 2025-10-03 15:46:53 +00:00
MingxuanGame
37b4eadf79 refactor(database): rename filename to find the models by table name easily 2025-10-03 03:33:47 +00:00
MingxuanGame
9ce99398ab refactor(user): refactor user database
**Breaking Change**

用户表变为 lazer_users

建议删除与用户关联的表进行迁移
2025-07-30 16:17:09 +00:00
MingxuanGame
0cba7e9dd2 fix(relationship): add target in response 2025-07-28 15:19:56 +00:00
MingxuanGame
e1ce364ac9 feat(user): support search user 2025-07-28 14:18:43 +00:00
MingxuanGame
9b889bc602 feat(database): use alembic 2025-07-28 13:09:55 +00:00
MingxuanGame
ec241ac200 fix(solo-score): fix submit solo-score & Bigint 2025-07-27 04:11:41 +00:00
MingxuanGame
b359be3637 feat(solo-score): support submit solo scores 2025-07-27 02:33:42 +00:00
MingxuanGame
585cb9d98a fix(database): fix score database 2025-07-26 12:05:54 +08:00
jimmy-sketch
7ea4570c17 feat(api): 添加测试,小修小补
- **未经测试**
2025-07-26 10:28:48 +08:00
陈晋瑭
75e7350649 Merge branch 'main' into score-database-model 2025-07-25 21:21:01 +08:00
MingxuanGame
f347b680b2 refactor(database): use asyncio 2025-07-25 20:43:50 +08:00
陈晋瑭
674b79cc91 Merge branch 'main' into score-database-model 2025-07-25 20:04:13 +08:00
MingxuanGame
376d98ad5a feat(beatmap,beatmapset): get beatmap & beatmapset information by id 2025-07-25 17:01:01 +08:00
jimmy-sketch
86e815b4e2 feat(database): 新增 Score 数据库模型并更新 User 关系
- 创建 Score 类作为成绩数据库模型,对应 osu! API 中的 Score 对象
- 在 User 模型中添加与 Score 的关系- 优化了数据库表结构,增加了索引和字段约束
2025-07-25 12:34:56 +08:00
MingxuanGame
f8abc7067f refactor(database): re-structure 2025-07-24 21:01:00 +08:00