]>
cat aescling's git repositories - mastodon.git/blob - app/controllers/statuses_controller.rb
1 # frozen_string_literal: true
3 class StatusesController
< ApplicationController
4 include SignatureAuthentication
9 before_action
:set_account
10 before_action
:set_status
11 before_action
:set_link_headers
12 before_action
:check_account_suspension
13 before_action
:redirect_to_original, only
: [:show]
14 before_action
:set_cache_headers
17 respond_to
do |format
|
20 @ancestors = @status.reply
? ? cache_collection(@status.ancestors(current_account
), Status
) : []
21 @descendants = cache_collection(@status.descendants(current_account
), Status
)
23 render
'stream_entries/show'
27 skip_session!
unless @stream_entry.hidden
?
29 render_cached_json(['activitypub', 'note', @status.cache_key
], content_type
: 'application/activity+json
', public: !@stream_entry.hidden
?) do
30 ActiveModelSerializers
::SerializableResource.new(@status, serializer
: ActivityPub
::NoteSerializer, adapter
: ActivityPub
::Adapter)
39 render_cached_json(['activitypub', 'activity', @status.cache_key
], content_type
: 'application/activity+json
', public: !@stream_entry.hidden
?) do
40 ActiveModelSerializers
::SerializableResource.new(@status, serializer
: ActivityPub
::ActivitySerializer, adapter
: ActivityPub
::Adapter)
46 response
.headers
['X-Frame-Options'] = 'ALLOWALL'
47 render
'stream_entries/embed', layout
: 'embedded'
53 @account = Account
.find_local!
(params
[:account_username])
57 response
.headers
['Link'] = LinkHeader
.new(
59 [account_stream_entry_url(@account, @status.stream_entry
, format
: 'atom'), [%w(rel alternate
), %w(type application
/atom+xml
)]],
60 [ActivityPub
::TagManager.instance
.uri_for(@status), [%w(rel alternate
), %w(type application
/activity+json
)]],
66 @status = @account.statuses
.find(params
[:id])
67 @stream_entry = @status.stream_entry
68 @type = @stream_entry.activity_type
.downcase
70 authorize
@status, :show?
71 rescue Mastodon
::NotPermittedError
72 # Reraise in order to get a 404
73 raise ActiveRecord
::RecordNotFound
76 def check_account_suspension
77 gone
if @account.suspended
?
80 def redirect_to_original
81 redirect_to
::TagManager.instance
.url_for(@status.reblog
) if @status.reblog
?
This page took 0.091188 seconds and 4 git commands to generate.