1 parent
7c8b71c33f
commit
2660fc7b13
42 files changed
+701
-634
No files matched your search
@@ -1,7 +0,0 @@
|
||||
package auth
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestDkimGen(t *testing.T) {
|
||||
DkimGen()
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
package del_email
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pmail/db"
|
||||
"pmail/models"
|
||||
"pmail/services/auth"
|
||||
"pmail/utils/array"
|
||||
"pmail/utils/context"
|
||||
"pmail/utils/errors"
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
func DelEmail(ctx *context.Context, ids []int) error {
|
||||
var emails []*models.Email
|
||||
|
||||
err := db.Instance.ID(ids).Find(&emails)
|
||||
err := db.Instance.Table("email").Where(builder.In("id", ids)).Find(&emails)
|
||||
if err != nil {
|
||||
return errors.Wrap(err)
|
||||
}
|
||||
@@ -23,9 +22,11 @@ func DelEmail(ctx *context.Context, ids []int) error {
|
||||
if !hasAuth {
|
||||
return errors.New("No Auth!")
|
||||
}
|
||||
email.Status = 3
|
||||
}
|
||||
|
||||
_, err = db.Instance.Exec(db.WithContext(ctx, fmt.Sprintf("update email set status = 3 where id in (%s)", array.Join(ids, ","))))
|
||||
_, err = db.Instance.Table("email").Where(builder.In("id", ids)).Cols("status").Update(map[string]interface{}{"status": 3})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err)
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"pmail/models"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRegexMatch_Match(t *testing.T) {
|
||||
r := NewRegexMatch("Subject", "\\d+")
|
||||
|
||||
ret := r.Match(nil, &models.Email{
|
||||
Subject: "111",
|
||||
})
|
||||
|
||||
if !ret {
|
||||
t.Errorf("失败")
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,6 @@ func SetDatabaseSettings(ctx *context.Context, dbType, dbDSN string) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err)
|
||||
}
|
||||
models.SyncTables()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSetAdminPassword(t *testing.T) {
|
||||
|
||||
SetAdminPassword(nil, "admin", "admin")
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package setup
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetIp(t *testing.T) {
|
||||
getIp()
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func GetSSL() string {
|
||||
return cfg.SSLType
|
||||
}
|
||||
|
||||
func SetSSL(sslType string) error {
|
||||
func SetSSL(sslType, priKey, crtKey string) error {
|
||||
cfg, err := setup.ReadConfig()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -61,6 +61,11 @@ func SetSSL(sslType string) error {
|
||||
return errors.New("SSL Type Error!")
|
||||
}
|
||||
|
||||
if cfg.SSLType == config.SSLTypeUser {
|
||||
cfg.SSLPrivateKeyPath = priKey
|
||||
cfg.SSLPublicKeyPath = crtKey
|
||||
}
|
||||
|
||||
err = setup.WriteConfig(cfg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package ssl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenSSL(t *testing.T) {
|
||||
err := GenSSL(false)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
func TestGetSSLCrtInfo(t *testing.T) {
|
||||
days, tm, err := CheckSSLCrtInfo()
|
||||
|
||||
fmt.Println(days, tm, err)
|
||||
}
|
||||
Reference in new issue
Block a user