diff options
Diffstat (limited to 'lib/nickserver/hkp')
-rw-r--r-- | lib/nickserver/hkp/client.rb | 6 | ||||
-rw-r--r-- | lib/nickserver/hkp/source.rb | 35 |
2 files changed, 19 insertions, 22 deletions
diff --git a/lib/nickserver/hkp/client.rb b/lib/nickserver/hkp/client.rb index 6bd239d..d9a9b48 100644 --- a/lib/nickserver/hkp/client.rb +++ b/lib/nickserver/hkp/client.rb @@ -21,7 +21,7 @@ module Nickserver; module Hkp # used to fetch an array of KeyInfo objects that match the given email # def get_key_infos_by_email(email, &block) - get op: 'vindex', search: email, fingerprint: 'on', &block + get op: 'vindex', search: email, fingerprint: 'on' end # @@ -35,10 +35,10 @@ module Nickserver; module Hkp attr_reader :adapter - def get(query, &block) + def get(query) # in practice, exact=on seems to have no effect query = {exact: 'on', options: 'mr'}.merge query - adapter.get Config.hkp_url, query: query, &block + adapter.get Config.hkp_url, query: query end end end; end diff --git a/lib/nickserver/hkp/source.rb b/lib/nickserver/hkp/source.rb index 9c79546..0d79856 100644 --- a/lib/nickserver/hkp/source.rb +++ b/lib/nickserver/hkp/source.rb @@ -14,22 +14,20 @@ require "nickserver/hkp/key_info" module Nickserver; module Hkp class Source < Nickserver::Source - def query(nick, &block) - search(nick) do |status, response| - if status == 200 - best = pick_best_key(response) - get_key_by_fingerprint(nick, best.keyid, &block) - else - yield Nickserver::Response.new(status, response) - end + def query(nick) + status, response = search(nick) + if status == 200 + best = pick_best_key(response) + get_key_by_fingerprint(nick, best.keyid) + else + Nickserver::Response.new(status, response) end end - def search(nick, &block) - client.get_key_infos_by_email(nick) do |status, response| - parser = ParseKeyInfo.new status, response - yield parser.status_for(nick), parser.response_for(nick) - end + def search(nick) + status, response = client.get_key_infos_by_email(nick) + parser = ParseKeyInfo.new status, response + return parser.status_for(nick), parser.response_for(nick) end protected @@ -45,12 +43,11 @@ module Nickserver; module Hkp end def get_key_by_fingerprint(nick, fingerprint) - client.get_key_by_fingerprint fingerprint do |status, response| - if status == 200 - yield Response.new nick, response - else - yield Nickserver::Response.new status, "HKP Request failed" - end + status, response = client.get_key_by_fingerprint fingerprint + if status == 200 + Response.new nick, response + else + Nickserver::Response.new status, "HKP Request failed" end end |