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   1398 use v5.26;
  8         33  
3 8     8   41 use strict;
  8         17  
  8         271  
4 8     8   34 use warnings;
  8         15  
  8         3511  
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 918 my $class = shift;
12 93 100 100     366 my $argvs = shift // return ""; return '' unless length $argvs->{'diagnosticcode'};
  92         374  
13              
14 91         202 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         203 my $issuedcode = $argvs->{'diagnosticcode'};
19 91         169 my $reasontext = '';
20              
21 91         326 for my $e ( keys %$messagesof ) {
22             # Try to find the error message matches with the given error message string
23 167 100       370 next unless grep { index($issuedcode, $_) > -1 } $messagesof->{ $e }->@*;
  167         643  
24 22         44 $reasontext = $e;
25 22         41 last;
26             }
27 91         368 return $reasontext;
28             }
29              
30             1;
31             __END__