This commit is contained in:
eson 2023-09-05 17:24:46 +08:00
parent ca6a10c373
commit 4342e09699
2 changed files with 8 additions and 3 deletions

View File

@ -67,7 +67,8 @@ func FinishRegister(svcCtx *svc.ServiceContext, user *gmodel.FsUser, token *auth
} }
func CommonNotify(WebsocketAddr, wid string, event *wevent.WebsocketEvent) error { func CommonNotify(WebsocketAddr, wid string, event *wevent.WebsocketEvent) error {
tp := requests.Post(fmt.Sprintf("%s/api/websocket/common_notify", WebsocketAddr)) reqWebsocketAddr := fmt.Sprintf("%s/api/websocket/common_notify", WebsocketAddr)
tp := requests.Post(reqWebsocketAddr)
tp.SetBodyJson(requests.M{ tp.SetBodyJson(requests.M{
"wid": wid, "wid": wid,
"data": event, "data": event,
@ -80,7 +81,11 @@ func CommonNotify(WebsocketAddr, wid string, event *wevent.WebsocketEvent) error
} }
result := wresp.Json() result := wresp.Json()
logx.Error(result.String())
if !result.Get("code").Exists() {
return fmt.Errorf("send %s is error", reqWebsocketAddr)
}
if result.Get("code").Int() != 200 { if result.Get("code").Int() != 200 {
return fmt.Errorf("%s", result.String()) return fmt.Errorf("%s", result.String())
} }

View File

@ -79,7 +79,7 @@ func (l *UserResetPasswordLogic) UserResetPassword(req *types.RequestUserResetPa
} }
event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId) event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId)
err = CommonNotify(l.svcCtx.Config.MainAddress, rt.Wid, event) err = CommonNotify(l.svcCtx.Config.WebsocketAddr, rt.Wid, event)
if err != nil { if err != nil {
logx.Error(err, rt.TraceId) logx.Error(err, rt.TraceId)
return resp.SetStatusWithMessage(basic.CodeResetPasswordErr, err.Error()) return resp.SetStatusWithMessage(basic.CodeResetPasswordErr, err.Error())