about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-09 19:13:04 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-09 19:13:04 -0500
commitb2d0389fea353f834c507da05106dabd4ae47831 (patch)
treea08120e4fb6e002affbedfd6f8a57204fdfb7f42 /app/workers
parent8c196e70b17729a7bdf7d7412e914526af0cccc3 (diff)
transparancy log - automatically add a content warning if there are admin comments; support a custom `subject`
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/log_worker.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/workers/log_worker.rb b/app/workers/log_worker.rb
index f6a837153..35c9df44e 100644
--- a/app/workers/log_worker.rb
+++ b/app/workers/log_worker.rb
@@ -5,7 +5,7 @@ class LogWorker
 
   sidekiq_options unique: :until_executed
 
-  def perform(log_text, scope: nil, markdown: false)
+  def perform(log_text, subject: nil, markdown: false, scope: nil)
     logger_id = ENV['LOG_USER'].to_i
     return true if logger_id == 0
 
@@ -14,9 +14,13 @@ class LogWorker
 
     scope_prefix = ENV.fetch('LOG_SCOPE_PREFIX', 'admin.log')
     tag = scope.nil? ? scope_prefix : "#{scope_prefix}.#{scope}"
+    if subject.nil? && log_text.match?(/comments?:/i)
+      subject = 'This admin action may contain sensitive content.'
+    end
 
     PostStatusService.new.call(
       logger,
+      spoiler_text: subject,
       created_at: Time.now.utc,
       text: log_text.strip,
       tags: [tag],