Commit 865242b131a3e54295788d6dad3b340f5f3e9722

Authored by Alessandro Beltrão
1 parent 00b9a4c0

Adding new fields for webfinger server

Signed-off-by: Alessandro Caetano <alessandro.caetanob@gmail.com>
Showing 1 changed file with 24 additions and 2 deletions   Show diff stats
app/api/federation/webfinger.rb
  1 +require 'rails/commands/server'
  2 +
1 3 module Api
2 4 module Federation
3 5 class Webfinger < Grape::API
... ... @@ -38,9 +40,29 @@ def request_acct?
38 40 end
39 41  
40 42 def acct_hash
41   - acct = {}
  43 + rails = Rails::Server.new
  44 + acct = Hash.new{|hash, key| hash[key] =
  45 + Hash.new{|hash, key| hash[key] = Array.new}}
  46 +
  47 + person = Person.find_by_identifier(extract_person_identifier)
  48 + url = rails.options[:Host] + ':' + rails.options[:Port].to_s + '/'
  49 +
42 50 acct[:subject] = params[:resource]
43   - acct[:properties] = Person.find_by_identifier(extract_person_identifier)
  51 + acct[:alias] = url + person.identifier
  52 + acct[:properties][:identifier] = person.identifier
  53 + acct[:properties][:created_at] = person.created_at
  54 + for blog in person.blogs do
  55 + acct[:links][:rel] << url + 'rel/' + blog.path
  56 + acct[:links][:href] << url + person.identifier + '/' + blog.path
  57 + end
  58 +
  59 + for galleries in person.articles.galleries do
  60 + acct[:links][:rel] << url + 'rel/' + galleries.path
  61 + acct[:links][:href] << url + person.identifier + '/' + galleries.path
  62 + end
  63 +
  64 + acct[:titles][:name] = person.name
  65 +
44 66 if acct[:properties].nil?
45 67 Rails.logger.error 'Person not found'
46 68 not_found!
... ...