type-fix-6

This commit is contained in:
Untone 2024-03-02 14:40:40 +03:00
parent 132f965c8b
commit f244330401

View File

@ -238,29 +238,27 @@ func (c *provider) GetUserAppDataFromRedis(userId string) (string, error) {
if err != nil {
return "", err
}
// Use authorProfileMap["id"] here if necessary
authorId := int(authorProfileMap["id"].(float64)) // convert float64 to int
authorFollowsAuthorsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-authors`, authorId))
authorFollowsTopicsString := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-topics`, authorId))
authorFollowers := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:followers`, authorId))
// Combine user data into a JSON string
combinedData := "{"
if authorProfileString != nil {
// Use authorProfileMap["id"] here if necessary
authorId, err := int(authorProfileMap["id"].(float64)) // convert float64 to int
if err != nil {
combinedData += fmt.Sprintf(`"profile": %s`, authorProfileString)
}
if authorFollowsAuthorsString != nil {
authorFollowsAuthorsString, err := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-authors`, authorId))
if err != nil {
combinedData += fmt.Sprintf(`,"authors": %s`, authorFollowsAuthorsString)
}
if authorFollowsTopicsString != nil {
authorFollowsTopicsString, err := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:follows-topics`, authorId))
if err != nil {
combinedData += fmt.Sprintf(`,"topics": %s`, authorFollowsTopicsString)
}
if authorFollowers != nil {
authorFollowers, err := c.store.Get(c.ctx, fmt.Sprintf(`author:%d:followers`, authorId))
if err != nil {
combinedData += fmt.Sprintf(`,"followers": %s`, authorFollowers)
}