Repository navigation
下线旧 notify token,推送统一改用 API Key(POST /api/notify) - #112
Merged
todosdev[bot] merged 1 commit intoOct 17, 2026
Merged
Conversation
- POST /api/notify/:token now returns 410 Gone and no longer reads the KV notify_token record or queries the DB; legacy clients must migrate to POST /api/notify with an enk_... bearer key. - POST/DELETE /api/me/notifications/token(/:token) now return 410 Gone and no longer generate or delete any token. - Inlined the now single-caller notifyByUserId helper into POST /api/notify, removed the unused findUserById import, and dropped the :token rate limiter since the deprecated route no longer touches KV. - Log redaction for /api/notify/<token> (index.ts) is unchanged; README (zh/en) updated to document the retirement and the API-key migration path. Existing notify_token:* KV records are left to expire within their one-year TTL; no migration cleanup is needed. Checkpoint: 2IOucMQCOPHQph6u7Ww6n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/notify。POST /api/notify/:token及 token 管理接口POST/DELETE /api/me/notifications/token(/:token)现在一律返回410 Gone,不再读 KV、不查库、不发推送,也不生成/删除任何 token。POST /api/notify(API Key / cookie)行为与 30 次/分钟限流保持不变。Changes
worker/src/routes/notify.tsPOST /api/notify/:token改为静态返回410 Gone,提示改用POST /api/notify+Authorization: Bearer enk_...。/:token上的rateLimit中间件(其本身会读写 KV,与「不碰 KV」冲突)。notifyByUserId内联进POST /,并删除不再使用的findUserById、Context导入。worker/src/routes/me.tsPOST /api/me/notifications/token与DELETE /api/me/notifications/token/:token改为返回410 Gone,共用NOTIFY_TOKEN_DEPRECATED常量,不再生成或删除 token。README.md/README.en.md/api/notify/:token与新路由共享 30 次/分钟限流」的说明,改为补一句 token 已下线、返回 410、请改用 API Key。未改动:
worker/src/index.ts的日志脱敏正则(/api/(setup|notify)/...)保留,旧客户端仍会请求/api/notify/<token>。已存在的
notify_token:*KV 记录不做专门清理,会在一年 TTL 内自然过期(它们已不再被任何代码路径读取)。Testing
本地
wrangler dev实测(注册用户 → 登录拿 cookie → 建 API Key → 配置 webhook 渠道指向 webhook.site):POST /api/notify/sometoken→410 Gone,报文提示改用 API Key,且 webhook.site 未收到任何推送。POST /api/me/notifications/token(cookie)→410 Gone;DELETE /api/me/notifications/token/abc(cookie)→410 Gone。POST /api/notify+ 无效 key →401 Unauthorized;+ 有效enk_...key →200且 webhook.site 收到真实推送;+ cookie →200且收到真实推送。pnpm typecheck、pnpm build、pnpm format:check全部通过;pnpm lint无 error(仅 2 条与本次改动无关的既有 warning)。仓库不跟踪生成产物:
web/dist、worker无构建产物纳入版本控制,pnpm build已在本机重新验证通过,无需额外提交产物。