Skip to main content
四个端点全部挂 supabaseAuth()(Bearer JWT,用户 ID 取 jwtPayload.sub)。源:src/hono/support/index.ts

GET /support/hash

为 Front Chat 生成身份验证哈希(identity verification)。

响应

{ "email": "user@example.com", "userHash": "hex hmac" }
  • userHash = HMAC-SHA256(secret = FRONT_CHAT_SECRET, message = userId) 的 hex
  • email 取自 Supabase auth user

错误

状态码含义
401无 JWT
500取不到 user email / FRONT_CHAT_SECRET 未配置

POST /support/delete-account

调度账号删除(30 天倒计时),不立即删。

请求体

{ "reason": "string", "reasonText": "string (可选)" }
reason 必填,缺失 → 400。

响应

{ "message": "ok" }

副作用

  1. 先查 get_account_deletion_status RPC,已调度 → 409
  2. 入队 account_deletion PGMQ(sleep_seconds: 30 * 24 * 3600,30 天后触发硬删 → DELETE /user/
  3. 入队 account_deletion_reminder PGMQ(sleep_seconds: 27 * 24 * 3600,删除前 3 天提醒)
  4. insert deletion_reasons (user_id, reason, reason_text)
  5. fire-and-forget notify("account_deletion.scheduled", userId)(kira-notify 发确认邮件)

错误

状态码含义
400reason 缺失
401无 JWT
409已有调度中的删除
500PGMQ send 失败

GET /support/deletion-status

查询当前用户的删除调度状态。

响应

{ "scheduled": true, "deletionDate": "2026-07-03T..." }
或:
{ "scheduled": false }
deletionDate 取队列消息的 vt(visible-at 时间,即 30 天后的触发时刻)。

错误

状态码含义
401无 JWT
500get_account_deletion_status RPC 失败

POST /support/cancel-delete-account

取消已调度的账号删除。

响应

{ "message": "ok" }

副作用

  1. get_account_deletion_status 拿到 msg_id,无调度 → 404
  2. pgmq_public.delete(queue_name: "account_deletion", message_id: msgId) 删除主删除消息
  3. get_account_deletion_reminder_status 拿 reminder msg_idpgmq_public.deleteaccount_deletion_reminder
  4. delete deletion_reasons where user_id = userId
  5. fire-and-forget notify("account_deletion.cancelled", userId)

错误

状态码含义
401无 JWT
404无调度中的删除
500RPC / PGMQ delete 失败

src/hono/support/index.ts

相关