File Coverage

blib/lib/Siesta/Plugin/Resume.pm
Criterion Covered Total %
statement 13 21 61.9
branch 1 8 12.5
condition n/a
subroutine 5 5 100.0
pod 1 2 50.0
total 20 36 55.5


line stmt bran cond sub pod time code
1 3     3   2165 use strict;
  3         9  
  3         151  
2             package Siesta::Plugin::Resume;
3 3     3   20 use base 'Siesta::Plugin';
  3         18  
  3         335  
4 3     3   20 use Digest::MD5 qw(md5_hex);
  3         6  
  3         796  
5 1     1 0 512 sub description { "set a deferred message on its way" }
6              
7             sub process {
8 1     1 1 3 my $self = shift;
9 1         2 my $mail = shift;
10              
11 1 50       7 return unless $mail->body =~ /resume (\d+) (\S+)/;
12 0           my ($id, $hash) = ($1, $2);
13              
14 0 0         my $deferred = Siesta::Deferred->retrieve( $id ) or return;
15 0 0         unless ($deferred->who->email eq $mail->from) {
16             # you don't own this message, so you can't resume it
17 0           return 1;
18             }
19 0 0         unless ( $deferred->hash eq $hash ) {
20             # wrong magic cookie
21 0           return 1;
22             }
23 0           $deferred->resume;
24 0           return 1;
25             }
26              
27             1;