aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/outgoing_message.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 8240eb784..3448009bd 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -140,18 +140,28 @@ class OutgoingMessage < ActiveRecord::Base
end
end
- def body
+ # Public: The body text of the OutgoingMessage. The text is cleaned and
+ # CensorRules are applied.
+ #
+ # options - Hash of options
+ # :censor_rules - Array of CensorRules to apply. Defaults to the
+ # applicable_censor_rules of the associated
+ # InfoRequest. (optional)
+ #
+ # Returns a String
+ def body(options = {})
text = raw_body.dup
return text if text.nil?
text = clean_text(text)
- # Remove things from censor rules
- unless info_request.nil?
- self.info_request.apply_censor_rules_to_text!(text)
+ # Use the given censor_rules; otherwise fetch them from the associated
+ # info_request
+ censor_rules = options.fetch(:censor_rules) do
+ info_request.try(:applicable_censor_rules) or []
end
- text
+ censor_rules.reduce(text) { |text, rule| rule.apply_to_text(text) }
end
def raw_body