fix webfinger using the configured class ...

This commit is contained in:
Benjamin Neff 2015-06-16 02:00:10 +02:00
parent 5bd13563c5
commit 96af095d84
3 changed files with 9 additions and 3 deletions

View file

@ -9,12 +9,18 @@ module DiasporaFederation
## ##
# this is the pre RFC 7033 webfinger # this is the pre RFC 7033 webfinger
def legacy_webfinger def legacy_webfinger
@person = Person.find_local_by_diaspora_handle(params[:q].strip.downcase.gsub("acct:", "")) if params[:q] @person = find_person(params[:q]) if params[:q]
return render nothing: true, status: 404 if @person.nil? return render nothing: true, status: 404 if @person.nil?
logger.info "webfinger profile request for: #{@person.diaspora_handle}" logger.info "webfinger profile request for: #{@person.diaspora_handle}"
render "webfinger", content_type: "application/xrd+xml" render "webfinger", content_type: "application/xrd+xml"
end end
private
def find_person(query)
DiasporaFederation.person_class.find_local_by_diaspora_handle(query.strip.downcase.gsub("acct:", ""))
end
end end
end end

View file

@ -20,7 +20,7 @@ module DiasporaFederation
# the class to use as person. # the class to use as person.
# #
# Example: # Example:
# config.person_class = Person.class.to_s # config.person_class = Person.to_s
attr_accessor :person_class attr_accessor :person_class
def person_class def person_class
const_get(@person_class) const_get(@person_class)

View file

@ -4,5 +4,5 @@ DiasporaFederation.configure do |config|
config.server_uri = URI("http://localhost:3000/") config.server_uri = URI("http://localhost:3000/")
# the class to be used for a person # the class to be used for a person
config.person_class = Person.class.to_s config.person_class = Person.to_s
end end