diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 2b942541fb5671f40f6e0ba2e2dcd93bdf533c43..91edf995d9776deb4a8f96e39e429a4ae89388b8 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 99f73be66e2a4c9cd1eddef79b27fff329176a1d..478d9853bed75903cc1cad2c8fdb8705e9f524fd 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 cf4899a1ece12d21df31e46f7f0be13cef8a4bc4..50a3cc410bbcde8e3371c147c4547b0ef9505241 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