rev 1515 - trunk/siesta/lib/Siesta/Plugin

[prev] [thread] [next] [lurker] [Date index for 2004/04/13]

From: richardc
Subject: rev 1515 - trunk/siesta/lib/Siesta/Plugin
Date: 09:01 on 13 Apr 2004
Author: richardc
Date: 2004-04-13 09:01:45 +0100 (Tue, 13 Apr 2004)
New Revision: 1515

Added:
   trunk/siesta/lib/Siesta/Plugin/AvoidDups.pm
Log:
Subject: [siesta-dev] quick throwtogether of an AvoidDups plugin
From: Jody Belka
Date: Fri, 9 Apr 2004 00:24:52 +0000


Added: trunk/siesta/lib/Siesta/Plugin/AvoidDups.pm
===================================================================
--- trunk/siesta/lib/Siesta/Plugin/AvoidDups.pm	2004-04-07 16:47:21 UTC (rev 1514)
+++ trunk/siesta/lib/Siesta/Plugin/AvoidDups.pm	2004-04-13 08:01:45 UTC (rev 1515)
@@ -0,0 +1,45 @@
+package Siesta::Plugin::AvoidDups;
+use strict;
+use Siesta::Plugin;
+use base 'Siesta::Plugin';
+
+sub description {
+    "avoids duplicate copies of messages when listed in To:/Cc:";
+}
+sub personal { 1 }
+
+sub process {
+    my $self = shift;
+    my $mail = shift;
+
+    return 0 unless $self->pref( 'avoid_dups' );
+
+    if ($self->member) {
+      my $found = 0;
+
+      my $finder = Email::Find->new(
+        sub {
+          my($email, $orig_email) = @_;
+          $found = 1 if lc($self->member->email) eq lc($email->format);
+          return $orig_email;
+        });
+
+      $finder->find(\$mail->header("To")); return 1 if $found;
+      $finder->find(\$mail->header("Cc")); return 1 if $found;
+    }
+
+    return 0;
+}
+
+sub options {
+    +{
+      'avoid_dups' => {
+          description => "should we stop the list copy being sent when mentioned in to: or cc:",
+          type        => "boolean",
+          default     => 0,
+         },
+     };
+}
+
+1;
+

Generated at 13:57 on 01 Jul 2004 by mariachi 0.52