email-responder.js

Go to the documentation of this file.
00001 /***
00002 email-responder: A TextMill module that treats an email that's not the first
00003 in a thread as a possible endorsement of the sender. Simplistic - takes any
00004 email with a References header or a quotation line as not-the-first.
00005 
00006 Copyright 2008 Michael Wojcik, wojcikm4@msu.edu.
00007 ***/
00008 
00009 var emailResponder =
00010 {
00011    /* Module name for TM */
00012    name: "emailResponder",
00013 
00014    /***
00015    A TM Taker for an email. It will identify the source and add it if it
00016    doesn't already exist. It will try to see if the message is a reply, by
00017    looking for a References header, or failing that a standard quoted-text
00018    marker. If it finds a References header, it'll add a
00019    {probable, maybe-strength} update to the source's standing. If it finds
00020    what appears to be quoted text, it'll add a {maybe, maybe-strength}
00021    update.
00022    ***/
00023 
00024    TakeEmail: function(self, email, multiText)
00025    {
00026       var author =
00027          email.replace(/.*\n?From: *([^\n(]*)(.|\n)*/,"$1").replace(/ *$/,"");
00028       var references = email.search(/\n?References:[^:]*</);
00029       var quote = email.search(/\n> /);
00030       var source;
00031 
00032       /* New source? */
00033       source = TextMill.sources? TextMill.sources[author] : null;
00034       if (! source) source = new Source(author);
00035 
00036       /* Is this definitely a reply? */
00037       if (references >= 0) source.updateStanding(0.8, 0.6);
00038 
00039       /* Is this probably a reply? */
00040       else if (quote >= 0) source.updateStanding(0.5, 0.5);
00041 
00042       return true;   /* tell caller we're done with this transform */
00043    }
00044 };
00045 

Based on content generated using Doxygen