From ee3a73d69561ace6df8608db935338caf73efe05 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 17 Oct 2024 11:22:49 +0800 Subject: [PATCH] by Robin at 20241017 --- api/consts/status.go | 7 +++++++ app/mix/service/apiservice.go | 29 +++++++++++++++++++++++------ dbstruct/email.go | 1 + 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/api/consts/status.go b/api/consts/status.go index 4ce638fd..47d7dbcd 100644 --- a/api/consts/status.go +++ b/api/consts/status.go @@ -321,3 +321,10 @@ const ( VideoManuallyReview_Passed = 1 //已复审通过 VideoManuallyReview_Rejected = 2 //已复审拒绝 ) + +// 邮件 +const ( + Email_Created = 0 // 已创建 + Email_Success = 1 // 已发送 + Email_Fail = 2 // 发送失败 +) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 715a96dd..27da2033 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -4040,6 +4040,7 @@ func (s *Service) ApiSendRavenIQTestResultAsEmail(ctx *gin.Context, req *emailpr req.Email.From = goproto.String(emailInfoCfg.Address) req.Email.Subject = goproto.String(emailContentCfg.Subject) req.Email.Text = goproto.String(emailContentCfg.Text) + req.Email.Status = goproto.Int64(consts.Email_Created) err = _DefaultEmail.OpCreate(ctx, &emailproto.OpCreateReq{ BaseRequest: req.BaseRequest, @@ -4059,12 +4060,28 @@ func (s *Service) ApiSendRavenIQTestResultAsEmail(ctx *gin.Context, req *emailpr return } - err = email.SendRavenIQTestResult(req.Email, emailInfoCfg.Host, emailInfoCfg.Port, emailInfoCfg.Address, emailInfoCfg.Password) - if err != nil { - logger.Error("SendRavenIQTestResult fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeEmailSrvFail - return - } + go func() { + err = email.SendRavenIQTestResult(req.Email, emailInfoCfg.Host, emailInfoCfg.Port, emailInfoCfg.Address, emailInfoCfg.Password) + if err != nil { + logger.Error("SendRavenIQTestResult fail, req: %v, err: %v", util.ToJson(req), err) + // 更新状态为失败 + _DefaultEmail.OpUpdate(ctx, &emailproto.OpUpdateReq{ + Email: &dbstruct.Email{ + Id: req.Id, + Status: goproto.Int64(consts.Email_Fail), + }, + }) + return + } + // 更新状态为成功 + _DefaultEmail.OpUpdate(ctx, &emailproto.OpUpdateReq{ + Email: &dbstruct.Email{ + Id: req.Id, + Status: goproto.Int64(consts.Email_Success), + }, + }) + }() + return } diff --git a/dbstruct/email.go b/dbstruct/email.go index 5a1487cf..cb7d4e4f 100644 --- a/dbstruct/email.go +++ b/dbstruct/email.go @@ -8,6 +8,7 @@ type Email struct { Subject *string `json:"subject" bson:"subject"` // 标题 Text *string `json:"text" bson:"text"` // 文本 MediaComponent *MediaComponent `json:"media_component" bson:"media_component"` // 媒体 + Status *int64 `json:"status" bson:"status"` // 状态 Ct *int64 `json:"ct" bson:"ct"` // 创建时间 Ut *int64 `json:"ut" bson:"ut"` // 更新时间 DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记