mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 02:58:26 +08:00
Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
This commit is contained in:
commit
07b5c7fef4
@ -8,23 +8,25 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/pkg/statistics"
|
"Open_IM/pkg/statistics"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rpcServer RPCServer
|
rpcServer RPCServer
|
||||||
pushCh PushConsumerHandler
|
pushCh PushConsumerHandler
|
||||||
producer *kafka.Producer
|
pushTerminal []int32
|
||||||
count uint64
|
producer *kafka.Producer
|
||||||
|
count uint64
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(rpcPort int) {
|
func Init(rpcPort int) {
|
||||||
|
|
||||||
rpcServer.Init(rpcPort)
|
rpcServer.Init(rpcPort)
|
||||||
pushCh.Init()
|
pushCh.Init()
|
||||||
|
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
|
||||||
}
|
}
|
||||||
func init() {
|
func init() {
|
||||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
||||||
|
@ -59,61 +59,64 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
if v.ResultCode == 0 {
|
if v.ResultCode == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//Use offline push messaging
|
if utils.IsContainInt32(v.RecvPlatFormID, pushTerminal) {
|
||||||
var UIDList []string
|
//Use offline push messaging
|
||||||
UIDList = append(UIDList, v.RecvID)
|
var UIDList []string
|
||||||
customContent := OpenIMContent{
|
UIDList = append(UIDList, v.RecvID)
|
||||||
SessionType: int(pushMsg.MsgData.SessionType),
|
customContent := OpenIMContent{
|
||||||
From: pushMsg.MsgData.SendID,
|
SessionType: int(pushMsg.MsgData.SessionType),
|
||||||
To: pushMsg.MsgData.RecvID,
|
From: pushMsg.MsgData.SendID,
|
||||||
Seq: pushMsg.MsgData.Seq,
|
To: pushMsg.MsgData.RecvID,
|
||||||
}
|
Seq: pushMsg.MsgData.Seq,
|
||||||
bCustomContent, _ := json.Marshal(customContent)
|
|
||||||
jsonCustomContent := string(bCustomContent)
|
|
||||||
var content string
|
|
||||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
|
||||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
|
||||||
|
|
||||||
} else {
|
|
||||||
switch pushMsg.MsgData.ContentType {
|
|
||||||
case constant.Text:
|
|
||||||
content = constant.ContentType2PushContent[constant.Text]
|
|
||||||
case constant.Picture:
|
|
||||||
content = constant.ContentType2PushContent[constant.Picture]
|
|
||||||
case constant.Voice:
|
|
||||||
content = constant.ContentType2PushContent[constant.Voice]
|
|
||||||
case constant.Video:
|
|
||||||
content = constant.ContentType2PushContent[constant.Video]
|
|
||||||
case constant.File:
|
|
||||||
content = constant.ContentType2PushContent[constant.File]
|
|
||||||
case constant.AtText:
|
|
||||||
a := AtContent{}
|
|
||||||
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
|
||||||
if utils.IsContain(v.RecvID, a.AtUserList) {
|
|
||||||
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
|
||||||
} else {
|
|
||||||
content = constant.ContentType2PushContent[constant.GroupMsg]
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
content = constant.ContentType2PushContent[constant.Common]
|
|
||||||
}
|
}
|
||||||
}
|
bCustomContent, _ := json.Marshal(customContent)
|
||||||
var offlinePusher pusher.OfflinePusher
|
jsonCustomContent := string(bCustomContent)
|
||||||
if config.Config.Push.Getui.Enable {
|
var content string
|
||||||
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), config.Config.Push.Getui)
|
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||||
offlinePusher = getui.GetuiClient
|
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||||
}
|
|
||||||
if config.Config.Push.Jpns.Enable {
|
} else {
|
||||||
offlinePusher = jpush.JPushClient
|
switch pushMsg.MsgData.ContentType {
|
||||||
}
|
case constant.Text:
|
||||||
if offlinePusher == nil {
|
content = constant.ContentType2PushContent[constant.Text]
|
||||||
offlinePusher = jpush.JPushClient
|
case constant.Picture:
|
||||||
}
|
content = constant.ContentType2PushContent[constant.Picture]
|
||||||
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID)
|
case constant.Voice:
|
||||||
if err != nil {
|
content = constant.ContentType2PushContent[constant.Voice]
|
||||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
case constant.Video:
|
||||||
} else {
|
content = constant.ContentType2PushContent[constant.Video]
|
||||||
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
case constant.File:
|
||||||
|
content = constant.ContentType2PushContent[constant.File]
|
||||||
|
case constant.AtText:
|
||||||
|
a := AtContent{}
|
||||||
|
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||||
|
if utils.IsContain(v.RecvID, a.AtUserList) {
|
||||||
|
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||||
|
} else {
|
||||||
|
content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
content = constant.ContentType2PushContent[constant.Common]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var offlinePusher pusher.OfflinePusher
|
||||||
|
if config.Config.Push.Getui.Enable {
|
||||||
|
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), config.Config.Push.Getui)
|
||||||
|
offlinePusher = getui.GetuiClient
|
||||||
|
}
|
||||||
|
if config.Config.Push.Jpns.Enable {
|
||||||
|
offlinePusher = jpush.JPushClient
|
||||||
|
}
|
||||||
|
if offlinePusher == nil {
|
||||||
|
offlinePusher = jpush.JPushClient
|
||||||
|
}
|
||||||
|
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||||
|
} else {
|
||||||
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,14 @@ func IsContain(target string, List []string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
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) {
|
func InterfaceArrayToStringArray(data []interface{}) (i []string) {
|
||||||
for _, param := range data {
|
for _, param := range data {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user