R-415 fixed on hub main (no duplicate/nested/felhom.eu customer domain; R-138 option B); R-762 closed (9202 proven, catalog eec9a0d); R-905 opened (wger static in backups); decision sheet D10; 130 -> 129
gates / gates (push) Successful in 3m55s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-08 10:19:39 +02:00
parent 78121aa475
commit d9147b02de
18 changed files with 818 additions and 9 deletions
+47
View File
@@ -0,0 +1,47 @@
package store
import "strings"
// R-415 / R-138 option B (2026-10-08; operator ruling 2026-09-14, `01` §7: every customer has their OWN domain, never a
// name under felhom.eu). The hub enforced uniqueness on customer_id only, so two customers could be given the same
// domain — or one inside the other, a shared zone in all but name — silently. DomainConflict answers, for a domain about
// to be saved for customerID, which rule it breaks ("" = none):
//
// - "felhom.eu" — the domain is felhom.eu or a name under it;
// - "<other id>" — another customer's domain equals it, contains it, or lies under it.
//
// Matching is case-insensitive, ignores a trailing dot, and is on LABEL boundaries („notexample.hu" is not under
// „example.hu"). An empty domain conflicts with nothing. Pinned by TestR415_* (domain_conflict_test.go) and the
// handler test TestR415_CreateAndEditRefuseConflictingDomain.
func (s *Store) DomainConflict(customerID, domain string) (string, error) {
d := normDomain(domain)
if d == "" {
return "", nil
}
if d == "felhom.eu" || strings.HasSuffix(d, ".felhom.eu") {
return "felhom.eu", nil
}
rows, err := s.db.Query(`SELECT customer_id, domain FROM customer_configs WHERE customer_id != ? AND domain != ''`, customerID)
if err != nil {
return "", err
}
defer rows.Close()
for rows.Next() {
var id, other string
if err := rows.Scan(&id, &other); err != nil {
return "", err
}
o := normDomain(other)
if o == "" {
continue
}
if d == o || strings.HasSuffix(d, "."+o) || strings.HasSuffix(o, "."+d) {
return id, nil
}
}
return "", rows.Err()
}
func normDomain(d string) string {
return strings.TrimSuffix(strings.ToLower(strings.TrimSpace(d)), ".")
}