1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-21 11:37:07 +00:00

lua: bind BeforeMessageStored function (#418)

* lua: Restore missing test log output
* lua: Use logger for test assert_async output
* lua: add InboundMessage bindings
* lua: bind BeforeMessageStored function

---------

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2023-11-06 18:10:02 -08:00
committed by GitHub
parent 01fb161df8
commit 4a6b727cbc
7 changed files with 355 additions and 13 deletions

View File

@@ -29,7 +29,8 @@ type InbucketAfterFuncs struct {
// InbucketBeforeFuncs holds references to Lua extension functions to be called
// before Inbucket handles an event.
type InbucketBeforeFuncs struct {
MailAccepted *lua.LFunction
MailAccepted *lua.LFunction
MessageStored *lua.LFunction
}
func registerInbucketTypes(ls *lua.LState) {
@@ -186,6 +187,8 @@ func inbucketBeforeIndex(ls *lua.LState) int {
switch field {
case "mail_accepted":
ls.Push(funcOrNil(before.MailAccepted))
case "message_stored":
ls.Push(funcOrNil(before.MessageStored))
default:
// Unknown field.
ls.Push(lua.LNil)
@@ -202,6 +205,8 @@ func inbucketBeforeNewIndex(ls *lua.LState) int {
switch index {
case "mail_accepted":
m.MailAccepted = ls.CheckFunction(3)
case "message_stored":
m.MessageStored = ls.CheckFunction(3)
default:
ls.RaiseError("invalid inbucket.before index %q", index)
}