fix: team invitation acceptance 404 error
- Relax team_sessions collection rules to allow authenticated users to view/update - Reorder respondInvitation: join session before marking invitation as accepted - Add $autoCancel: false to prevent request cancellation during invitation flow Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -77,20 +77,21 @@ export async function respondInvitation(
|
||||
updateData.rejectReason = rejectReason
|
||||
}
|
||||
|
||||
// 更新邀请状态
|
||||
await pb.collection('invitations').update(invitationId, updateData)
|
||||
|
||||
// 接受邀请:前端处理加入 team session + 更新用户状态
|
||||
// 接受邀请:先加入 team session,再更新邀请状态
|
||||
if (response === 'accepted') {
|
||||
const user = pb.authStore.model
|
||||
if (!user) return
|
||||
|
||||
// 获取邀请详情以找到 team session
|
||||
const invitation = await pb.collection('invitations').getOne(invitationId) as any
|
||||
const invitation = await pb.collection('invitations').getOne(invitationId, {
|
||||
$autoCancel: false
|
||||
}) as any
|
||||
const teamSessionId = invitation.teamSession
|
||||
|
||||
// 加入 team session
|
||||
const session = await pb.collection('team_sessions').getOne(teamSessionId) as any
|
||||
const session = await pb.collection('team_sessions').getOne(teamSessionId, {
|
||||
$autoCancel: false
|
||||
}) as any
|
||||
const members: string[] = session.members || []
|
||||
if (!members.includes(user.id)) {
|
||||
members.push(user.id)
|
||||
@@ -100,6 +101,9 @@ export async function respondInvitation(
|
||||
// 更新用户状态为 in_team
|
||||
await pb.collection('users').update(user.id, { status: 'in_team' })
|
||||
}
|
||||
|
||||
// 更新邀请状态
|
||||
await pb.collection('invitations').update(invitationId, updateData)
|
||||
}
|
||||
|
||||
// 订阅邀请变更
|
||||
|
||||
Reference in New Issue
Block a user