A few new messages to auto-update client's state while logging itself.
parent
35072753d4
commit
63da767caa
|
@ -14,7 +14,12 @@ class DNSManager::Request
|
|||
#dnsmanagerd.auth.edit_profile_content user.uid, {
|
||||
# "dnsmanager-last-connection" => JSON::Any.new Time.utc.to_s
|
||||
#}
|
||||
dnsmanagerd.storage.ensure_user_data response.user.uid
|
||||
user_data = dnsmanagerd.storage.ensure_user_data response.user.uid
|
||||
return Response::Error.new "invalid user" unless user_data
|
||||
|
||||
accepted_domains = dnsmanagerd.configuration.accepted_domains.not_nil!
|
||||
user_domains = user_data.domains
|
||||
Response::Logged.new accepted_domains, user_domains
|
||||
else
|
||||
Response::ErrorInvalidToken.new
|
||||
end
|
||||
|
|
|
@ -34,5 +34,27 @@ class DNSManager::Response
|
|||
end
|
||||
end
|
||||
DNSManager.responses << DomainList
|
||||
|
||||
IPC::JSON.message AcceptedDomains, 15 do
|
||||
property domains : Array(String)
|
||||
def initialize(@domains)
|
||||
end
|
||||
end
|
||||
DNSManager.responses << AcceptedDomains
|
||||
|
||||
IPC::JSON.message Logged, 16 do
|
||||
property accepted_domains : Array(String)
|
||||
property my_domains : Array(String)
|
||||
def initialize(@accepted_domains, @my_domains)
|
||||
end
|
||||
end
|
||||
DNSManager.responses << Logged
|
||||
|
||||
IPC::JSON.message DomainAdded, 17 do
|
||||
property domain : String
|
||||
def initialize(@domain)
|
||||
end
|
||||
end
|
||||
DNSManager.responses << DomainAdded
|
||||
end
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class DNSManager::Storage
|
|||
@user_data << UserData.new user_id
|
||||
end
|
||||
|
||||
Response::Success.new
|
||||
user_data
|
||||
end
|
||||
|
||||
def new_domain(accepted_domains : Array(String),
|
||||
|
@ -100,7 +100,7 @@ class DNSManager::Storage
|
|||
# Add the new zone in the database.
|
||||
zones_by_domain.update_or_create domain, default_zone
|
||||
|
||||
Response::Success.new
|
||||
Response::DomainAdded.new domain
|
||||
end
|
||||
|
||||
def add_or_update_zone(user_id : Int32, zone : Zone) : IPC::JSON
|
||||
|
|
Loading…
Reference in New Issue