fix(account): exclude failed sessions when looking up sign session by invite code

When multiple sign sessions share the same invite code (due to retries),
the query now:
1. Excludes failed sessions (status != 'failed')
2. Orders by created_at DESC to get the most recent session
3. Limits to 1 result

This prevents participants from seeing an old failed session's status
when they look up the invite code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-31 02:09:18 -08:00
parent 138650d943
commit cd63643ba4
1 changed files with 3 additions and 1 deletions

View File

@ -691,7 +691,9 @@ func (h *CoManagedHTTPHandler) GetSignSessionByInviteCode(c *gin.Context) {
SELECT id, COALESCE(wallet_name, ''), COALESCE(keygen_session_id::text, ''),
threshold_n, threshold_t, status, expires_at, COALESCE(message_hash, '')
FROM mpc_sessions
WHERE invite_code = $1 AND session_type = 'sign'
WHERE invite_code = $1 AND session_type = 'sign' AND status != 'failed'
ORDER BY created_at DESC
LIMIT 1
`, inviteCode).Scan(&sessionID, &walletName, &keygenSessionID, &thresholdN, &thresholdT, &status, &expiresAt, &messageHash)
if err != nil {