mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 09:37:02 +00:00
extension: BeforeMessageStored event to rewrite envelope (#417)
* extension: add InboundMessage type * manager: fires BeforeMessageStored event * manager: Reacts to BeforeMessageStored event response * manager: Apply BeforeMessageStored response fields to message Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// EventBroker maintains a list of listeners interested in a specific type
|
||||
// of event.
|
||||
type EventBroker[E any, R comparable] struct {
|
||||
type EventBroker[E any, R interface{}] struct {
|
||||
sync.RWMutex
|
||||
listenerNames []string // Ordered listener names.
|
||||
listenerFuncs []func(E) *R // Ordered listener functions.
|
||||
|
||||
@@ -11,6 +11,15 @@ type AddressParts struct {
|
||||
Domain string
|
||||
}
|
||||
|
||||
// InboundMessage contains the basic header and mailbox data for a message being received.
|
||||
type InboundMessage struct {
|
||||
Mailboxes []string
|
||||
From mail.Address
|
||||
To []mail.Address
|
||||
Subject string
|
||||
Size int64
|
||||
}
|
||||
|
||||
// MessageMetadata contains the basic header data for a message event.
|
||||
type MessageMetadata struct {
|
||||
Mailbox string
|
||||
|
||||
@@ -23,6 +23,7 @@ type Events struct {
|
||||
AfterMessageDeleted AsyncEventBroker[event.MessageMetadata]
|
||||
AfterMessageStored AsyncEventBroker[event.MessageMetadata]
|
||||
BeforeMailAccepted EventBroker[event.AddressParts, bool]
|
||||
BeforeMessageStored EventBroker[event.InboundMessage, event.InboundMessage]
|
||||
}
|
||||
|
||||
// Void indicates the event emitter will ignore any value returned by listeners.
|
||||
|
||||
Reference in New Issue
Block a user