mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-19 00:01:14 +00:00
24422ed427
Add an advisory content score endpoint that reuses warmup linting heuristics for campaign templates. Surface the score in the sequence editor so users can check subject and body deliverability before sending.
32 lines
932 B
Go
32 lines
932 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/warmbly/warmbly/internal/errx"
|
|
"github.com/warmbly/warmbly/internal/pkg/warmlint"
|
|
)
|
|
|
|
type scoreTemplateRequest struct {
|
|
Subject string `json:"subject"`
|
|
BodyHTML string `json:"body_html"`
|
|
BodyPlain string `json:"body_plain"`
|
|
}
|
|
|
|
// ScoreTemplateContent returns an advisory deliverability content score for a
|
|
// campaign template (subject + body) before it is sent. Advisory only — it
|
|
// never blocks sending — so the user gets content feedback on the mail that
|
|
// actually reaches prospects, which warmup-only linting never covered.
|
|
func (h *Handler) ScoreTemplateContent(c *gin.Context) {
|
|
var req scoreTemplateRequest
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
errx.JSON(c, errx.New(errx.BadRequest, "invalid request body"))
|
|
return
|
|
}
|
|
|
|
res := warmlint.Score(req.Subject, req.BodyHTML, req.BodyPlain)
|
|
c.JSON(http.StatusOK, res)
|
|
}
|