}
}
+// Wrapper around makeIncreasedSOARecord()
+static void updateZoneSerial(DomainInfo& domainInfo, SOAData& soaData, const std::string& increaseKind, const std::string& editKind)
+{
+ DNSResourceRecord resourceRecord;
+
+ if (makeIncreasedSOARecord(soaData, increaseKind, editKind, resourceRecord)) {
+ if (!domainInfo.backend->replaceRRSet(domainInfo.id, resourceRecord.qname, resourceRecord.qtype, vector<DNSResourceRecord>(1, resourceRecord))) {
+ throw ApiException("Hosting backend does not support editing records.");
+ }
+ }
+}
+
// Must be called within backend transaction.
static void updateDomainSettingsFromDocument(UeberBackend& backend, DomainInfo& domainInfo, const ZoneName& zonename, const Json& document, bool zoneWasModified)
{
string soa_edit_kind;
domainInfo.backend->getDomainMetadataOne(zonename, "SOA-EDIT", soa_edit_kind);
- DNSResourceRecord resourceRecord;
- if (makeIncreasedSOARecord(soaData, soa_edit_api_kind, soa_edit_kind, resourceRecord)) {
- if (!domainInfo.backend->replaceRRSet(domainInfo.id, resourceRecord.qname, resourceRecord.qtype, vector<DNSResourceRecord>(1, resourceRecord))) {
- throw ApiException("Hosting backend does not support editing records.");
- }
- }
+ updateZoneSerial(domainInfo, soaData, soa_edit_api_kind, soa_edit_kind);
}
}
// return old serial in headers, before changing it
resp->headers["X-PDNS-Old-Serial"] = std::to_string(soaData.serial);
- DNSResourceRecord resourceRecord;
- if (makeIncreasedSOARecord(soaData, soa_edit_api_kind, soa_edit_kind, resourceRecord)) {
- if (!domainInfo.backend->replaceRRSet(domainInfo.id, resourceRecord.qname, resourceRecord.qtype, vector<DNSResourceRecord>(1, resourceRecord))) {
- throw ApiException("Hosting backend does not support editing records.");
- }
- }
+ updateZoneSerial(domainInfo, soaData, soa_edit_api_kind, soa_edit_kind);
// return new serial in headers
resp->headers["X-PDNS-New-Serial"] = std::to_string(soaData.serial);