Merge branch 'master' into feature/nostr_login
This commit is contained in:
@@ -3,7 +3,7 @@ class Services::ChatController < Services::BaseController
|
||||
before_action :require_service_available
|
||||
|
||||
def show
|
||||
@service_enabled = current_user.services_enabled.include?(:xmpp)
|
||||
@service_enabled = current_user.service_enabled?(:xmpp)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -3,7 +3,7 @@ class Services::MastodonController < Services::BaseController
|
||||
before_action :require_service_available
|
||||
|
||||
def show
|
||||
@service_enabled = current_user.services_enabled.include?(:mastodon)
|
||||
@service_enabled = current_user.service_enabled?(:mastodon)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -5,7 +5,7 @@ class Services::RemotestorageController < Services::BaseController
|
||||
|
||||
# Dashboard
|
||||
def show
|
||||
# unless current_user.services_enabled.include?(:remotestorage)
|
||||
# unless current_user.service_enabled?(:remotestorage)
|
||||
# redirect_to service_remotestorage_info_path
|
||||
# end
|
||||
@rs_auths = current_user.remote_storage_authorizations
|
||||
|
||||
@@ -7,14 +7,15 @@ class WebfingerController < ApplicationController
|
||||
resource = params[:resource]
|
||||
|
||||
if resource && @useraddress = resource.match(/acct:(.+)/)&.[](1)
|
||||
@username, @org = @useraddress.split("@")
|
||||
@username, @domain = @useraddress.split("@")
|
||||
|
||||
unless Rails.env.development?
|
||||
# Allow different domains (e.g. localhost:3000) in development only
|
||||
head 404 and return unless @org == Setting.primary_domain
|
||||
head 404 and return unless @domain == Setting.primary_domain
|
||||
end
|
||||
|
||||
unless User.where(cn: @username.downcase, ou: Setting.primary_domain).any?
|
||||
unless @user = User.where(ou: Setting.primary_domain)
|
||||
.find_by(cn: @username.downcase)
|
||||
head 404 and return
|
||||
end
|
||||
|
||||
@@ -28,12 +29,50 @@ class WebfingerController < ApplicationController
|
||||
private
|
||||
|
||||
def webfinger
|
||||
links = [];
|
||||
jrd = {
|
||||
subject: "acct:#{@user.address}",
|
||||
aliases: [],
|
||||
links: []
|
||||
}
|
||||
|
||||
# TODO check if storage service is enabled for user, not just globally
|
||||
links << remotestorage_link if Setting.remotestorage_enabled
|
||||
if Setting.mastodon_enabled && @user.service_enabled?(:mastodon)
|
||||
# https://docs.joinmastodon.org/spec/webfinger/
|
||||
jrd[:aliases] += mastodon_aliases
|
||||
jrd[:links] += mastodon_links
|
||||
end
|
||||
|
||||
{ "links" => links }
|
||||
if Setting.remotestorage_enabled && @user.service_enabled?(:remotestorage)
|
||||
# https://datatracker.ietf.org/doc/draft-dejong-remotestorage/
|
||||
jrd[:links] << remotestorage_link
|
||||
end
|
||||
|
||||
jrd
|
||||
end
|
||||
|
||||
def mastodon_aliases
|
||||
[
|
||||
"#{Setting.mastodon_public_url}/@#{@user.cn}",
|
||||
"#{Setting.mastodon_public_url}/users/#{@user.cn}"
|
||||
]
|
||||
end
|
||||
|
||||
def mastodon_links
|
||||
[
|
||||
{
|
||||
rel: "http://webfinger.net/rel/profile-page",
|
||||
type: "text/html",
|
||||
href: "#{Setting.mastodon_public_url}/@#{@user.cn}"
|
||||
},
|
||||
{
|
||||
rel: "self",
|
||||
type: "application/activity+json",
|
||||
href: "#{Setting.mastodon_public_url}/users/#{@user.cn}"
|
||||
},
|
||||
{
|
||||
rel: "http://ostatus.org/schema/1.0/subscribe",
|
||||
template: "#{Setting.mastodon_public_url}/authorize_interaction?uri={uri}"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
def remotestorage_link
|
||||
@@ -41,9 +80,9 @@ class WebfingerController < ApplicationController
|
||||
storage_url = "#{Setting.rs_storage_url}/#{@username}"
|
||||
|
||||
{
|
||||
"rel" => "http://tools.ietf.org/id/draft-dejong-remotestorage",
|
||||
"href" => storage_url,
|
||||
"properties" => {
|
||||
rel: "http://tools.ietf.org/id/draft-dejong-remotestorage",
|
||||
href: storage_url,
|
||||
properties: {
|
||||
"http://remotestorage.io/spec/version" => "draft-dejong-remotestorage-13",
|
||||
"http://tools.ietf.org/html/rfc6749#section-4.2" => auth_url,
|
||||
"http://tools.ietf.org/html/rfc6750#section-2.3" => nil, # access token via a HTTP query parameter
|
||||
|
||||
Reference in New Issue
Block a user