Flatten webhook payload for simpler template access
- Add uid, from, subject at top level of WebhookPayload
- Allows {{body.from}} instead of {{body.message.from}}
- Fixes empty fields in OpenClaw hook templates
- Full message object still available for detailed access
This commit is contained in:
parent
59ddae7540
commit
1dacfdbaf9
BIN
mail-bridge
BIN
mail-bridge
Binary file not shown.
11
main.go
11
main.go
|
|
@ -67,10 +67,16 @@ type Message struct {
|
|||
}
|
||||
|
||||
// WebhookPayload for new mail events
|
||||
// Fields are flattened for simpler template access ({{body.from}} vs {{body.message.from}})
|
||||
type WebhookPayload struct {
|
||||
Event string `json:"event"`
|
||||
Account string `json:"account"`
|
||||
Folder string `json:"folder"`
|
||||
// Flattened message fields for easier template access
|
||||
UID uint32 `json:"uid"`
|
||||
From string `json:"from"`
|
||||
Subject string `json:"subject"`
|
||||
// Full message object still available for detailed access
|
||||
Message *Message `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -266,11 +272,14 @@ func handleNewMail(accountName string, acc AccountConfig, folder string) {
|
|||
msg := msgs[0]
|
||||
log.Printf("[%s] Webhook: from=%q subject=%q", accountName, msg.From, msg.Subject)
|
||||
|
||||
// Send webhook
|
||||
// Send webhook with flattened fields for easy template access
|
||||
payload := WebhookPayload{
|
||||
Event: "new_mail",
|
||||
Account: accountName,
|
||||
Folder: folder,
|
||||
UID: msg.UID,
|
||||
From: msg.From,
|
||||
Subject: msg.Subject,
|
||||
Message: msg,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue