mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-29 22:11:46 +08:00
Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release
This commit is contained in:
commit
482c502356
@ -66,6 +66,7 @@ func (f *Fcm) Push(accounts []string, alert, detailContent, operationID string,
|
|||||||
Fail := 0
|
Fail := 0
|
||||||
for i := 0; i < pages; i++ {
|
for i := 0; i < pages; i++ {
|
||||||
Msg := new(messaging.MulticastMessage)
|
Msg := new(messaging.MulticastMessage)
|
||||||
|
Msg.Notification = &messaging.Notification{}
|
||||||
Msg.Notification.Body = detailContent
|
Msg.Notification.Body = detailContent
|
||||||
Msg.Notification.Title = alert
|
Msg.Notification.Title = alert
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -11,11 +11,15 @@ import (
|
|||||||
http2 "net/http"
|
http2 "net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func callbackBeforePush(operationID string, userIDList []string, msg *commonPb.MsgData, command string, callbackResp cbApi.CommonCallbackResp, timeOut int) cbApi.CommonCallbackResp {
|
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
||||||
|
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||||
|
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
||||||
|
return callbackResp
|
||||||
|
}
|
||||||
req := cbApi.CallbackBeforePushReq{
|
req := cbApi.CallbackBeforePushReq{
|
||||||
UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{
|
UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{
|
||||||
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
||||||
CallbackCommand: command,
|
CallbackCommand: constant.CallbackOfflinePushCommand,
|
||||||
OperationID: operationID,
|
OperationID: operationID,
|
||||||
PlatformID: msg.SenderPlatformID,
|
PlatformID: msg.SenderPlatformID,
|
||||||
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||||
@ -31,7 +35,7 @@ func callbackBeforePush(operationID string, userIDList []string, msg *commonPb.M
|
|||||||
Content: string(msg.Content),
|
Content: string(msg.Content),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||||
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, timeOut); err != nil {
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
||||||
@ -45,20 +49,42 @@ func callbackBeforePush(operationID string, userIDList []string, msg *commonPb.M
|
|||||||
return callbackResp
|
return callbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
|
||||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
|
||||||
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
|
||||||
return callbackResp
|
|
||||||
}
|
|
||||||
return callbackBeforePush(operationID, userIDList, msg, constant.CallbackOfflinePushCommand, callbackResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut)
|
|
||||||
}
|
|
||||||
|
|
||||||
func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp {
|
||||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||||
if !config.Config.Callback.CallbackOnlinePush.Enable {
|
if !config.Config.Callback.CallbackOnlinePush.Enable {
|
||||||
return callbackResp
|
return callbackResp
|
||||||
}
|
}
|
||||||
return callbackBeforePush(operationID, userIDList, msg, constant.CallbackOnlinePushCommand, callbackResp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut)
|
req := cbApi.CallbackBeforePushReq{
|
||||||
|
UserStatusBatchCallbackReq: cbApi.UserStatusBatchCallbackReq{
|
||||||
|
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
|
||||||
|
CallbackCommand: constant.CallbackOnlinePushCommand,
|
||||||
|
OperationID: operationID,
|
||||||
|
PlatformID: msg.SenderPlatformID,
|
||||||
|
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||||
|
},
|
||||||
|
UserIDList: userIDList,
|
||||||
|
},
|
||||||
|
OfflinePushInfo: msg.OfflinePushInfo,
|
||||||
|
SendID: msg.SendID,
|
||||||
|
GroupID: msg.GroupID,
|
||||||
|
ContentType: msg.ContentType,
|
||||||
|
SessionType: msg.SessionType,
|
||||||
|
AtUserIDList: msg.AtUserIDList,
|
||||||
|
Content: string(msg.Content),
|
||||||
|
}
|
||||||
|
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
||||||
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil {
|
||||||
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
|
callbackResp.ErrMsg = err.Error()
|
||||||
|
if !config.Config.Callback.CallbackOnlinePush.CallbackFailedContinue {
|
||||||
|
callbackResp.ActionCode = constant.ActionForbidden
|
||||||
|
return callbackResp
|
||||||
|
} else {
|
||||||
|
callbackResp.ActionCode = constant.ActionAllow
|
||||||
|
return callbackResp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return callbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg *commonPb.MsgData, pushToUserList *[]string) cbApi.CommonCallbackResp {
|
func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg *commonPb.MsgData, pushToUserList *[]string) cbApi.CommonCallbackResp {
|
||||||
@ -85,7 +111,7 @@ func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg
|
|||||||
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 {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
|
if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackFailedContinue {
|
||||||
callbackResp.ActionCode = constant.ActionForbidden
|
callbackResp.ActionCode = constant.ActionForbidden
|
||||||
return callbackResp
|
return callbackResp
|
||||||
} else {
|
} else {
|
||||||
|
@ -169,7 +169,8 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
||||||
} else {
|
}
|
||||||
|
if len(pushToUserIDList) == 0 {
|
||||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
|
@ -126,6 +126,13 @@ func Test_SetFcmToken(t *testing.T) {
|
|||||||
err := DB.SetFcmToken(uid, platformID, token, 0)
|
err := DB.SetFcmToken(uid, platformID, token, 0)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
func Test_GetFcmToken(t *testing.T) {
|
||||||
|
uid := "test_uid"
|
||||||
|
platformID := 2
|
||||||
|
token, err := DB.GetFcmToken(uid, platformID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
fmt.Println("token is :", token)
|
||||||
|
}
|
||||||
|
|
||||||
//func Test_GetGroupMemberList(t *testing.T) {
|
//func Test_GetGroupMemberList(t *testing.T) {
|
||||||
// groupID := "3791742301"
|
// groupID := "3791742301"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user