High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Disable template type updation after creation to prevent breaking of campaign relations.
Kailash Nadhe99c8ed86b71
diff --git a/cmd/templates.go b/cmd/templates.goindex 92e5d961..ee13a880 100644--- a/cmd/templates.go+++ b/cmd/templates.go@@ -221,7 +221,7 @@ func handleUpdateTemplate(c echo.Context) error {return echo.NewHTTPError(http.StatusBadRequest, err.Error())}- out, err := app.core.UpdateTemplate(id, o.Name, o.Type, o.Subject, []byte(o.Body))+ out, err := app.core.UpdateTemplate(id, o.Name, o.Subject, []byte(o.Body))if err != nil {return err}diff --git a/frontend/src/views/TemplateForm.vue b/frontend/src/views/TemplateForm.vueindex 9158b927..0cba0c7d 100644--- a/frontend/src/views/TemplateForm.vue+++ b/frontend/src/views/TemplateForm.vue@@ -20,7 +20,7 @@</div><div class="column is-3"><b-field :label="$t('globals.fields.type')" label-position="on-border">- <b-select v-model="form.type" expanded>+ <b-select v-model="form.type" :disabled="isEditing" expanded><option value="campaign">{{ $tc('globals.terms.campaign') }}</option><option value="tx">{{ $tc('globals.terms.tx') }}</option></b-select>@@ -31,7 +31,7 @@<div class="column is-12"><b-field :label="$t('templates.subject')" label-position="on-border"><b-input :maxlength="200" :ref="'focus'" v-model="form.subject" name="name"- :placeholder="$t('templates.subject')" required />+ :placeholder="$t('templates.subject')" required /></b-field></div></div>diff --git a/internal/core/templates.go b/internal/core/templates.goindex 307f8d7b..8573094e 100644--- a/internal/core/templates.go+++ b/internal/core/templates.go@@ -47,8 +47,8 @@ func (c *Core) CreateTemplate(name, typ, subject string, body []byte) (models.Te}// UpdateTemplate updates a given template.-func (c *Core) UpdateTemplate(id int, name, typ, subject string, body []byte) (models.Template, error) {- res, err := c.q.UpdateTemplate.Exec(id, name, typ, subject, body)+func (c *Core) UpdateTemplate(id int, name, subject string, body []byte) (models.Template, error) {+ res, err := c.q.UpdateTemplate.Exec(id, name, subject, body)if err != nil {return models.Template{}, echo.NewHTTPError(http.StatusInternalServerError,c.i18n.Ts("globals.messages.errorUpdating", "name", "{globals.terms.template}", "error", pqErrMsg(err)))diff --git a/queries.sql b/queries.sqlindex 0015c539..ce5a4ec5 100644--- a/queries.sql+++ b/queries.sql@@ -757,9 +757,8 @@ INSERT INTO templates (name, type, subject, body) VALUES($1, $2, $3, $4) RETURNI-- name: update-templateUPDATE templates SETname=(CASE WHEN $2 != '' THEN $2 ELSE name END),- type=(CASE WHEN $3 != '' THEN $3::template_type ELSE type END),- subject=(CASE WHEN $4 != '' THEN $4 ELSE name END),- body=(CASE WHEN $5 != '' THEN $5 ELSE body END),+ subject=(CASE WHEN $3 != '' THEN $3 ELSE name END),+ body=(CASE WHEN $4 != '' THEN $4 ELSE body END),updated_at=NOW()WHERE id = $1;