diff options
-rw-r--r-- | app/models/incoming_message.rb | 73 | ||||
-rw-r--r-- | app/views/request/_bubble.rhtml | 1 | ||||
-rw-r--r-- | todo.txt | 3 |
3 files changed, 73 insertions, 4 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 28a06ac65..2eaaee1e2 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.185 2009-01-26 16:52:15 francis Exp $ +# $Id: incoming_message.rb,v 1.186 2009-02-03 03:43:00 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -155,6 +155,56 @@ def normalise_content_type(content_type) return content_type end + +$dsn_to_message = { + 'X.1.0' => 'Other address status', + 'X.1.1' => 'Bad destination mailbox address', + 'X.1.2' => 'Bad destination system address', + 'X.1.3' => 'Bad destination mailbox address syntax', + 'X.1.4' => 'Destination mailbox address ambiguous', + 'X.1.5' => 'Destination mailbox address valid', + 'X.1.6' => 'Mailbox has moved', + 'X.1.7' => 'Bad sender\'s mailbox address syntax', + 'X.1.8' => 'Bad sender\'s system address', + 'X.2.0' => 'Other or undefined mailbox status', + 'X.2.1' => 'Mailbox disabled, not accepting messages', + 'X.2.2' => 'Mailbox full', + 'X.2.3' => 'Message length exceeds administrative limit.', + 'X.2.4' => 'Mailing list expansion problem', + 'X.3.0' => 'Other or undefined mail system status', + 'X.3.1' => 'Mail system full', + 'X.3.2' => 'System not accepting network messages', + 'X.3.3' => 'System not capable of selected features', + 'X.3.4' => 'Message too big for system', + 'X.4.0' => 'Other or undefined network or routing status', + 'X.4.1' => 'No answer from host', + 'X.4.2' => 'Bad connection', + 'X.4.3' => 'Routing server failure', + 'X.4.4' => 'Unable to route', + 'X.4.5' => 'Network congestion', + 'X.4.6' => 'Routing loop detected', + 'X.4.7' => 'Delivery time expired', + 'X.5.0' => 'Other or undefined protocol status', + 'X.5.1' => 'Invalid command', + 'X.5.2' => 'Syntax error', + 'X.5.3' => 'Too many recipients', + 'X.5.4' => 'Invalid command arguments', + 'X.5.5' => 'Wrong protocol version', + 'X.6.0' => 'Other or undefined media error', + 'X.6.1' => 'Media not supported', + 'X.6.2' => 'Conversion required and prohibited', + 'X.6.3' => 'Conversion required but not supported', + 'X.6.4' => 'Conversion with loss performed', + 'X.6.5' => 'Conversion failed', + 'X.7.0' => 'Other or undefined security status', + 'X.7.1' => 'Delivery not authorized, message refused', + 'X.7.2' => 'Mailing list expansion prohibited', + 'X.7.3' => 'Security conversion required but not possible', + 'X.7.4' => 'Security features not supported', + 'X.7.5' => 'Cryptographic failure', + 'X.7.6' => 'Cryptographic algorithm not supported', + 'X.7.7' => 'Message integrity failure' +} # This is the type which is used to send data about attachments to the view class FOIAttachment @@ -164,6 +214,27 @@ class FOIAttachment attr_accessor :url_part_number attr_accessor :within_rfc822_subject # we use the subject as the filename for email attachments + # Returns HTML, of extra comment to put by attachment + def extra_note + # For delivery status notification attachments, extract the status and + # look up what it means in the DSN table. + if @content_type == 'message/delivery-status': + if !@body.match(/Status:\s+([0-9]+\.([0-9]+\.[0-9]+))\s+/) + return "" + end + dsn = $1 + dsn_part = 'X.' + $2 + + dsn_message = "" + if $dsn_to_message.include?(dsn_part) + dsn_message = " (" + $dsn_to_message[dsn_part] + ")" + end + + return "<br><em>DSN: " + dsn + dsn_message + "</em>" + end + return "" + end + def display_filename calc_ext = mimetype_to_extension(@content_type) diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.rhtml index d58573247..e6d271e4c 100644 --- a/app/views/request/_bubble.rhtml +++ b/app/views/request/_bubble.rhtml @@ -27,6 +27,7 @@ <%= link_to "View as HTML", attachment_as_html_url %> <% end %> <!-- (<%= a.content_type %>) --> + <%= a.extra_note %> </p> <% end %> <hr class="bottom"> @@ -278,9 +278,6 @@ And indeed so links work: Failed to detect attachments are emails and decode them: http://www.whatdotheyknow.com/request/malicious_communication_act#incoming-12964 -Make it read the number in DSNs and decode it to describe problem? - http://www.whatdotheyknow.com/request/febrile_neutropenia_123#incoming-13165 - Totally new features -------------------- |