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.

41 lines
951 B

  1. class StreamEntriesController < ApplicationController
  2. layout 'public'
  3. before_action :set_account
  4. before_action :set_stream_entry
  5. before_action :authenticate_user!, only: [:reblog, :favourite]
  6. before_action :only_statuses!, only: [:reblog, :favourite]
  7. def show
  8. @type = @stream_entry.activity_type.downcase
  9. respond_to do |format|
  10. format.html
  11. format.atom
  12. end
  13. end
  14. def reblog
  15. ReblogService.new.(current_user.account, @stream_entry.activity)
  16. redirect_to root_path
  17. end
  18. def favourite
  19. FavouriteService.new.(current_user.account, @stream_entry.activity)
  20. redirect_to root_path
  21. end
  22. private
  23. def set_account
  24. @account = Account.find_by!(username: params[:account_username], domain: nil)
  25. end
  26. def set_stream_entry
  27. @stream_entry = @account.stream_entries.find(params[:id])
  28. end
  29. def only_statuses!
  30. redirect_to root_url unless @stream_entry.activity_type == 'Status'
  31. end
  32. end