From 5a3253aa02ec83b53cf62832b6b85ea2fb94483c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 20 Aug 2024 14:29:27 +0800 Subject: [PATCH] 1 --- server/mailserver/mail/mailmgr.go | 153 ------------------------- server/mailserver/middleware/caauth.go | 6 - 2 files changed, 159 deletions(-) diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index 861ae8af..45d3ad5f 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -3,9 +3,7 @@ package mail import ( "q5" "f5" - "jccommon" "main/common" - "main/mt" "main/constant" "sync" "fmt" @@ -48,7 +46,6 @@ func (this *mailMgr) Init() { f5.GetApp().RegisterCaHandle("Mail", "getUnreadMailCnt", this.CaGetUnreadMailCnt) f5.GetApp().RegisterCaHandle("Mail", "getAttachment", this.CaGetAttachment) f5.GetApp().RegisterCaHandle("Mail", "deleteMails", this.CaDeleteMails) - f5.GetApp().RegisterCaHandle("MailMgr", "sendMail", this.CaSendMail) this.timerWp = f5.GetTimer().SetIntervalWp( 300, func (e int32, args* q5.Args) { @@ -218,156 +215,6 @@ func (this *mailMgr) CaDeleteMails(c *gin.Context) { c.JSON(200, rspObj) } -func (this *mailMgr) CaSendMail(c *gin.Context) { - rspObj := struct { - ErrCode int32 `json:"errcode"` - ErrMsg string `json:"errmsg"` - }{} - - key := c.DefaultQuery("key", "") - if mt.Table.Config.GetById(0).GetGmSecretKey() != key { - rspObj.ErrCode = 2 - rspObj.ErrMsg = "is not gm error" - c.JSON(200, rspObj) - return - } - if mt.Table.Config.GetById(0).GetGmOpen() == 0 { - rspObj.ErrCode = 3 - rspObj.ErrMsg = "is not gm open" - c.JSON(200, rspObj) - return - } - reqJson := struct { - UniKey string `json:"unikey"` - Subject string `json:"subject"` - Content string `json:"content"` - Recipients []string`json:"recipients"` - SendTime int32 `json:"sendtime"` - ExpireTime int32 `json:"expiretime"` - Attachments []*common.AttachmentDto `json:"attachments"` - }{} - if err := c.ShouldBindJSON(&reqJson); err != nil { - c.JSON(200, gin.H{ - "code": 1, - "message": err.Error(), - }) - return - } - - if reqJson.UniKey == "" { - rspObj.ErrCode = 500 - rspObj.ErrMsg = "unikey param error" - c.JSON(200, rspObj) - return - } - /* - if reqJson.Subject == "" { - c.JSON(200, rspObj) - return - }*/ - if reqJson.Content == "" { - rspObj.ErrCode = 500 - rspObj.ErrMsg = "unikey param error" - c.JSON(200, rspObj) - return - } - if len(reqJson.Recipients) <= 0 { - rspObj.ErrCode = 500 - rspObj.ErrMsg = "recipients param error" - c.JSON(200, rspObj) - return - } - if f5.GetApp().GetRealSeconds() >= q5.ToInt64(reqJson.ExpireTime) { - rspObj.ErrCode = 500 - rspObj.ErrMsg = "expiretime param error" - c.JSON(200, rspObj) - return - } - for _, val := range reqJson.Attachments { - if val.ItemId == 0 { - rspObj.ErrCode = 500 - rspObj.ErrMsg = "Attachments param error" - c.JSON(200, rspObj) - return - } - if val.ItemNum <= 0 || val.ItemNum > 10000 * 100 { - rspObj.ErrCode = 500 - rspObj.ErrMsg = "Attachments param error" - c.JSON(200, rspObj) - return - } - } - { - var dbErr error - found := false - f5.GetGoStyleDb().OrmSelectOne( - constant.MAIL_DB, - "t_mail", - [][]string{ - {"unikey", reqJson.UniKey}, - }, - func (err error, ds *f5.DataSet) { - dbErr = err - if err == nil { - if ds.Next() { - found = true - } - } - }); - if dbErr != nil { - rspObj.ErrCode = 500 - rspObj.ErrMsg = dbErr.Error() - c.JSON(200, rspObj) - return - } - if found { - rspObj.ErrCode = 3 - rspObj.ErrMsg = "mail already exists" - c.JSON(200, rspObj) - return - } - } - mailId := f5.GetApp().NewLockNodeUuid() - nowTime := f5.GetApp().GetRealSeconds() - f5.GetGoStyleDb().Insert( - constant.MAIL_DB, - "t_mail", - [][]string{ - {"mail_id", q5.ToString(mailId)}, - {"mail_type", q5.ToString(jccommon.MAIL_TYPE_GROUP)}, - {"unikey", reqJson.UniKey}, - {"subject", reqJson.Subject}, - {"content", reqJson.Content}, - {"recipients", q5.EncodeJson(reqJson.Recipients)}, - {"attachments", q5.EncodeJson(reqJson.Attachments)}, - {"sendtime", q5.ToString(reqJson.SendTime)}, - {"expiretime", q5.ToString(reqJson.ExpireTime)}, - {"user_reg_start_time", q5.ToString(0)}, - {"user_reg_end_time", q5.ToString(nowTime + 3600 * 24 * 365 * 10)}, - {"createtime", q5.ToString(nowTime)}, - {"modifytime", q5.ToString(nowTime)}, - }, - func (err error, lastInsertId int64, rowsAffected int64) { - if err != nil { - rspObj.ErrCode = 500 - rspObj.ErrMsg = err.Error() - return - } - f5.GetGoStyleDb().Insert( - constant.MAIL_DB, - "t_event", - [][]string{ - {"event_name", constant.EVENT_MAIL_UPDATE}, - {"param1", q5.ToString(mailId)}, - {"createtime", q5.ToString(nowTime)}, - {"modifytime", q5.ToString(nowTime)}, - }, - func (err error, lastInsertId int64, rowsAffected int64) { - c.JSON(200, rspObj) - }) - }) -} - func (this *mailMgr) traversePlayerMail(hum common.Player, cb func(*mail) bool) { stop := false traversedMails := make(map[int64]*mail, 10) diff --git a/server/mailserver/middleware/caauth.go b/server/mailserver/middleware/caauth.go index da7678d2..73320822 100644 --- a/server/mailserver/middleware/caauth.go +++ b/server/mailserver/middleware/caauth.go @@ -9,12 +9,6 @@ import ( func CaAuth(c *gin.Context) { accountId := c.DefaultQuery("account_id", "") sessionId := c.DefaultQuery("session_id", "") - class := c.DefaultQuery("c", "") - action := c.DefaultQuery("a", "") - if class == "MailMgr" && action == "sendMail" { - c.Next() - return - } hum := GetPlayerMgr().GetPlayerByAccountId(accountId) if hum == nil { hum = GetPlayerMgr().ForceCreatePlayer(accountId, sessionId)