Skip to content

Commit

Permalink
$BounceType variable has been moved to the inside of Sisimai::Lhost::…
Browse files Browse the repository at this point in the history
…AmazonSES->json() method and renamed with $bouncetype #332 #333
  • Loading branch information
azumakuniyuki committed Nov 14, 2019
1 parent 1366cba commit 401c207
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/Sisimai/Lhost/AmazonSES.pm
Expand Up @@ -216,22 +216,6 @@ sub make {
}
}

# https://docs.aws.amazon.com/en_us/ses/latest/DeveloperGuide/notification-contents.html
my $BounceType = {
'Permanent' => {
'General' => '',
'NoEmail' => '',
'Suppressed' => '',
},
'Transient' => {
'General' => '',
'MailboxFull' => 'mailboxfull',
'MessageTooLarge' => 'mesgtoobig',
'ContentRejected' => '',
'AttachmentRejected' => '',
},
};

sub json {
# Adapt Amazon SES bounce object for Sisimai::Message format
# @param [Hash] argvs bounce object(JSON) retrieved from Amazon SNS
Expand All @@ -245,8 +229,24 @@ sub json {
return undef unless ref $argvs eq 'HASH';
return undef unless keys %$argvs;
return undef unless exists $argvs->{'notificationType'};

use Sisimai::RFC5322;

# https://docs.aws.amazon.com/en_us/ses/latest/DeveloperGuide/notification-contents.html
my $bouncetype = {
'Permanent' => {
'General' => '',
'NoEmail' => '',
'Suppressed' => '',
},
'Transient' => {
'General' => '',
'MailboxFull' => 'mailboxfull',
'MessageTooLarge' => 'mesgtoobig',
'ContentRejected' => '',
'AttachmentRejected' => '',
},
};

my $dscontents = [__PACKAGE__->DELIVERYSTATUS];
my $rfc822head = {}; # (Hash) Check flags for headers in RFC822 part
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
Expand Down Expand Up @@ -297,13 +297,13 @@ sub json {
# 'reportingMTA' => 'dsn; a27-23.smtp-out.us-west-2.amazonses.com',
$v->{'lhost'} = $1 if $o->{'reportingMTA'} =~ /\Adsn;[ ](.+)\z/;

if( exists $BounceType->{ $o->{'bounceType'} } &&
exists $BounceType->{ $o->{'bounceType'} }->{ $o->{'bounceSubType'} } ) {
if( exists $bouncetype->{ $o->{'bounceType'} } &&
exists $bouncetype->{ $o->{'bounceType'} }->{ $o->{'bounceSubType'} } ) {
# 'bounce' => {
# 'bounceType' => 'Permanent',
# 'bounceSubType' => 'General'
# },
$v->{'reason'} = $BounceType->{ $o->{'bounceType'} }->{ $o->{'bounceSubType'} };
$v->{'reason'} = $bouncetype->{ $o->{'bounceType'} }->{ $o->{'bounceSubType'} };
}
} else {
# 'complainedRecipients' => [ {
Expand Down

0 comments on commit 401c207

Please sign in to comment.