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.

45 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. class StreamEntriesController < ApplicationController
  3. layout 'public'
  4. before_action :set_account
  5. before_action :set_stream_entry
  6. before_action :set_link_headers
  7. before_action :check_account_suspension
  8. def show
  9. @type = @stream_entry.activity_type.downcase
  10. respond_to do |format|
  11. format.html do
  12. return gone if @stream_entry.activity.nil?
  13. if @stream_entry.activity_type == 'Status'
  14. @ancestors = @stream_entry.activity.ancestors
  15. @descendants = @stream_entry.activity.descendants
  16. end
  17. end
  18. format.atom
  19. end
  20. end
  21. private
  22. def set_account
  23. @account = Account.find_local!(params[:account_username])
  24. end
  25. def set_link_headers
  26. response.headers['Link'] = LinkHeader.new([[account_stream_entry_url(@account, @stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]]])
  27. end
  28. def set_stream_entry
  29. @stream_entry = @account.stream_entries.find(params[:id])
  30. end
  31. def check_account_suspension
  32. head 410 if @account.suspended?
  33. end
  34. end