diff --git a/server/memorystore/providers/redis/store.go b/server/memorystore/providers/redis/store.go index b8b6220..db2c72c 100644 --- a/server/memorystore/providers/redis/store.go +++ b/server/memorystore/providers/redis/store.go @@ -246,10 +246,26 @@ func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) { authorFollowers := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:followers`, authorId)) // Combine user data into a JSON string - combinedData := fmt.Sprintf(`{"profile": %s, "authors": %s, "topics": %s, "followers": %s}`, - authorProfileString, authorFollowsAuthorsString, authorFollowsTopicsString, authorFollowers) + combinedData := "{" - log.Printf("%v", combinedData) + if authorProfileString != nil { + combinedData += fmt.Sprintf(`"profile": %s`, authorProfileString) + } + + if authorFollowsAuthorsString != nil { + combinedData += fmt.Sprintf(`,"authors": %s`, authorFollowsAuthorsString) + } + + if authorFollowsTopicsString != nil { + combinedData += fmt.Sprintf(`,"topics": %s`, authorFollowsTopicsString) + } + + if authorFollowers != nil { + combinedData += fmt.Sprintf(`,"followers": %s`, authorFollowers) + } + + combinedData += "}" + // log.Printf("%v", combinedData) return combinedData, nil }