| 58 | } |
| 59 | |
| 60 | func (w *WebhookHandler) Dispatcher(payload types.MessagePayload, titleMarkdown, bodyMarkdown string, _ template.FuncMap) (DeliveryFunc, error) { |
| 61 | if w.cfg.Endpoint.String() == "" { |
| 62 | return nil, xerrors.New("webhook endpoint not defined") |
| 63 | } |
| 64 | |
| 65 | titlePlaintext, err := markdown.PlaintextFromMarkdown(titleMarkdown) |
| 66 | if err != nil { |
| 67 | return nil, xerrors.Errorf("render title: %w", err) |
| 68 | } |
| 69 | bodyPlaintext, err := markdown.PlaintextFromMarkdown(bodyMarkdown) |
| 70 | if err != nil { |
| 71 | return nil, xerrors.Errorf("render body: %w", err) |
| 72 | } |
| 73 | |
| 74 | return w.dispatch(payload, titlePlaintext, titleMarkdown, bodyPlaintext, bodyMarkdown, w.cfg.Endpoint.String()), nil |
| 75 | } |
| 76 | |
| 77 | func (w *WebhookHandler) dispatch(msgPayload types.MessagePayload, titlePlaintext, titleMarkdown, bodyPlaintext, bodyMarkdown, endpoint string) DeliveryFunc { |
| 78 | return func(ctx context.Context, msgID uuid.UUID) (retryable bool, err error) { |