mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-31 03:23:43 +08:00
callback fix
This commit is contained in:
parent
f687f2eafb
commit
a99dbf634b
@ -2,6 +2,7 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
cbApi "Open_IM/pkg/call_back_struct"
|
cbApi "Open_IM/pkg/call_back_struct"
|
||||||
|
"Open_IM/pkg/common/callback"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/http"
|
"Open_IM/pkg/common/http"
|
||||||
@ -32,7 +33,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
|||||||
ContentType: msg.ContentType,
|
ContentType: msg.ContentType,
|
||||||
SessionType: msg.SessionType,
|
SessionType: msg.SessionType,
|
||||||
AtUserIDList: msg.AtUserIDList,
|
AtUserIDList: msg.AtUserIDList,
|
||||||
Content: string(msg.Content),
|
Content: callback.GetContent(msg),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
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,
|
ContentType: msg.ContentType,
|
||||||
SessionType: msg.SessionType,
|
SessionType: msg.SessionType,
|
||||||
AtUserIDList: msg.AtUserIDList,
|
AtUserIDList: msg.AtUserIDList,
|
||||||
Content: string(msg.Content),
|
Content: callback.GetContent(msg),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil {
|
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,
|
ContentType: msg.ContentType,
|
||||||
SessionType: msg.SessionType,
|
SessionType: msg.SessionType,
|
||||||
AtUserIDList: msg.AtUserIDList,
|
AtUserIDList: msg.AtUserIDList,
|
||||||
Content: string(msg.Content),
|
Content: callback.GetContent(msg),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp}
|
||||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {
|
||||||
|
@ -2,6 +2,7 @@ package msg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
cbApi "Open_IM/pkg/call_back_struct"
|
cbApi "Open_IM/pkg/call_back_struct"
|
||||||
|
"Open_IM/pkg/common/callback"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/http"
|
"Open_IM/pkg/common/http"
|
||||||
@ -12,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq {
|
func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq {
|
||||||
return cbApi.CommonCallbackReq{
|
req := cbApi.CommonCallbackReq{
|
||||||
SendID: msg.MsgData.SendID,
|
SendID: msg.MsgData.SendID,
|
||||||
ServerMsgID: msg.MsgData.ServerMsgID,
|
ServerMsgID: msg.MsgData.ServerMsgID,
|
||||||
ClientMsgID: msg.MsgData.ClientMsgID,
|
ClientMsgID: msg.MsgData.ClientMsgID,
|
||||||
@ -24,10 +25,11 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbApi.CommonCallbackReq
|
|||||||
ContentType: msg.MsgData.ContentType,
|
ContentType: msg.MsgData.ContentType,
|
||||||
Status: msg.MsgData.Status,
|
Status: msg.MsgData.Status,
|
||||||
CreateTime: msg.MsgData.CreateTime,
|
CreateTime: msg.MsgData.CreateTime,
|
||||||
Content: string(msg.MsgData.Content),
|
|
||||||
AtUserIDList: msg.MsgData.AtUserIDList,
|
AtUserIDList: msg.MsgData.AtUserIDList,
|
||||||
SenderFaceURL: msg.MsgData.SenderFaceURL,
|
SenderFaceURL: msg.MsgData.SenderFaceURL,
|
||||||
|
Content: callback.GetContent(msg.MsgData),
|
||||||
}
|
}
|
||||||
|
return req
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
||||||
|
24
pkg/common/callback/callback.go
Normal file
24
pkg/common/callback/callback.go
Normal file
@ -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…
x
Reference in New Issue
Block a user