You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/push/logic/callback.go

47 lines
1.7 KiB

3 years ago
package logic
import (
cbApi "Open_IM/pkg/call_back_struct"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/http"
commonPb "Open_IM/pkg/proto/sdk_ws"
http2 "net/http"
)
3 years ago
func callbackOfflinePush(operationID, userID string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
3 years ago
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
3 years ago
if !config.Config.Callback.CallbackOfflinePush.Enable {
3 years ago
return callbackResp
}
callbackOfflinePushReq := cbApi.CallbackOfflinePushReq{
UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
CallbackCommand: constant.CallbackOfflinePushCommand,
OperationID: operationID,
UserID: userID,
3 years ago
PlatformID: msg.SenderPlatformID,
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
3 years ago
},
3 years ago
OfflinePushInfo: msg.OfflinePushInfo,
SendID: msg.SendID,
GroupID: msg.GroupID,
ContentType: msg.ContentType,
SessionType: msg.SessionType,
AtUserIDList: msg.AtUserIDList,
Content: string(msg.Content),
3 years ago
}
3 years ago
callbackOfflinePushResp := &cbApi.CallbackOfflinePushResp{CommonCallbackResp: &callbackResp}
3 years ago
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflinePushReq, callbackOfflinePushResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error()
3 years ago
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
callbackResp.ActionCode = constant.ActionForbidden
return callbackResp
} else {
callbackResp.ActionCode = constant.ActionAllow
return callbackResp
}
3 years ago
}
return callbackResp
}