diff --git a/api/consts/status.go b/api/consts/status.go index b0f23f59..bf48bd63 100644 --- a/api/consts/status.go +++ b/api/consts/status.go @@ -322,6 +322,13 @@ const ( VideoManuallyReview_Rejected = 2 //已复审拒绝 ) +// 邮件 +const ( + Email_Created = 0 // 已创建 + Email_Success = 1 // 已发送 + Email_Fail = 2 // 发送失败 +) + // 系统通知表的已读状态 const ( Notification_NotRead = 0 //未读 diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 4731f23d..63312413 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -4256,6 +4256,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, @@ -4275,12 +4276,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"` // 删除标记