Skip to content

Commit

Permalink
Accessor "smtpagent" has been renamed to "decodedby" for the compatib…
Browse files Browse the repository at this point in the history
…ility with the Go language version of sisimai #563
  • Loading branch information
azumakuniyuki committed Dec 20, 2024
1 parent 0ef725c commit bc0b5d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Developers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private-sample:
$(PARSERSCRIPT) $(E)
@echo
@while true; do \
d=`$(PARSERSCRIPT) -Fjson $(E) | jq -M '.[].smtpagent' | head -1 \
d=`$(PARSERSCRIPT) -Fjson $(E) | jq -M '.[].decodedby' | head -1 \
| tr '[A-Z]' '[a-z]' | tr -d '-' | sed -e 's/"//g' -e 's/^/lhost-/g'`; \
if [ -d "$(PRIVATEMAILS)/$$d" ]; then \
latestfile=`ls -1 $(PRIVATEMAILS)/$$d/*.$(SAMPLEPREFIX) | tail -1`; \
Expand Down
17 changes: 9 additions & 8 deletions lib/Sisimai/Fact.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use Class::Accessor::Lite ('new' => 0, 'rw' => [
'replycode', # [String] SMTP Reply Code
'rhost', # [String] Remote host name/Remote MTA
'senderdomain', # [String] The domain part of the "addresser"
'smtpagent', # [String] Module(Engine) name
'decodedby', # [String] Module(Engine) name
'smtpcommand', # [String] The last SMTP command
'subject', # [String] UTF-8 Subject text
'timestamp', # [Sisimai::Time] Date: header in the original message
Expand Down Expand Up @@ -91,7 +91,7 @@ sub rise {
'recipient' => $e->{'recipient'} // '',
'replycode' => $e->{'replycode'} // '',
'rhost' => $e->{'rhost'} // '',
'smtpagent' => $e->{'agent'} // '',
'decodedby' => $e->{'agent'} // '',
'smtpcommand' => $e->{'command'} // '',
};

Expand Down Expand Up @@ -317,7 +317,7 @@ sub rise {
my $ar = Sisimai::Address->new({'address' => $piece->{'recipient'}}) || next RISEOF;
my @ea = (qw|
action deliverystatus diagnosticcode diagnostictype feedbacktype lhost listid
messageid origin reason replycode rhost smtpagent smtpcommand subject
messageid origin reason replycode rhost decodedby smtpcommand subject
|);

$thing = {
Expand Down Expand Up @@ -438,7 +438,7 @@ sub damn {
my $data = undef;
state $stringdata = [qw|
action alias catch deliverystatus destination diagnosticcode diagnostictype feedbacktype
lhost listid messageid origin reason replycode rhost senderdomain smtpagent smtpcommand
lhost listid messageid origin reason replycode rhost senderdomain decodedby smtpcommand
subject timezoneoffset token
|];

Expand Down Expand Up @@ -702,11 +702,12 @@ to get the value from C<Received:> headers.
C<senderdomain> is the domain part of the sender address. This value is the same as the return value
from C<host()> method of addresser accessor.
=head2 C<smtpagent> (I<String>)
=head2 C<decodedby> (I<String>)
C<smtpagent> is a module name to be used for detecting bounce reason. For example, when the value is
C<Sendmail>, Sisimai used L<Sisimai::Lhost::Sendmail> to get the recipient address and other delivery
status information from a bounce message.
C<decodedby> is a module name to be used for decoding a bounce message. For example, when the value
is C<Sendmail>, Sisimai used L<Sisimai::Lhost::Sendmail> to decode the bounce message, to find the
recipient address, and collect error messages for deciding a bounce reason.
Until v5.2.0, this accessor name was C<smtpagent>.
=head2 C<smtpcommand> (I<String>)
Expand Down
2 changes: 1 addition & 1 deletion t/001-sisimai.t
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ MAKETEST: {
DUMP: {
my $jsonstring = $Package->dump($Samples->{ $e });
my $perlobject = undef;
my $tobetested = [qw|addresser recipient senderdomain destination reason timestamp token smtpagent origin|];
my $tobetested = [qw|addresser recipient senderdomain destination reason timestamp token decodedby origin|];
ok length $jsonstring;
utf8::encode $jsonstring if utf8::is_utf8 $jsonstring;
$perlobject = JSON::decode_json($jsonstring);
Expand Down
6 changes: 3 additions & 3 deletions t/600-lhost-code
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ my $moduletest = sub {
}
}

SMTPAGENT: {
$cv = $rr->smtpagent;
DECODEDBY: {
$cv = $rr->decodedby;
$cr = qr/\A[-.0-9A-Za-z]+\z/;
$ct = sprintf("[%s-%02d] ->smtpagent =", $e, $errorindex);
$ct = sprintf("[%s-%02d] ->decodedby =", $e, $errorindex);

ok length $cv, sprintf("%s %s", $ct, $cv);
if( index($nameprefix, 'rhost') == 0 ) {
Expand Down

0 comments on commit bc0b5d9

Please sign in to comment.