mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-07-26 11:38:13 +00:00
Improve DNS record synchronization with providers.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/f7fa905d-72e6-4805-8324-0dbaae1462ea.jpg
This commit is contained in:
@@ -239,6 +239,21 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
req.user?.id
|
||||
);
|
||||
|
||||
// Sync with provider if applicable
|
||||
try {
|
||||
const providerRecordId = await syncDnsRecordWithProvider('create', record.domainId, record);
|
||||
if (providerRecordId) {
|
||||
console.log(`Record synced with provider, got provider record ID: ${providerRecordId}`);
|
||||
// Update the record with the provider record ID
|
||||
await storage.updateDnsRecord(record.id, {
|
||||
providerRecordId
|
||||
});
|
||||
}
|
||||
} catch (providerError) {
|
||||
console.error("Error syncing with provider (continuing):", providerError);
|
||||
// We don't fail the request if provider sync fails
|
||||
}
|
||||
|
||||
// Trigger webhooks
|
||||
await triggerDnsWebhooks("create", record.domainId, record, null, req.user?.id);
|
||||
|
||||
@@ -318,6 +333,27 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
req.user?.id
|
||||
);
|
||||
|
||||
// Sync with provider if applicable
|
||||
try {
|
||||
const providerRecordId = await syncDnsRecordWithProvider(
|
||||
'update',
|
||||
record.domainId,
|
||||
record,
|
||||
record.providerRecordId || undefined
|
||||
);
|
||||
|
||||
if (providerRecordId && providerRecordId !== record.providerRecordId) {
|
||||
console.log(`Record synced with provider, updating provider record ID: ${providerRecordId}`);
|
||||
// Update the record with the provider record ID
|
||||
await storage.updateDnsRecord(record.id, {
|
||||
providerRecordId
|
||||
});
|
||||
}
|
||||
} catch (providerError) {
|
||||
console.error("Error syncing with provider (continuing):", providerError);
|
||||
// We don't fail the request if provider sync fails
|
||||
}
|
||||
|
||||
// Trigger webhooks
|
||||
await triggerDnsWebhooks("update", record.domainId, record, currentRecord, req.user?.id);
|
||||
} catch (historyError) {
|
||||
@@ -374,6 +410,20 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
req.user?.id
|
||||
);
|
||||
|
||||
// Sync with provider if applicable
|
||||
try {
|
||||
if (currentRecord.providerRecordId) {
|
||||
console.log(`Deleting record with provider record ID: ${currentRecord.providerRecordId}`);
|
||||
await syncDnsRecordWithProvider('delete', currentRecord.domainId, null, currentRecord.providerRecordId);
|
||||
console.log(`Record deleted from provider successfully`);
|
||||
} else {
|
||||
console.log(`No provider record ID found for record ${recordId}, skipping provider sync`);
|
||||
}
|
||||
} catch (providerError) {
|
||||
console.error("Error syncing with provider (continuing):", providerError);
|
||||
// We don't fail the request if provider sync fails
|
||||
}
|
||||
|
||||
// Trigger webhooks
|
||||
await triggerDnsWebhooks("delete", currentRecord.domainId, null, currentRecord, req.user?.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user