From e2cb572c15bee415b8340f9aa5289f61a31fa753 Mon Sep 17 00:00:00 2001
From: Maxwell Salzberg <maxwell@joindiaspora.com>
Date: Fri, 27 Jan 2012 02:11:45 -0800
Subject: [PATCH] random cleanup; delete some unused methods, clean up some
 logic in some controllers; update the default referee to /stream [ci skip]

---
 app/controllers/application_controller.rb | 19 ++++-----------
 app/controllers/publics_controller.rb     | 29 +++++++++--------------
 app/controllers/tags_controller.rb        |  1 -
 3 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 97d3b36fa3..4c2706ad4f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base
                 :open_publisher
 
   def ensure_http_referer_is_set
-    request.env['HTTP_REFERER'] ||= '/aspects'
+    request.env['HTTP_REFERER'] ||= '/stream'
   end
 
   # Overwriting the sign_out redirect path method
@@ -63,6 +63,10 @@ class ApplicationController < ActionController::Base
     @only_sharing_count ||= current_user.contacts.only_sharing.count
   end
 
+  def tags
+    @tags ||= current_user.followed_tags
+  end
+
   def ensure_page
     params[:page] = params[:page] ? params[:page].to_i : 1
   end
@@ -115,19 +119,6 @@ class ApplicationController < ActionController::Base
     stored_location_for(:user) || (current_user.getting_started? ? getting_started_path : multi_stream_path)
   end
 
-  def tag_followings
-    if current_user
-      if @tag_followings == nil
-        @tag_followings = current_user.tag_followings
-      end
-      @tag_followings
-    end
-  end
-
-  def tags
-    @tags ||= current_user.followed_tags
-  end
-
   def max_time
     params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now + 1
   end
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index f3221d123a..2e70e72831 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -16,7 +16,6 @@ class PublicsController < ApplicationController
   # newrelic_ignore if EnviromentConfiguration.using_new_relic?
 
   skip_before_filter :set_header_data
-  skip_before_filter :which_action_and_user
   skip_before_filter :set_grammatical_gender
   before_filter :allow_cross_origin, :only => [:hcard, :host_meta, :webfinger]
   before_filter :check_for_xml, :only => [:receive, :receive_public]
@@ -25,22 +24,14 @@ class PublicsController < ApplicationController
   respond_to :html
   respond_to :xml, :only => :post
 
-  def allow_cross_origin
-    headers["Access-Control-Allow-Origin"] = "*"
-  end
 
   layout false
   caches_page :host_meta
 
   def hcard
-    @person = Person.where(:guid => params[:guid]).first
-
-    if @person && @person.closed_account?
-      render :nothing => true, :status => 404
-      return
-    end
+    @person = Person.find_by_guid_and_closed_account(params[:guid], false)
 
-    unless @person.nil? || @person.owner.nil?
+    if @person.present? && @person.local?
       render 'publics/hcard'
     else
       render :nothing => true, :status => 404
@@ -54,16 +45,12 @@ class PublicsController < ApplicationController
   def webfinger
     @person = Person.local_by_account_identifier(params[:q]) if params[:q]
 
-    if @person && @person.closed_account?
+    if @person.nil? || @person.closed_account?
       render :nothing => true, :status => 404
       return
     end
 
-    unless @person.nil?
-      render 'webfinger', :content_type => 'application/xrd+xml'
-    else
-      render :nothing => true, :status => 404
-    end
+    render 'webfinger', :content_type => 'application/xrd+xml'
   end
 
   def hub
@@ -76,7 +63,7 @@ class PublicsController < ApplicationController
   end
 
   def receive
-    person = Person.where(:guid => params[:guid]).first
+    person = Person.find_by_guid(params[:guid])
 
     if person.nil? || person.owner_id.nil?
       Rails.logger.error("Received post for nonexistent person #{params[:guid]}")
@@ -91,6 +78,12 @@ class PublicsController < ApplicationController
   end
 
 
+  def allow_cross_origin
+    headers["Access-Control-Allow-Origin"] = "*"
+  end
+
+
+
   private
 
   def check_for_xml
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 83f69203b3..8128c03d27 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -5,7 +5,6 @@ require File.join(Rails.root, 'app', 'models', 'acts_as_taggable_on', 'tag')
 require File.join(Rails.root, 'lib', 'stream', 'tag')
 
 class TagsController < ApplicationController
-  skip_before_filter :which_action_and_user
   skip_before_filter :set_grammatical_gender
   before_filter :ensure_page, :only => :show
 
-- 
GitLab