feat(coderd): add format option to inbox notifications watch endpoint (#17034)

This PR aims to allow clients to use different format for the title and
content of inbox notifications - on the watch endpoint.

This solution will help to have it working and formatted differently on
VSCode, WebUI ...
[Related to this issue](https://github.com/coder/internal/issues/523)
This commit is contained in:
Vincent Vielle
2025-03-21 16:41:13 +01:00
committed by GitHub
parent 0474888eb4
commit 82e37732ea
6 changed files with 128 additions and 17 deletions
+1 -12
View File
@@ -16,7 +16,6 @@ import (
"github.com/coder/coder/v2/coderd/database/pubsub"
"github.com/coder/coder/v2/coderd/notifications/types"
coderdpubsub "github.com/coder/coder/v2/coderd/pubsub"
markdown "github.com/coder/coder/v2/coderd/render"
"github.com/coder/coder/v2/codersdk"
)
@@ -36,17 +35,7 @@ func NewInboxHandler(log slog.Logger, store InboxStore, ps pubsub.Pubsub) *Inbox
}
func (s *InboxHandler) Dispatcher(payload types.MessagePayload, titleTmpl, bodyTmpl string, _ template.FuncMap) (DeliveryFunc, error) {
subject, err := markdown.PlaintextFromMarkdown(titleTmpl)
if err != nil {
return nil, xerrors.Errorf("render subject: %w", err)
}
htmlBody, err := markdown.PlaintextFromMarkdown(bodyTmpl)
if err != nil {
return nil, xerrors.Errorf("render html body: %w", err)
}
return s.dispatch(payload, subject, htmlBody), nil
return s.dispatch(payload, titleTmpl, bodyTmpl), nil
}
func (s *InboxHandler) dispatch(payload types.MessagePayload, title, body string) DeliveryFunc {