package storage import ( "context" "fmt" "time" ) func (s *Store) RevokeOwnForwardSessionAudited(ctx context.Context, userID, sessionID string, audit AppendAuditInput) error { return s.RevokeOwnForwardSessionAuditedAt(ctx, userID, sessionID, audit, s.now()) } func (s *Store) RevokeOwnForwardSessionAuditedAt(ctx context.Context, userID, sessionID string, audit AppendAuditInput, now time.Time) error { const operation = "revoke own forward session" if err := s.checkOpen(operation); err != nil { return err } tx, err := s.sql.BeginTx(ctx, nil) if err != nil { return classify("begin "+operation, err) } defer tx.Rollback() changed, err := execCount(ctx, tx, operation, `UPDATE forward_sessions SET revoked = 1 WHERE id = ? AND user_id = ? AND revoked = 0`, sessionID, userID) if err != nil { return err } if changed == 0 { return fmt.Errorf("%s: %w", operation, ErrNotFound) } if _, err := appendAudit(ctx, tx, operation+" audit", audit, canonicalTime(now)); err != nil { return err } return classify("commit "+operation, tx.Commit()) }