callback fix

pull/261/head
wangchuxiao 3 years ago
parent f687f2eafb
commit a99dbf634b

@ -2,6 +2,7 @@ package logic
import (
cbApi "Open_IM/pkg/call_back_struct"
"Open_IM/pkg/common/callback"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/http"
@ -32,7 +33,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
ContentType: msg.ContentType,
SessionType: msg.SessionType,
AtUserIDList: msg.AtUserIDList,
Content: string(msg.Content),
Content: callback.GetContent(msg),
}
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
@ -74,7 +75,7 @@ func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.M
ContentType: msg.ContentType,
SessionType: msg.SessionType,
AtUserIDList: msg.AtUserIDList,
Content: string(msg.Content),
Content: callback.GetContent(msg),
}
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil {
@ -110,7 +111,7 @@ func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg
ContentType: msg.ContentType,
SessionType: msg.SessionType,
AtUserIDList: msg.AtUserIDList,
Content: string(msg.Content),
Content: callback.GetContent(msg),
}
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {

@ -2,6 +2,7 @@ package msg
import (
cbApi "Open_IM/pkg/call_back_struct"
"Open_IM/pkg/common/callback"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/http"
@ -12,7 +13,7 @@ import (
)
func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq {
return cbApi.CommonCallbackReq{
req := cbApi.CommonCallbackReq{
SendID: msg.MsgData.SendID,
ServerMsgID: msg.MsgData.ServerMsgID,
ClientMsgID: msg.MsgData.ClientMsgID,
@ -24,10 +25,11 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq
ContentType: msg.MsgData.ContentType,
Status: msg.MsgData.Status,
CreateTime: msg.MsgData.CreateTime,
Content: string(msg.MsgData.Content),
AtUserIDList: msg.MsgData.AtUserIDList,
SenderFaceURL: msg.MsgData.SenderFaceURL,
Content: callback.GetContent(msg.MsgData),
}
return req
}
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {

@ -0,0 +1,24 @@
package callback
import (
"Open_IM/pkg/common/constant"
server_api_params "Open_IM/pkg/proto/sdk_ws"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func GetContent(msg *server_api_params.MsgData) string {
if msg.ContentType >= constant.NotificationBegin && msg.ContentType <= constant.NotificationEnd {
var tips server_api_params.TipsComm
_ = proto.Unmarshal(msg.Content, &tips)
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
content, _ := marshaler.MarshalToString(&tips)
return content
} else {
return string(msg.Content)
}
}
Loading…
Cancel
Save