diff options
| author | Bobby <[email protected]> | 2026-03-08 18:17:23 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-08 18:17:23 +0530 |
| commit | 1136af49815be77a0aca151f3b8ec7348bf4b4c8 (patch) | |
| tree | ca4d94f981be59c51fa7d160e32be978a8d4b4fb /controllers | |
| parent | f48054e9bc5e4fb36b9aba9126c6ace9c5b1f470 (diff) | |
| download | dove-1136af49815be77a0aca151f3b8ec7348bf4b4c8.tar.xz dove-1136af49815be77a0aca151f3b8ec7348bf4b4c8.zip | |
feat(dns): add update functionality for DNS records (MX, SRV, TXT)
- Implemented UpdateMXRecord, UpdateSRVRecord, and UpdateTXTRecord functions in their respective repositories.
- Added UpdateRecord method in dns service to handle updates for various DNS record types.
- Updated router to include a new route for updating DNS records.
- Enhanced error messages for record updates in messages.go.
- Modified the frontend forms to support editing DNS records with improved UI components.
- Refactored existing domain management code to remove unused update functionality.
- Improved email handling by adding MX record validation during email delivery.
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/auth/auth.go | 2 | ||||
| -rw-r--r-- | controllers/dns/records.go | 23 | ||||
| -rw-r--r-- | controllers/domain/domain.go | 21 |
3 files changed, 25 insertions, 21 deletions
diff --git a/controllers/auth/auth.go b/controllers/auth/auth.go index 8140ddd..f700716 100644 --- a/controllers/auth/auth.go +++ b/controllers/auth/auth.go @@ -29,4 +29,4 @@ func Logout(context *fiber.Ctx) error { } return shortcuts.Redirect(context, "home") -}
\ No newline at end of file +} diff --git a/controllers/dns/records.go b/controllers/dns/records.go index d16a6b3..2f7036f 100644 --- a/controllers/dns/records.go +++ b/controllers/dns/records.go @@ -25,6 +25,29 @@ func CreateRecord(context *fiber.Ctx) error { return shortcuts.RedirectToPath(context, fmt.Sprintf("/domains/manage/%d", body.DomainID)) } +func UpdateRecord(context *fiber.Ctx) error { + recordID, parseError := strconv.ParseUint(meta.Request(context).Param("id"), 10, 64) + if parseError != nil { + return shortcuts.BadRequestError(context, parseError) + } + + recordType := meta.Request(context).Param("type") + + body, bodyError := meta.Body[dnsService.UpdateRecordRequest](context) + if bodyError != nil { + return shortcuts.BadRequestError(context, bodyError) + } + + serviceError := dnsService.UpdateRecord(recordType, uint(recordID), body) + if serviceError != nil { + return shortcuts.HandleError(context, serviceError) + } + + domainID := meta.Request(context).Query("domain_id") + + return shortcuts.RedirectToPath(context, fmt.Sprintf("/domains/manage/%s", domainID)) +} + func DeleteRecord(context *fiber.Ctx) error { recordID, parseError := strconv.ParseUint(meta.Request(context).Param("id"), 10, 64) if parseError != nil { diff --git a/controllers/domain/domain.go b/controllers/domain/domain.go index ac61c94..ef450ac 100644 --- a/controllers/domain/domain.go +++ b/controllers/domain/domain.go @@ -24,25 +24,6 @@ func CreateDomain(context *fiber.Ctx) error { return shortcuts.Redirect(context, "domains.manage") } -func UpdateDomain(context *fiber.Ctx) error { - domainID, parseError := strconv.ParseUint(meta.Request(context).Param("id"), 10, 64) - if parseError != nil { - return shortcuts.BadRequestError(context, parseError) - } - - body, bodyError := meta.Body[domainService.UpdateDomainRequest](context) - if bodyError != nil { - return shortcuts.BadRequestError(context, bodyError) - } - - serviceError := domainService.UpdateDomain(uint(domainID), body) - if serviceError != nil { - return shortcuts.HandleError(context, serviceError) - } - - return shortcuts.Redirect(context, "domains.manage") -} - func DeleteDomain(context *fiber.Ctx) error { domainID, parseError := strconv.ParseUint(meta.Request(context).Param("id"), 10, 64) if parseError != nil { @@ -97,4 +78,4 @@ func DeleteTLD(context *fiber.Ctx) error { } return shortcuts.Redirect(context, "domains.tlds") -}
\ No newline at end of file +} |
