rpc protocol update

pull/131/head
Gordon 3 years ago
parent 0e99fb27b5
commit c6ade8d9bc

@ -27,7 +27,7 @@ type paramsUserSendMsg struct {
RecvID string `json:"recvID" binding:"required"`
ForceList []string `json:"forceList"`
Content string `json:"content" binding:"required"`
Options map[string]interface{} `json:"options" `
Options map[string]int32 `json:"options" `
ClientMsgID string `json:"clientMsgID" binding:"required"`
OffLineInfo map[string]interface{} `json:"offlineInfo" `
Ex map[string]interface{} `json:"ext"`
@ -49,7 +49,7 @@ func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.UserSend
RecvID: params.Data.RecvID,
ForceList: params.Data.ForceList,
Content: params.Data.Content,
Options: utils.MapToJsonString(params.Data.Options),
Options: params.Data.Options,
ClientMsgID: params.Data.ClientMsgID,
OffLineInfo: utils.MapToJsonString(params.Data.OffLineInfo),
Ex: utils.MapToJsonString(params.Data.Ex),

@ -72,7 +72,7 @@ func newUserSendMsgReq(params *paramsManagementSendMsg) *pbChat.UserSendMsgReq {
ForceList: params.ForceList,
Content: newContent,
ClientMsgID: utils.GetMsgID(params.SendID),
Options: utils.MapIntToJsonString(options),
Options: options,
}
return &pbData
}

@ -34,11 +34,9 @@ type AtContent struct {
IsAtSelf bool `json:"isAtSelf"`
}
func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) {
func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo string, Options map[string]int32) {
var wsResult []*pbRelay.SingleMsgToUser
MOptions := utils.JsonStringToMap(Options) //Control whether to push message to sender's other terminal
//isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync")
isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush")
isOfflinePush := utils.GetSwitchFromOptions(Options, "offlinePush")
log.InfoByKv("Get chat from msg_transfer And push chat", sendPbData.OperationID, "PushData", sendPbData)
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
//Online push message

@ -71,8 +71,7 @@ func (rpc *rpcChat) UserSendMsg(_ context.Context, pb *pbChat.UserSendMsgReq) (*
} else {
pbData.SendTime = pb.SendTime
}
Options := utils.JsonStringToMap(pbData.Options)
isHistory := utils.GetSwitchFromOptions(Options, "history")
isHistory := utils.GetSwitchFromOptions(pbData.Options, "history")
mReq := MsgCallBackReq{
SendID: pb.SendID,
RecvID: pb.RecvID,
@ -224,10 +223,7 @@ func modifyMessageByUserMessageReceiveOpt(userID, sourceID string, sessionType i
case constant.NotReceiveMessage:
return false
case constant.ReceiveNotNotifyMessage:
m := utils.JsonStringToMap(msg.Options)
utils.SetSwitchFromOptions(m, "offlinePush", 0)
s := utils.MapToJsonString(m)
msg.OfflineInfo = s
utils.SetSwitchFromOptions(msg.Options, "offlinePush", 0)
return true
}

@ -115,12 +115,12 @@ func JsonStringToMap(str string) (tempMap map[string]interface{}) {
_ = json.Unmarshal([]byte(str), &tempMap)
return tempMap
}
func GetSwitchFromOptions(Options map[string]interface{}, key string) (result bool) {
if flag, ok := Options[key]; !ok || flag.(float64) == 1 {
func GetSwitchFromOptions(Options map[string]int32, key string) (result bool) {
if flag, ok := Options[key]; !ok || flag == 1 {
return true
}
return false
}
func SetSwitchFromOptions(Options map[string]interface{}, key string, value interface{}) {
func SetSwitchFromOptions(Options map[string]int32, key string, value int32) {
Options[key] = value
}

Loading…
Cancel
Save