diff --git a/server/memorystore/providers/redis/store.go b/server/memorystore/providers/redis/store.go index a3d8fec..c22335a 100644 --- a/server/memorystore/providers/redis/store.go +++ b/server/memorystore/providers/redis/store.go @@ -3,9 +3,7 @@ package redis import ( "fmt" "strconv" - "strings" "time" - "errors" "encoding/json" "github.com/authorizerdev/authorizer/server/constants" @@ -232,12 +230,22 @@ type AuthorProfile struct { // GetUserAppDataFromRedis retrieves user profile and follows from Redis, combines them into a JSON format, // and assigns the JSON string to the provided user's ID. func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) { - // Получаем профиль автора из Redis - rkey := fmt.Sprintf("author:user:%s", strings.TrimSpace(userId)) - authorProfileString, err := c.store.Get(c.ctx, rkey).Result() + // Получаем ID автора из Redis + authorIdString, err := c.store.Get(c.ctx, fmt.Sprintf("author:user:%s", userId)).Result() + if err != nil { + return "", err + } + + // Преобразуем ID автора из строки в int + var authorId int + err = json.Unmarshal([]byte(authorIdString), &authorId) + if err != nil { + return "", err + } + + // Получаем профиль автора из Redis + authorProfileString, err := c.store.Get(c.ctx, fmt.Sprintf("author:id:%d", authorId)).Result() if err != nil { - fmt.Println("redis GET:", rkey) - fmt.Println(authorProfileString) return "", err } @@ -247,13 +255,6 @@ func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) { if err != nil { return "", err } - - authorIdFloat, ok := authorProfileMap["id"].(float64) - if !ok { - return "", errors.New("id not found or is of incorrect type") - } - authorId := int(authorIdFloat) - fmt.Println("author id:", authorId) // Начинаем сбор данных в общий JSON combinedData := map[string]interface{}{