summaryrefslogtreecommitdiff
path: root/lib/nickserver/couch_db/source.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2016-06-08 12:44:38 +0200
committerAzul <azul@riseup.net>2016-06-08 12:54:23 +0200
commita89e2ba55399e6bddd9e052cf2064ed0056c958a (patch)
treec28ec332f9763f395a88db991defcae59fa46806 /lib/nickserver/couch_db/source.rb
parent712c1d062c08a58ca8772aafcdc39d0281959b4a (diff)
refactor: use new couch_db classes from fetch_key
This moves all the em_http related stuff into a single adapter. We're also not using callback and errback inside fetch_key or server for couch requests anymore. Changing the interface for hkp to do the same will follow.
Diffstat (limited to 'lib/nickserver/couch_db/source.rb')
-rw-r--r--lib/nickserver/couch_db/source.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/nickserver/couch_db/source.rb b/lib/nickserver/couch_db/source.rb
index fffa76e..874fe4f 100644
--- a/lib/nickserver/couch_db/source.rb
+++ b/lib/nickserver/couch_db/source.rb
@@ -2,6 +2,7 @@
# This class allows querying couch for public keys.
#
require 'nickserver/couch_db/response'
+require 'nickserver/config'
module Nickserver::CouchDB
class Source
@@ -13,13 +14,17 @@ module Nickserver::CouchDB
end
def query(nick)
- adapter.get VIEW, query: query_for(nick) do |status, body|
- yield Response.new nick, status: status, body: body
+ adapter.get url, query: query_for(nick) do |status, body|
+ yield Response.new(nick, status: status, body: body)
end
end
protected
+ def url
+ Nickserver::Config.couch_url + VIEW
+ end
+
def query_for(nick)
{ reduce: "false", key: "\"#{nick}\"" }
end