New request: NewDomain.

This commit is contained in:
Philippe Pittoli 2023-06-17 12:57:51 +02:00
parent 009fdea353
commit 22f83b8729
3 changed files with 10 additions and 4 deletions

View File

@ -6,7 +6,7 @@ class DNSManager::Request
IPC::JSON.message NewDomain, 9 do
property domain : String
def initialize(@zone)
def initialize(@domain)
end
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON

View File

@ -12,4 +12,10 @@ class DNSManager::Response
end
end
DNSManager.responses << ErrorInvalidToken
IPC::JSON.message DomainAlreadyExists, 3 do
def initialize()
end
end
DNSManager.responses << ErrorInvalidToken
end

View File

@ -54,11 +54,11 @@ class DNSManager::Storage
Response::Success.new
end
def add_or_update_zone(user_id : Int32, domain : String) : IPC::JSON
def new_domain(user_id : Int32, domain : String) : IPC::JSON
# User must exist.
user_data = user_data_by_uid.get? user_id.to_s
unless user_data
Baguette::Log.warning "unknown user #{user_id} tries to add -or update- zone #{zone.domain}"
Baguette::Log.warning "unknown user #{user_id} tries to add domain #{domain}"
return Response::UnknownUser.new
end
@ -66,7 +66,7 @@ class DNSManager::Storage
Response::DomainAlreadyExists.new
else
# Add the domain to the user's domain.
user_data.domains << zone.domain
user_data.domains << domain
# Actually write data on-disk.
update_user_data user_data