From 51622e77d4a87ebab1ed0a44419ae9f29b46e573 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 3 Nov 2021 15:59:08 +0800 Subject: [PATCH] push log add --- src/push/jpush/push.go | 6 ++++-- src/push/logic/init.go | 2 +- src/push/logic/push_to_client.go | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/push/jpush/push.go b/src/push/jpush/push.go index 90b8e8602..3a214c16d 100644 --- a/src/push/jpush/push.go +++ b/src/push/jpush/push.go @@ -6,13 +6,14 @@ import ( "Open_IM/src/push/jpush/requestBody" "bytes" "encoding/json" + "io/ioutil" "net/http" ) type JPushResp struct { } -func JGAccountListPush(accounts []string, jsonCustomContent string, platform string) (*http.Response, error) { +func JGAccountListPush(accounts []string, jsonCustomContent string, platform string) ([]byte, error) { var pf requestBody.Platform _ = pf.SetPlatform(platform) @@ -46,8 +47,9 @@ func JGAccountListPush(accounts []string, jsonCustomContent string, platform str return nil, err } defer resp.Body.Close() + result, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } - return resp, nil + return result, nil } diff --git a/src/push/logic/init.go b/src/push/logic/init.go index eb2515caf..5828f3227 100644 --- a/src/push/logic/init.go +++ b/src/push/logic/init.go @@ -24,7 +24,7 @@ func Init(rpcPort int) { log.NewPrivateLog(config.Config.ModuleName.PushName) rpcServer.Init(rpcPort) pushCh.Init() - pushTerminal = []int32{utils.IOSPlatformID, utils.AndroidPlatformID} + pushTerminal = []int32{utils.AndroidPlatformID} } func init() { producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic) diff --git a/src/push/logic/push_to_client.go b/src/push/logic/push_to_client.go index 09c4c36e8..b535dd11a 100644 --- a/src/push/logic/push_to_client.go +++ b/src/push/logic/push_to_client.go @@ -68,7 +68,12 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { } bCustomContent, _ := json.Marshal(customContent) jsonCustomContent := string(bCustomContent) - push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t)) + pushResult, err := push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t)) + if err != nil { + log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), t) + } else { + log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, t) + } } }