mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 20:30:40 +08:00
callback start
This commit is contained in:
parent
e83a070e81
commit
e147dc5b1b
@ -7,5 +7,5 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
startrpc.Start(config.Config.RpcPort.OpenImGroupPort[0], config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort[0], group.Start)
|
startrpc.Start(config.Config.RpcPort.OpenImGroupPort, config.Config.RpcRegisterName.OpenImGroupName, config.Config.Prometheus.GroupPrometheusPort, group.Start)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) {
|
func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (err error) {
|
||||||
@ -21,72 +22,44 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (
|
|||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req)
|
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", req)
|
||||||
}()
|
}()
|
||||||
operationID := tracelog.GetOperationID(ctx)
|
cbReq := &callbackstruct.CallbackBeforeCreateGroupReq{
|
||||||
commonCallbackReq := &callbackstruct.CallbackBeforeCreateGroupReq{
|
|
||||||
CallbackCommand: constant.CallbackBeforeCreateGroupCommand,
|
CallbackCommand: constant.CallbackBeforeCreateGroupCommand,
|
||||||
OperationID: operationID,
|
OperationID: tracelog.GetOperationID(ctx),
|
||||||
GroupInfo: *req.GroupInfo,
|
GroupInfo: *req.GroupInfo,
|
||||||
}
|
}
|
||||||
commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
||||||
UserID: req.OwnerUserID,
|
UserID: req.OwnerUserID,
|
||||||
RoleLevel: constant.GroupOwner,
|
RoleLevel: constant.GroupOwner,
|
||||||
})
|
})
|
||||||
for _, userID := range req.AdminUserIDs {
|
for _, userID := range req.AdminUserIDs {
|
||||||
commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
RoleLevel: constant.GroupAdmin,
|
RoleLevel: constant.GroupAdmin,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for _, userID := range req.AdminUserIDs {
|
for _, userID := range req.AdminUserIDs {
|
||||||
commonCallbackReq.InitMemberList = append(commonCallbackReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
RoleLevel: constant.GroupOrdinaryUsers,
|
RoleLevel: constant.GroupOrdinaryUsers,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
resp := &callbackstruct.CallbackBeforeCreateGroupResp{
|
resp := &callbackstruct.CallbackBeforeCreateGroupResp{}
|
||||||
CommonCallbackResp: &callbackstruct.CommonCallbackResp{OperationID: operationID},
|
err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeCreateGroup)
|
||||||
}
|
|
||||||
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeCreateGroup)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
utils.NotNilReplace(&req.GroupInfo.GroupID, resp.GroupID)
|
||||||
if resp.GroupID != nil {
|
utils.NotNilReplace(&req.GroupInfo.GroupName, resp.GroupName)
|
||||||
req.GroupInfo.GroupID = *resp.GroupID
|
utils.NotNilReplace(&req.GroupInfo.Notification, resp.Notification)
|
||||||
}
|
utils.NotNilReplace(&req.GroupInfo.Introduction, resp.Introduction)
|
||||||
if resp.GroupName != nil {
|
utils.NotNilReplace(&req.GroupInfo.FaceURL, resp.FaceURL)
|
||||||
req.GroupInfo.GroupName = *resp.GroupName
|
utils.NotNilReplace(&req.GroupInfo.OwnerUserID, resp.OwnerUserID)
|
||||||
}
|
utils.NotNilReplace(&req.GroupInfo.Ex, resp.Ex)
|
||||||
if resp.Notification != nil {
|
utils.NotNilReplace(&req.GroupInfo.Status, resp.Status)
|
||||||
req.GroupInfo.Notification = *resp.Notification
|
utils.NotNilReplace(&req.GroupInfo.CreatorUserID, resp.CreatorUserID)
|
||||||
}
|
utils.NotNilReplace(&req.GroupInfo.GroupType, resp.GroupType)
|
||||||
if resp.Introduction != nil {
|
utils.NotNilReplace(&req.GroupInfo.NeedVerification, resp.NeedVerification)
|
||||||
req.GroupInfo.Introduction = *resp.Introduction
|
utils.NotNilReplace(&req.GroupInfo.LookMemberInfo, resp.LookMemberInfo)
|
||||||
}
|
|
||||||
if resp.FaceURL != nil {
|
|
||||||
req.GroupInfo.FaceURL = *resp.FaceURL
|
|
||||||
}
|
|
||||||
if resp.OwnerUserID != nil {
|
|
||||||
req.GroupInfo.OwnerUserID = *resp.OwnerUserID
|
|
||||||
}
|
|
||||||
if resp.Ex != nil {
|
|
||||||
req.GroupInfo.Ex = *resp.Ex
|
|
||||||
}
|
|
||||||
if resp.Status != nil {
|
|
||||||
req.GroupInfo.Status = *resp.Status
|
|
||||||
}
|
|
||||||
if resp.CreatorUserID != nil {
|
|
||||||
req.GroupInfo.CreatorUserID = *resp.CreatorUserID
|
|
||||||
}
|
|
||||||
if resp.GroupType != nil {
|
|
||||||
req.GroupInfo.GroupType = *resp.GroupType
|
|
||||||
}
|
|
||||||
if resp.NeedVerification != nil {
|
|
||||||
req.GroupInfo.NeedVerification = *resp.NeedVerification
|
|
||||||
}
|
|
||||||
if resp.LookMemberInfo != nil {
|
|
||||||
req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,39 +70,26 @@ func CallbackBeforeMemberJoinGroup(ctx context.Context, groupMember *relation.Gr
|
|||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx)
|
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx)
|
||||||
}()
|
}()
|
||||||
operationID := tracelog.GetOperationID(ctx)
|
callbackReq := &callbackstruct.CallbackBeforeMemberJoinGroupReq{
|
||||||
callbackResp := callbackstruct.CommonCallbackResp{OperationID: operationID}
|
|
||||||
callbackReq := callbackstruct.CallbackBeforeMemberJoinGroupReq{
|
|
||||||
CallbackCommand: constant.CallbackBeforeMemberJoinGroupCommand,
|
CallbackCommand: constant.CallbackBeforeMemberJoinGroupCommand,
|
||||||
OperationID: operationID,
|
OperationID: tracelog.GetOperationID(ctx),
|
||||||
GroupID: groupMember.GroupID,
|
GroupID: groupMember.GroupID,
|
||||||
UserID: groupMember.UserID,
|
UserID: groupMember.UserID,
|
||||||
Ex: groupMember.Ex,
|
Ex: groupMember.Ex,
|
||||||
GroupEx: groupEx,
|
GroupEx: groupEx,
|
||||||
}
|
}
|
||||||
resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{
|
resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{}
|
||||||
CommonCallbackResp: &callbackResp,
|
err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeMemberJoinGroup)
|
||||||
}
|
|
||||||
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeMemberJoinGroupCommand, callbackReq,
|
|
||||||
resp, config.Config.Callback.CallbackBeforeMemberJoinGroup)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resp.MuteEndTime != nil {
|
if resp.MuteEndTime != nil {
|
||||||
groupMember.MuteEndTime = utils.UnixSecondToTime(*resp.MuteEndTime)
|
groupMember.MuteEndTime = time.UnixMilli(*resp.MuteEndTime)
|
||||||
}
|
|
||||||
if resp.FaceURL != nil {
|
|
||||||
groupMember.FaceURL = *resp.FaceURL
|
|
||||||
}
|
|
||||||
if resp.Ex != nil {
|
|
||||||
groupMember.Ex = *resp.Ex
|
|
||||||
}
|
|
||||||
if resp.NickName != nil {
|
|
||||||
groupMember.Nickname = *resp.NickName
|
|
||||||
}
|
|
||||||
if resp.RoleLevel != nil {
|
|
||||||
groupMember.RoleLevel = *resp.RoleLevel
|
|
||||||
}
|
}
|
||||||
|
utils.NotNilReplace(&groupMember.FaceURL, resp.FaceURL)
|
||||||
|
utils.NotNilReplace(&groupMember.Ex, resp.Ex)
|
||||||
|
utils.NotNilReplace(&groupMember.Nickname, resp.Nickname)
|
||||||
|
utils.NotNilReplace(&groupMember.RoleLevel, resp.RoleLevel)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,44 +100,40 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe
|
|||||||
defer func() {
|
defer func() {
|
||||||
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req)
|
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "req", *req)
|
||||||
}()
|
}()
|
||||||
operationID := tracelog.GetOperationID(ctx)
|
|
||||||
callbackResp := callbackstruct.CommonCallbackResp{OperationID: operationID}
|
|
||||||
callbackReq := callbackstruct.CallbackBeforeSetGroupMemberInfoReq{
|
callbackReq := callbackstruct.CallbackBeforeSetGroupMemberInfoReq{
|
||||||
CallbackCommand: constant.CallbackBeforeSetGroupMemberInfoCommand,
|
CallbackCommand: constant.CallbackBeforeSetGroupMemberInfoCommand,
|
||||||
OperationID: operationID,
|
OperationID: tracelog.GetOperationID(ctx),
|
||||||
GroupID: req.GroupID,
|
GroupID: req.GroupID,
|
||||||
UserID: req.UserID,
|
UserID: req.UserID,
|
||||||
}
|
}
|
||||||
if req.Nickname != nil {
|
if req.Nickname != nil {
|
||||||
callbackReq.Nickname = req.Nickname.Value
|
callbackReq.Nickname = &req.Nickname.Value
|
||||||
}
|
}
|
||||||
if req.FaceURL != nil {
|
if req.FaceURL != nil {
|
||||||
callbackReq.FaceURL = req.FaceURL.Value
|
callbackReq.FaceURL = &req.FaceURL.Value
|
||||||
}
|
}
|
||||||
if req.RoleLevel != nil {
|
if req.RoleLevel != nil {
|
||||||
callbackReq.RoleLevel = req.RoleLevel.Value
|
callbackReq.RoleLevel = &req.RoleLevel.Value
|
||||||
}
|
}
|
||||||
if req.Ex != nil {
|
if req.Ex != nil {
|
||||||
callbackReq.Ex = req.Ex.Value
|
callbackReq.Ex = &req.Ex.Value
|
||||||
}
|
}
|
||||||
resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{
|
resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{}
|
||||||
CommonCallbackResp: &callbackResp,
|
err = http.CallBackPostReturnV2(config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo)
|
||||||
}
|
|
||||||
err = http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSetGroupMemberInfoCommand, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupMemberInfo)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if resp.FaceURL != nil {
|
if resp.FaceURL != nil {
|
||||||
req.FaceURL = &wrapperspb.StringValue{Value: *resp.FaceURL}
|
req.FaceURL = wrapperspb.String(*resp.FaceURL)
|
||||||
}
|
}
|
||||||
if resp.Nickname != nil {
|
if resp.Nickname != nil {
|
||||||
req.Nickname = &wrapperspb.StringValue{Value: *resp.Nickname}
|
req.Nickname = wrapperspb.String(*resp.Nickname)
|
||||||
}
|
}
|
||||||
if resp.RoleLevel != nil {
|
if resp.RoleLevel != nil {
|
||||||
req.RoleLevel = &wrapperspb.Int32Value{Value: *resp.RoleLevel}
|
req.RoleLevel = wrapperspb.Int32(*resp.RoleLevel)
|
||||||
}
|
}
|
||||||
if resp.Ex != nil {
|
if resp.Ex != nil {
|
||||||
req.Ex = &wrapperspb.StringValue{Value: *resp.Ex}
|
req.Ex = wrapperspb.String(*resp.Ex)
|
||||||
}
|
}
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
||||||
mysql, err := relation.NewGormDB()
|
db, err := relation.NewGormDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := mysql.AutoMigrate(&relationTb.GroupModel{}, &relationTb.GroupMemberModel{}, &relationTb.GroupRequestModel{}); err != nil {
|
if err := db.AutoMigrate(&relationTb.GroupModel{}, &relationTb.GroupMemberModel{}, &relationTb.GroupRequestModel{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
redis, err := cache.NewRedis()
|
redis, err := cache.NewRedis()
|
||||||
@ -44,7 +44,7 @@ func Start(client *openKeeper.ZkClient, server *grpc.Server) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pbGroup.RegisterGroupServer(server, &groupServer{
|
pbGroup.RegisterGroupServer(server, &groupServer{
|
||||||
GroupInterface: controller.NewGroupInterface(mysql, redis.GetClient(), mongo.GetClient()),
|
GroupInterface: controller.NewGroupInterface(controller.NewGroupDatabase(db, redis.GetClient(), mongo.GetClient())),
|
||||||
UserCheck: check.NewUserCheck(client),
|
UserCheck: check.NewUserCheck(client),
|
||||||
ConversationChecker: check.NewConversationChecker(client),
|
ConversationChecker: check.NewConversationChecker(client),
|
||||||
})
|
})
|
||||||
|
@ -15,15 +15,13 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error {
|
func start(rpcPorts []int, rpcRegisterName string, prometheusPorts []int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options []grpc.ServerOption) error {
|
||||||
flagRpcPort := flag.Int("port", rpcPort, "get RpcGroupPort from cmd,default 16000 as port")
|
flagRpcPort := flag.Int("port", rpcPorts[0], "get RpcGroupPort from cmd,default 16000 as port")
|
||||||
flagPrometheusPort := flag.Int("prometheus_port", prometheusPort, "groupPrometheusPort default listen port")
|
flagPrometheusPort := flag.Int("prometheus_port", prometheusPorts[0], "groupPrometheusPort default listen port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
rpcPort = *flagRpcPort
|
fmt.Println("start group rpc server, port: ", *flagRpcPort, ", OpenIM version: ", constant.CurrentVersion)
|
||||||
prometheusPort = *flagPrometheusPort
|
|
||||||
fmt.Println("start group rpc server, port: ", rpcPort, ", OpenIM version: ", constant.CurrentVersion)
|
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, rpcPort))
|
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, *flagRpcPort))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -50,12 +48,12 @@ func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
|
|||||||
}
|
}
|
||||||
srv := grpc.NewServer(options...)
|
srv := grpc.NewServer(options...)
|
||||||
defer srv.GracefulStop()
|
defer srv.GracefulStop()
|
||||||
err = zkClient.Register(rpcRegisterName, registerIP, rpcPort)
|
err = zkClient.Register(rpcRegisterName, registerIP, *flagRpcPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if config.Config.Prometheus.Enable {
|
if config.Config.Prometheus.Enable {
|
||||||
err := promePkg.StartPromeSrv(prometheusPort)
|
err := promePkg.StartPromeSrv(*flagPrometheusPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -63,7 +61,7 @@ func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
|
|||||||
return rpcFn(zkClient, srv)
|
return rpcFn(zkClient, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options ...grpc.ServerOption) {
|
func Start(rpcPorts []int, rpcRegisterName string, prometheusPorts []int, rpcFn func(client *openKeeper.ZkClient, server *grpc.Server) error, options ...grpc.ServerOption) {
|
||||||
err := start(rpcPort, rpcRegisterName, prometheusPort, rpcFn, options)
|
err := start(rpcPorts, rpcRegisterName, prometheusPorts, rpcFn, options)
|
||||||
fmt.Println("end", err)
|
fmt.Println("end", err)
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,9 @@ type CommonCallbackResp struct {
|
|||||||
ActionCode int `json:"actionCode"`
|
ActionCode int `json:"actionCode"`
|
||||||
ErrCode int32 `json:"errCode"`
|
ErrCode int32 `json:"errCode"`
|
||||||
ErrMsg string `json:"errMsg"`
|
ErrMsg string `json:"errMsg"`
|
||||||
//OperationID string `json:"operationID"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommonCallbackResp) Parse() error {
|
func (c CommonCallbackResp) Parse() error {
|
||||||
if c == nil {
|
|
||||||
return constant.ErrData.Wrap("callback common is nil")
|
|
||||||
}
|
|
||||||
if c.ActionCode != constant.NoError || c.ErrCode != constant.NoError {
|
if c.ActionCode != constant.NoError || c.ErrCode != constant.NoError {
|
||||||
newErr := constant.ErrCallback
|
newErr := constant.ErrCallback
|
||||||
newErr.ErrCode = c.ErrCode
|
newErr.ErrCode = c.ErrCode
|
||||||
|
@ -9,5 +9,5 @@ type CallbackBeforeAddFriendReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeAddFriendResp struct {
|
type CallbackBeforeAddFriendResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,21 @@ import (
|
|||||||
common "Open_IM/pkg/proto/sdkws"
|
common "Open_IM/pkg/proto/sdkws"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CallbackCommand string
|
||||||
|
|
||||||
|
func (c CallbackCommand) GetCallbackCommand() string {
|
||||||
|
return string(c)
|
||||||
|
}
|
||||||
|
|
||||||
type CallbackBeforeCreateGroupReq struct {
|
type CallbackBeforeCreateGroupReq struct {
|
||||||
CallbackCommand string `json:"callbackCommand"`
|
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
||||||
|
CallbackCommand `json:"callbackCommand"`
|
||||||
common.GroupInfo
|
common.GroupInfo
|
||||||
InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"`
|
InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeCreateGroupResp struct {
|
type CallbackBeforeCreateGroupResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
GroupID *string `json:"groupID"`
|
GroupID *string `json:"groupID"`
|
||||||
GroupName *string `json:"groupName"`
|
GroupName *string `json:"groupName"`
|
||||||
Notification *string `json:"notification"`
|
Notification *string `json:"notification"`
|
||||||
@ -30,7 +36,7 @@ type CallbackBeforeCreateGroupResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeMemberJoinGroupReq struct {
|
type CallbackBeforeMemberJoinGroupReq struct {
|
||||||
CallbackCommand string `json:"callbackCommand"`
|
CallbackCommand `json:"callbackCommand"`
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
@ -39,8 +45,8 @@ type CallbackBeforeMemberJoinGroupReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeMemberJoinGroupResp struct {
|
type CallbackBeforeMemberJoinGroupResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
NickName *string `json:"nickName"`
|
Nickname *string `json:"nickname"`
|
||||||
FaceURL *string `json:"faceURL"`
|
FaceURL *string `json:"faceURL"`
|
||||||
RoleLevel *int32 `json:"roleLevel"`
|
RoleLevel *int32 `json:"roleLevel"`
|
||||||
MuteEndTime *int64 `json:"muteEndTime"`
|
MuteEndTime *int64 `json:"muteEndTime"`
|
||||||
@ -48,18 +54,18 @@ type CallbackBeforeMemberJoinGroupResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSetGroupMemberInfoReq struct {
|
type CallbackBeforeSetGroupMemberInfoReq struct {
|
||||||
CallbackCommand string `json:"callbackCommand"`
|
CallbackCommand `json:"callbackCommand"`
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
Nickname string `json:"nickName"`
|
Nickname *string `json:"nickName"`
|
||||||
FaceURL string `json:"faceURL"`
|
FaceURL *string `json:"faceURL"`
|
||||||
RoleLevel int32 `json:"roleLevel"`
|
RoleLevel *int32 `json:"roleLevel"`
|
||||||
Ex string `json:"ex"`
|
Ex *string `json:"ex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSetGroupMemberInfoResp struct {
|
type CallbackBeforeSetGroupMemberInfoResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
Ex *string `json:"ex"`
|
Ex *string `json:"ex"`
|
||||||
Nickname *string `json:"nickName"`
|
Nickname *string `json:"nickName"`
|
||||||
FaceURL *string `json:"faceURL"`
|
FaceURL *string `json:"faceURL"`
|
||||||
|
@ -11,7 +11,7 @@ type CallbackBeforeSendSingleMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSendSingleMsgResp struct {
|
type CallbackBeforeSendSingleMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendSingleMsgReq struct {
|
type CallbackAfterSendSingleMsgReq struct {
|
||||||
@ -20,7 +20,7 @@ type CallbackAfterSendSingleMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendSingleMsgResp struct {
|
type CallbackAfterSendSingleMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSendGroupMsgReq struct {
|
type CallbackBeforeSendGroupMsgReq struct {
|
||||||
@ -29,7 +29,7 @@ type CallbackBeforeSendGroupMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSendGroupMsgResp struct {
|
type CallbackBeforeSendGroupMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendGroupMsgReq struct {
|
type CallbackAfterSendGroupMsgReq struct {
|
||||||
@ -38,7 +38,7 @@ type CallbackAfterSendGroupMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendGroupMsgResp struct {
|
type CallbackAfterSendGroupMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackMsgModifyCommandReq struct {
|
type CallbackMsgModifyCommandReq struct {
|
||||||
@ -46,7 +46,7 @@ type CallbackMsgModifyCommandReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackMsgModifyCommandResp struct {
|
type CallbackMsgModifyCommandResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
Content *string `json:"content"`
|
Content *string `json:"content"`
|
||||||
RecvID *string `json:"recvID"`
|
RecvID *string `json:"recvID"`
|
||||||
GroupID *string `json:"groupID"`
|
GroupID *string `json:"groupID"`
|
||||||
@ -79,7 +79,7 @@ type CallbackBeforeSetMessageReactionExtReq struct {
|
|||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
}
|
}
|
||||||
type CallbackBeforeSetMessageReactionExtResp struct {
|
type CallbackBeforeSetMessageReactionExtResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ type CallbackDeleteMessageReactionExtReq struct {
|
|||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
}
|
}
|
||||||
type CallbackDeleteMessageReactionExtResp struct {
|
type CallbackDeleteMessageReactionExtResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ type CallbackUserOnlineReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackUserOnlineResp struct {
|
type CallbackUserOnlineResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackUserOfflineReq struct {
|
type CallbackUserOfflineReq struct {
|
||||||
@ -19,7 +19,7 @@ type CallbackUserOfflineReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackUserOfflineResp struct {
|
type CallbackUserOfflineResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackUserKickOffReq struct {
|
type CallbackUserKickOffReq struct {
|
||||||
@ -28,5 +28,5 @@ type CallbackUserKickOffReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackUserKickOffResp struct {
|
type CallbackUserKickOffResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ type CallbackBeforePushReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforePushResp struct {
|
type CallbackBeforePushResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
UserIDList []string `json:"userIDList"`
|
UserIDList []string `json:"userIDList"`
|
||||||
OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"`
|
OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"`
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ type CallbackBeforeSuperGroupOnlinePushReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSuperGroupOnlinePushResp struct {
|
type CallbackBeforeSuperGroupOnlinePushResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
UserIDList []string `json:"userIDList"`
|
UserIDList []string `json:"userIDList"`
|
||||||
OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"`
|
OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"`
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ type GroupInterface interface {
|
|||||||
|
|
||||||
var _ GroupInterface = (*GroupController)(nil)
|
var _ GroupInterface = (*GroupController)(nil)
|
||||||
|
|
||||||
func NewGroupInterface(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupInterface {
|
func NewGroupInterface(database GroupDataBaseInterface) GroupInterface {
|
||||||
return &GroupController{database: NewGroupDatabase(db, rdb, mgoClient)}
|
return &GroupController{database: database}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupController struct {
|
type GroupController struct {
|
||||||
@ -72,7 +72,7 @@ func (g *GroupController) CreateGroup(ctx context.Context, groups []*relationTb.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||||
return g.TakeGroup(ctx, groupID)
|
return g.database.TakeGroup(ctx, groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||||
@ -175,6 +175,53 @@ func (g *GroupController) CreateSuperGroupMember(ctx context.Context, groupID st
|
|||||||
return g.database.CreateSuperGroupMember(ctx, groupID, userIDs)
|
return g.database.CreateSuperGroupMember(ctx, groupID, userIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Group interface {
|
||||||
|
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||||
|
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||||
|
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||||
|
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error)
|
||||||
|
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||||
|
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupMember interface {
|
||||||
|
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error)
|
||||||
|
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||||
|
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error)
|
||||||
|
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||||
|
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||||
|
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||||
|
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error
|
||||||
|
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||||
|
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||||
|
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||||
|
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||||
|
UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupRequest interface {
|
||||||
|
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||||
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||||
|
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SuperGroup interface {
|
||||||
|
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationTb.SuperGroupModel, error)
|
||||||
|
FindJoinSuperGroup(ctx context.Context, userID string) (*unrelationTb.UserToSuperGroupModel, error)
|
||||||
|
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||||
|
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||||
|
DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
|
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupDataBase1 interface {
|
||||||
|
Group
|
||||||
|
GroupMember
|
||||||
|
GroupRequest
|
||||||
|
SuperGroup
|
||||||
|
}
|
||||||
|
|
||||||
type GroupDataBaseInterface interface {
|
type GroupDataBaseInterface interface {
|
||||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||||
@ -291,7 +338,10 @@ func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.Gr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||||
return g.cache.GetGroupInfo(ctx, groupID)
|
//return g.cache.GetGroupInfo(ctx, groupID)
|
||||||
|
return cache.GetCache(ctx, g.rcClient, g.getGroupInfoKey(groupID), g.expireTime, func(ctx context.Context) (*relationTb.GroupModel, error) {
|
||||||
|
return g.group.Take(ctx, groupID)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user