From 132f965c8b7e3fad72f7e51d546bd4f7fe6c9f08 Mon Sep 17 00:00:00 2001 From: Untone Date: Sat, 2 Mar 2024 14:35:40 +0300 Subject: [PATCH] type-fix-5 --- server/memorystore/providers/redis/store.go | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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 }