Skip to content

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

Add the "urls" field to the domain table

lotk66c01d30763c
diff --git a/core/api/domains/v1/domains.go b/core/api/domains/v1/domains.go
index 53d488e9..f21d9574 100644
--- a/core/api/domains/v1/domains.go
+++ b/core/api/domains/v1/domains.go
@@ -47,17 +47,19 @@ type Domain struct {
CertInfo CertInfo `json:"cert_info" dc:"Certificate information"`
Catchall string `json:"email" dc:"Cache all DNS records, used for domain verification"`
Default int `json:"default" dc:"Default sender domain, 1-yes, 0-no"`
+ Urls []string `json:"urls" dc:"Additional URLs associated with the domain"`
}
type AddDomainReq struct {
g.Meta `path:"/domains/create" tags:"Domain" method:"post" sm:"Add domain" in:"body"`
- Authorization string `json:"authorization" dc:"Authorization" in:"header"`
- Domain string `json:"domain" v:"required|domain" dc:"Domain"`
- Mailboxes int `json:"mailboxes" v:"min:1" dc:"Mailboxes" d:"50"`
- MailboxQuota int `json:"mailboxQuota" v:"min:1" dc:"MailboxQuota" d:"5242880"`
- Quota int `json:"quota" v:"required" dc:"Quota" d:"10485760"`
- RateLimit int `json:"rateLimit" v:"min:1" dc:"RateLimit" d:"12"`
- Catchall string `json:"email" v:"email" dc:"Catch all email address, used for domain verification"`
+ Authorization string `json:"authorization" dc:"Authorization" in:"header"`
+ Domain string `json:"domain" v:"required|domain" dc:"Domain"`
+ Mailboxes int `json:"mailboxes" v:"min:1" dc:"Mailboxes" d:"50"`
+ MailboxQuota int `json:"mailboxQuota" v:"min:1" dc:"MailboxQuota" d:"5242880"`
+ Quota int `json:"quota" v:"required" dc:"Quota" d:"10485760"`
+ RateLimit int `json:"rateLimit" v:"min:1" dc:"RateLimit" d:"12"`
+ Catchall string `json:"email" v:"email" dc:"Catch all email address, used for domain verification"`
+ Urls []string `json:"urls" dc:"Additional URLs associated with the domain"`
}
type AddDomainRes struct {
@@ -66,14 +68,15 @@ type AddDomainRes struct {
type UpdateDomainReq struct {
g.Meta `path:"/domains/update" tags:"Domain" method:"post" sm:"Update domain" in:"body"`
- Authorization string `json:"authorization" dc:"Authorization" in:"header"`
- Domain string `json:"domain" v:"required|domain" dc:"Domain"`
- Mailboxes int `json:"mailboxes" v:"min:1" dc:"Mailboxes" d:"50"`
- MailboxQuota int `json:"mailboxQuota" v:"min:1" dc:"MailboxQuota" d:"5242880"`
- Quota int `json:"quota" v:"required" dc:"Quota" d:"10485760"`
- RateLimit int `json:"rateLimit" v:"min:1" dc:"RateLimit" d:"12"`
- Active int `json:"active" v:"required" dc:"Active" d:"1"`
- Catchall string `json:"email" v:"email" dc:"Catch all email address, used for domain verification"`
+ Authorization string `json:"authorization" dc:"Authorization" in:"header"`
+ Domain string `json:"domain" v:"required|domain" dc:"Domain"`
+ Mailboxes int `json:"mailboxes" v:"min:1" dc:"Mailboxes" d:"50"`
+ MailboxQuota int `json:"mailboxQuota" v:"min:1" dc:"MailboxQuota" d:"5242880"`
+ Quota int `json:"quota" v:"required" dc:"Quota" d:"10485760"`
+ RateLimit int `json:"rateLimit" v:"min:1" dc:"RateLimit" d:"12"`
+ Active int `json:"active" v:"required" dc:"Active" d:"1"`
+ Catchall string `json:"email" v:"email" dc:"Catch all email address, used for domain verification"`
+ Urls []string `json:"urls" dc:"Additional URLs associated with the domain"`
}
type UpdateDomainRes struct {
diff --git a/core/internal/controller/domains/domains_v1_add_domain.go b/core/internal/controller/domains/domains_v1_add_domain.go
index 77456678..6a0ae154 100644
--- a/core/internal/controller/domains/domains_v1_add_domain.go
+++ b/core/internal/controller/domains/domains_v1_add_domain.go
@@ -24,6 +24,7 @@ func (c *ControllerV1) AddDomain(ctx context.Context, req *v1.AddDomainReq) (res
Quota: int64(req.Quota),
RateLimit: req.RateLimit,
Catchall: req.Catchall,
+ Urls: req.Urls,
}
if err = domains.Add(ctx, domain); err != nil {
diff --git a/core/internal/controller/domains/domains_v1_update_domain.go b/core/internal/controller/domains/domains_v1_update_domain.go
index c276f5ec..0f9cd980 100644
--- a/core/internal/controller/domains/domains_v1_update_domain.go
+++ b/core/internal/controller/domains/domains_v1_update_domain.go
@@ -27,6 +27,7 @@ func (c *ControllerV1) UpdateDomain(ctx context.Context, req *v1.UpdateDomainReq
RateLimit: req.RateLimit,
Active: req.Active,
Catchall: req.Catchall,
+ Urls: req.Urls,
}
if err = domains.Update(ctx, domain); err != nil {
diff --git a/core/internal/service/database_initialization/mail_serv.go b/core/internal/service/database_initialization/mail_serv.go
index f2e6aed8..c2112d17 100644
--- a/core/internal/service/database_initialization/mail_serv.go
+++ b/core/internal/service/database_initialization/mail_serv.go
@@ -18,6 +18,7 @@ func init() {
rate_limit INT DEFAULT 12, -- How many emails per second
create_time INT NOT NULL default 0,
active SMALLINT NOT NULL DEFAULT 1,
+ urls TEXT[] NOT NULL DEFAULT '{}'::TEXT[],
PRIMARY KEY (domain)
)`,
@@ -113,5 +114,8 @@ func init() {
return
}
}
+
+ // domain
+ _ = AddColumnIfNotExists("domain", "urls", "TEXT[]", "'{}'::TEXT[]", false)
})
}