diff options
author | Azul <azul@leap.se> | 2013-01-25 19:26:51 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-01-25 19:26:51 +0100 |
commit | 9563ed191556e739c8f99be4d0fc75ac31c8f6cd (patch) | |
tree | 5a87fc1947921766a5430896f4bcf531dc396bff /users/lib/webfinger/user_presenter.rb | |
parent | 77a51e1de520299afd2b33e7a3992aaafab1d6ae (diff) | |
parent | dac578781baf73a006cc78e29588dd1f6fdc0fd3 (diff) |
Merge branch 'master' into merge_leap_ca
Diffstat (limited to 'users/lib/webfinger/user_presenter.rb')
-rw-r--r-- | users/lib/webfinger/user_presenter.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/users/lib/webfinger/user_presenter.rb b/users/lib/webfinger/user_presenter.rb new file mode 100644 index 0000000..329f477 --- /dev/null +++ b/users/lib/webfinger/user_presenter.rb @@ -0,0 +1,35 @@ +class Webfinger::UserPresenter + include Rails.application.routes.url_helpers + attr_accessor :user + + def initialize(user, request) + @user = user + @request = request + end + + def to_json(options = {}) + { + subject: subject, + links: links + }.to_json(options) + end + + def subject + "acct:#{@user.email_address}" + end + + def links + links = {} + links[:public_key] = { type: 'PGP', href: key } if key + return links + end + + protected + + def key + if @user.public_key.present? + Base64.encode64(@user.public_key.to_s) + end + end + +end |