From 8a81429f0eb8aa5041d47557d0c5b5359bb959e6 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 25 May 2016 13:13:30 +0200 Subject: copy over all files from rewritten attempt I started a nickserver from scratch to implement the things that are independent of our choice of stack (eventmachine or other). This commit copies them over and tests both things in parallel. --- lib/nickserver/couch_db/source.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/nickserver/couch_db/source.rb (limited to 'lib/nickserver/couch_db/source.rb') diff --git a/lib/nickserver/couch_db/source.rb b/lib/nickserver/couch_db/source.rb new file mode 100644 index 0000000..fffa76e --- /dev/null +++ b/lib/nickserver/couch_db/source.rb @@ -0,0 +1,34 @@ +# +# This class allows querying couch for public keys. +# +require 'nickserver/couch_db/response' + +module Nickserver::CouchDB + class Source + + VIEW = '/_design/Identity/_view/pgp_key_by_email' + + def initialize(adapter) + @adapter = adapter + end + + def query(nick) + adapter.get VIEW, query: query_for(nick) do |status, body| + yield Response.new nick, status: status, body: body + end + end + + protected + + def query_for(nick) + { reduce: "false", key: "\"#{nick}\"" } + end + + def adapter + @adapter + # Nickserver::Adapters::Http.new(config) + end + + attr_reader :config + end +end -- cgit v1.2.3