DeleteZone

master
Philippe Pittoli 2023-05-07 20:23:34 +02:00
parent 4545f5472c
commit 22d110d45d
3 changed files with 20 additions and 9 deletions

View File

@ -29,14 +29,21 @@ class DNSManager::Client < IPC
def login(token : String)
request = DNSManager::Request::Login.new token
send_now request
parse_message [ DNSManager::Response::Success ], read
parse_message [ Response::Success ], read
end
# Adding a full zone.
def user_zone_add(zone : DNSManager::Storage::Zone)
request = DNSManager::Request::AddOrUpdateZone.new zone
send_now request
parse_message [ DNSManager::Response::Success, DNSManager::Response::InvalidZone ], read
parse_message [ Response::Success ], read
end
# Removing a zone.
def user_zone_del(domain : String)
request = DNSManager::Request::DeleteZone.new domain
send_now request
parse_message [ Response::Success ], read
end
#

View File

@ -85,7 +85,7 @@ class Actions
domains.each do |domain|
begin
pp! domain
#pp! @dnsmanagerd.user_zone_del domain
pp! @dnsmanagerd.user_zone_del domain
rescue e
puts "error for user_zone_del: #{e.message}"
end

View File

@ -102,15 +102,19 @@ class DNSManager::Storage
# User must own the domain.
unless user_data.domains.includes? domain
Baguette::Log.warning "user #{user_id} tries to delete domain #{domain} doesn't own it"
Baguette::Log.warning "user #{user_id} tries to delete domain #{domain} but doesn't own it"
return Response::NoOwnership.new
end
# TODO: remove this domain from the list of user's domains.
# TODO: remove the related zone.
#unless errors = Storage::Zone.is_domain_valid? domain
# return Response::InvalidZone.new errors
#end
# Remove this domain from the list of user's domains.
user_data.domains.delete domain
# Update on-disk user data.
update_user_data user_data
# Remove the related zone.
zones_by_domain.delete domain
Response::Success.new
rescue e
Baguette::Log.error "trying to delete a domain #{domain}: #{e}"