From 1eb82493966c15b6fb065de17f5ec190b8882f12 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 13 Mar 2026 17:28:23 +0700 Subject: [PATCH] [WIP] Add zone-level checker between domain-level and service-level --- internal/usecase/check/check_usecase.go | 9 +++++++++ model/checker.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/internal/usecase/check/check_usecase.go b/internal/usecase/check/check_usecase.go index 5f79a11b..1d9f0372 100644 --- a/internal/usecase/check/check_usecase.go +++ b/internal/usecase/check/check_usecase.go @@ -238,6 +238,14 @@ func (tu *checkerUsecase) buildAutoFillContext(userid *happydns.Identifier, doma if domainid != nil { if domain, err := tu.autoFillStore.GetDomain(*domainid); err == nil { ctx[happydns.AutoFillDomainName] = domain.DomainName + + if len(domain.ZoneHistory) > 0 { + // The first element in ZoneHistory is the current (most recent) zone. + zoneMsg, err := tu.autoFillStore.GetZone(domain.ZoneHistory[0]) + if err == nil { + ctx[happydns.AutoFillZone] = zoneMsg + } + } } } else if serviceid != nil && userid != nil { // To resolve service context we need to find which domain/zone owns the service. @@ -263,6 +271,7 @@ func (tu *checkerUsecase) buildAutoFillContext(userid *happydns.Identifier, doma if svc.Id.Equals(*serviceid) { ctx[happydns.AutoFillDomainName] = domain.DomainName ctx[happydns.AutoFillSubdomain] = string(subdomain) + ctx[happydns.AutoFillZone] = zoneMsg ctx[happydns.AutoFillService] = svc ctx[happydns.AutoFillServiceType] = svc.Type return ctx diff --git a/model/checker.go b/model/checker.go index 9929f3ef..0b96adcf 100644 --- a/model/checker.go +++ b/model/checker.go @@ -38,6 +38,10 @@ const ( // applicable for service-scoped tests. AutoFillSubdomain = "subdomain" + // AutoFillZone fills the option with the zone object. Only applicable + // for domain-scoped and service-scoped tests. + AutoFillZone = "zone" + // AutoFillServiceType fills the option with the service type identifier // (e.g. "abstract.MatrixIM"). Only applicable for service-scoped tests. AutoFillServiceType = "service_type"