mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-21 01:53:20 +00:00
fix: adds proper error message when user is trying to create another default outgoing email template.
This commit is contained in:
@@ -67,6 +67,9 @@ func (m *Manager) Create(t models.Template) error {
|
||||
t.Type = TypeEmailOutgoing
|
||||
}
|
||||
if _, err := m.q.InsertTemplate.Exec(t.Name, t.Body, t.IsDefault, t.Subject, t.Type); err != nil {
|
||||
if dbutil.IsUniqueViolationError(err) && t.IsDefault {
|
||||
return envelope.NewError(envelope.GeneralError, "Default template already exists", nil)
|
||||
}
|
||||
m.lo.Error("error inserting template", "error", err)
|
||||
return envelope.NewError(envelope.GeneralError, "Error creating template", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user