diff options
author | Azul <azul@riseup.net> | 2016-08-30 12:38:43 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-08-31 12:14:52 +0200 |
commit | 625416ac16a1216240fc4c48aa19802ef8a967a1 (patch) | |
tree | f3a4a54627fcae49bf896f5f58e60b506f9a55d4 /lib/nickserver/request_handlers | |
parent | b22e23eb9f5a1cb3e37ab2a26b1091183574f4e4 (diff) |
wip: key lookup by address via leaps nicknym
I added a RequestHandler that uses Nicknym::Source - but that has not
been implemented yet.
Diffstat (limited to 'lib/nickserver/request_handlers')
-rw-r--r-- | lib/nickserver/request_handlers/leap_email_handler.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/nickserver/request_handlers/leap_email_handler.rb b/lib/nickserver/request_handlers/leap_email_handler.rb new file mode 100644 index 0000000..548bc8a --- /dev/null +++ b/lib/nickserver/request_handlers/leap_email_handler.rb @@ -0,0 +1,36 @@ +require 'nickserver/email_address' +require 'nickserver/nicknym/source' + +module Nickserver + module RequestHandlers + class LeapEmailHandler < Base + + def handle + source.query(email) if request.email && remote_email? && nicknym_email? + end + + protected + + def source + @source ||= Nicknym::Source.new + end + + def remote_email? + !email.domain?(domain) + end + + def nicknym_email? + source.available_for?(email.domain) + end + + def email + @email ||= EmailAddress.new(request.email) + end + + def domain + Config.domain || request.domain + end + + end + end +end |