diff options
| -rw-r--r-- | users/app/controllers/webfinger_controller.rb | 3 | ||||
| -rw-r--r-- | users/app/views/webfinger/search.xml.erb (renamed from users/app/views/webfinger/search.erb) | 0 | ||||
| -rw-r--r-- | users/lib/webfinger/user_presenter.rb | 12 | 
3 files changed, 15 insertions, 0 deletions
| diff --git a/users/app/controllers/webfinger_controller.rb b/users/app/controllers/webfinger_controller.rb index ac05934..d3a4ad3 100644 --- a/users/app/controllers/webfinger_controller.rb +++ b/users/app/controllers/webfinger_controller.rb @@ -1,15 +1,18 @@  class WebfingerController < ApplicationController +  respond_to :xml, :json    layout false    def host_meta      @host_meta = Webfinger::HostMetaPresenter.new(request) +    respond_with @host_meta    end    def search      username = params[:q].split('@')[0].to_s.downcase      user = User.find_by_login(username) || not_found      @subject = Webfinger::UserPresenter.new(user, request) +    respond_with @subject    end  end diff --git a/users/app/views/webfinger/search.erb b/users/app/views/webfinger/search.xml.erb index 0bcb7e5..0bcb7e5 100644 --- a/users/app/views/webfinger/search.erb +++ b/users/app/views/webfinger/search.xml.erb diff --git a/users/lib/webfinger/user_presenter.rb b/users/lib/webfinger/user_presenter.rb index bbfc908..8184c52 100644 --- a/users/lib/webfinger/user_presenter.rb +++ b/users/lib/webfinger/user_presenter.rb @@ -1,4 +1,5 @@  class Webfinger::UserPresenter +  include Rails.application.routes.url_helpers    attr_accessor :subject    def initialize(subject, request) @@ -13,4 +14,15 @@ class Webfinger::UserPresenter    def key      Base64.encode64(@subject.public_key.to_s)    end + +  def to_json(options) +    { +      subject: "acct:#{email_identifier}", +      aliases: [ user_url(@subject, :host => @request.host) ], +      links:   { +        public_key:  { type: 'PGP', href: key } +      } +    }.to_json(options) +  end +  end | 
