mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 19:32:17 +08:00 
			
		
		
		
	Merge branch 'openimsdk:main' into fix/ws-heartbest
This commit is contained in:
		
						commit
						afd3421773
					
				@ -1,7 +1,7 @@
 | 
				
			|||||||
# Log storage path, default is acceptable, change to a full path if modification is needed
 | 
					# Log storage path, default is acceptable, change to a full path if modification is needed
 | 
				
			||||||
storageLocation: ../../../../logs/
 | 
					storageLocation: ../../../../logs/
 | 
				
			||||||
# Log rotation period (in hours), default is acceptable
 | 
					# Log rotation period (in hours), default is acceptable
 | 
				
			||||||
rotationTime: 1
 | 
					rotationTime: 24
 | 
				
			||||||
# Maximum size of each log file (in MB), default is acceptable, it means unlimited
 | 
					# Maximum size of each log file (in MB), default is acceptable, it means unlimited
 | 
				
			||||||
maxSize: 0
 | 
					maxSize: 0
 | 
				
			||||||
# Number of log files to retain, default is acceptable, it means whenever the log file is rotated, the old log file will be deleted
 | 
					# Number of log files to retain, default is acceptable, it means whenever the log file is rotated, the old log file will be deleted
 | 
				
			||||||
 | 
				
			|||||||
@ -55,7 +55,6 @@ func (a *authDatabase) SetTokenMapByUidPid(ctx context.Context, userID string, p
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Create Token.
 | 
					// Create Token.
 | 
				
			||||||
func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformID int) (string, error) {
 | 
					func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformID int) (string, error) {
 | 
				
			||||||
	isCreate := true // flag is create or update
 | 
					 | 
				
			||||||
	tokens, err := a.cache.GetTokensWithoutError(ctx, userID, platformID)
 | 
						tokens, err := a.cache.GetTokensWithoutError(ctx, userID, platformID)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return "", err
 | 
							return "", err
 | 
				
			||||||
@ -66,9 +65,6 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
 | 
				
			|||||||
		if err != nil || v != constant.NormalToken {
 | 
							if err != nil || v != constant.NormalToken {
 | 
				
			||||||
			deleteTokenKey = append(deleteTokenKey, k)
 | 
								deleteTokenKey = append(deleteTokenKey, k)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if v == constant.NormalToken {
 | 
					 | 
				
			||||||
			isCreate = false
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(deleteTokenKey) != 0 {
 | 
						if len(deleteTokenKey) != 0 {
 | 
				
			||||||
		err = a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey)
 | 
							err = a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey)
 | 
				
			||||||
@ -84,16 +80,8 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
 | 
				
			|||||||
		return "", errs.WrapMsg(err, "token.SignedString")
 | 
							return "", errs.WrapMsg(err, "token.SignedString")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if isCreate {
 | 
						if err = a.cache.SetTokenFlagEx(ctx, userID, platformID, tokenString, constant.NormalToken); err != nil {
 | 
				
			||||||
		// should create,should specify expiration time
 | 
							return "", err
 | 
				
			||||||
		if err = a.cache.SetTokenFlagEx(ctx, userID, platformID, tokenString, constant.NormalToken); err != nil {
 | 
					 | 
				
			||||||
			return "", err
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		// should update
 | 
					 | 
				
			||||||
		if err = a.cache.SetTokenFlag(ctx, userID, platformID, tokenString, constant.NormalToken); err != nil {
 | 
					 | 
				
			||||||
			return "", err
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return tokenString, nil
 | 
						return tokenString, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user