push update

This commit is contained in:
Gordon 2022-04-13 18:33:22 +08:00
parent 6449c4a53d
commit 4f8fcd2d3d
3 changed files with 71 additions and 59 deletions

View File

@ -8,6 +8,7 @@ package logic
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/statistics"
"fmt"
@ -16,6 +17,7 @@ import (
var (
rpcServer RPCServer
pushCh PushConsumerHandler
pushTerminal []int32
producer *kafka.Producer
count uint64
)
@ -24,7 +26,7 @@ func Init(rpcPort int) {
rpcServer.Init(rpcPort)
pushCh.Init()
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
}
func init() {
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)

View File

@ -59,6 +59,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
if v.ResultCode == 0 {
continue
}
if utils.IsContainInt32(v.RecvPlatFormID, pushTerminal) {
//Use offline push messaging
var UIDList []string
UIDList = append(UIDList, v.RecvID)
@ -115,6 +116,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
} else {
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
}
}
}

View File

@ -43,6 +43,14 @@ func IsContain(target string, List []string) bool {
}
return false
}
func IsContainInt32(target int32, List []int32) bool {
for _, element := range List {
if target == element {
return true
}
}
return false
}
func InterfaceArrayToStringArray(data []interface{}) (i []string) {
for _, param := range data {