Skip to content

Commit 82a9d25

Browse files
committed
ingress: pass context with event bus to SMTP mail parser
The SMTP session handler calls ParseMail with context.Background() which does not carry the EventBus. When Commit() tries to enqueue pending events, it dereferences a nil pointer and panics. The --stdin and --mbox paths already use the proper context. Store the context (with the bus) in the backend struct and pass it through to ParseMail. Fixes: bc70c37 ("events: add event bus") Signed-off-by: Robin Jarry <robin@jarry.cc>
1 parent 243ed59 commit 82a9d25

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎cmd/pw/ingress/main.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func (c *CLI) Run(ctx *pw.Context) error {
8282
}
8383

8484
be := &backend{
85+
ctx: ctx.Context,
8586
database: ctx.DB,
8687
cfg: ctx.Config,
8788
listID: c.ListID,
@@ -141,6 +142,7 @@ func startSMTPServer(cfg *config.Config, be smtp.Backend) (net.Listener, *smtp.S
141142
}
142143

143144
type backend struct {
145+
ctx context.Context
144146
database *bun.DB
145147
cfg *config.Config
146148
listID string
@@ -223,7 +225,7 @@ func (s *session) Data(r io.Reader) error {
223225
entity.Header.Get("Subject"))
224226

225227
err = mail.ParseMail(
226-
context.Background(), s.backend.database,
228+
s.backend.ctx, s.backend.database,
227229
bytes.NewReader(data), s.backend.listID,
228230
)
229231
if err != nil {

0 commit comments

Comments
 (0)