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.

46 lines
1.2 KiB

  1. class StreamEntriesController < ApplicationController
  2. layout 'public'
  3. before_action :set_account
  4. before_action :set_stream_entry
  5. before_action :set_link_headers
  6. def show
  7. @type = @stream_entry.activity_type.downcase
  8. if @stream_entry.activity_type == 'Status'
  9. @ancestors = @stream_entry.activity.ancestors
  10. @descendants = @stream_entry.activity.descendants
  11. if user_signed_in?
  12. status_ids = [@stream_entry.activity_id] + @ancestors.map(&:id) + @descendants.map(&:id)
  13. @favourited = Status.favourites_map(status_ids, current_user.account_id)
  14. @reblogged = Status.reblogs_map(status_ids, current_user.account_id)
  15. else
  16. @favourited = {}
  17. @reblogged = {}
  18. end
  19. end
  20. respond_to do |format|
  21. format.html
  22. format.atom
  23. end
  24. end
  25. private
  26. def set_account
  27. @account = Account.find_local!(params[:account_username])
  28. end
  29. def set_link_headers
  30. response.headers['Link'] = LinkHeader.new([
  31. [account_stream_entry_url(@account, @stream_entry, format: 'atom'), [['rel', 'alternate'], ['type', 'application/atom+xml']]]
  32. ])
  33. end
  34. def set_stream_entry
  35. @stream_entry = @account.stream_entries.find(params[:id])
  36. end
  37. end