| 1 | # | ||||||||||||||||||||
| 2 | # Mail/Salsa/Action/Return.pm | ||||||||||||||||||||
| 3 | # Last Modification: Wed Apr 20 17:09:05 WEST 2005 | ||||||||||||||||||||
| 4 | # | ||||||||||||||||||||
| 5 | # Copyright (c) 2005 Henrique Dias <hdias@aesbuc.pt>. All rights reserved. | ||||||||||||||||||||
| 6 | # This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 7 | # it under the same terms as Perl itself. | ||||||||||||||||||||
| 8 | # | ||||||||||||||||||||
| 9 | package Mail::Salsa::Action::Return; | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | ▶ | use 5.008000; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | require Exporter; | |||||||||||||||||||
| 16 | 1 | ▶ | use Mail::Salsa::Logs qw(logs); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 1 | ▶ | use Mail::Salsa::Action::Unsubscribe qw(remove_from_list); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | use Mail::Salsa::Utils qw(file_path); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 1 | ▶ | use SelfLoader; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||
| 24 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||
| 25 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # This allows declaration use Mail::Salsa ':all'; | ||||||||||||||||||||
| 28 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||
| 29 | # will save memory. | ||||||||||||||||||||
| 30 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw() ] ); | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||
| 33 | 1 | our @EXPORT = qw(); | |||||||||||||||||||
| 34 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 1 | SelfLoader->load_stubs(); | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 39 | 0 | my $proto = shift; | |||||||||||||||||||
| 40 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 41 | 0 | my $self = {@_}; | |||||||||||||||||||
| 42 | 0 | bless ($self, $class); | |||||||||||||||||||
| 43 | 0 | $self->process_msg(); | |||||||||||||||||||
| 44 | 0 | return($self); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub process_msg { | ||||||||||||||||||
|
Subroutine
process_msg: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 48 | 0 | my $self = shift; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | my ($name, $domain) = split(/\@/, $self->{'list'}); | |||||||||||||||||||
| 51 | 0 | my $returnedfile = join("/", $self->{'tmp_dir'}, 'file'); | |||||||||||||||||||
| 52 | 0 | ▶ | (-e $returnedfile) or return(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 0 | my $addrs = &find_wrong_email($returnedfile); | |||||||||||||||||||
| 54 | 0 | ▶ | scalar(keys(%{$addrs})) or return(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | my $file = file_path($self->{'list'}, $self->{'list_dir'}, "list\.txt"); | |||||||||||||||||||
| 56 | 0 | my $res = remove_from_list($file, $addrs); | |||||||||||||||||||
| 57 | 0 | for my $email (keys(%{$addrs})) { | |||||||||||||||||||
| 58 | 0 | ▶ | $self->logs(join("", "[user unknown unsubscribed] user: ", $email), "list") if($email); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | #exit(); | ||||||||||||||||||||
| 61 | 0 | return(); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | ▶ | sub find_wrong_email { | ||||||||||||||||||
|
Subroutine
find_wrong_email: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||
| 65 | 0 | my $file = shift; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | my %addresses = (); | |||||||||||||||||||
| 68 | 0 | ▶ | open(FILE, "<", $file) or return({}); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | 0 | ▶ | while(<FILE>) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | 0 | ▶ | if(my $email = &look4email($_)) { exists($addresses{$email}) or $addresses{$email} = 0; } | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | 0 | close(FILE); | |||||||||||||||||||
| 73 | 0 | return(\%addresses); | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 1 | 1; | |||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | __DATA__ | ||||||||||||||||||||