FEATURE: new 'suppress_email_logs_after_days' site setting
This commit is contained in:
parent
1beb6070aa
commit
ac863bab91
|
@ -0,0 +1,18 @@
|
||||||
|
module Jobs
|
||||||
|
|
||||||
|
class CleanUpEmailLogs < Jobs::Scheduled
|
||||||
|
every 1.day
|
||||||
|
|
||||||
|
def execute(args)
|
||||||
|
return if SiteSetting.suppress_email_logs_after_days <= 0
|
||||||
|
|
||||||
|
threshold = SiteSetting.suppress_email_logs_after_days.days.ago
|
||||||
|
|
||||||
|
EmailLog.where(reply_key: nil)
|
||||||
|
.where("created_at < ?", threshold)
|
||||||
|
.destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1116,6 +1116,8 @@ en:
|
||||||
unsubscribe_via_email: "Allow users to unsubscribe from emails by sending an email with 'unsubscribe' in the subject or body"
|
unsubscribe_via_email: "Allow users to unsubscribe from emails by sending an email with 'unsubscribe' in the subject or body"
|
||||||
unsubscribe_via_email_footer: "Attach an unsubscribe link to the footer of sent emails"
|
unsubscribe_via_email_footer: "Attach an unsubscribe link to the footer of sent emails"
|
||||||
|
|
||||||
|
suppress_email_logs_after_days: "Delete email logs after (N) days. 0 to keep indefinitely"
|
||||||
|
|
||||||
pop3_polling_enabled: "Poll via POP3 for email replies."
|
pop3_polling_enabled: "Poll via POP3 for email replies."
|
||||||
pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)"
|
pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)"
|
||||||
pop3_polling_period_mins: "The period in minutes between checking the POP3 account for email. NOTE: requires restart."
|
pop3_polling_period_mins: "The period in minutes between checking the POP3 account for email. NOTE: requires restart."
|
||||||
|
|
|
@ -539,6 +539,9 @@ email:
|
||||||
default: true
|
default: true
|
||||||
unsubscribe_via_email_footer:
|
unsubscribe_via_email_footer:
|
||||||
default: false
|
default: false
|
||||||
|
suppress_email_logs_after_days:
|
||||||
|
default: 365
|
||||||
|
min: 0
|
||||||
|
|
||||||
files:
|
files:
|
||||||
max_image_size_kb: 3072
|
max_image_size_kb: 3072
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe Jobs::CleanUpEmailLogs do
|
||||||
|
|
||||||
|
before do
|
||||||
|
Fabricate(:email_log, created_at: 2.years.ago, reply_key: "something")
|
||||||
|
Fabricate(:email_log, created_at: 2.years.ago)
|
||||||
|
Fabricate(:email_log, created_at: 2.weeks.ago)
|
||||||
|
Fabricate(:email_log, created_at: 2.days.ago)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "removes old email logs without a reply_key" do
|
||||||
|
Jobs::CleanUpEmailLogs.new.execute({})
|
||||||
|
expect(EmailLog.count).to eq(3)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not remove old email logs when suppress_email_logs_after_days is 0" do
|
||||||
|
SiteSetting.suppress_email_logs_after_days = 0
|
||||||
|
Jobs::CleanUpEmailLogs.new.execute({})
|
||||||
|
expect(EmailLog.count).to eq(4)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue