From 046c5238804c91760aabdde20842f7bf800a1eab Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 8 Apr 2022 17:00:28 +0800 Subject: [PATCH] getui --- internal/push/getui/push.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/push/getui/push.go b/internal/push/getui/push.go index 18ae45c9b..95080f0b8 100644 --- a/internal/push/getui/push.go +++ b/internal/push/getui/push.go @@ -19,6 +19,11 @@ var ( GetuiClient *Getui ) +const ( + PushURL = "/push/single/cid" + AuthURL = "/auth" +) + func init() { GetuiClient = newGetuiClient() } @@ -99,7 +104,7 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, platform, operat pushReq.PushMssage.Notification.ClickType = "intent" } pushResp := PushResp{} - err = g.request(pushReq, token, &pushResp, operationID) + err = g.request(PushURL, pushReq, token, &pushResp, operationID) if err != nil { return "", utils.Wrap(err, "push failed") } @@ -120,7 +125,7 @@ func (g *Getui) Auth(operationID string, timeStamp int64) (token string, expireT Appkey: config.Config.Push.Getui.AppKey, } respAuth := AuthResp{} - err = g.request(reqAuth, "", &respAuth, operationID) + err = g.request(AuthURL, reqAuth, "", &respAuth, operationID) if err != nil { return "", 0, err } @@ -129,7 +134,7 @@ func (g *Getui) Auth(operationID string, timeStamp int64) (token string, expireT return respAuth.Token, int64(expire), err } -func (g *Getui) request(content interface{}, token string, returnStruct interface{}, operationID string) error { +func (g *Getui) request(url, content interface{}, token string, returnStruct interface{}, operationID string) error { con, err := json.Marshal(content) if err != nil { return err