同步、邀请与专属令牌

待处理同步、接受/拒绝、邀请与邀请码/专属 token API。

同步(/api/sync/*)

路由作用
POST /api/sync/handle-update对 pending 同步记录执行 accept | reject | ignore;校验 target_user_uuid;accept 时合并差异到统一模块(generateContentDiff、unified-modules-simple)
GET /api/sync/pending-updates当前用户待处理列表
POST /api/sync/trigger-update-check触发服务端更新检查
POST /api/sync/batch-handle-update批量处理
POST /api/sync/create-invitation创建同步/分享邀请(权限见路由实现)

模型 src/models/sync.ts。

邀请与口令

路由作用
POST /api/update-invite更新邀请相关信息
POST /api/update-invite-code更新邀请码
.../admin/invitations管理端邀请
POST /api/user/generate-exclusive-token生成专属 token
POST /api/user/update-exclusive-token更新 token
POST /api/resolve-exclusive-token服务端解析 token
POST /api/user/copy-from-referrer从推荐人复制内容

数据流(接受同步)

  1. 产生 sync_record,状态 pending。
  2. 目标用户 POST handle-update,action=accept。
  3. 合并至统一模块;更新状态;可能联动黑名单等。

关键文件

  • src/app/api/sync/**
  • src/app/api/update-invite*.ts
  • src/app/api/user/*exclusive-token*、copy-from-referrer
  • src/app/api/resolve-exclusive-token/route.ts
  • src/models/sync.ts、src/lib/content-diff.ts

Dependencies

环境变量

  • DATABASE_URL
  • ADMIN_EMAILS — 若 create-invitation 等路由要求管理员(以具体 route.ts 为准)。

数据库(src/db/schema.ts)

  • content_sync_records、user_invitations、user_notification_blacklist
  • users — invite_code、invited_by、exclusive_link_token
  • accept 后: user_profiles、user_module_configs、user_module_website_relations、user_custom_module_types、user_custom_websites 等
同步、邀请与专属令牌 | 追踪狗文档