mirror of
https://github.com/knadh/listmonk.git
synced 2025-11-24 12:04:48 +08:00
Add sane defaults to POST creation APIs.
This commit is contained in:
parent
f6cd24d6c9
commit
4056187fec
3 changed files with 20 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue