about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/v1/accounts_controller.rb2
-rw-r--r--app/controllers/api/v1/search_controller.rb9
-rw-r--r--app/controllers/statuses_controller.rb39
3 files changed, 49 insertions, 1 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index 51c948955..f07450eb0 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -115,7 +115,7 @@ class Api::V1::AccountsController < ApiController
   end
 
   def search
-    @accounts = SearchService.new.call(params[:q], limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:resolve] == 'true', current_account)
+    @accounts = AccountSearchService.new.call(params[:q], limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:resolve] == 'true', current_account)
 
     set_account_counters_maps(@accounts) unless @accounts.nil?
 
diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb
new file mode 100644
index 000000000..6b1292458
--- /dev/null
+++ b/app/controllers/api/v1/search_controller.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class Api::V1::SearchController < ApiController
+  respond_to :json
+
+  def index
+    @search = OpenStruct.new(SearchService.new.call(params[:q], 5, params[:resolve] == 'true', current_account))
+  end
+end
diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb
new file mode 100644
index 000000000..696bb4f52
--- /dev/null
+++ b/app/controllers/statuses_controller.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+class StatusesController < ApplicationController
+  layout 'public'
+
+  before_action :set_account
+  before_action :set_status
+  before_action :set_link_headers
+  before_action :check_account_suspension
+
+  def show
+    @ancestors   = @status.reply? ? cache_collection(@status.ancestors(current_account), Status) : []
+    @descendants = cache_collection(@status.descendants(current_account), Status)
+
+    render 'stream_entries/show'
+  end
+
+  private
+
+  def set_account
+    @account = Account.find_local!(params[:account_username])
+  end
+
+  def set_link_headers
+    response.headers['Link'] = LinkHeader.new([[account_stream_entry_url(@account, @status.stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]]])
+  end
+
+  def set_status
+    @status       = @account.statuses.find(params[:id])
+    @stream_entry = @status.stream_entry
+    @type         = @stream_entry.activity_type.downcase
+
+    raise ActiveRecord::RecordNotFound unless @status.permitted?(current_account)
+  end
+
+  def check_account_suspension
+    gone if @account.suspended?
+  end
+end