diff --git a/campaigns.go b/campaigns.go index 7fa42a2..5843ea3 100644 --- a/campaigns.go +++ b/campaigns.go @@ -117,12 +117,7 @@ func handlePreviewCampaign(c echo.Context) error { if err := app.Queries.GetOneCampaignSubscriber.Get(&sub, camp.ID); err != nil { if err == sql.ErrNoRows { // There's no subscriber. Mock one. - sub = models.Subscriber{ - Name: "Dummy Subscriber", - Email: "dummy@subscriber.com", - UUID: "00000000-0000-0000-0000-000000000000", - Status: models.SubscriberStatusEnabled, - } + sub = dummySubscriber } else { return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Error fetching subscriber: %s", pqErrMsg(err))) diff --git a/subscribers.go b/subscribers.go index acda01c..fd4a91f 100644 --- a/subscribers.go +++ b/subscribers.go @@ -38,7 +38,15 @@ type queryAddReq struct { TargetLists pq.Int64Array `json:"target_lists"` } -var jsonMap = []byte("{}") +var ( + jsonMap = []byte("{}") + + dummySubscriber = models.Subscriber{ + Email: "dummy@listmonk.app", + Name: "Dummy Subscriber", + UUID: "00000000-0000-0000-0000-000000000000", + } +) // handleGetSubscriber handles the retrieval of a single subscriber by ID. func handleGetSubscriber(c echo.Context) error { diff --git a/templates.go b/templates.go index 8273a3c..664f4c0 100644 --- a/templates.go +++ b/templates.go @@ -27,11 +27,6 @@ const (
Here is a link to listmonk.
` ) -var dummySubscriber = models.Subscriber{ - Email: "dummy@listmonk.app", - Name: "Dummy User", -} - type dummyMessage struct { UnsubscribeURL string }