mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 10:52:33 +08:00
update callback after join group
This commit is contained in:
parent
ac8d60e9e7
commit
b5dc1a8709
@ -369,7 +369,6 @@ callback:
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
|
||||
##TODO CALLBACK/
|
||||
beforeInviteUserToGroup:
|
||||
enable: true
|
||||
timeout: 5
|
||||
|
||||
@ -312,7 +312,7 @@ iosPush:
|
||||
# Timeout in seconds
|
||||
# Whether to continue execution if callback fails
|
||||
callback:
|
||||
url: "http://125.124.195.201:8080/sdkName/callbackBeforeInviteJoinGroupCommand"
|
||||
url: "http://125.124.195.201:18889/sdkName/callbackBeforeInviteJoinGroupCommand"
|
||||
beforeSendSingleMsg:
|
||||
enable: false
|
||||
timeout: 5
|
||||
@ -376,11 +376,35 @@ callback:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
##TODO CALLBACK/
|
||||
beforeInviteUserToGroup:
|
||||
afterGroupMsgRead:
|
||||
enable: true
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
afterGroupMsgRevoke:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
afterJoinGroup:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
beforeInviteUserToGroup:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
##TODO CALLBACK
|
||||
joinGroupAfter:
|
||||
enable: true
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
setGroupInfoAfter:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
setGroupInfoBefore:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
###################### Prometheus ######################
|
||||
# Prometheus configuration for various services
|
||||
# The number of Prometheus ports per service needs to correspond to rpcPort
|
||||
|
||||
2
go.mod
2
go.mod
@ -38,7 +38,7 @@ require github.com/google/uuid v1.3.1
|
||||
require (
|
||||
github.com/IBM/sarama v1.41.3
|
||||
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/go-redis/redis v6.15.9+incompatible
|
||||
github.com/go-sql-driver/mysql v1.7.1
|
||||
|
||||
4
go.sum
4
go.sum
@ -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/OpenIMSDK/protocol v0.0.31 h1:ax43x9aqA6EKNXNukS5MT5BSTqkUmwO4uTvbJLtzCgE=
|
||||
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.16/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
||||
github.com/OpenIMSDK/tools v0.0.17 h1:1E1HUOL2W09YUHBb4wBwrXoTSZm5ONVwLxlEX1GhlKw=
|
||||
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/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=
|
||||
|
||||
@ -171,7 +171,6 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO CALLBACK
|
||||
func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserToGroupReq) (err error) {
|
||||
if !config.Config.Callback.CallbackBeforeInviteUserToGroup.Enable {
|
||||
return nil
|
||||
@ -183,7 +182,7 @@ func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserT
|
||||
GroupID: req.GroupID,
|
||||
Reason: req.Reason,
|
||||
InvitedUserIDs: req.InvitedUserIDs,
|
||||
EventTime: time.Now().UnixNano() / int64(time.Millisecond), // Event trigger timestamp in milliseconds
|
||||
EventTime: time.Now().Unix(),
|
||||
}
|
||||
|
||||
resp := &callbackstruct.CallbackBeforeInviteUserToGroupResp{}
|
||||
@ -203,6 +202,32 @@ func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserT
|
||||
// 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
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
// TODO CALLBACK
|
||||
|
||||
@ -387,7 +387,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
||||
}
|
||||
groupMember = groupMembers[0]
|
||||
}
|
||||
//TODO CALLBACK
|
||||
|
||||
if err := CallbackBeforeInviteUserToGroup(ctx, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -807,6 +807,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
||||
case constant.GroupResponseRefuse:
|
||||
s.Notification.GroupApplicationRejectedNotification(ctx, req)
|
||||
}
|
||||
|
||||
return &pbgroup.GroupApplicationResponseResp{}, nil
|
||||
}
|
||||
|
||||
@ -855,6 +856,10 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
||||
return nil, err
|
||||
}
|
||||
s.Notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID)
|
||||
//TODO CALLBACK1
|
||||
if err = CallbackAfterJoinGroup(ctx, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
groupRequest := relationtb.GroupRequestModel{
|
||||
|
||||
@ -55,6 +55,7 @@ type CommonCallbackResp struct {
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
ErrDlt string `json:"errDlt"`
|
||||
NextCode string `json:"nextCode"`
|
||||
}
|
||||
|
||||
func (c CommonCallbackResp) Parse() error {
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
package callbackstruct
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
// TODO CALLBACK 2
|
||||
type CallbackBeforeInviteUserToGroupReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
@ -100,3 +99,18 @@ type CallbackBeforeInviteUserToGroupResp struct {
|
||||
CommonCallbackResp
|
||||
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"`
|
||||
//TODO CALLBACK/
|
||||
CallbackBeforeInviteUserToGroup CallBackConfig `yaml:"beforeInviteUserToGroup"`
|
||||
CallbackAfterJoinGroup CallBackConfig `yaml:"joinGroupAfter"`
|
||||
CallbackAfterSetGroupInfo CallBackConfig `yaml:"setGroupInfoAfter"`
|
||||
CallbackBeforeSetGroupInfo CallBackConfig `yaml:"setGroupInfoBefore"`
|
||||
} `yaml:"callback"`
|
||||
|
||||
Prometheus struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user