VerifyDomain marks a domain as verified, only if owned by the given user.
(ctx context.Context, domain, userID string)
| 732 | |
| 733 | // VerifyDomain marks a domain as verified, only if owned by the given user. |
| 734 | func (s *Store) VerifyDomain(ctx context.Context, domain, userID string) error { |
| 735 | tag, err := s.pool.Exec(ctx, |
| 736 | `UPDATE domains SET verified = true, verified_at = now() |
| 737 | WHERE domain = $1 AND user_id = $2 AND verified = false`, |
| 738 | normalizeDomain(domain), userID, |
| 739 | ) |
| 740 | if err != nil { |
| 741 | return err |
| 742 | } |
| 743 | if tag.RowsAffected() == 0 { |
| 744 | return fmt.Errorf("domain not found, not owned by user, or already verified") |
| 745 | } |
| 746 | return nil |
| 747 | } |
| 748 | |
| 749 | // ListDomainsByUser returns all domains owned by the user (excludes system rows). |
| 750 | // AgentCount is computed inline via a correlated subquery — one round-trip |