From 4c731bf81871b778f2b7ba666f22013fc9eddbd6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 16 Aug 2010 11:29:14 -0700 Subject: [PATCH] special-casing local webfinger --- app/controllers/publics_controller.rb | 2 +- app/helpers/requests_helper.rb | 13 ++++++++++--- app/models/person.rb | 6 +++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 2b942541f..91edf995d 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -15,7 +15,7 @@ class PublicsController < ApplicationController end def webfinger - @person = Person.first(:email => params[:q].gsub('acct:', '')) + @person = Person.by_webfinger(params[:q]) unless @person.nil? || @person.owner.nil? render 'webfinger', :layout => false, :content_type => 'application/xrd+xml' end diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 99f73be66..478d9853b 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -26,9 +26,16 @@ module RequestsHelper end def relationship_flow(identifier) - f = Redfinger.finger(identifier) - action = subscription_mode(f) - url = subscription_url(action, f) + puts request.host + if identifier.include?(request.host) + person = Person.by_webfinger identifier + action = :friend + url = person.owner.receive_url + else + f = Redfinger.finger(identifier) + action = subscription_mode(f) + url = subscription_url(action, f) + end { action => url } end diff --git a/app/models/person.rb b/app/models/person.rb index cf4899a1e..50a3cc410 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -75,7 +75,7 @@ class Person false end - def send_comment c + def send_comment( c ) if self.owner.nil? if c.post.person.owner.nil? #puts "The commenter is not here, and neither is the poster" @@ -112,6 +112,10 @@ class Person "#{self.url}receive/users/#{self.id}/" end + def self.by_webfinger( identifier ) + Person.first(:email => identifier.gsub('acct:', '')) + end + protected def clean_url self.url ||= "http://localhost:3000/" if self.class == User