Commit Graph

106 Commits

Author SHA1 Message Date
MingxuanGame
046f894407 refactor(assets_proxy): use decorators to simplify code 2025-10-03 17:12:28 +00:00
MingxuanGame
d490239f46 chore(linter): update ruff rules 2025-10-03 15:46:53 +00:00
MingxuanGame
0d9019c6cc refactor(signalr): remove SignalR server & msgpack_lazer_api
Maybe we can make `msgpack_lazer_api` independent?
2025-10-03 13:20:12 +00:00
MingxuanGame
d23f32f08d refactor(log): refactor the whole project
format: {time:YYYY-MM-DD HH:mm:ss} [{level}] | {name} | {message}
{name} is:
- Uvicorn: log from uvicorn server (#228B22)
- Service: log from class of `app.service` (blue)
- Fetcher: log from fetchers (magenta)
- Task: log from `app.tasks` (#FFD700)
- System: log from `system_logger` (red)
- Normal: log from `log(name)` (#FFC1C1)
- Default: the module name of caller

if you are writing services or tasks, you can just call `logger.`, we will pack it with name `Service` or `Task`
if you want to print fetcher logs, system-related logs, or normal logs, use `logger = (fetcher_logger / system_logger / log)(name)`
2025-10-03 11:53:05 +00:00
MingxuanGame
fce88272b5 refactor(task): move schedulers and startup/shutdown task into tasks directory 2025-10-03 10:15:22 +00:00
MingxuanGame
346c2557cf refactor(api): use Annotated-style dependency injection 2025-10-03 05:41:31 +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
9a77c8d246 feat(beatmapset): use https://catboy.best as global downloading service 2025-10-02 14:50:36 +00:00
MingxuanGame
f31056ced3 perf(score): divide score processing into small parts and make them run in background
resolve #47
2025-10-02 14:30:57 +00: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
017b058e63 chore(linter): make linter happy 2025-09-30 07:57:08 +00:00
咕谷酱
3a434ee02c 修复部分报错 2025-09-24 03:04:09 +08:00
咕谷酱
86c7bbb74e 优化验证 2025-09-24 02:08:13 +08:00
咕谷酱
8054281b15 添加防止重放攻击 2025-09-24 00:35:57 +08:00
咕谷酱
79805c2858 Update ranking.py 2025-09-23 02:37:04 +08:00
咕谷酱
0cd10bc543 修复排行榜返回用户数量问题 2025-09-23 02:36:20 +08:00
咕谷酱
bb06643de8 fix error 2025-09-23 01:56:50 +08:00
咕谷酱
f8e5fdc08e 添加排行榜/战队 total字段 2025-09-23 01:54:00 +08:00
咕谷酱
edbf01daa1 添加谱面查询缓存 2025-09-23 01:34:43 +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
MingxuanGame
bef303cc93 fix(ranking): missing arguments when calling get_country_ranking 2025-09-21 05:28:28 +00:00
MingxuanGame
ca9a2abc6f fix(ranking): remove redirect to make client to access
Client will not attach `Authorization` to the redirected request
2025-09-21 05:23:06 +00:00
MingxuanGame
ad78663ba0 chore(linter): make ruff happy 2025-09-20 10:41:15 +00:00
咕谷酱
08ff35509e 修复代理问题,添加头像接口 2025-09-19 17:02:24 +08:00
咕谷酱
0b43f2aad8 支持个人介绍编辑 2025-09-16 00:33:46 +08:00
咕谷酱
6baaeda1af 修复 kudosu 422 错误 2025-09-15 18:22:27 +08:00
咕谷酱
fa6b7487aa 占位 kudosu 接口 2025-09-15 18:11:45 +08:00
MingxuanGame
c31c05d3f6 fix(score): typo eventgi_payload -> event_payload 2025-09-14 06:53:13 +00:00
MingxuanGame
19f94fffbb feat(api): 支持 x-api-version (#29)
* feat(relationship): support legacy-compatible response format

* feat(score): add support for legacy score response format in API

* fix(score): avoid missing greenlet

* fix(score): fix missing field for model validation

* feat(user): apply legacy score format for user

* feat(api): use `int` to hint `APIVersion`
2025-09-14 14:09:53 +08:00
MingxuanGame
ad6bed4333 fix(relationship): add check for non-existent target user 2025-09-14 05:01:05 +00:00
MingxuanGame
c4f002fd45 fix(room): change the scope of get room API from lazer to public 2025-09-14 04:56:27 +00:00
MingxuanGame
6382b744c1 chore(deps): upgrade packages 2025-09-13 16:41:35 +00:00
MingxuanGame
7d0b2c657d feat(event): replace beatmap url with server url 2025-09-13 14:38:43 +00:00
MingxuanGame
c167cbcea6 feat(score): add specific rate limit for download replay API 2025-08-30 12:28:53 +00:00
MingxuanGame
617fdc2cfc fix(api): see details
/team/{team_id}: fix tag typo

beatmapset: remove download-service API

API Doc: fix v1 APi prefix
2025-08-30 12:08:31 +00:00
MingxuanGame
59ee88c603 feat(team): return team & member count in ranking 2025-08-30 11:58:43 +00:00
MingxuanGame
e872c25918 fix(score): make scores of loved beatmap as ranked scores 2025-08-30 11:49:23 +00: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
MingxuanGame
fdb08fe31f fix(rate-limit): apply on router to avoid TypeError on ws endpoint 2025-08-28 16:41:33 +00:00
MingxuanGame
c7f6c76b0f refactor(api): standardizate API Router 2025-08-28 13:49:34 +00:00
MingxuanGame
7ec716d4de feat(user): support get the user's first scores 2025-08-26 16:42:57 +00:00
MingxuanGame
d2e3b86bd1 feat(user): only show activities of the last 30 days 2025-08-26 16:07:27 +00:00
MingxuanGame
bc12182770 fix(user): rank lost event uses the owner of the displaced score's username 2025-08-26 15:53:32 +00:00
MingxuanGame
8d9f1d2750 feat(ranking): support team ranking 2025-08-26 10:51:31 +00:00
MingxuanGame
d11303b562 fix(score): return failed score which read from cache & remove legacy score error 2025-08-26 13:18:11 +08:00
MingxuanGame
29857506f2 refactor(lio): use REALTIME for multiplayer room 2025-08-26 13:18:11 +08:00
MingxuanGame
2f033f108a fix(playlist): cannot get playlist rooms 2025-08-26 13:18:11 +08:00
pre-commit-ci[bot]
7625cd99f5 chore(deps): auto fix by pre-commit hooks 2025-08-26 13:18:11 +08:00
咕谷酱
6fa9d5ba79 修复密码房问题 2025-08-26 13:18:11 +08:00