DEV: Do not clean up chat message uploads (#14267)

DEV: Do not clean up chat message uploads (#14267)

diff --git a/app/jobs/scheduled/clean_up_uploads.rb b/app/jobs/scheduled/clean_up_uploads.rb
index 77f6503..a3d9f1e 100644
--- a/app/jobs/scheduled/clean_up_uploads.rb
+++ b/app/jobs/scheduled/clean_up_uploads.rb
@@ -39,6 +39,10 @@ module Jobs
           next if ReviewableQueuedPost.pending.where("payload->>'raw' LIKE '%#{upload.sha1}%' OR payload->>'raw' LIKE '%#{encoded_sha}%'").exists?
           next if Draft.where("data LIKE '%#{upload.sha1}%' OR data LIKE '%#{encoded_sha}%'").exists?
           next if ThemeSetting.where(data_type: ThemeSetting.types[:upload]).where("value LIKE ?", "%#{upload.sha1}%").exists?
+          if defined?(ChatMessage) &&
+              ChatMessage.where("message LIKE ? OR message LIKE ?", "%#{upload.sha1}%", "%#{encoded_sha}%").exists?
+            next
+          end
           upload.destroy
         else
           upload.delete

GitHub sha: f4cca4af75aa724d49b6b45090905cdff26a8e56

This commit appears in #14267 which was approved by eviltrout. It was merged by markvanlan.