Refactor dummyUser struct for use in multiple places

This commit is contained in:
Kailash Nadh 2018-10-31 19:50:26 +05:30
parent b63e3907c5
commit acee18c58c
3 changed files with 10 additions and 12 deletions

View File

@ -117,12 +117,7 @@ func handlePreviewCampaign(c echo.Context) error {
if err := app.Queries.GetOneCampaignSubscriber.Get(&sub, camp.ID); err != nil { if err := app.Queries.GetOneCampaignSubscriber.Get(&sub, camp.ID); err != nil {
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
// There's no subscriber. Mock one. // There's no subscriber. Mock one.
sub = models.Subscriber{ sub = dummySubscriber
Name: "Dummy Subscriber",
Email: "dummy@subscriber.com",
UUID: "00000000-0000-0000-0000-000000000000",
Status: models.SubscriberStatusEnabled,
}
} else { } else {
return echo.NewHTTPError(http.StatusInternalServerError, return echo.NewHTTPError(http.StatusInternalServerError,
fmt.Sprintf("Error fetching subscriber: %s", pqErrMsg(err))) fmt.Sprintf("Error fetching subscriber: %s", pqErrMsg(err)))

View File

@ -38,7 +38,15 @@ type queryAddReq struct {
TargetLists pq.Int64Array `json:"target_lists"` 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. // handleGetSubscriber handles the retrieval of a single subscriber by ID.
func handleGetSubscriber(c echo.Context) error { func handleGetSubscriber(c echo.Context) error {

View File

@ -27,11 +27,6 @@ const (
<p>Here is a link to <a href="https://listmonk.app" target="_blank">listmonk</a>.</p>` <p>Here is a link to <a href="https://listmonk.app" target="_blank">listmonk</a>.</p>`
) )
var dummySubscriber = models.Subscriber{
Email: "dummy@listmonk.app",
Name: "Dummy User",
}
type dummyMessage struct { type dummyMessage struct {
UnsubscribeURL string UnsubscribeURL string
} }