update callback after join group

pull/1499/head
AndrewZuo01 2 years ago
parent ac8d60e9e7
commit b5dc1a8709

@ -369,7 +369,6 @@ callback:
timeout: 5 timeout: 5
failedContinue: true failedContinue: true
##TODO CALLBACK/
beforeInviteUserToGroup: beforeInviteUserToGroup:
enable: true enable: true
timeout: 5 timeout: 5

@ -312,7 +312,7 @@ iosPush:
# Timeout in seconds # Timeout in seconds
# Whether to continue execution if callback fails # Whether to continue execution if callback fails
callback: callback:
url: "http://125.124.195.201:8080/sdkName/callbackBeforeInviteJoinGroupCommand" url: "http://125.124.195.201:18889/sdkName/callbackBeforeInviteJoinGroupCommand"
beforeSendSingleMsg: beforeSendSingleMsg:
enable: false enable: false
timeout: 5 timeout: 5
@ -376,11 +376,35 @@ callback:
enable: false enable: false
timeout: 5 timeout: 5
failedContinue: true failedContinue: true
##TODO CALLBACK/ afterGroupMsgRead:
enable: true
timeout: 5
failedContinue: true
afterGroupMsgRevoke:
enable: false
timeout: 5
failedContinue: true
afterJoinGroup:
enable: false
timeout: 5
failedContinue: true
beforeInviteUserToGroup: beforeInviteUserToGroup:
enable: false
timeout: 5
failedContinue: true
##TODO CALLBACK
joinGroupAfter:
enable: true enable: true
timeout: 5 timeout: 5
failedContinue: true failedContinue: true
setGroupInfoAfter:
enable: false
timeout: 5
failedContinue: true
setGroupInfoBefore:
enable: false
timeout: 5
failedContinue: true
###################### Prometheus ###################### ###################### Prometheus ######################
# Prometheus configuration for various services # Prometheus configuration for various services
# The number of Prometheus ports per service needs to correspond to rpcPort # The number of Prometheus ports per service needs to correspond to rpcPort

@ -38,7 +38,7 @@ require github.com/google/uuid v1.3.1
require ( require (
github.com/IBM/sarama v1.41.3 github.com/IBM/sarama v1.41.3
github.com/OpenIMSDK/protocol v0.0.31 github.com/OpenIMSDK/protocol v0.0.31
github.com/OpenIMSDK/tools v0.0.16 github.com/OpenIMSDK/tools v0.0.17
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible
github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis v6.15.9+incompatible
github.com/go-sql-driver/mysql v1.7.1 github.com/go-sql-driver/mysql v1.7.1

@ -20,8 +20,8 @@ github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c=
github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ=
github.com/OpenIMSDK/protocol v0.0.31 h1:ax43x9aqA6EKNXNukS5MT5BSTqkUmwO4uTvbJLtzCgE= github.com/OpenIMSDK/protocol v0.0.31 h1:ax43x9aqA6EKNXNukS5MT5BSTqkUmwO4uTvbJLtzCgE=
github.com/OpenIMSDK/protocol v0.0.31/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= github.com/OpenIMSDK/protocol v0.0.31/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/tools v0.0.16 h1:te/GIq2imCMsrRPgU9OObYKbzZ3rT08Lih/o+3QFIz0= github.com/OpenIMSDK/tools v0.0.17 h1:1E1HUOL2W09YUHBb4wBwrXoTSZm5ONVwLxlEX1GhlKw=
github.com/OpenIMSDK/tools v0.0.16/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/OpenIMSDK/tools v0.0.17/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=

@ -171,7 +171,6 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe
return nil return nil
} }
// TODO CALLBACK
func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserToGroupReq) (err error) { func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserToGroupReq) (err error) {
if !config.Config.Callback.CallbackBeforeInviteUserToGroup.Enable { if !config.Config.Callback.CallbackBeforeInviteUserToGroup.Enable {
return nil return nil
@ -183,7 +182,7 @@ func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserT
GroupID: req.GroupID, GroupID: req.GroupID,
Reason: req.Reason, Reason: req.Reason,
InvitedUserIDs: req.InvitedUserIDs, InvitedUserIDs: req.InvitedUserIDs,
EventTime: time.Now().UnixNano() / int64(time.Millisecond), // Event trigger timestamp in milliseconds EventTime: time.Now().Unix(),
} }
resp := &callbackstruct.CallbackBeforeInviteUserToGroupResp{} resp := &callbackstruct.CallbackBeforeInviteUserToGroupResp{}
@ -203,6 +202,32 @@ func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserT
// Handle the scenario where certain members are refused // Handle the scenario where certain members are refused
// You might want to update the req.Members list or handle it as per your business logic // You might want to update the req.Members list or handle it as per your business logic
} }
utils.StructFieldNotNilReplace(req, resp)
return nil
}
func CallbackAfterJoinGroup(ctx context.Context, req *group.JoinGroupReq) error {
if !config.Config.Callback.CallbackAfterJoinGroup.Enable {
return nil
}
callbackReq := &callbackstruct.CallbackAfterJoinGroupReq{
CallbackCommand: callbackstruct.CallbackAfterJoinGroupCommand,
OperationID: mcontext.GetOperationID(ctx),
GroupID: req.GroupID,
ReqMessage: req.ReqMessage,
JoinSource: req.JoinSource,
InviterUserID: req.InviterUserID,
EventTime: time.Now().Unix(),
}
resp := &callbackstruct.CallbackAfterJoinGroupResp{}
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackAfterJoinGroup); err != nil {
if err == errs.ErrCallbackContinue {
return nil
}
return err
}
return nil return nil
} }
// TODO CALLBACK

@ -387,7 +387,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
} }
groupMember = groupMembers[0] groupMember = groupMembers[0]
} }
//TODO CALLBACK
if err := CallbackBeforeInviteUserToGroup(ctx, req); err != nil { if err := CallbackBeforeInviteUserToGroup(ctx, req); err != nil {
return nil, err return nil, err
} }
@ -807,6 +807,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
case constant.GroupResponseRefuse: case constant.GroupResponseRefuse:
s.Notification.GroupApplicationRejectedNotification(ctx, req) s.Notification.GroupApplicationRejectedNotification(ctx, req)
} }
return &pbgroup.GroupApplicationResponseResp{}, nil return &pbgroup.GroupApplicationResponseResp{}, nil
} }
@ -855,6 +856,10 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
return nil, err return nil, err
} }
s.Notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID) s.Notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID)
//TODO CALLBACK1
if err = CallbackAfterJoinGroup(ctx, req); err != nil {
return nil, err
}
return resp, nil return resp, nil
} }
groupRequest := relationtb.GroupRequestModel{ groupRequest := relationtb.GroupRequestModel{

@ -55,6 +55,7 @@ type CommonCallbackResp struct {
ErrCode int32 `json:"errCode"` ErrCode int32 `json:"errCode"`
ErrMsg string `json:"errMsg"` ErrMsg string `json:"errMsg"`
ErrDlt string `json:"errDlt"` ErrDlt string `json:"errDlt"`
NextCode string `json:"nextCode"`
} }
func (c CommonCallbackResp) Parse() error { func (c CommonCallbackResp) Parse() error {

@ -1,3 +1,8 @@
package callbackstruct package callbackstruct
const CallbackBeforeInviteJoinGroupCommand = "CallbackBeforeInviteJoinGroupCommand" const CallbackBeforeInviteJoinGroupCommand = "CallbackBeforeInviteJoinGroupCommand"
// TODO CALLBACK
const CallbackAfterJoinGroupCommand = "CallbackAfterJoinGroupCommand"
const CallbackAfterSetGroupInfoCommand = "CallbackAfterSetGroupInfoCommand"
const CallbackBeforeSetGroupInfoCommand = "CallbackBeforeSetGroupInfoCommand"

@ -87,7 +87,6 @@ type CallbackBeforeSetGroupMemberInfoResp struct {
RoleLevel *int32 `json:"roleLevel"` RoleLevel *int32 `json:"roleLevel"`
} }
// TODO CALLBACK 2
type CallbackBeforeInviteUserToGroupReq struct { type CallbackBeforeInviteUserToGroupReq struct {
CallbackCommand `json:"callbackCommand"` CallbackCommand `json:"callbackCommand"`
OperationID string `json:"operationID"` OperationID string `json:"operationID"`
@ -100,3 +99,18 @@ type CallbackBeforeInviteUserToGroupResp struct {
CommonCallbackResp CommonCallbackResp
RefusedMembersAccount []string `json:"refusedMembersAccount,omitempty"` // Optional field to list members whose invitation is refused. RefusedMembersAccount []string `json:"refusedMembersAccount,omitempty"` // Optional field to list members whose invitation is refused.
} }
// TODO CALLBACK 2
type CallbackAfterJoinGroupReq struct {
CallbackCommand `json:"callbackCommand"`
OperationID string `json:"operationID"`
GroupID string `json:"groupID"`
ReqMessage string `json:"reqMessage"`
JoinSource int32 `json:"joinSource"`
InviterUserID string `json:"string"`
EventTime int64 `json:"eventTime"`
}
type CallbackAfterJoinGroupResp struct {
CommonCallbackResp
}

@ -265,6 +265,9 @@ type configStruct struct {
CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"beforeSetGroupMemberInfo"` CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"beforeSetGroupMemberInfo"`
//TODO CALLBACK/ //TODO CALLBACK/
CallbackBeforeInviteUserToGroup CallBackConfig `yaml:"beforeInviteUserToGroup"` CallbackBeforeInviteUserToGroup CallBackConfig `yaml:"beforeInviteUserToGroup"`
CallbackAfterJoinGroup CallBackConfig `yaml:"joinGroupAfter"`
CallbackAfterSetGroupInfo CallBackConfig `yaml:"setGroupInfoAfter"`
CallbackBeforeSetGroupInfo CallBackConfig `yaml:"setGroupInfoBefore"`
} `yaml:"callback"` } `yaml:"callback"`
Prometheus struct { Prometheus struct {

Loading…
Cancel
Save