同步、邀请与专属令牌
待处理同步、接受/拒绝、邀请与邀请码/专属 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 | 从推荐人复制内容 |
数据流(接受同步)
- 产生 sync_record,状态
pending。 - 目标用户 POST
handle-update,action=accept。 - 合并至统一模块;更新状态;可能联动黑名单等。
关键文件
src/app/api/sync/**src/app/api/update-invite*.tssrc/app/api/user/*exclusive-token*、copy-from-referrersrc/app/api/resolve-exclusive-token/route.tssrc/models/sync.ts、src/lib/content-diff.ts
Dependencies
环境变量
DATABASE_URLADMIN_EMAILS— 若create-invitation等路由要求管理员(以具体route.ts为准)。
数据库(src/db/schema.ts)
content_sync_records、user_invitations、user_notification_blacklistusers—invite_code、invited_by、exclusive_link_token- accept 后:
user_profiles、user_module_configs、user_module_website_relations、user_custom_module_types、user_custom_websites等