-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Sisimai::Reason::Speeding for parsing a bounce mail rejecte…
…d due to exceeding a rate limit or sending too fast #239
- Loading branch information
1 parent
7a445ce
commit 346c08e
Showing
9 changed files
with
69 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Sisimai | ||
module Reason | ||
# Sisimai::Reason::Speeding checks the bounce reason is "speeding" or not. This class is called | ||
# only Sisimai::Reason class. This is the error that a connection rejected due to exceeding a | ||
# rate limit or sending too fast. | ||
module Speeding | ||
class << self | ||
Index = [ | ||
'please try again slower', | ||
'receiving mail at a rate that prevents additional messages from being delivered', | ||
] | ||
|
||
def text; return 'speeding'; end | ||
def description; return 'Rejected due to exceeding a rate limit or sending too fast'; end | ||
|
||
# Try to match that the given text and regular expressions | ||
# @param [String] argv1 String to be matched with regular expressions | ||
# @return [True,False] false: Did not match | ||
# true: Matched | ||
def match(argv1) | ||
return nil unless argv1 | ||
return true if Index.any? { |a| argv1.include?(a) } | ||
return false | ||
end | ||
|
||
# Speeding or not | ||
# @param [Sisimai::Fact] argvs Object to be detected the reason | ||
# @return [True,False] true: is speeding | ||
# false: is not speeding | ||
# @see http://www.ietf.org/rfc/rfc2822.txt | ||
def true(argvs) | ||
return nil if argvs['deliverystatus'].empty? | ||
return true if argvs['reason'] == 'speeding' | ||
|
||
# Action: failed | ||
# Status: 4.7.1 | ||
# Remote-MTA: dns; smtp.example.jp | ||
# Diagnostic-Code: smtp; 451 4.7.1 <mx.example.org[192.0.2.2]>: Client host rejected: | ||
# Please try again slower | ||
return true if match(argvs['diagnosticcode'].downcase) | ||
return false | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ class ReasonTest < Minitest::Test | |
'smtp;550 5.2.2 <[email protected]>... Mailbox Full', | ||
'smtp;550 Requested action not taken: mailbox unavailable (-2019901852:4030:-2147467259)', | ||
'smtp;550 5.1.1 <[email protected]>... User unknown', | ||
'451 4.7.1 <smtp3.example.jp[192.0.2.1]>: Client host rejected: Please try again slower', | ||
'550 5.1.1 <[email protected]>... User Unknown ', | ||
'550 5.1.1 <[email protected]>... ', | ||
'550 Bad SPF records for [example.org:192.0.2.2], see http://spf.pobox.com/', | ||
|