BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
AddMailForward removes the domain parameter
lotk4811a5d2a622
diff --git a/core/api/mail_services/v1/mail_forward.go b/core/api/mail_services/v1/mail_forward.goindex 6223883a..916b0175 100644--- a/core/api/mail_services/v1/mail_forward.go+++ b/core/api/mail_services/v1/mail_forward.go@@ -34,7 +34,6 @@ type AddMailForwardReq struct {g.Meta `path:"/mail_forward/add" method:"post" summary:"add mail forward"`Address string `json:"address" v:"required|email" desc:"forwarded email address, e.g. [email protected]"`Goto string `json:"goto" v:"required" desc:"forward target address, multiple addresses separated by newline"`- Domain string `json:"domain" v:"required" desc:"domain"`Active int `json:"active" v:"in:0,1" desc:"status: 1-enabled, 0-disabled" default:"1"`}diff --git a/core/internal/controller/mail_services/mail_services_v1_add_mail_forward.go b/core/internal/controller/mail_services/mail_services_v1_add_mail_forward.goindex 64b69c07..c846e284 100644--- a/core/internal/controller/mail_services/mail_services_v1_add_mail_forward.go+++ b/core/internal/controller/mail_services/mail_services_v1_add_mail_forward.go@@ -26,7 +26,18 @@ func (c *ControllerV1) AddMailForward(ctx context.Context, req *v1.AddMailForwarreturn res, nil}- count, err = g.DB().Model("domain").Where("domain=?", req.Domain).Count()+ domainParts := strings.Split(req.Address, "@")+ if len(domainParts) != 2 {+ res.SetError(gerror.New(public.LangCtx(ctx, "invalid email format: {}", req.Address)))+ return+ }+ domain := domainParts[1]+ if domain == "" {+ res.SetError(gerror.New(public.LangCtx(ctx, "domain part is empty in address: {}", req.Address)))+ return+ }++ count, err = g.DB().Model("domain").Where("domain=?", domain).Count()if err != nil {res.SetError(gerror.New(public.LangCtx(ctx, "check domain failed: {}", err.Error())))return res, nil@@ -49,7 +60,7 @@ func (c *ControllerV1) AddMailForward(ctx context.Context, req *v1.AddMailForwar_, err = g.DB().Model("alias").Insert(g.Map{"address": req.Address,"goto": strings.Join(forwardUsers, ","),- "domain": req.Domain,+ "domain": domain,"create_time": now,"update_time": now,"active": req.Active,