调整邮件过滤
This commit is contained in:
parent
1da5609f8d
commit
e7585a638f
@ -6,6 +6,7 @@ import (
|
||||
"main/common"
|
||||
"main/constant"
|
||||
"main/model/system"
|
||||
"main/mt"
|
||||
"net/http"
|
||||
"q5"
|
||||
|
||||
@ -141,6 +142,10 @@ func (this *MailApi) AddMail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !this.CheckAttachment(reqJson.Attachments, c) {
|
||||
return
|
||||
}
|
||||
|
||||
s := c.MustGet("session").(common.Session)
|
||||
acc := s.GetAccountAddress()
|
||||
|
||||
@ -222,6 +227,10 @@ func (this *MailApi) EditMail(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !this.CheckAttachment(reqJson.Attachments, c) {
|
||||
return
|
||||
}
|
||||
|
||||
nowDaySeconds := int32(f5.GetApp().GetRealSeconds())
|
||||
mail.MailId = reqJson.MailId
|
||||
mail.MailType = reqJson.MailType
|
||||
@ -289,3 +298,25 @@ func (this *MailApi) DelMail(c *gin.Context) {
|
||||
"message": "",
|
||||
})
|
||||
}
|
||||
|
||||
func (this *MailApi) CheckAttachment(list []common.Attachment, c *gin.Context) bool {
|
||||
if len(list) > 7 {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 2,
|
||||
"message": "附件过多",
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
for _, item := range list {
|
||||
if !mt.Table.Item.Search(item.ItemId) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 2,
|
||||
"message": "item id error:" + q5.SafeToString(item.ItemId),
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
27
server/adminserver/mt/Item.go
Normal file
27
server/adminserver/mt/Item.go
Normal file
@ -0,0 +1,27 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"main/mtb"
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
mtb.Item
|
||||
}
|
||||
|
||||
type ItemTable struct {
|
||||
f5.IdMetaTable[Item]
|
||||
}
|
||||
|
||||
func (this *ItemTable) Search(id int32) bool {
|
||||
// _, ret := it.itemIdHash[id]
|
||||
ret := false
|
||||
this.Traverse(func(ele *Item) bool {
|
||||
if ele.GetId() == id {
|
||||
ret = true
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
return ret
|
||||
}
|
@ -16,6 +16,7 @@ type table struct {
|
||||
NFTDb *NFTDbTable
|
||||
Permission *PermissionTable
|
||||
ConfDb *ConfDbTable
|
||||
Item *ItemTable
|
||||
}
|
||||
|
||||
var Table = f5.New(func(this *table) {
|
||||
@ -69,4 +70,9 @@ var Table = f5.New(func(this *table) {
|
||||
})
|
||||
|
||||
this.Permission = new(PermissionTable)
|
||||
|
||||
this.Item = f5.New(func(this *ItemTable) {
|
||||
this.FileName = "../res/item@item.json"
|
||||
this.PrimKey = "id"
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user