You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. class StatusesController < ApplicationController
  3. layout 'public'
  4. before_action :set_account
  5. before_action :set_status
  6. before_action :set_link_headers
  7. before_action :check_account_suspension
  8. def show
  9. @ancestors = @status.reply? ? cache_collection(@status.ancestors(current_account), Status) : []
  10. @descendants = cache_collection(@status.descendants(current_account), Status)
  11. render 'stream_entries/show'
  12. end
  13. private
  14. def set_account
  15. @account = Account.find_local!(params[:account_username])
  16. end
  17. def set_link_headers
  18. response.headers['Link'] = LinkHeader.new([[account_stream_entry_url(@account, @status.stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]]])
  19. end
  20. def set_status
  21. @status = @account.statuses.find(params[:id])
  22. @stream_entry = @status.stream_entry
  23. @type = @stream_entry.activity_type.downcase
  24. raise ActiveRecord::RecordNotFound unless @status.permitted?(current_account)
  25. end
  26. def check_account_suspension
  27. gone if @account.suspended?
  28. end
  29. end