File Coverage

lib/Sisimai/Rhost/Cloudflare.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::Cloudflare;
2 3     3   864 use v5.26;
  3         14  
3 3     3   19 use strict;
  3         5  
  3         91  
4 3     3   17 use warnings;
  3         7  
  3         788  
5              
6             sub find {
7             # Detect bounce reason for Cloudflare Email Routing
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] Detected bounce reason
10             # @since v5.2.1
11             # @see https://developers.cloudflare.com/email-routing/postmaster/
12 10     10 0 1096 my $class = shift;
13 10 100 100     49 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  9         45  
14              
15 8         29 state $messagesof = {
16             # - 554 found on one or more RBLs (abusixip). Refer to
17             # https://developers.cloudflare.com/email-routing/postmaster/#spam-and-abusive-traffic/
18             "blocked" => ["found on one or more DNSBLs"],
19             "systemerror" => ["Upstream error"],
20             };
21 8         32 for my $e ( keys %$messagesof ) {
22             # Try to find the error message matches with the given error message string
23 14 100       32 return $e if grep { index($argvs->{"diagnosticcode"}, $_) > -1 } $messagesof->{ $e }->@*;
  14         86  
24             }
25 2         10 return "";
26             }
27              
28             1;
29             __END__