about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-12-21 15:59:39 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-12-21 15:59:39 +0100
commitb248aa4d3eb52c2bb7459848ff09619bb8830ed7 (patch)
treeb40d2a4546fa42a0373127bf11cb06491a1d75f3 /app/services
parentba1569400322930ebe32693750b8e1abff395829 (diff)
parentc4a429ed47e85a6bbf0d470a41cc2f64cf120c19 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/services')
-rw-r--r--app/services/suspend_account_service.rb5
-rw-r--r--app/services/unsuspend_account_service.rb5
2 files changed, 10 insertions, 0 deletions
diff --git a/app/services/suspend_account_service.rb b/app/services/suspend_account_service.rb
index b8dc8d5e0..6856c2c51 100644
--- a/app/services/suspend_account_service.rb
+++ b/app/services/suspend_account_service.rb
@@ -76,10 +76,15 @@ class SuspendAccountService < BaseService
         styles.each do |style|
           case Paperclip::Attachment.default_options[:storage]
           when :s3
+            # Prevent useless S3 calls if ACLs are disabled
+            next if ENV['S3_PERMISSION'] == ''
+
             begin
               attachment.s3_object(style).acl.put(acl: 'private')
             rescue Aws::S3::Errors::NoSuchKey
               Rails.logger.warn "Tried to change acl on non-existent key #{attachment.s3_object(style).key}"
+            rescue Aws::S3::Errors::NotImplemented => e
+              Rails.logger.error "Error trying to change ACL on #{attachment.s3_object(style).key}: #{e.message}"
             end
           when :fog
             # Not supported
diff --git a/app/services/unsuspend_account_service.rb b/app/services/unsuspend_account_service.rb
index 39d8a6ba7..534203dce 100644
--- a/app/services/unsuspend_account_service.rb
+++ b/app/services/unsuspend_account_service.rb
@@ -73,10 +73,15 @@ class UnsuspendAccountService < BaseService
         styles.each do |style|
           case Paperclip::Attachment.default_options[:storage]
           when :s3
+            # Prevent useless S3 calls if ACLs are disabled
+            next if ENV['S3_PERMISSION'] == ''
+
             begin
               attachment.s3_object(style).acl.put(acl: Paperclip::Attachment.default_options[:s3_permissions])
             rescue Aws::S3::Errors::NoSuchKey
               Rails.logger.warn "Tried to change acl on non-existent key #{attachment.s3_object(style).key}"
+            rescue Aws::S3::Errors::NotImplemented => e
+              Rails.logger.error "Error trying to change ACL on #{attachment.s3_object(style).key}: #{e.message}"
             end
           when :fog
             # Not supported