Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Add sane defaults to POST creation APIs.

Kailash Nadh4056187fecf4
diff --git a/cmd/campaigns.go b/cmd/campaigns.go
index a281c59c..e8d1eb81 100644
--- a/cmd/campaigns.go
+++ b/cmd/campaigns.go
@@ -251,6 +251,15 @@ func handleCreateCampaign(c echo.Context) error {
return err
}
o = op
+ } else if o.Type == "" {
+ o.Type = models.CampaignTypeRegular
+ }
+
+ if o.ContentType == "" {
+ o.ContentType = models.CampaignContentTypeRichtext
+ }
+ if o.Messenger == "" {
+ o.Messenger = "email"
}
// Validate.
diff --git a/cmd/lists.go b/cmd/lists.go
index 353693e0..9fb957b4 100644
--- a/cmd/lists.go
+++ b/cmd/lists.go
@@ -132,6 +132,13 @@ func handleCreateList(c echo.Context) error {
app.i18n.Ts("globals.messages.errorUUID", "error", err.Error()))
}
+ if o.Type == "" {
+ o.Type = models.ListTypePrivate
+ }
+ if o.Optin == "" {
+ o.Optin = models.ListOptinSingle
+ }
+
// Insert and read ID.
var newID int
o.UUID = uu.String()
diff --git a/cmd/subscribers.go b/cmd/subscribers.go
index 6f743c53..105faa9e 100644
--- a/cmd/subscribers.go
+++ b/cmd/subscribers.go
@@ -704,6 +704,10 @@ func insertSubscriber(req subimporter.SubReq, app *App) (models.Subscriber, bool
subStatus = models.SubscriptionStatusConfirmed
}
+ if req.Status == "" {
+ req.Status = models.UserStatusEnabled
+ }
+
if err = app.queries.InsertSubscriber.Get(&req.ID,
req.UUID,
req.Email,