|
|
|
@ -17,6 +17,7 @@ package user
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"github.com/openimsdk/tools/db/redisutil"
|
|
|
|
|
"math/rand"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
@ -29,7 +30,6 @@ import (
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/mgo"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
|
|
|
|
tablerelation "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/unrelation"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient/notification"
|
|
|
|
@ -61,11 +61,11 @@ func (s *userServer) GetGroupOnlineUser(ctx context.Context, req *pbuser.GetGrou
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Start(ctx context.Context, config *config.GlobalConfig, client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
|
|
|
|
rdb, err := cache.NewRedis(ctx, &config.Redis)
|
|
|
|
|
mgocli, err := mongoutil.NewMongoDB(ctx, config.Mongo.Build())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
mongo, err := unrelation.NewMongoDB(ctx, &config.Mongo)
|
|
|
|
|
rdb, err := redisutil.NewRedisClient(ctx, config.Redis.Build())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -76,13 +76,13 @@ func Start(ctx context.Context, config *config.GlobalConfig, client registry.Svc
|
|
|
|
|
for k, v := range config.IMAdmin.UserID {
|
|
|
|
|
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.IMAdmin.Nickname[k], AppMangerLevel: constant.AppNotificationAdmin})
|
|
|
|
|
}
|
|
|
|
|
userDB, err := mgo.NewUserMongo(mongo.GetDatabase(config.Mongo.Database))
|
|
|
|
|
userDB, err := mgo.NewUserMongo(mgocli.GetDB())
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
cache := cache.NewUserCacheRedis(rdb, userDB, cache.GetDefaultOpt())
|
|
|
|
|
userMongoDB := mgo.NewUserMongoDriver(mongo.GetDatabase(config.Mongo.Database))
|
|
|
|
|
database := controller.NewUserDatabase(userDB, cache, mongoutil.NewMongo(mongo.GetClient()), userMongoDB)
|
|
|
|
|
userMongoDB := mgo.NewUserMongoDriver(mgocli.GetDB())
|
|
|
|
|
database := controller.NewUserDatabase(userDB, cache, mgocli.GetTx(), userMongoDB)
|
|
|
|
|
friendRpcClient := rpcclient.NewFriendRpcClient(client, config.RpcRegisterName.OpenImFriendName)
|
|
|
|
|
groupRpcClient := rpcclient.NewGroupRpcClient(client, config.RpcRegisterName.OpenImGroupName)
|
|
|
|
|
msgRpcClient := rpcclient.NewMessageRpcClient(client, config.RpcRegisterName.OpenImMsgName)
|
|
|
|
|