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

extension: Add MessageStored event (#316)

* Replace existing direct StoreManager->msghub communication with this
  event
* For #280 #309 #312 #310

Signed-off-by: James Hillyerd <james@hillyerd.com>

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2023-01-16 21:30:47 -08:00
committed by GitHub
parent 3bf4b5c39b
commit f0d457b8f5
8 changed files with 124 additions and 67 deletions

View File

@@ -0,0 +1,17 @@
package event
import (
"net/mail"
"time"
)
// MessageMetadata contains the basic header data for a message event.
type MessageMetadata struct {
Mailbox string
ID string
From *mail.Address
To []*mail.Address
Date time.Time
Subject string
Size int64
}

23
pkg/extension/host.go Normal file
View File

@@ -0,0 +1,23 @@
package extension
import (
"github.com/inbucket/inbucket/pkg/extension/event"
)
// Host defines extension points for Inbucket.
type Host struct {
Events *Events
}
// Events defines all the event types supported by the extension host.
type Events struct {
MessageStored EventBroker[event.MessageMetadata, Void]
}
// Void indicates the event emitter will ignore any value returned by listeners.
type Void struct{}
// NewHost creates a new extension host.
func NewHost() *Host {
return &Host{Events: &Events{}}
}