make.webhook function params : tenant campaign are nil

Hello, noticed that the kumo.on('make.webhook', function(domain, tenant, campaign) event receives only the domain param, which is webhook, tenant and campaign are nil, did not find anything related to the other params in the documentation examples. Is there any way of setting this data, the tenant especially needed for fetching tenant(client) specific webhook endpoints

Domain is set by default as part of the underlying code. The others (and domain if you choose) can be set using msg:set_meta() where the message object is available. For instance in the smtp_server_message_received event you could set the tenant with msg:set_meta(‘tenant’, myvariable)

This page is relevant: set_meta - KumoMTA Docs

This is also relevant: smtp_server_message_received - KumoMTA Docs

@faithful-ostrich @yummy-echidna means for a log message enqueued.

@yummy-echidna the campaign and tenant are not actually message metadata, they are part of the queue name in the scheduled queue. The log messages are not part of a tenant or campaign because they are not messages from the tenant or campaign, but from the logger. There may be an option to have that inherited from the message the log is referring to, but I get the feeling introspecting the message payload to extract that info may be the more immediate solution.

yes for the logs, as @yearning-hyena said, i found a workaround, but i feel at least the tenant could be present in th make.webhook event, for the reason of using tenant specific webhooks

Can you share your workaround for future reference?

yes sure just a second

    kumo.configure_log_hook {
        name = 'webhook-bounce',
        headers = {'X-Campaign-ID'},
        meta = {'tenant'},
...

setting meta key for the log
then getting it in the webhook event like this

kumo.on('make.webhook-reception', function(domain, tenant, campaign)
    local connection = {}
    local client = kumo.http.build_client {}
    function connection:send(message)
        local tenant_with_domain = message:get_meta('tenant')
...

That’s quite good.

when you assign the queue metadata for the message in the should_enqueue_log_record event, you can encode the tenant and campaign by following the queue naming convention documented here: Queues - KumoMTA Docs

Alternatively, you can assign the domain using set_recipient - KumoMTA Docs and then the tenant and campaign metadata via set_meta - KumoMTA Docs