quick throwtogether of an AvoidDups plugin

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

From: Jody Belka
Subject: quick throwtogether of an AvoidDups plugin
Date: 01:24 on 09 Apr 2004
--+QahgC5+KEYLbs62
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Just saw this at the bottom of the mailman options:

----
Avoid duplicate copies of messages?

When you are listed explicitly in the To: or Cc: headers of a list
message, you can opt to not receive another copy from the mailing
list. Select Yes to avoid receiving copies from the mailing list;
select No to receive copies. 
----

So i've thrown together a siesta plugin to do the same. not tested, but syntax checks ok.

-- 
Jody
knew (at) pimb (dot) org

--+QahgC5+KEYLbs62
Content-Type: application/x-perl
Content-Disposition: attachment; filename="AvoidDups.pm"
Content-Transfer-Encoding: quoted-printable

package Siesta::Plugin::AvoidDups;=0Ause strict;=0Ause Siesta::Plugin;=0Aus=
e base 'Siesta::Plugin';=0A=0Asub description {=0A    "avoids duplicate cop=
ies of messages when listed in To:/Cc:";=0A}=0Asub personal { 1 }=0A=0Asub =
process {=0A    my $self =3D shift;=0A    my $mail =3D shift;=0A=0A    retu=
rn 0 unless $self->pref( 'avoid_dups' );=0A=0A    if ($self->member) {=0A  =
    my $found =3D 0;=0A=0A      my $finder =3D Email::Find->new(=0A        =
sub {=0A          my($email, $orig_email) =3D @_;=0A          $found =3D 1 =
if lc($self->member->email) eq lc($email->format);=0A          return $orig=
_email;=0A        });=0A=0A      $finder->find(\$mail->header("To")); retur=
n 1 if $found;=0A      $finder->find(\$mail->header("Cc")); return 1 if $fo=
und;=0A    }=0A=0A    return 0;=0A}=0A=0Asub options {=0A    +{=0A      'av=
oid_dups'=0A      =3D> {=0A          description =3D> "should we stop the l=
ist copy being sent when mentioned in to: or cc:",=0A          type        =
=3D> "boolean",=0A          default     =3D> 0,=0A         },=0A     };=0A}=
=0A=0A1;=0A=0A
--+QahgC5+KEYLbs62--

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