about summary refs log tree commit diff
path: root/app/services/activitypub/process_status_update_service.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-27 20:39:05 +0100
committerGitHub <noreply@github.com>2022-11-27 20:39:05 +0100
commit625216d8e14cd567bffe14fb73343f27e81dcb1d (patch)
treeb97f9da8d87bc9c1cbc9c8ce0a02975d13ce6e9f /app/services/activitypub/process_status_update_service.rb
parentd587a268fdcee4ab8795fe4f03dff683e668ae15 (diff)
Fix attachments of edited statuses not being fetched (#21565)
* Fix attachments of edited statuses not being fetched

* Fix tests
Diffstat (limited to 'app/services/activitypub/process_status_update_service.rb')
-rw-r--r--app/services/activitypub/process_status_update_service.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/activitypub/process_status_update_service.rb b/app/services/activitypub/process_status_update_service.rb
index addd5fc27..a0605b1a3 100644
--- a/app/services/activitypub/process_status_update_service.rb
+++ b/app/services/activitypub/process_status_update_service.rb
@@ -92,7 +92,13 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
 
         next if unsupported_media_type?(media_attachment_parser.file_content_type) || skip_download?
 
-        RedownloadMediaWorker.perform_async(media_attachment.id) if media_attachment.remote_url_previously_changed? || media_attachment.thumbnail_remote_url_previously_changed?
+        begin
+          media_attachment.download_file! if media_attachment.remote_url_previously_changed?
+          media_attachment.download_thumbnail! if media_attachment.thumbnail_remote_url_previously_changed?
+          media_attachment.save
+        rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError
+          RedownloadMediaWorker.perform_in(rand(30..600).seconds, media_attachment.id)
+        end
       rescue Addressable::URI::InvalidURIError => e
         Rails.logger.debug "Invalid URL in attachment: #{e}"
       end