Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(feed): Properly get reactions from Posts endpoint #1396

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion go/internal/indexerhandler/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ func (h *Handler) handleExecuteReactPost(_ *Message, execMsg *wasmtypes.MsgExecu
}

userReactions := make(map[string]interface{})
post.UserReactions.Scan(&userReactions)
if err := json.Unmarshal(post.UserReactions, &userReactions); err != nil {
h.logger.Error("failed to unmarshal UserReactions", zap.String("data", string(post.UserReactions)), zap.Error(err))
}

var users []networks.UserID
reactedUsers, found := userReactions[reactPost.Icon]
if found {
Expand Down
9 changes: 7 additions & 2 deletions go/pkg/feed/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,13 @@ func (s *FeedService) Posts(ctx context.Context, req *feedpb.PostsRequest) (*fee
posts := make([]*feedpb.Post, len(dbPostWithExtras))
for idx, dbPost := range dbPostWithExtras {
var reactions []*feedpb.Reaction
reactionsMap := map[string]interface{}{}
dbPost.UserReactions.Scan(&reactionsMap)

reactionsMap := make(map[string]interface{})
if err := json.Unmarshal(dbPost.UserReactions, &reactionsMap); err != nil {
s.conf.Logger.Error("failed to unmarshal UserReactions", zap.String("data", string(dbPost.UserReactions)), zap.Error(err))
continue
}

for icon, users := range reactionsMap {
ownState := false
if queryUserID != "" {
Expand Down
Loading