aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/outgoing_message.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index c2c8ef4f2..e59ca4bd4 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -141,21 +141,17 @@ class OutgoingMessage < ActiveRecord::Base
end
def body
- ret = read_attribute(:body)
- if ret.nil?
- return ret
- end
+ text = read_attribute(:body).dup
+ return text if text.nil?
- ret = ret.dup
- ret.strip!
- ret.gsub!(/(?:\n\s*){2,}/, "\n\n") # remove excess linebreaks that unnecessarily space it out
+ text = clean_text(text)
# Remove things from censor rules
unless info_request.nil?
- self.info_request.apply_censor_rules_to_text!(ret)
+ self.info_request.apply_censor_rules_to_text!(text)
end
- ret
+ text
end
def raw_body
@@ -332,6 +328,11 @@ class OutgoingMessage < ActiveRecord::Base
errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.'))
end
end
+
+ # remove excess linebreaks that unnecessarily space it out
+ def clean_text(text)
+ text.strip.gsub(/(?:\n\s*){2,}/, "\n\n")
+ end
end