Commit Graph

36 Commits

Author SHA1 Message Date
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
1163a93053 refactor(scores): rename models of score to match with filename 2025-10-04 08:01:38 +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
40670c094b feat(auth): support trusted device (#52)
New API to maintain sessions and devices:

- GET /api/private/admin/sessions
- DELETE /api/private/admin/sessions/{session_id}
- GET /api/private/admin/trusted-devices
- DELETE /api/private/admin/trusted-devices/{device_id}

Auth:

web clients request `/oauth/token` and `/api/v2/session/verify` with `X-UUID` header to save the client as trusted device.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-03 11:26:43 +08:00
MingxuanGame
3f6776847e feat(beatmap,score): update beatmaps from Bancho & deleting scores (#50)
New API:

- DELETE /api/private/score/{score_id}: delete a score
- POST /api/private/beatmapsets/{beatmapset_id}/sync: request for syncing a beatmapset

New configuration:

- OLD_SCORE_PROCESSING_MODE
2025-10-02 13:36:09 +08:00
MingxuanGame
1527e23b43 feat(session-verify): 添加 TOTP 支持 (#34)
* chore(deps): add pyotp

* feat(auth): implement TOTP verification

feat(auth): implement TOTP verification and email verification services

- Added TOTP keys management with a new database model `TotpKeys`.
- Introduced `EmailVerification` and `LoginSession` models for email verification.
- Created `verification_service` to handle email verification logic and TOTP processes.
- Updated user response models to include session verification methods.
- Implemented routes for TOTP creation, verification, and fallback to email verification.
- Enhanced login session management to support new location checks and verification methods.
- Added migration script to create `totp_keys` table in the database.

* feat(config): update config example

* docs(totp): complete creating TOTP flow

* refactor(totp): resolve review

* feat(api): forbid unverified request

* fix(totp): trace session by token id to avoid other sessions are forbidden

* chore(linter): make pyright happy

* fix(totp): only mark sessions with a specified token id
2025-09-21 19:50:11 +08:00
陈晋瑭
6c2e88c485 feat(beatmap): 添加谱面用户标签功能 (#25)
* feat(tags): 添加 beatmap tags 相关功能

- 新增 BeatmapTags 模型类,用于表示 beatmap 的标签信息
- 实现加载标签数据、根据 ID 获取标签、获取所有标签等功能

* feat(database): 新增 BeatmapTagVote 数据库模型和迁移脚本

* fix(database): 修改 BeatmapTagVote 模型并创建新表

- 将 BeatmapTagVote 模型的表名从 "beatmap_tag_votes" 改为 "beatmap_tags"
- 创建新的数据库迁移文件以替换错误的原迁移文件
- 删除错误的迁移文件 "4a827ddba235_add_table_beatmap_tags.py"

* feat(tags): 添加用户标签功能

- 在 BeatmapResp 类中添加了 top_tag_ids 和 current_user_tag_ids 字段
- 新增了 /tags 相关的路由,包括获取所有标签和投票/取消投票功能
- 实现了标签投票和取消投票的数据库操作

* fix(tags): 修复标签投票查询和返回过程中的逻辑问题

- 修复 BeatmapResp 类中 current_user_tag_ids 字段的查询逻辑
- 优化 vote_beatmap_tags 函数中的标签验证过程

* fix(tags): add suggested changes from reviews

- 在 BeatmapResp 中添加 top_tag_ids 和 current_user_tag_ids 字段
- 实现用户标签投票功能,包括检查用户是否有资格投票
- 优化标签数据的加载方式
- 调整标签相关路由,增加路径参数描述

* fix(tags): apply changes from review

* fix(tag): apply changes from review suggests

- 更新标签接口文档,统一参数描述
- 修改标签投票接口状态码为 204
- 优化标签投票接口的用户认证方式
- 改进标签相关错误处理,使用更友好的错误信息

* fix(tag): use client authorization

* chore(linter): auto fix by pre-commit hooks

---------

Co-authored-by: MingxuanGame <MingxuanGame@outlook.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-08-30 16:23:59 +08:00
陈晋瑭
3c5336ed61 添加谱面用户打分(评分)相关接口 (#24)
* feat(database): 添加 beatmap_ratings 表用于用户评分

- 新增 BeatmapRating 模型类,用于表示 beatmap_ratings 表
- 该表包含 id、beatmapset_id、user_id 字段
- 建立与 Beatmapset 和 User 表的关联关系

* feat(beatmapset_ratings): 添加判断用户是否可以对谱面集进行评分的接口

- 新增 /beatmapsets/{beatmapset_id}/can_rate 接口
- 判断用户是否能对谱面集进行过评分,返回True/False

* feat(ratings): 添加为谱面评分的接口

- 新增 POST /beatmapsets/{beatmapset_id} 路由,用于用户给谱面集评分
- 实现谱面集评分的添加和更新逻辑
- 在 BeatmapRating 模型中添加 rating 字段 (漏了最重要的,我真tm丢脸)

* chore(database): 添加alembic数据库迁移脚本

* fix(ratings): 更改上传谱面打分的api路径,防止冲突

* fix(ratings): add changes from pr review

* refactor(ratings): remove swears from code

* feat(ratings): 从beatmapset中移除ratings字段,并改由从beatmap_ratings表中直接计算评分

* chore(deps): 添加 git 包并更新依赖项

- 在 builder 阶段添加了 git 包的安装

* chore(database): 更新数据库连接地址并删除意外的迁移脚本

- 将 Alembic 配置文件中的数据库连接地址从本地地址改为 Docker Compose 中的 mysql 服务地址
- 删除了 migrations/versions 目录下的 dba1f8d9992e_add_beatmap_ratings_table.py 文件

* chore(database): generate alembic script for beatmap ratings

* fix(ratings): apply changes suggested in review

- revert changes to alembic.ini
- add name to apis
- modify migration scripts

* chore: format server.py using ruff

- who forgot to do this?

* fix(migrate): fix remove achievement index

* perf(rating): optimize SQL query

* fix(rating): ensure user can rate beatmapset

* fix(rating): add boundary check

* chore(project): remove submodule

---------

Co-authored-by: MingxuanGame <MingxuanGame@outlook.com>
2025-08-28 20:55:00 +08:00
MingxuanGame
545fc9e0c6 fix(recent_activity): fix rank & achievement event
运行 tools/fix_user_rank_event.py 修复现存的 event
2025-08-22 11:00:36 +00:00
MingxuanGame
f63eb97486 feat(team): support team 2025-08-22 04:21:36 +00:00
咕谷酱
3bee2421fa 添加邮件验证 2025-08-22 08:19:12 +08:00
MingxuanGame
9fb0d0c198 feat(notification): support notification 2025-08-21 07:22:44 +00:00
咕谷酱
6e496a1123 add ip log 2025-08-18 00:23:57 +08:00
MingxuanGame
f992e4cc71 feat(chat): support public channel chat 2025-08-16 05:29:16 +00:00
MingxuanGame
a8906b8194 feat(v1-api): support api v1 2025-08-14 09:11:53 +00:00
MingxuanGame
52df05648c feat(user): support global rank & country rank 2025-08-12 13:36:15 +00:00
MingxuanGame
6e71141146 feat(developer): support custom OAuth 2.0 client 2025-08-11 12:33:31 +00:00
MingxuanGame
b9babb8f24 feat(score): support download replay 2025-08-11 08:19:05 +00:00
MingxuanGame
bee0befc26 chore(merge): merge pull request #8 from feat/multiplayer-api
feat: 增加mp房间相关接口
2025-08-10 00:00:47 +08:00
MingxuanGame
832a6fc95d feat(daily-challenge): simple implement 2025-08-09 11:18:29 +00:00
MingxuanGame
319599cacc feat(multiplayer,playlist): show host & renect participants 2025-08-09 05:49:01 +00:00
MingxuanGame
d7002374b6 fix(playlist): fix user attempts 2025-08-09 04:53:20 +00:00
MingxuanGame
7a2c8c1fb4 feat(multiplayer): support multiplayer events 2025-08-07 16:18:54 +00:00
MingxuanGame
bc2961de10 feat(playlist): support leaderboard
**UNTESTED**
2025-08-07 14:52:02 +00:00
MingxuanGame
4f3ab38454 feat(beatmap): support playcount & passcount 2025-08-06 12:07:12 +00:00
MingxuanGame
87bb74d1ca feat(multiplayer): support leaderboard 2025-08-06 10:51:37 +00:00
MingxuanGame
a25cb852d9 feat(multiplay): support CreateRoom hub method 2025-08-01 11:08:59 +00:00
MingxuanGame
d938998239 feat(beatmapset): support post favoutite to beatmapset 2025-08-01 04:22:17 +00:00
MingxuanGame
1635641654 feat(score): support leaderboard for country/friends/team/selected mods 2025-07-31 14:11:42 +00:00
MingxuanGame
9ce99398ab refactor(user): refactor user database
**Breaking Change**

用户表变为 lazer_users

建议删除与用户关联的表进行迁移
2025-07-30 16:17:09 +00:00
MingxuanGame
70399a2e50 feat(score): update statistics & return user in score 2025-07-29 07:36:33 +00:00
MingxuanGame
b359be3637 feat(solo-score): support submit solo scores 2025-07-27 02:33:42 +00:00
MingxuanGame
ef977d1c2d feat(relationship): implement relationship(friends, blocks) api (close #6) 2025-07-26 15:31:09 +00:00
MingxuanGame
585cb9d98a fix(database): fix score database 2025-07-26 12:05:54 +08:00
MingxuanGame
376d98ad5a feat(beatmap,beatmapset): get beatmap & beatmapset information by id 2025-07-25 17:01:01 +08:00
MingxuanGame
f8abc7067f refactor(database): re-structure 2025-07-24 21:01:00 +08:00