fix: reject snapshot when template already attached (409); handle domains-load error; drop orphaned useDeleteDomain
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,16 @@ func (a *API) handleTemplateFromZone(w http.ResponseWriter, r *http.Request) {
|
||||
writeErr(w, http.StatusNotFound, "домен не найден")
|
||||
return
|
||||
}
|
||||
// This endpoint only makes sense for a domain with no template attached
|
||||
// yet — it snapshots the zone's live state into a brand-new template.
|
||||
// If a template is already bound, re-attaching a fresh snapshot would
|
||||
// silently orphan the existing one; re-pointing a domain to a different
|
||||
// template is a separate, explicit action and must not happen as a side
|
||||
// effect of a retried/duplicate POST here.
|
||||
if dom.TemplateID != nil {
|
||||
writeErr(w, http.StatusConflict, "шаблон уже привязан")
|
||||
return
|
||||
}
|
||||
recs, err := a.Svc.ZoneRecords(r.Context(), pid, did)
|
||||
if err != nil {
|
||||
log.Printf("api: template-from-zone: zone records failed: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user