The code powering m.abunchtell.com https://m.abunchtell.com
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

62 wiersze
1.7 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. respond_to do |format|
  11. format.html do
  12. @ancestors = @status.reply? ? cache_collection(@status.ancestors(current_account), Status) : []
  13. @descendants = cache_collection(@status.descendants(current_account), Status)
  14. render 'stream_entries/show'
  15. end
  16. format.json do
  17. render json: @status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
  18. end
  19. end
  20. end
  21. def activity
  22. render json: @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
  23. end
  24. private
  25. def set_account
  26. @account = Account.find_local!(params[:account_username])
  27. end
  28. def set_link_headers
  29. response.headers['Link'] = LinkHeader.new(
  30. [
  31. [account_stream_entry_url(@account, @status.stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]],
  32. [ActivityPub::TagManager.instance.uri_for(@status), [%w(rel alternate), %w(type application/activity+json)]],
  33. ]
  34. )
  35. end
  36. def set_status
  37. @status = @account.statuses.find(params[:id])
  38. @stream_entry = @status.stream_entry
  39. @type = @stream_entry.activity_type.downcase
  40. authorize @status, :show?
  41. rescue Mastodon::NotPermittedError
  42. # Reraise in order to get a 404
  43. raise ActiveRecord::RecordNotFound
  44. end
  45. def check_account_suspension
  46. gone if @account.suspended?
  47. end
  48. end