Strip quoted emails in replies
subdian - April 27, 2009 - 16:00
| Project: | Listhandler |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi,
A really useful feature would be the ability to strip out quoted emails in replies. The problem is that if a mail client quotes the original email in a reply, then the original email will be displayed in the forum, so each forum post will be getting longer and longer, and it becomes hard to find the actual messages.

#1
While I'm not sure how to make a proper patch file, here's a diff file with my changes:
2c2< // $Id: listhandler.module,v 1.75.2.13 2008/10/27 20:10:29 philipnet Exp $
---
> // $Id: listhandler.module,v 1.75.2.12 2008/07/26 16:21:15 philipnet Exp $
83,91d82
<
< $form['listhandler_strip_body'] = array(
< '#type' => 'textfield',
< '#title' => t('Strip body from'),
< '#default_value' => variable_get('listhandler_strip_body', '/(On .*? wrote)|(_{10,}\s*From:)|((>\s*){0,1}-{5,}\s*Original Message\s*-{5,})/'),
< '#size' => 50,
< '#maxlength' => 1024,
< '#description' => t("A comma delimited regex from which the body of messages should be discarded. Useful for deleting unwanted reply emails"));
<
161,162d151
< variable_set('listhandler_strip_body', $form_values['listhandler_strip_body']);
<
190,192c179,183
< $node->subject = $node->title;
< $node->comment = $node->body;
< listhandler_send_mail((array) $node);
---
> if(!spam_content_filter('forum', $node->nid, $node->title, $node->body)) {
> $node->subject = $node->title;
> $node->comment = $node->body;
> listhandler_send_mail((array) $node);
> }
239,240c230,232
<
< listhandler_send_mail($edit);
---
> if(!spam_content_filter('comment', $edit['cid'], $edit['subject'], $edit['comment'])) {
> listhandler_send_mail($edit);
> }
251,259c243
<
< if (!$user->uid) {
< $edit['name'] = variable_get('anonymous', 'Anonymous');
< $edit['mail'] = variable_get('listhandler_from', '');
< }
< else {
< $edit["name"] = $user->name;
< $edit["mail"] = $user->mail;
< }
---
>
296a281,294
> // Fill the user email, check if subscribed
> if (!$user->uid) {
> $edit['name'] = variable_get('anonymous', 'Anonymous');
> $edit['mail'] = variable_get('listhandler_from', '');
> }
> else if(!_listhandler_user_subscribed($mboxen[0][1], $user->mail)) {
> $edit['name'] = variable_get('anonymous', 'Anonymous');
> $edit['mail'] = $user->name . ' <' . variable_get('listhandler_from', '').'>';
> }
> else {
> $edit["name"] = $user->name;
> $edit["mail"] = $user->mail;
> }
>
437,443d434
<
< //Remove body from regex
< $strip_body_regex = variable_get('listhandler_strip_body', '');
< $body = preg_split($strip_body_regex, $node->body);
<
< $node->body = $body[0];
<
581c572
< $message .= "Content-Type:$file->filemime;\n\tname=\"$file->filename\"\n";
---
> $message .= "Content-Type:$file->filemime;\n\tname=$file->filename\n";
583c574
< $message .= "Content-Disposition: attachment;\n\tfilename=\"$file->filename\"\n\n";
---
> $message .= "Content-Disposition: attachment;\n\tfilename=$file->filename\n\n";
627a619,631
>
> function _listhandler_user_subscribed($list_mail, $user_mail) {
> //Get the mail up to the @, add -request to it
> $list_name = substr($list_mail, 0, strpos($list_mail, '@'));
> $list_req = $list_name . '-request'.substr($list_mail, strpos($list_mail, '@'));
>
> //Match mailman users table
> $sql = "SELECT lstatus FROM {mailman_users} mu LEFT JOIN {mailman_lists} ml on mu.lid=ml.lid WHERE mu.lmail='".$user_mail."' AND ml.command='".$list_req."' AND mu.lstatus<>0";
> $result = db_query("SELECT lstatus FROM {mailman_users} mu LEFT JOIN {mailman_lists} ml on mu.lid=ml.lid WHERE mu.lmail='".$user_mail."' AND ml.command='".$list_req."' AND mu.lstatus<>0");
> if(db_num_rows($result)>0) return true;
> else return false;
>
> }
#2
Check also #225375: A Question about quoted messages in body.
Less intuitive but, in my opinion, more customizable and,above all, it doesn't delete portions of the message source (that is useful to revert errouneous filters or for further actions).
#3
I would love a d6 port of something like this. I've been trying to make a workable flexifilter, but it's that module seems to be a bit, err, rough around the edges. ;-)