FEATURE: Remove attachments and truncate raw field for incoming emails (#8253)

Adds the settings: 

raw_email_max_length, raw_rejected_email_max_length, delete_rejected_email_after_days. 

These settings control retention of the "raw" emails logs.

raw_email_max_length ensures that if we get incoming email that is huge we will truncate it removing uploads from the raw log.

raw_rejected_email_max_length introduces an even more aggressive truncation for rejected incoming mail. 

delete_rejected_email_after_days controls how many days we will keep rejected emails for (default 90)
This commit is contained in:
Krzysztof Kotlarek
2019-10-30 16:54:35 +11:00
committed by Sam
parent fcb1ca52f9
commit c32bd8ae48
9 changed files with 124 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe "incoming emails tasks" do
before do
Rake::Task.clear
Discourse::Application.load_tasks
end
describe 'email with attachment' do
fab!(:incoming_email) { Fabricate(:incoming_email, raw: email(:attached_txt_file)) }
it 'updates record' do
expect { Rake::Task['incoming_emails:truncate_long'].invoke }.to change { incoming_email.reload.raw }
end
end
describe 'short email without attachment' do
fab!(:incoming_email) { Fabricate(:incoming_email, raw: email(:html_reply)) }
it 'does not update record' do
expect { Rake::Task['incoming_emails:truncate_long'].invoke }.not_to change { incoming_email.reload.raw }
end
end
end