From 0784391a21b75ca52892e992a614b0f927ade00e Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 29 Aug 2016 11:59:54 +0200 Subject: refactor: split EmailHandler in 3 InvalidEmailHandler - handle emails with an invalid format LocalEmailHandler - handle emails on the local domain EmailHandler - handle all other emails by using hkp This is a preparation to add leap provider email lookup and remove hkp eventually. But for now we keep the behaviour the same and only refactor. --- lib/nickserver/request_handlers/invalid_email_handler.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/nickserver/request_handlers/invalid_email_handler.rb (limited to 'lib/nickserver/request_handlers/invalid_email_handler.rb') diff --git a/lib/nickserver/request_handlers/invalid_email_handler.rb b/lib/nickserver/request_handlers/invalid_email_handler.rb new file mode 100644 index 0000000..eaf8156 --- /dev/null +++ b/lib/nickserver/request_handlers/invalid_email_handler.rb @@ -0,0 +1,15 @@ +require 'nickserver/email_address' +require 'nickserver/error_response' + +module Nickserver + module RequestHandlers + class InvalidEmailHandler + def call(request) + return unless request.email + email = EmailAddress.new(request.email) + ErrorResponse.new("Not a valid address") if email.invalid? + end + + end + end +end -- cgit v1.2.3