diff --git a/Gemfile b/Gemfile
index 0964f1f2f..eace32a37 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,11 +3,6 @@ source "https://rubygems.org"
gem "rails", "4.2.3"
# Legacy Rails features, remove me!
-
-# caches_page
-gem "actionpack-action_caching"
-gem "actionpack-page_caching"
-
# responders (class level)
gem "responders", "2.1.0"
@@ -15,6 +10,10 @@ gem "responders", "2.1.0"
gem "unicorn", "4.9.0", require: false
+# Federation
+
+gem "diaspora_federation-rails", "0.0.2"
+
# API and JSON
gem "acts_as_api", "0.4.2"
diff --git a/Gemfile.lock b/Gemfile.lock
index 141d14d61..87e856e95 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -16,10 +16,6 @@ GEM
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionpack-action_caching (1.1.1)
- actionpack (>= 4.0.0, < 5.0)
- actionpack-page_caching (1.0.2)
- actionpack (>= 4.0.0, < 5)
actionview (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
@@ -157,6 +153,11 @@ GEM
eventmachine (>= 1.0.5, < 1.1)
http_parser.rb (~> 0.6)
nokogiri (~> 1.6)
+ diaspora_federation (0.0.2)
+ nokogiri (~> 1.6, >= 1.6.6)
+ diaspora_federation-rails (0.0.2)
+ diaspora_federation (= 0.0.2)
+ rails (~> 4.2)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.24)
@@ -743,8 +744,6 @@ PLATFORMS
ruby
DEPENDENCIES
- actionpack-action_caching
- actionpack-page_caching
active_model_serializers (= 0.9.3)
activerecord-import (= 0.8.0)
acts-as-taggable-on (= 3.5.0)
@@ -765,6 +764,7 @@ DEPENDENCIES
devise_lastseenable (= 0.0.4)
diaspora-vines (~> 0.1.27)
entypo-rails (= 2.2.3)
+ diaspora_federation-rails (= 0.0.2)
eye (= 0.7.pre)
facebox-rails (= 0.2.0)
factory_girl_rails (= 4.5.0)
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index af9d57f9c..cca482bbd 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -13,36 +13,8 @@ class PublicsController < ApplicationController
respond_to :html
respond_to :xml, :only => :post
- caches_page :host_meta, :if => Proc.new{ Rails.env == 'production'}
-
layout false
- def hcard
- @person = Person.find_by_guid_and_closed_account(params[:guid], false)
-
- if @person.present? && @person.local?
- render 'publics/hcard'
- else
- render :nothing => true, :status => 404
- end
- end
-
- def host_meta
- render 'host_meta', :content_type => 'application/xrd+xml'
- end
-
- def webfinger
- @person = Person.local_by_account_identifier(params[:q]) if params[:q]
-
- if @person.nil? || @person.closed_account?
- render :nothing => true, :status => 404
- return
- end
-
- logger.info "webfinger profile request for: #{@person.id}"
- render 'webfinger', :content_type => 'application/xrd+xml'
- end
-
def hub
render :text => params['hub.challenge'], :status => 202, :layout => false
end
diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb
index 63d39af21..e52612bf9 100644
--- a/app/helpers/people_helper.rb
+++ b/app/helpers/people_helper.rb
@@ -50,10 +50,6 @@ module PeopleHelper
end
end
- def person_href(person, opts={})
- "href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe
- end
-
# Rails.application.routes.url_helpers is needed since this is indirectly called from a model
def local_or_remote_person_path(person, opts={})
opts.merge!(:protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.authority)
diff --git a/app/models/person.rb b/app/models/person.rb
index 814dfe1e0..e419cce30 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -28,7 +28,7 @@ class Person < ActiveRecord::Base
xml_attr :profile, :as => Profile
xml_attr :exported_key
- has_one :profile, :dependent => :destroy
+ has_one :profile, dependent: :destroy
delegate :last_name, :image_url, :tag_string, :bio, :location,
:gender, :birthday, :formatted_birthday, :tags, :searchable,
to: :profile
@@ -222,7 +222,7 @@ class Person < ActiveRecord::Base
end
def public_key_hash
- Base64.encode64(OpenSSL::Digest::SHA256.new(self.exported_key).to_s)
+ Base64.encode64(OpenSSL::Digest::SHA256.new(serialized_public_key).to_s)
end
def public_key
@@ -238,15 +238,18 @@ class Person < ActiveRecord::Base
serialized_public_key = new_key
end
- #database calls
+ # database calls
def self.by_account_identifier(identifier)
- identifier = identifier.strip.downcase.gsub('acct:', '')
- self.where(:diaspora_handle => identifier).first
+ identifier = identifier.strip.downcase.sub("acct:", "")
+ find_by(diaspora_handle: identifier)
end
- def self.local_by_account_identifier(identifier)
- person = self.by_account_identifier(identifier)
- (person.nil? || person.remote?) ? nil : person
+ def self.find_local_by_diaspora_handle(handle)
+ where(diaspora_handle: handle, closed_account: false).where.not(owner: nil).take
+ end
+
+ def self.find_local_by_guid(guid)
+ where(guid: guid, closed_account: false).where.not(owner: nil).take
end
def self.create_from_webfinger(profile, hcard)
diff --git a/app/views/publics/hcard.haml b/app/views/publics/hcard.haml
deleted file mode 100644
index f19bffb35..000000000
--- a/app/views/publics/hcard.haml
+++ /dev/null
@@ -1,50 +0,0 @@
-#content
- %h1= @person.name
- #content_inner
- #i.entity_profile.vcard.author
- %h2 User profile
-
- %dl.entity_nickname
- %dt Nickname
- %dd
- %a.nickname.url.uid{:href=>@person.url, :rel=>'me'}= @person.name
-
- %dl.entity_given_name
- %dt First name
- %dd
- %span.given_name= @person.profile.first_name
-
- %dl.entity_family_name
- %dt Family name
- %dd
- %span.family_name= @person.last_name
-
- %dl.entity_fn
- %dt Full name
- %dd
- %span.fn= @person.name
-
- %dl.entity_url
- %dt URL
- %dd
- %a#pod_location.url{:href=>@person.url, :rel=>'me'}= @person.url
-
- %dl.entity_photo
- %dt Photo
- %dd
- %img.photo.avatar{:src=>@person.image_url, :width=>'300px', :height=>'300px'}
-
- %dl.entity_photo_medium
- %dt Photo
- %dd
- %img.photo.avatar{:src=>@person.image_url(:thumb_medium), :width=>'100px', :height=>'100px'}
-
- %dl.entity_photo_small
- %dt Photo
- %dd
- %img.photo.avatar{:src=>@person.image_url(:thumb_small), :width=>'50px', :height=>'50px'}
-
- %dl.entity_searchable
- %dt Searchable
- %dd
- %span.searchable= @person.searchable
diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb
deleted file mode 100644
index f5efcab11..000000000
--- a/app/views/publics/host_meta.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-
-