This commit is contained in:
withchao
2023-06-05 17:35:41 +08:00
parent f3387c3787
commit 69cf9dbcbe
11 changed files with 59 additions and 45 deletions
+3 -3
View File
@@ -39,7 +39,7 @@ func callbackOfflinePush(ctx context.Context, userIDs []string, msg *sdkws.MsgDa
Content: utils.GetContent(msg),
}
resp := &callbackstruct.CallbackBeforePushResp{}
err := http.CallBackPostReturn(url(), req, resp, config.Config.Callback.CallbackOfflinePush)
err := http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackOfflinePush)
if err != nil {
return err
}
@@ -75,7 +75,7 @@ func callbackOnlinePush(ctx context.Context, userIDs []string, msg *sdkws.MsgDat
Content: utils.GetContent(msg),
}
resp := &callbackstruct.CallbackBeforePushResp{}
return http.CallBackPostReturn(url(), req, resp, config.Config.Callback.CallbackOnlinePush)
return http.CallBackPostReturn(ctx, url(), req, resp, config.Config.Callback.CallbackOnlinePush)
}
func callbackBeforeSuperGroupOnlinePush(ctx context.Context, groupID string, msg *sdkws.MsgData, pushToUserIDs *[]string) error {
@@ -99,7 +99,7 @@ func callbackBeforeSuperGroupOnlinePush(ctx context.Context, groupID string, msg
Seq: msg.Seq,
}
resp := &callbackstruct.CallbackBeforeSuperGroupOnlinePushResp{}
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush); err != nil {
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush); err != nil {
return err
}
if len(resp.UserIDs) != 0 {
+3 -3
View File
@@ -146,11 +146,11 @@ func (g *Client) request(ctx context.Context, url string, input interface{}, tok
header := map[string]string{"token": token}
resp := &Resp{}
resp.Data = output
return g.postReturn(config.Config.Push.Getui.PushUrl+url, header, input, resp, 3)
return g.postReturn(ctx, config.Config.Push.Getui.PushUrl+url, header, input, resp, 3)
}
func (g *Client) postReturn(url string, header map[string]string, input interface{}, output RespI, timeout int) error {
err := http2.PostReturn(url, header, input, output, timeout)
func (g *Client) postReturn(ctx context.Context, url string, header map[string]string, input interface{}, output RespI, timeout int) error {
err := http2.PostReturn(ctx, url, header, input, output, timeout)
if err != nil {
return err
}
+3 -3
View File
@@ -55,9 +55,9 @@ func (j *JPush) Push(ctx context.Context, userIDs []string, title, content strin
pushObj.SetMessage(&msg)
pushObj.SetOptions(&opt)
var resp interface{}
return j.request(pushObj, resp, 5)
return j.request(ctx, pushObj, resp, 5)
}
func (j *JPush) request(po body.PushObj, resp interface{}, timeout int) error {
return http2.PostReturn(config.Config.Push.Jpns.PushUrl, map[string]string{"Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret)}, po, resp, timeout)
func (j *JPush) request(ctx context.Context, po body.PushObj, resp interface{}, timeout int) error {
return http2.PostReturn(ctx, config.Config.Push.Jpns.PushUrl, map[string]string{"Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret)}, po, resp, timeout)
}