aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2007-12-23 13:44:18 +0000
committerfrancis <francis>2007-12-23 13:44:18 +0000
commit61d5517821d89c561b7522ef2a2bbdd1b50f6ada (patch)
tree2ba47dbca8b7630a6f71b77d081fb89695c13150
parent8e4d6d0b7bd57a2517129256efca91f2efffdc42 (diff)
Make links in incoming and outgoing messages hyperlinks.
-rw-r--r--app/models/incoming_message.rb14
-rw-r--r--app/models/outgoing_message.rb3
-rw-r--r--todo.txt2
3 files changed, 12 insertions, 7 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 089ff0842..bb54be2bb 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -19,7 +19,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: incoming_message.rb,v 1.11 2007-12-22 13:12:08 francis Exp $
+# $Id: incoming_message.rb,v 1.12 2007-12-23 13:44:18 francis Exp $
class IncomingMessage < ActiveRecord::Base
belongs_to :info_request
@@ -48,7 +48,7 @@ class IncomingMessage < ActiveRecord::Base
# Remove email addresses from text (mainly to reduce spam - particularly
# we want to stop spam to our own magic archiving request-* addresses,
# which would otherwise appear a lot in bounce messages and reply quotes etc.)
- def self.email_filter(text)
+ def self.remove_email_addresses(text)
text = text.dup
# Remove any email addresses - we don't want bounce messages to leak out
@@ -63,7 +63,7 @@ class IncomingMessage < ActiveRecord::Base
# Remove quoted sections from emails (eventually the aim would be for this
# to do as good a job as GMail does) XXX bet it needs a proper parser
# XXX and this BEGIN_QUOTED / END_QUOTED stuff is a mess
- def self.remove_email_quotage(text)
+ def self.remove_quoted_sections(text)
text = text.dup
text.gsub!(/^(>.+\n)/, "BEGIN_QUOTED\\1END_QUOTED")
@@ -81,6 +81,8 @@ class IncomingMessage < ActiveRecord::Base
# Returns body text as HTML with quotes flattened, and emails removed.
def get_body_for_display(collapse_quoted_sections = true)
+ # Find the body text
+
# XXX make this part scanning for mime parts properly recursive,
# allow download of specific parts, and always show them all (in
# case say the HTML differs from the text part)
@@ -105,9 +107,11 @@ class IncomingMessage < ActiveRecord::Base
text = self.mail.body
end
- text = IncomingMessage.email_filter(text)
- text = IncomingMessage.remove_email_quotage(text)
+ # Format the body text
+ text = IncomingMessage.remove_email_addresses(text)
+ text = IncomingMessage.remove_quoted_sections(text)
text = CGI.escapeHTML(text)
+ text = MySociety::Format.make_clickable(text, :contract => 1)
if collapse_quoted_sections
text = text.gsub(/(BEGIN_QUOTED(.+?)END_QUOTED)+/m, '<a href="?unfold=1">show quoted sections</a>')
else
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 2f46ce84e..e24e8ae97 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -20,7 +20,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: outgoing_message.rb,v 1.13 2007-12-22 03:04:27 francis Exp $
+# $Id: outgoing_message.rb,v 1.14 2007-12-23 13:44:18 francis Exp $
class OutgoingMessage < ActiveRecord::Base
belongs_to :info_request
@@ -81,6 +81,7 @@ class OutgoingMessage < ActiveRecord::Base
# Return body for display as HTML
def get_body_for_display
text = body
+ text = MySociety::Format.make_clickable(text, :contract => 1)
text = text.gsub(/\n/, '<br>')
return text
diff --git a/todo.txt b/todo.txt
index 86d7832ea..47a5d82ac 100644
--- a/todo.txt
+++ b/todo.txt
@@ -34,7 +34,7 @@ Either rotate log files, or merge with Apache ones
Format user emails as well as request ones
-Let requester send follow-ups
+Let requester send follow-ups - but to which email address???!! aargh
Do something after 20 working days if you get no response
Work out how to get it to tell you code coverage of .rhtml files