about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-08 02:40:51 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-08 02:40:51 +0200
commit509c18eb139ead0d2e2f02f580ef04b28d874f48 (patch)
treecb87396ee928a5d9bc349e15846d54179f7e2dbd /app/controllers
parent0f4bc567195d368de596cdeeee6bc0b6507ae95e (diff)
Fix local follows, 404 in logs
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/accounts_controller.rb7
-rw-r--r--app/controllers/application_controller.rb13
2 files changed, 14 insertions, 6 deletions
diff --git a/app/controllers/api/accounts_controller.rb b/app/controllers/api/accounts_controller.rb
index 8c4da5270..4a4431b2d 100644
--- a/app/controllers/api/accounts_controller.rb
+++ b/app/controllers/api/accounts_controller.rb
@@ -19,12 +19,7 @@ class Api::AccountsController < ApiController
   end
 
   def follow
-    if @account.local?
-      @follow = current_user.account.follow!(@account)
-    else
-      @follow = FollowService.new.(current_user.account, @account.acct)
-    end
-
+    @follow = FollowService.new.(current_user.account, @account.acct)
     render action: :show
   end
 
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 73de1838c..90e923951 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -7,8 +7,21 @@ class ApplicationController < ActionController::Base
 
   helper_method :current_account
 
+  rescue_from ActionController::RoutingError, with: :not_found
+  rescue_from ActiveRecord::RecordNotFound, with: :not_found
+
+  def raise_not_found
+    raise ActionController::RoutingError.new("No route matches #{params[:unmatched_route]}")
+  end
+
   protected
 
+  def not_found
+    respond_to do |format|
+      format.any { head 404 }
+    end
+  end
+
   def current_account
     current_user.try(:account)
   end