local data_rows = {}
local custom_rows = {}
local nrows = 0
-local schema_version = 2 -- Current schema version
+local schema_version = 3 -- Current schema version
local settings = {
limit = 1000,
use_https = false,
use_gzip = true,
allow_local = false,
+ insert_subject = false,
+ subject_privacy = false, -- subject privacy is off
+ subject_privacy_alg = 'blake2', -- default hash-algorithm to obfuscate subject
+ subject_privacy_prefix = 'obf', -- prefix to show it's obfuscated
+ subject_privacy_length = 16, -- cut the length of the hash
user = nil,
password = nil,
no_ssl_verify = false,
RcptUser String,
RcptDomain String,
ListId String,
+ Subject String,
`Attachments.FileName` Array(String),
`Attachments.ContentType` Array(String),
`Attachments.Length` Array(UInt32),
-- Add explicit version
[[CREATE TABLE rspamd_version ( Version UInt32) ENGINE = TinyLog]],
[[INSERT INTO rspamd_version (Version) Values (2)]],
+ },
+ [2] = {
+ -- Add `Subject` column
+ [[ALTER TABLE rspamd
+ ADD COLUMN Subject String AFTER ListId]],
+ -- New version
+ [[INSERT INTO rspamd_version (Version) Values (3)]],
}
}
'RcptUser',
'RcptDomain',
'ListId',
- 'Digest'
+ 'Subject',
+ 'Digest',
}
for _,v in ipairs(fields) do table.insert(res, v) end
local action = task:get_metric_action('default')
local digest = task:get_digest()
+ local subject = ''
+ if settings.insert_subject then
+ subject = lua_util.maybe_obfuscate_subject(task:get_subject() or '', settings)
+ end
+
local row = {
today(timestamp),
timestamp,
rcpt_user,
rcpt_domain,
list_id,
+ subject,
digest
}