File Coverage

lib/Sisimai/Reason/Expired.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 8 8 100.0
pod 2 4 50.0
total 39 41 95.1


line stmt bran cond sub pod time code
1             package Sisimai::Reason::Expired;
2 34     34   2170 use v5.26;
  34         92  
3 34     34   136 use strict;
  34         46  
  34         625  
4 34     34   124 use warnings;
  34         39  
  34         1386  
5 34     34   137 use Sisimai::String;
  34         50  
  34         8397  
6              
7 7     7 1 31 sub text { 'expired' }
8 4     4 0 17 sub description { 'Delivery time has expired due to a connection failure' }
9             sub match {
10             # Try to match that the given text and regular expressions
11             # @param [String] argv1 String to be matched with regular expressions
12             # @return [Integer] 0: Did not match
13             # 1: Matched
14             # @since v4.0.0
15 422     422 1 1472 my $class = shift;
16 422   100     1219 my $argv1 = shift // return 0;
17              
18 421         544 state $index = [
19             "connection timed out",
20             "could not find a gateway for",
21             "delay reason: ", # Exim/deliver.c:7459
22             "delivery attempts will continue to be",
23             "envelope expired", # OpenSMTPD/smtpd/queue.c:221
24             "failed to deliver to domain ",
25             "frozen on arrival", # Exim/receive.c:4022
26             "has been delayed",
27             "has been frozen", # Exim/deliver.c:7586
28             "have been failing for a long time", # Exim/smtp.c:3508
29             "host not reachable",
30             "it has not been collected after",
31             "message could not be delivered for more than",
32             "message expired, ",
33             "message has been in the queue too long",
34             "message was not delivered within ",
35             "message timed out",
36             "retry timeout exceeded", # Exim/retry.c:902
37             "server did not accept our requests to connect",
38             "server did not respond",
39             "unable to deliver message after multiple retries",
40             ];
41 421         562 state $pairs = [
42             ["could not be delivered for", " days"],
43             ["could not deliver for the last", "second"],
44             ["delivery ", "expired"],
45             ["delivery ", "delayed"],
46             ["exceed", "time", "out"],
47             ["not", "reach", "period"], # Exim/smtp.c:3508
48             ];
49              
50 421 100       707 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  8841         11113  
51 229 100       344 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  1374         1796  
52 206         665 return 0;
53             }
54              
55             sub true {
56             # Delivery expired due to connection failure or network error
57             # @param [Sisimai::Fact] argvs Object to be detected the reason
58             # @return [Integer] 1: is expired
59             # 0: is not expired
60             # @see http://www.ietf.org/rfc/rfc2822.txt
61 2     2 0 31 return 0;
62             }
63              
64             1;
65             __END__