summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/app/views/webfinger/search.xml.erb4
-rw-r--r--users/lib/webfinger/user_presenter.rb14
2 files changed, 13 insertions, 5 deletions
diff --git a/users/app/views/webfinger/search.xml.erb b/users/app/views/webfinger/search.xml.erb
index 0bcb7e5..270383e 100644
--- a/users/app/views/webfinger/search.xml.erb
+++ b/users/app/views/webfinger/search.xml.erb
@@ -2,5 +2,7 @@
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>acct:<%= @subject.email_identifier %></Subject>
<Alias>"<%= user_url(@subject.subject) %>"</Alias>
- <Link rel="public-key" type = 'PGP' href="<%= @subject.key %>"/>
+ <%- if @subject.key.present? %>
+ <Link rel="public-key" type = 'PGP' href="<%= @subject.key %>"/>
+ <% end %>
</XRD>
diff --git a/users/lib/webfinger/user_presenter.rb b/users/lib/webfinger/user_presenter.rb
index 8184c52..8288bff 100644
--- a/users/lib/webfinger/user_presenter.rb
+++ b/users/lib/webfinger/user_presenter.rb
@@ -12,16 +12,22 @@ class Webfinger::UserPresenter
end
def key
- Base64.encode64(@subject.public_key.to_s)
+ if @subject.public_key.present?
+ Base64.encode64(@subject.public_key.to_s)
+ end
+ end
+
+ def links
+ links = {}
+ links[:public_key] = { type: 'PGP', href: key } if key
+ return links
end
def to_json(options)
{
subject: "acct:#{email_identifier}",
aliases: [ user_url(@subject, :host => @request.host) ],
- links: {
- public_key: { type: 'PGP', href: key }
- }
+ links: links
}.to_json(options)
end