mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: only send 1 rejection email per day to prevent loops
This commit is contained in:
parent
7848a84e0e
commit
8d2c878b34
1 changed files with 4 additions and 4 deletions
|
@ -74,8 +74,8 @@ module Email
|
||||||
|
|
||||||
client_message = RejectionMailer.send_rejection(message_template, message.from, template_args)
|
client_message = RejectionMailer.send_rejection(message_template, message.from, template_args)
|
||||||
|
|
||||||
# don't send more than 1 reply per day to auto-generated emails
|
# only send one rejection email per day to the same email address
|
||||||
if !incoming_email.try(:is_auto_generated) || can_reply_to_auto_generated?(message.from)
|
if can_send_rejection_email?(message.from, message_template)
|
||||||
Email::Sender.new(client_message, message_template).send
|
Email::Sender.new(client_message, message_template).send
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -89,8 +89,8 @@ module Email
|
||||||
client_message
|
client_message
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_reply_to_auto_generated?(email)
|
def can_send_rejection_email?(email, type)
|
||||||
key = "auto_generated_reply:#{email}:#{Date.today}"
|
key = "rejection_email:#{email}:#{type}:#{Date.today}"
|
||||||
|
|
||||||
if $redis.setnx(key, "1")
|
if $redis.setnx(key, "1")
|
||||||
$redis.expire(key, 25.hours)
|
$redis.expire(key, 25.hours)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue