Merge branch 'feature/user_avatars' into live
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -33,6 +33,10 @@ class WebfingerController < WellKnownController
|
||||
links: []
|
||||
}
|
||||
|
||||
if @user.avatar.attached?
|
||||
jrd[:links] += avatar_link
|
||||
end
|
||||
|
||||
if Setting.mastodon_enabled && @user.service_enabled?(:mastodon)
|
||||
# https://docs.joinmastodon.org/spec/webfinger/
|
||||
jrd[:aliases] += mastodon_aliases
|
||||
@@ -47,6 +51,16 @@ class WebfingerController < WellKnownController
|
||||
jrd
|
||||
end
|
||||
|
||||
def avatar_link
|
||||
[
|
||||
{
|
||||
rel: "http://webfinger.net/rel/avatar",
|
||||
type: @user.avatar.content_type,
|
||||
href: helpers.image_url_for(@user.avatar)
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
def mastodon_aliases
|
||||
[
|
||||
"#{Setting.mastodon_public_url}/@#{@user.cn}",
|
||||
|
||||
@@ -16,8 +16,15 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def image_url_for(attachment)
|
||||
if Setting.s3_enabled?
|
||||
s3_image_url(attachment)
|
||||
return s3_image_url(attachment) if Setting.s3_enabled?
|
||||
|
||||
if attachment.record.is_a?(User) && attachment.name == "avatar"
|
||||
hash, format = attachment.blob.filename.to_s.split(".", 2)
|
||||
user_avatar_url(
|
||||
username: attachment.record.cn,
|
||||
hash: hash,
|
||||
format: format
|
||||
)
|
||||
else
|
||||
Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user