FEATURE: Clean up PostReplyKey records.

* Default retention of 90 days.
This commit is contained in:
Guo Xiang Tan
2018-08-21 16:17:08 +08:00
parent 8da2d8df3d
commit 36a7028f19
9 changed files with 97 additions and 7 deletions

View File

@@ -85,6 +85,7 @@ module Email
if message_template == :email_reject_old_destination
template_args[:short_url] = e.message
template_args[:number_of_days] = SiteSetting.disallow_reply_by_email_after_days
end
if message_template

View File

@@ -171,8 +171,12 @@ module Email
raise first_exception if first_exception
if post = find_related_post(force: true)
if Guardian.new(user).can_see_post?(post) && post.created_at < 90.days.ago
post = find_related_post(force: true)
if post && Guardian.new(user).can_see_post?(post)
num_of_days = SiteSetting.disallow_reply_by_email_after_days
if num_of_days > 0 && post.created_at < num_of_days.days.ago
raise OldDestinationError.new("#{Discourse.base_url}/p/#{post.id}")
end
end