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.

44 lines
1.2 KiB

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