mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-06 05:12:10 +08:00
refactor: remove msggateway redis.
This commit is contained in:
parent
a921efe62d
commit
8e09f3ca04
@ -16,10 +16,7 @@ package msggateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/openimsdk/tools/db/redisutil"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/startrpc"
|
||||
"github.com/openimsdk/protocol/constant"
|
||||
@ -32,14 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func (s *Server) InitServer(ctx context.Context, config *Config, disCov discovery.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
rdb, err := redisutil.NewRedisClient(ctx, config.RedisConfig.Build())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tokenCacheModel := cache.NewTokenCacheModel(rdb)
|
||||
s.LongConnServer.SetDiscoveryRegistry(disCov, config)
|
||||
s.LongConnServer.SetCacheHandler(tokenCacheModel)
|
||||
msggateway.RegisterMsgGatewayServer(server, s)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -25,7 +25,6 @@ import (
|
||||
|
||||
type Config struct {
|
||||
MsgGateway config.MsgGateway
|
||||
RedisConfig config.Redis
|
||||
ZookeeperConfig config.ZooKeeper
|
||||
Share config.Share
|
||||
WebhooksConfig config.Webhooks
|
||||
|
||||
@ -25,7 +25,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/cache"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
||||
@ -44,7 +43,6 @@ type LongConnServer interface {
|
||||
GetUserAllCons(userID string) ([]*Client, bool)
|
||||
GetUserPlatformCons(userID string, platform int) ([]*Client, bool, bool)
|
||||
Validate(s any) error
|
||||
SetCacheHandler(cache cache.TokenModel)
|
||||
SetDiscoveryRegistry(client discovery.SvcDiscoveryRegistry, config *Config)
|
||||
KickUserConn(client *Client) error
|
||||
UnRegister(c *Client)
|
||||
@ -68,7 +66,6 @@ type WsServer struct {
|
||||
handshakeTimeout time.Duration
|
||||
writeBufferSize int
|
||||
validate *validator.Validate
|
||||
cache cache.TokenModel
|
||||
userClient *rpcclient.UserRpcClient
|
||||
authClient *rpcclient.Auth
|
||||
disCov discovery.SvcDiscoveryRegistry
|
||||
@ -110,10 +107,6 @@ func (ws *WsServer) SetUserOnlineStatus(ctx context.Context, client *Client, sta
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *WsServer) SetCacheHandler(cache cache.TokenModel) {
|
||||
ws.cache = cache
|
||||
}
|
||||
|
||||
func (ws *WsServer) UnRegister(c *Client) {
|
||||
ws.unregisterChan <- c
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import (
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
|
||||
"github.com/openimsdk/tools/mcontext"
|
||||
"github.com/openimsdk/tools/tokenverify"
|
||||
"github.com/openimsdk/tools/utils/datautil"
|
||||
)
|
||||
|
||||
@ -57,17 +56,3 @@ func CheckAdmin(ctx context.Context, imAdminUserID []string) error {
|
||||
func IsManagerUserID(opUserID string, imAdminUserID []string) bool {
|
||||
return datautil.Contain(opUserID, imAdminUserID...)
|
||||
}
|
||||
|
||||
func WsVerifyToken(token, userID, secret string, platformID int) error {
|
||||
claim, err := tokenverify.GetClaimFromToken(token, Secret(secret))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if claim.UserID != userID {
|
||||
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", claim.UserID, userID))
|
||||
}
|
||||
if claim.PlatformID != platformID {
|
||||
return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token platform %d != %d", claim.PlatformID, platformID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ func NewMsgGatewayCmd() *MsgGatewayCmd {
|
||||
ret := &MsgGatewayCmd{msgGatewayConfig: msgGatewayConfig}
|
||||
ret.configMap = map[string]any{
|
||||
OpenIMMsgGatewayCfgFileName: &msgGatewayConfig.MsgGateway,
|
||||
RedisConfigFileName: &msgGatewayConfig.RedisConfig,
|
||||
ZookeeperConfigFileName: &msgGatewayConfig.ZookeeperConfig,
|
||||
ShareFileName: &msgGatewayConfig.Share,
|
||||
WebhooksConfigFileName: &msgGatewayConfig.WebhooksConfig,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user