mirror of
https://github.com/Jinnrry/PMail.git
synced 2025-11-01 12:22:38 +08:00
v2.1.2
修复协程调度顺序错误
This commit is contained in:
@@ -128,14 +128,16 @@ func Send(ctx *dto.Context, w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
as := async.New(ctx)
|
||||
for _, hook := range hooks.HookList {
|
||||
if hook == nil {
|
||||
continue
|
||||
}
|
||||
async.New(ctx).Process(func() {
|
||||
hook.SendBefore(ctx, e)
|
||||
})
|
||||
as.WaitProcess(func(hk any) {
|
||||
hk.(hooks.EmailHook).SendBefore(ctx, e)
|
||||
}, hook)
|
||||
}
|
||||
as.Wait()
|
||||
|
||||
// 邮件落库
|
||||
sql := "INSERT INTO email (type,subject, reply_to, from_name, from_address, `to`, bcc, cc, text, html, sender, attachments,spf_check, dkim_check, create_time,send_user_id,error) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
@@ -166,17 +168,18 @@ func Send(ctx *dto.Context, w http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
async.New(ctx).Process(func() {
|
||||
async.New(ctx).Process(func(p any) {
|
||||
errMsg := ""
|
||||
err, sendErr := smtp_server.Send(ctx, e)
|
||||
|
||||
as2 := async.New(ctx)
|
||||
for _, hook := range hooks.HookList {
|
||||
if hook == nil {
|
||||
continue
|
||||
}
|
||||
async.New(ctx).Process(func() {
|
||||
hook.SendAfter(ctx, e, sendErr)
|
||||
})
|
||||
as2.WaitProcess(func(hk any) {
|
||||
hk.(hooks.EmailHook).SendAfter(ctx, e, sendErr)
|
||||
}, hook)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -192,7 +195,7 @@ func Send(ctx *dto.Context, w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}, nil)
|
||||
|
||||
response.NewSuccessResponse(i18n.GetText(ctx.Lang, "succ")).FPrint(w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user