File Coverage

lib/Sisimai/Rhost/Outlook.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::Outlook;
2 8     8   998 use v5.26;
  8         23  
3 8     8   37 use strict;
  8         41  
  8         216  
4 8     8   29 use warnings;
  8         9  
  8         1723  
5              
6             sub find {
7             # Detect bounce reason from Microsoft Outlook.com: https://www.outlook.com/
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] The bounce reason for Outlook
10             # @since v5.2.0
11 93     93 0 1103 my $class = shift;
12 93 100 100     214 my $argvs = shift // return ""; return '' unless length $argvs->{'diagnosticcode'};
  92         287  
13              
14 91         587 state $messagesof = {
15             'hostunknown' => ['The mail could not be delivered to the recipient because the domain is not reachable'],
16             'userunknown' => ['Requested action not taken: mailbox unavailable'],
17             };
18 91         167 my $issuedcode = $argvs->{'diagnosticcode'};
19 91         117 my $reasontext = '';
20              
21 91         203 for my $e ( keys %$messagesof ) {
22             # Try to find the error message matches with the given error message string
23 175 100       224 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  175         466  
24 22         41 $reasontext = $e;
25 22         35 last;
26             }
27 91         246 return $reasontext;
28             }
29              
30             1;
31             __END__