2016-11-15 15:56:29 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-29 18:42:08 +00:00
|
|
|
class StreamEntriesController < ApplicationController
|
2016-03-05 22:42:40 +00:00
|
|
|
layout 'public'
|
|
|
|
|
2016-02-29 18:42:08 +00:00
|
|
|
before_action :set_account
|
|
|
|
before_action :set_stream_entry
|
Fix #24 - Thread resolving for remote statuses
This is a big one, so let me enumerate:
Accounts as well as stream entry pages now contain Link headers that
reference the Atom feed and Webfinger URL for the former and Atom entry
for the latter. So you only need to HEAD those resources to get that
information, no need to download and parse HTML <link>s.
ProcessFeedService will now queue ThreadResolveWorker for each remote
status that it cannot find otherwise. Furthermore, entries are now
processed in reverse order (from bottom to top) in case a newer entry
references a chronologically previous one.
ThreadResolveWorker uses FetchRemoteStatusService to obtain a status
and attach the child status it was queued for to it.
FetchRemoteStatusService looks up the URL, first with a HEAD, tests
if it's an Atom feed, in which case it processes it directly. Next
for Link headers to the Atom feed, in which case that is fetched
and processed. Lastly if it's HTML, it is checked for <link>s to the Atom
feed, and if such is found, that is fetched and processed. The account for
the status is derived from author/name attribute in the XML and the hostname
in the URL (domain). FollowRemoteAccountService and ProcessFeedService
are used.
This means that potentially threads are resolved recursively until a dead-end
is encountered, however it is performed asynchronously over background jobs,
so it should be ok.
2016-09-21 00:34:14 +01:00
|
|
|
before_action :set_link_headers
|
2016-12-06 17:03:30 +00:00
|
|
|
before_action :check_account_suspension
|
2016-02-29 18:42:08 +00:00
|
|
|
|
|
|
|
def show
|
|
|
|
respond_to do |format|
|
2016-10-05 12:26:44 +01:00
|
|
|
format.html do
|
|
|
|
return gone if @stream_entry.activity.nil?
|
|
|
|
|
|
|
|
if @stream_entry.activity_type == 'Status'
|
2016-12-21 19:00:18 +00:00
|
|
|
@ancestors = @stream_entry.activity.ancestors(current_account)
|
|
|
|
@descendants = @stream_entry.activity.descendants(current_account)
|
2016-10-05 12:26:44 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-29 18:42:08 +00:00
|
|
|
format.atom
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-18 14:20:39 +00:00
|
|
|
def embed
|
|
|
|
response.headers['X-Frame-Options'] = 'ALLOWALL'
|
2016-12-18 18:47:11 +00:00
|
|
|
@external_links = true
|
2016-12-18 14:20:39 +00:00
|
|
|
|
|
|
|
return gone if @stream_entry.activity.nil?
|
|
|
|
|
|
|
|
render layout: 'embedded'
|
|
|
|
end
|
|
|
|
|
2016-02-29 18:42:08 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_account
|
2016-09-04 20:06:04 +01:00
|
|
|
@account = Account.find_local!(params[:account_username])
|
2016-02-29 18:42:08 +00:00
|
|
|
end
|
|
|
|
|
Fix #24 - Thread resolving for remote statuses
This is a big one, so let me enumerate:
Accounts as well as stream entry pages now contain Link headers that
reference the Atom feed and Webfinger URL for the former and Atom entry
for the latter. So you only need to HEAD those resources to get that
information, no need to download and parse HTML <link>s.
ProcessFeedService will now queue ThreadResolveWorker for each remote
status that it cannot find otherwise. Furthermore, entries are now
processed in reverse order (from bottom to top) in case a newer entry
references a chronologically previous one.
ThreadResolveWorker uses FetchRemoteStatusService to obtain a status
and attach the child status it was queued for to it.
FetchRemoteStatusService looks up the URL, first with a HEAD, tests
if it's an Atom feed, in which case it processes it directly. Next
for Link headers to the Atom feed, in which case that is fetched
and processed. Lastly if it's HTML, it is checked for <link>s to the Atom
feed, and if such is found, that is fetched and processed. The account for
the status is derived from author/name attribute in the XML and the hostname
in the URL (domain). FollowRemoteAccountService and ProcessFeedService
are used.
This means that potentially threads are resolved recursively until a dead-end
is encountered, however it is performed asynchronously over background jobs,
so it should be ok.
2016-09-21 00:34:14 +01:00
|
|
|
def set_link_headers
|
2016-11-15 15:56:29 +00:00
|
|
|
response.headers['Link'] = LinkHeader.new([[account_stream_entry_url(@account, @stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]]])
|
Fix #24 - Thread resolving for remote statuses
This is a big one, so let me enumerate:
Accounts as well as stream entry pages now contain Link headers that
reference the Atom feed and Webfinger URL for the former and Atom entry
for the latter. So you only need to HEAD those resources to get that
information, no need to download and parse HTML <link>s.
ProcessFeedService will now queue ThreadResolveWorker for each remote
status that it cannot find otherwise. Furthermore, entries are now
processed in reverse order (from bottom to top) in case a newer entry
references a chronologically previous one.
ThreadResolveWorker uses FetchRemoteStatusService to obtain a status
and attach the child status it was queued for to it.
FetchRemoteStatusService looks up the URL, first with a HEAD, tests
if it's an Atom feed, in which case it processes it directly. Next
for Link headers to the Atom feed, in which case that is fetched
and processed. Lastly if it's HTML, it is checked for <link>s to the Atom
feed, and if such is found, that is fetched and processed. The account for
the status is derived from author/name attribute in the XML and the hostname
in the URL (domain). FollowRemoteAccountService and ProcessFeedService
are used.
This means that potentially threads are resolved recursively until a dead-end
is encountered, however it is performed asynchronously over background jobs,
so it should be ok.
2016-09-21 00:34:14 +01:00
|
|
|
end
|
|
|
|
|
2016-02-29 18:42:08 +00:00
|
|
|
def set_stream_entry
|
2016-12-21 19:00:18 +00:00
|
|
|
@stream_entry = @account.stream_entries.where(hidden: false).find(params[:id])
|
2016-12-18 18:47:11 +00:00
|
|
|
@type = @stream_entry.activity_type.downcase
|
2016-02-29 18:42:08 +00:00
|
|
|
end
|
2016-12-06 17:03:30 +00:00
|
|
|
|
|
|
|
def check_account_suspension
|
|
|
|
head 410 if @account.suspended?
|
|
|
|
end
|
2016-02-29 18:42:08 +00:00
|
|
|
end
|