mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-07 13:07:09 +08:00
feat:callback test
This commit is contained in:
parent
e40aca81dc
commit
b7b049e4b1
@ -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:
|
url: "http://127.0.0.1:8080/sdkName"
|
||||||
beforeSendSingleMsg:
|
beforeSendSingleMsg:
|
||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
@ -364,6 +364,10 @@ callback:
|
|||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
failedContinue: true
|
failedContinue: true
|
||||||
|
afterCreateGroup:
|
||||||
|
enable: false
|
||||||
|
timeout: 5
|
||||||
|
failedContinue: true
|
||||||
beforeMemberJoinGroup:
|
beforeMemberJoinGroup:
|
||||||
enable: false
|
enable: false
|
||||||
timeout: 5
|
timeout: 5
|
||||||
|
|||||||
@ -86,6 +86,48 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CallbackAfterCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) {
|
||||||
|
if !config.Config.Callback.CallbackBeforeCreateGroup.Enable {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cbReq := &callbackstruct.CallbackBeforeCreateGroupReq{
|
||||||
|
CallbackCommand: "callbackAfterCreateGroupCommand",
|
||||||
|
OperationID: mcontext.GetOperationID(ctx),
|
||||||
|
GroupInfo: req.GroupInfo,
|
||||||
|
}
|
||||||
|
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
||||||
|
UserID: req.OwnerUserID,
|
||||||
|
RoleLevel: constant.GroupOwner,
|
||||||
|
})
|
||||||
|
for _, userID := range req.AdminUserIDs {
|
||||||
|
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
||||||
|
UserID: userID,
|
||||||
|
RoleLevel: constant.GroupAdmin,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for _, userID := range req.MemberUserIDs {
|
||||||
|
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
||||||
|
UserID: userID,
|
||||||
|
RoleLevel: constant.GroupOrdinaryUsers,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
resp := &callbackstruct.CallbackBeforeCreateGroupResp{}
|
||||||
|
err = http.CallBackPostReturn(
|
||||||
|
ctx,
|
||||||
|
config.Config.Callback.CallbackUrl,
|
||||||
|
cbReq,
|
||||||
|
resp,
|
||||||
|
config.Config.Callback.CallbackBeforeCreateGroup,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
if err == errs.ErrCallbackContinue {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func CallbackBeforeMemberJoinGroup(
|
func CallbackBeforeMemberJoinGroup(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
groupMember *relation.GroupMemberModel,
|
groupMember *relation.GroupMemberModel,
|
||||||
|
|||||||
@ -225,6 +225,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
if len(userMap) != len(userIDs) {
|
if len(userMap) != len(userIDs) {
|
||||||
return nil, errs.ErrUserIDNotFound.Wrap("user not found")
|
return nil, errs.ErrUserIDNotFound.Wrap("user not found")
|
||||||
}
|
}
|
||||||
|
// Callback Before create Group
|
||||||
if err := CallbackBeforeCreateGroup(ctx, req); err != nil {
|
if err := CallbackBeforeCreateGroup(ctx, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -298,6 +299,14 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
|||||||
}
|
}
|
||||||
s.Notification.GroupCreatedNotification(ctx, tips)
|
s.Notification.GroupCreatedNotification(ctx, tips)
|
||||||
}
|
}
|
||||||
|
reqCallBackAfter := &pbgroup.CreateGroupReq{
|
||||||
|
GroupInfo: resp.GroupInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := CallbackAfterCreateGroup(ctx, reqCallBackAfter); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,11 @@ type CallbackResp interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonCallbackResp struct {
|
type CommonCallbackResp struct {
|
||||||
ActionCode int `json:"actionCode"`
|
ActionCode int32 `json:"actionCode"`
|
||||||
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 int32 `json:"nextCode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c CommonCallbackResp) Parse() error {
|
func (c CommonCallbackResp) Parse() error {
|
||||||
|
|||||||
@ -25,3 +25,26 @@ type CallbackBeforeAddFriendReq struct {
|
|||||||
type CallbackBeforeAddFriendResp struct {
|
type CallbackBeforeAddFriendResp struct {
|
||||||
CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CallBackAddFriendReplyBeforeReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
FromUserID string `json:"fromUserID" `
|
||||||
|
ToUserID string `json:"toUserID"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallBackAddFriendReplyBeforeResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterAddFriendReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
FromUserID string `json:"fromUserID" `
|
||||||
|
ToUserID string `json:"toUserID"`
|
||||||
|
ReqMsg string `json:"reqMsg"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterAddFriendResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|||||||
@ -86,3 +86,74 @@ type CallbackBeforeSetGroupMemberInfoResp struct {
|
|||||||
FaceURL *string `json:"faceURL"`
|
FaceURL *string `json:"faceURL"`
|
||||||
RoleLevel *int32 `json:"roleLevel"`
|
RoleLevel *int32 `json:"roleLevel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CallbackAfterGroupMemberExitReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
GroupType *int32 `json:"groupType"`
|
||||||
|
ExitType string `json:"exitType"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterGroupMemberExitResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterUngroupReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
GroupType *int32 `json:"groupType"`
|
||||||
|
OwnerID string `json:"ownerID"`
|
||||||
|
MemberList []string `json:"memberList"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterUngroupResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterSetGroupInfoReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
GroupType *int32 `json:"groupType"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Notification string `json:"notification"`
|
||||||
|
GroupUrl string `json:"groupUrl"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterSetGroupInfoResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterRevokeMsgReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
GroupType *int32 `json:"groupType"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackAfterRevokeMsgResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackGroupMsgReadReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
SendID string `json:"sendID"`
|
||||||
|
ReceiveID string `json:"receiveID"`
|
||||||
|
UnreadMsgNum int64 `json:"UnreadMsgNum"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackGroupMsgReadResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|||||||
@ -79,3 +79,37 @@ type CallbackMsgModifyCommandResp struct {
|
|||||||
AttachedInfo *string `json:"attachedInfo"`
|
AttachedInfo *string `json:"attachedInfo"`
|
||||||
Ex *string `json:"ex"`
|
Ex *string `json:"ex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CallbackSendGroupMsgErrorReq struct {
|
||||||
|
CommonCallbackReq
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackSendGroupMsgErrorResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackSingleMsgReadReq struct {
|
||||||
|
CallbackCommand string `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
SendID string `json:"sendID"`
|
||||||
|
ReceiveID string `json:"receiveID"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackSingleMsgReadResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackSingleMsgRevokeReq struct {
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
SendID string `json:"sendID"`
|
||||||
|
ReceiveID string `json:"receiveID"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CallbackSingleMsgRevokeResp struct {
|
||||||
|
CommonCallbackResp
|
||||||
|
}
|
||||||
|
|||||||
@ -257,6 +257,7 @@ type configStruct struct {
|
|||||||
CallbackBeforeAddFriend CallBackConfig `yaml:"beforeAddFriend"`
|
CallbackBeforeAddFriend CallBackConfig `yaml:"beforeAddFriend"`
|
||||||
CallbackBeforeUpdateUserInfo CallBackConfig `yaml:"beforeUpdateUserInfo"`
|
CallbackBeforeUpdateUserInfo CallBackConfig `yaml:"beforeUpdateUserInfo"`
|
||||||
CallbackBeforeCreateGroup CallBackConfig `yaml:"beforeCreateGroup"`
|
CallbackBeforeCreateGroup CallBackConfig `yaml:"beforeCreateGroup"`
|
||||||
|
CallbackAfterCreateGroup CallBackConfig `yaml:"afterCreateGroup"`
|
||||||
CallbackBeforeMemberJoinGroup CallBackConfig `yaml:"beforeMemberJoinGroup"`
|
CallbackBeforeMemberJoinGroup CallBackConfig `yaml:"beforeMemberJoinGroup"`
|
||||||
CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"beforeSetGroupMemberInfo"`
|
CallbackBeforeSetGroupMemberInfo CallBackConfig `yaml:"beforeSetGroupMemberInfo"`
|
||||||
} `yaml:"callback"`
|
} `yaml:"callback"`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user