<commit_before>

require "slimta"

slimta.policies = slimta.policies or {}
slimta.policies.add_received_header = {}
slimta.policies.add_received_header.__index = slimta.policies.add_received_header

-- {{{ build_from_section()
local function build_from_section(message, parts)
    local template = "from %s (%s [%s]%s)"

    local ehlo = message.client.ehlo or "[]"
    local ip = message.client.ip or "unknown"
    local host = message.client.host or "unknown"
    local port = ""
    if message.client.port then
        port = ":" .. message.client.port
    end

    table.insert(parts, template:format(ehlo, host, ip, port))
end
-- }}}

-- {{{ build_by_section()
local function build_by_section(message, parts)
    local template = "by %s (slimta %s)"
    table.insert(parts, template:format(message.client.receiver, slimta.version))
end
-- }}}

-- {{{ build_with_section()
local function build_with_section(message, parts)
    local template = "with %s"
    table.insert(parts, template:format(message.client.protocol))
end
-- }}}

-- {{{ build_id_section()
local function build_id_section(message, parts)
    if message.storage then
        local template = "id %s"
        local id = message.storage.data
        table.insert(parts, template:format(id))
    end
end<commit_msg>use correct id in received header<commit_after>

require "slimta"

slimta.policies = slimta.policies or {}
slimta.policies.add_received_header = {}
slimta.policies.add_received_header.__index = slimta.policies.add_received_header

-- {{{ build_from_section()
local function build_from_section(message, parts)
    local template = "from %s (%s [%s]%s)"

    local ehlo = message.client.ehlo or "[]"
    local ip = message.client.ip or "unknown"
    local host = message.client.host or "unknown"
    local port = ""
    if message.client.port then
        port = ":" .. message.client.port
    end

    table.insert(parts, template:format(ehlo, host, ip, port))
end
-- }}}

-- {{{ build_by_section()
local function build_by_section(message, parts)
    local template = "by %s (slimta %s)"
    table.insert(parts, template:format(message.client.receiver, slimta.version))
end
-- }}}

-- {{{ build_with_section()
local function build_with_section(message, parts)
    local template = "with %s"
    table.insert(parts, template:format(message.client.protocol))
end
-- }}}

-- {{{ build_id_section()
local function build_id_section(message, parts)
    if message.id then
        local template = "id %s"
        table.insert(parts, template:format(message.id))
    end
end
{'fraction_non_alphanumeric': 0.1349548842683405, 'fraction_numerical': 0.0, 'mean_word_length': 3.8022598870056497, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '399392', 'n_tokens_mistral': 840, 'n_tokens_neox': 837, 'n_words': 189}