diff --git a/backend/model/campaignTemplate.go b/backend/model/campaignTemplate.go index 5c00b9b..6e684ce 100644 --- a/backend/model/campaignTemplate.go +++ b/backend/model/campaignTemplate.go @@ -125,6 +125,15 @@ func (c *CampaignTemplate) Validate() error { ) } + // validate that smtp configuration and api sender are mutually exclusive + _, errSMTP := c.SMTPConfigurationID.Get() + _, errAPISender := c.APISenderID.Get() + if errSMTP == nil && errAPISender == nil { + return errs.NewValidationError( + errors.New("smtp configuration and api sender cannot both be set"), + ) + } + return nil } diff --git a/frontend/src/routes/campaign-template/+page.svelte b/frontend/src/routes/campaign-template/+page.svelte index 4ab9832..367b0ba 100644 --- a/frontend/src/routes/campaign-template/+page.svelte +++ b/frontend/src/routes/campaign-template/+page.svelte @@ -101,6 +101,13 @@ modalText = getModalText('template', modalMode); } + // clear smtp or api sender when switching template type + $: if (formValues.templateType === 'Email') { + formValues.apiSender = null; + } else if (formValues.templateType === 'External API') { + formValues.smtpConfiguration = null; + } + // hooks onMount(() => { const context = appStateService.getContext();