mirror of
https://github.com/mailscope/kumomta.git
synced 2026-08-21 03:48:17 +00:00
db5ebb88a7
message:recipient() may now return an array style table holding the recipient list, if there is more than a single recipient on the message. Since this can be somewhat ambiguous/frustrating to work with, there is now also a message:recipient_list() that will always return an array style table, even if it holds just a single element. The included helpers have been updated to use `message:recipient_list`. message:set_recipient() will now optionally accept an array style table holding the recipient list to be set.
16 lines
493 B
Lua
16 lines
493 B
Lua
local kumo = require 'kumo'
|
|
local utils = require 'policy-extras.policy_utils'
|
|
|
|
local msg =
|
|
kumo.make_message('sender@example.com', 'recip@example.com', 'woot')
|
|
utils.assert_eq(tostring(msg:recipient()), 'recip@example.com')
|
|
|
|
msg:set_recipient { 'a@example.com' }
|
|
utils.assert_eq(tostring(msg:recipient()), 'a@example.com')
|
|
|
|
msg:set_recipient { 'a@example.com', 'b@example.com' }
|
|
utils.assert_eq(
|
|
utils.dumps(msg:recipient()),
|
|
'{\n [1] = "a@example.com",\n [2] = "b@example.com"\n}'
|
|
)
|