|
|
|
@ -20,6 +20,7 @@ import (
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/webhook"
|
|
|
|
|
"github.com/openimsdk/protocol/constant"
|
|
|
|
|
"github.com/openimsdk/protocol/group"
|
|
|
|
|
"github.com/openimsdk/protocol/wrapperspb"
|
|
|
|
@ -31,6 +32,7 @@ import (
|
|
|
|
|
|
|
|
|
|
// CallbackBeforeCreateGroup callback before create group.
|
|
|
|
|
func (s *groupServer) webhookBeforeCreateGroup(ctx context.Context, before *config.BeforeConfig, req *group.CreateGroupReq) error {
|
|
|
|
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
|
|
|
|
cbReq := &callbackstruct.CallbackBeforeCreateGroupReq{
|
|
|
|
|
CallbackCommand: callbackstruct.CallbackBeforeCreateGroupCommand,
|
|
|
|
|
OperationID: mcontext.GetOperationID(ctx),
|
|
|
|
@ -71,6 +73,7 @@ func (s *groupServer) webhookBeforeCreateGroup(ctx context.Context, before *conf
|
|
|
|
|
datautil.NotNilReplace(&req.GroupInfo.NeedVerification, resp.NeedVerification)
|
|
|
|
|
datautil.NotNilReplace(&req.GroupInfo.LookMemberInfo, resp.LookMemberInfo)
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookAfterCreateGroup(ctx context.Context, after *config.AfterConfig, req *group.CreateGroupReq) {
|
|
|
|
@ -98,6 +101,7 @@ func (s *groupServer) webhookAfterCreateGroup(ctx context.Context, after *config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookBeforeMemberJoinGroup(ctx context.Context, before *config.BeforeConfig, groupMember *relation.GroupMemberModel, groupEx string) error {
|
|
|
|
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
|
|
|
|
cbReq := &callbackstruct.CallbackBeforeMemberJoinGroupReq{
|
|
|
|
|
CallbackCommand: callbackstruct.CallbackBeforeMemberJoinGroupCommand,
|
|
|
|
|
GroupID: groupMember.GroupID,
|
|
|
|
@ -118,9 +122,11 @@ func (s *groupServer) webhookBeforeMemberJoinGroup(ctx context.Context, before *
|
|
|
|
|
datautil.NotNilReplace(&groupMember.Nickname, resp.Nickname)
|
|
|
|
|
datautil.NotNilReplace(&groupMember.RoleLevel, resp.RoleLevel)
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookBeforeSetGroupMemberInfo(ctx context.Context, before *config.BeforeConfig, req *group.SetGroupMemberInfo) error {
|
|
|
|
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
|
|
|
|
cbReq := callbackstruct.CallbackBeforeSetGroupMemberInfoReq{
|
|
|
|
|
CallbackCommand: callbackstruct.CallbackBeforeSetGroupMemberInfoCommand,
|
|
|
|
|
GroupID: req.GroupID,
|
|
|
|
@ -155,6 +161,7 @@ func (s *groupServer) webhookBeforeSetGroupMemberInfo(ctx context.Context, befor
|
|
|
|
|
req.Ex = wrapperspb.String(*resp.Ex)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookAfterSetGroupMemberInfo(ctx context.Context, after *config.AfterConfig, req *group.SetGroupMemberInfo) {
|
|
|
|
@ -202,12 +209,14 @@ func (s *groupServer) webhookAfterDismissGroup(ctx context.Context, after *confi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookBeforeApplyJoinGroup(ctx context.Context, before *config.BeforeConfig, req *callbackstruct.CallbackJoinGroupReq) (err error) {
|
|
|
|
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
|
|
|
|
req.CallbackCommand = callbackstruct.CallbackBeforeJoinGroupCommand
|
|
|
|
|
resp := &callbackstruct.CallbackJoinGroupResp{}
|
|
|
|
|
if err := s.webhookClient.SyncPost(ctx, req.GetCallbackCommand(), req, resp, before); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookAfterTransferGroupOwner(ctx context.Context, after *config.AfterConfig, req *group.TransferGroupOwnerReq) {
|
|
|
|
@ -221,6 +230,7 @@ func (s *groupServer) webhookAfterTransferGroupOwner(ctx context.Context, after
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookBeforeInviteUserToGroup(ctx context.Context, before *config.BeforeConfig, req *group.InviteUserToGroupReq) (err error) {
|
|
|
|
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
|
|
|
|
cbReq := &callbackstruct.CallbackBeforeInviteUserToGroupReq{
|
|
|
|
|
CallbackCommand: callbackstruct.CallbackBeforeInviteJoinGroupCommand,
|
|
|
|
|
OperationID: mcontext.GetOperationID(ctx),
|
|
|
|
@ -239,6 +249,7 @@ func (s *groupServer) webhookBeforeInviteUserToGroup(ctx context.Context, before
|
|
|
|
|
// You might want to update the req.Members list or handle it as per your business logic
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookAfterJoinGroup(ctx context.Context, after *config.AfterConfig, req *group.JoinGroupReq) {
|
|
|
|
@ -254,9 +265,7 @@ func (s *groupServer) webhookAfterJoinGroup(ctx context.Context, after *config.A
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookBeforeSetGroupInfo(ctx context.Context, before *config.BeforeConfig, req *group.SetGroupInfoReq) error {
|
|
|
|
|
if !before.Enable {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
|
|
|
|
cbReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{
|
|
|
|
|
CallbackCommand: callbackstruct.CallbackBeforeSetGroupInfoCommand,
|
|
|
|
|
GroupID: req.GroupInfoForSet.GroupID,
|
|
|
|
@ -301,6 +310,7 @@ func (s *groupServer) webhookBeforeSetGroupInfo(ctx context.Context, before *con
|
|
|
|
|
datautil.NotNilReplace(&req.GroupInfoForSet.FaceURL, &resp.FaceURL)
|
|
|
|
|
datautil.NotNilReplace(&req.GroupInfoForSet.Introduction, &resp.Introduction)
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) webhookAfterSetGroupInfo(ctx context.Context, after *config.AfterConfig, req *group.SetGroupInfoReq) {
|
|
|
|
|