diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index c550b38e8e4d4ea346ce1cab8e1633bcd8df481d..4ccf20bc97c0331ca336e27d6d055dd80edfda2f 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -18,6 +18,10 @@ class ApiController < ApplicationController render json: { error: 'Remote data could not be fetched' }, status: 503 end + rescue_from OpenSSL::SSL::SSLError do + render json: { error: 'Remote SSL certificate could not be verified' }, status: 503 + end + protected def current_resource_owner diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c8d7e2084ccf8a99ea2533196712cdaf57a5bb17..1f991cf6720723cbe98249bfe0c58c094b596d1c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -30,6 +30,12 @@ class ApplicationController < ActionController::Base end end + def gone + respond_to do |format| + format.any { head 410 } + end + end + def current_account current_user.try(:account) end diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb index e1b664b08a191fbda2539a1adfd41d12f100907c..a364fa01c4f96c7227aa7e1dba1feceb31817e9f 100644 --- a/app/controllers/stream_entries_controller.rb +++ b/app/controllers/stream_entries_controller.rb @@ -8,13 +8,16 @@ class StreamEntriesController < ApplicationController def show @type = @stream_entry.activity_type.downcase - if @stream_entry.activity_type == 'Status' - @ancestors = @stream_entry.activity.ancestors - @descendants = @stream_entry.activity.descendants - end - respond_to do |format| - format.html + format.html do + return gone if @stream_entry.activity.nil? + + if @stream_entry.activity_type == 'Status' + @ancestors = @stream_entry.activity.ancestors + @descendants = @stream_entry.activity.descendants + end + end + format.atom end end diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb index 4be7f6355791b6ff4127a3431cf5122bb94cc677..f2625dcaa3133721b2684470be70e3babb3c804d 100644 --- a/app/services/fetch_atom_service.rb +++ b/app/services/fetch_atom_service.rb @@ -12,6 +12,9 @@ class FetchAtomService < BaseService else return process_html(fetch(url)) end + + rescue OpenSSL::SSL::SSLError => e + Rails.logger.debug "SSL error: #{e}" end private diff --git a/app/services/fetch_remote_account_service.rb b/app/services/fetch_remote_account_service.rb index 5f45f9b2899f979186a9025d01bf2cbe697543dc..83a81a61be3ca75e0d10ecc8e1be43cc9497f610 100644 --- a/app/services/fetch_remote_account_service.rb +++ b/app/services/fetch_remote_account_service.rb @@ -19,5 +19,7 @@ class FetchRemoteAccountService < BaseService Rails.logger.debug "Going to webfinger #{username}@#{domain}" return FollowRemoteAccountService.new.call("#{username}@#{domain}") + rescue Nokogiri::XML::XPath::SyntaxError + Rails.logger.debug "Invalid XML or missing namespace" end end diff --git a/app/services/fetch_remote_status_service.rb b/app/services/fetch_remote_status_service.rb index 24a63e8414d0cba061a2a1145ccd9dd74a49451e..a507fbeed55001e8a5ea6a57aaca74831224eed4 100644 --- a/app/services/fetch_remote_status_service.rb +++ b/app/services/fetch_remote_status_service.rb @@ -31,5 +31,8 @@ class FetchRemoteStatusService < BaseService Rails.logger.debug "Going to webfinger #{username}@#{domain}" return FollowRemoteAccountService.new.call("#{username}@#{domain}") + rescue Nokogiri::XML::XPath::SyntaxError + Rails.logger.debug "Invalid XML or missing namespace" + end end end diff --git a/config/environments/production.rb b/config/environments/production.rb index ee7598c4cc9eb6f03ec13815594886f3dd07dea7..5e010b2065a2ea389a20c6a1dddcb204be79f778 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -85,4 +85,6 @@ Rails.application.configure do config.action_mailer.delivery_method = :smtp config.react.variant = :production + + config.active_record.logger = nil end