1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

feat: Add SMTPResponse type for extensions (#539)

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2024-10-05 18:16:49 -07:00
committed by GitHub
parent 8097b3cc8a
commit 3110183a17
11 changed files with 165 additions and 49 deletions

View File

@@ -148,7 +148,7 @@ func (h *Host) handleAfterMessageStored(msg event.MessageMetadata) {
}
}
func (h *Host) handleBeforeMailAccepted(addr event.AddressParts) *bool {
func (h *Host) handleBeforeMailAccepted(addr event.AddressParts) *event.SMTPResponse {
logger, ls, ib, ok := h.prepareInbucketFuncCall("before.mail_accepted")
if !ok {
return nil
@@ -169,16 +169,16 @@ func (h *Host) handleBeforeMailAccepted(addr event.AddressParts) *bool {
ls.Pop(1)
logger.Debug().Msgf("Lua function returned %q (%v)", lval, lval.Type().String())
if lval.Type() == lua.LTNil {
if lval.Type() == lua.LTNil || lua.LVIsFalse(lval) {
return nil
}
result := true
if lua.LVIsFalse(lval) {
result = false
result, err := unwrapSMTPResponse(lval)
if err != nil {
logger.Error().Err(err).Msg("Bad response from Lua Function")
}
return &result
return result
}
func (h *Host) handleBeforeMessageStored(msg event.InboundMessage) *event.InboundMessage {