| 1 | package Sisimai::Lhost::GoogleGroups; | ||||||||||||||||||||
| 2 | 37 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 37 | ▶ | use v5.26; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 37 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 37 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'Google Groups: https://groups.google.com' } | ||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 8 | 964 | ▶ | sub inquire { | ||||||||||||||||||
|
Subroutine
inquire: called CC=17 SCAR=29.9
Pod
documented
| |||||||||||||||||||||
| 9 | # Detect an error from Google Groups | ||||||||||||||||||||
| 10 | # @param [Hash] mhead Message headers of a bounce email | ||||||||||||||||||||
| 11 | # @param [String] mbody Message body of a bounce email | ||||||||||||||||||||
| 12 | # @return [Hash] Bounce data list and message/rfc822 part | ||||||||||||||||||||
| 13 | # @return [undef] failed to decode or the arguments are missing | ||||||||||||||||||||
| 14 | # @since v4.25.6 | ||||||||||||||||||||
| 15 | 964 | my $class = shift; | |||||||||||||||||||
| 16 | 964 | ▶ | my $mhead = shift // return undef; | ||||||||||||||||||
|
Condition100%2/2
shift() // (return undef)
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 17 | 963 | ▶ | my $mbody = shift // return undef; | ||||||||||||||||||
|
Condition100%2/2
shift() // (return undef)
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 962 | ▶ | return undef unless index($$mbody, "Google Group") > -1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 71 | ▶ | return undef unless rindex($mhead->{'from'}, '<mailer-daemon@googlemail.com>') > -1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 71 | ▶ | return undef unless index($mhead->{'subject'}, 'Delivery Status Notification') > -1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 71 | ▶ | return undef unless exists $mhead->{'x-failed-recipients'}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # Hello kijitora@libsisimai.org, | ||||||||||||||||||||
| 25 | # | ||||||||||||||||||||
| 26 | # We're writing to let you know that the group you tried to contact (group-name) | ||||||||||||||||||||
| 27 | # may not exist, or you may not have permission to post messages to the group. | ||||||||||||||||||||
| 28 | # A few more details on why you weren't able to post: | ||||||||||||||||||||
| 29 | # | ||||||||||||||||||||
| 30 | # * You might have spelled or formatted the group name incorrectly. | ||||||||||||||||||||
| 31 | # * The owner of the group may have removed this group. | ||||||||||||||||||||
| 32 | # * You may need to join the group before receiving permission to post. | ||||||||||||||||||||
| 33 | # * This group may not be open to posting. | ||||||||||||||||||||
| 34 | # | ||||||||||||||||||||
| 35 | # If you have questions related to this or any other Google Group, | ||||||||||||||||||||
| 36 | # visit the Help Center at https://groups.google.com/support/. | ||||||||||||||||||||
| 37 | # | ||||||||||||||||||||
| 38 | # Thanks, | ||||||||||||||||||||
| 39 | # | ||||||||||||||||||||
| 40 | # Google Groups | ||||||||||||||||||||
| 41 | 71 | require Sisimai::Eb; | |||||||||||||||||||
| 42 | 71 | state $boundaries = ['----- Original message -----', 'Content-Type: message/rfc822']; | |||||||||||||||||||
| 43 | 71 | ▶ | my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0]; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
MC/DC0%0/1
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
"Sisimai::RFC5322"->part($mbody, $boundaries)
Truth table50%1/2
A
A= "Sisimai::RFC5322"->part($mbody, $boundaries)
| |||||||||||||||||||||
| 44 | 71 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = $dscontents->[-1]; | |||||||||||||||||||
| 45 | 71 | my $recipients = 0; | |||||||||||||||||||
| 46 | 71 | my @entiremesg = split(/\n\n/, $emailparts->[0], 5); pop @entiremesg; | |||||||||||||||||||
| 47 | 71 | my $issuedcode = join(' ', @entiremesg); $issuedcode =~ y/\n/ /; | |||||||||||||||||||
| 48 | 71 | ▶ | my $receivedby = $mhead->{'received'} || []; | ||||||||||||||||||
|
Condition50%1/2
$mhead->{'received'} || []
MC/DC0%0/1
$mhead->{'received'} || []
$mhead->{'received'}
Truth table50%1/2
A
A= $mhead->{'received'}
| |||||||||||||||||||||
| 49 | 71 | my $recordwide = { | |||||||||||||||||||
| 50 | 'rhost' => Sisimai::RFC5322->received($receivedby->[0])->[1], | ||||||||||||||||||||
| 51 | 'reason' => $Sisimai::Eb::Re___1, | ||||||||||||||||||||
| 52 | 'diagnosis' => $issuedcode, | ||||||||||||||||||||
| 53 | }; | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | # * You might have spelled or formatted the group name incorrectly. | ||||||||||||||||||||
| 56 | # * The owner of the group may have removed this group. | ||||||||||||||||||||
| 57 | # * You may need to join the group before receiving permission to post. | ||||||||||||||||||||
| 58 | # * This group may not be open to posting. | ||||||||||||||||||||
| 59 | 71 | ▶ | my $fewdetails = [$emailparts->[0] =~ /^[ ]?[*][ ]?/gm] || []; | ||||||||||||||||||
|
Condition50%1/2
[$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu] || []
MC/DC0%0/1
[$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu] || []
[$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu]
Truth table50%1/2
A
A= [$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu]
| |||||||||||||||||||||
| 60 | 71 | ▶ | $recordwide->{'reason'} = $Sisimai::Eb::ReFROM if scalar @$fewdetails == 4; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 71 | for my $e ( split(',', $mhead->{'x-failed-recipients'}) ) { | |||||||||||||||||||
| 63 | # X-Failed-Recipients: neko@example.jp, nyaan@example.org, ... | ||||||||||||||||||||
| 64 | 71 | ▶ | next unless Sisimai::Address->is_emailaddress($e); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 71 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||
| 68 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||
| 69 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | 71 | $v->{'recipient'} = Sisimai::Address->s3s4($e); | |||||||||||||||||||
| 72 | 71 | $recipients++; | |||||||||||||||||||
| 73 | 71 | $v->{ $_ } = $recordwide->{ $_ } for keys %$recordwide; | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | 71 | ▶ | return undef unless $recipients; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 71 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 37 | 1; | |||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||