transparancy log - automatically add a content warning if there are admin comments; support a custom `subject`
parent
8c196e70b1
commit
b2d0389fea
|
@ -5,7 +5,7 @@ class LogWorker
|
||||||
|
|
||||||
sidekiq_options unique: :until_executed
|
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
|
logger_id = ENV['LOG_USER'].to_i
|
||||||
return true if logger_id == 0
|
return true if logger_id == 0
|
||||||
|
|
||||||
|
@ -14,9 +14,13 @@ class LogWorker
|
||||||
|
|
||||||
scope_prefix = ENV.fetch('LOG_SCOPE_PREFIX', 'admin.log')
|
scope_prefix = ENV.fetch('LOG_SCOPE_PREFIX', 'admin.log')
|
||||||
tag = scope.nil? ? scope_prefix : "#{scope_prefix}.#{scope}"
|
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(
|
PostStatusService.new.call(
|
||||||
logger,
|
logger,
|
||||||
|
spoiler_text: subject,
|
||||||
created_at: Time.now.utc,
|
created_at: Time.now.utc,
|
||||||
text: log_text.strip,
|
text: log_text.strip,
|
||||||
tags: [tag],
|
tags: [tag],
|
||||||
|
|
Loading…
Reference in New Issue