Fix template preview sending invalid view requests
This commit is contained in:
parent
ca032c89d6
commit
ba87801930
|
@ -255,9 +255,14 @@ func handleRegisterCampaignView(c echo.Context) error {
|
|||
campUUID = c.Param("campUUID")
|
||||
subUUID = c.Param("subUUID")
|
||||
)
|
||||
|
||||
// Exclude dummy hits from template previews.
|
||||
if campUUID != dummyUUID && subUUID != dummyUUID {
|
||||
if _, err := app.queries.RegisterCampaignView.Exec(campUUID, subUUID); err != nil {
|
||||
app.log.Printf("error registering campaign view: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
c.Response().Header().Set("Cache-Control", "no-cache")
|
||||
return c.Blob(http.StatusOK, "image/png", pixelPNG)
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ import (
|
|||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
const (
|
||||
dummyUUID = "00000000-0000-0000-0000-000000000000"
|
||||
)
|
||||
|
||||
// subQueryReq is a "catch all" struct for reading various
|
||||
// subscriber related requests.
|
||||
type subQueryReq struct {
|
||||
|
@ -57,7 +61,7 @@ type subOptin struct {
|
|||
var dummySubscriber = models.Subscriber{
|
||||
Email: "dummy@listmonk.app",
|
||||
Name: "Dummy Subscriber",
|
||||
UUID: "00000000-0000-0000-0000-000000000000",
|
||||
UUID: dummyUUID,
|
||||
}
|
||||
|
||||
// handleGetSubscriber handles the retrieval of a single subscriber by ID.
|
||||
|
|
|
@ -100,7 +100,7 @@ func handlePreviewTemplate(c echo.Context) error {
|
|||
|
||||
// Compile the template.
|
||||
camp := models.Campaign{
|
||||
UUID: "00000000-0000-0000-0000-000000000000",
|
||||
UUID: dummyUUID,
|
||||
Name: "Dummy Campaign",
|
||||
Subject: "Dummy Campaign Subject",
|
||||
FromEmail: "dummy-campaign@listmonk.app",
|
||||
|
|
Loading…
Reference in New Issue