Skip to content

Commit

Permalink
Enrich all users with relation info
Browse files Browse the repository at this point in the history
This adds the relation info to the user representations in lists where
it was missing until now.
  • Loading branch information
Alexander Simmerl committed Dec 1, 2016
1 parent 184df65 commit 0debc5a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions core/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ func CommentList(
return nil, err
}

for _, u := range um {
err = enrichRelation(connections, currentApp, origin, u)
if err != nil {
return nil, err
}
}

return &CommentFeed{Comments: cs, UserMap: um}, nil
}
}
Expand Down Expand Up @@ -254,6 +261,7 @@ type CommentUpdateFunc func(
new *object.Object,
) (*object.Object, error)

// CommentUpdate replaces the given comment with new values.
func CommentUpdate(
objects object.Service,
) CommentUpdateFunc {
Expand Down Expand Up @@ -306,6 +314,7 @@ func CommentUpdate(
}
}

// IsComment indicates if Object is a comment.
func IsComment(o *object.Object) bool {
if o.Type != TypeComment {
return false
Expand Down
7 changes: 7 additions & 0 deletions core/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ func ConnectionByState(
return nil, err
}

for _, u := range um {
err = enrichRelation(connections, currentApp, origin, u)
if err != nil {
return nil, err
}
}

return &ConnectionFeed{
Connections: cons,
UserMap: um,
Expand Down
16 changes: 15 additions & 1 deletion core/like.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ func LikeList(
return nil, err
}

for _, u := range um {
err = enrichRelation(connections, currentApp, origin, u)
if err != nil {
return nil, err
}
}

return &LikeFeed{
Likes: es,
UserMap: um,
Expand All @@ -256,7 +263,7 @@ type LikesUserFunc func(
opts event.QueryOptions,
) (*LikeFeed, error)

// LikesUserFunc returns all Likes for the given user.
// LikesUser returns all Likes for the given user.
func LikesUser(
connections connection.Service,
events event.Service,
Expand Down Expand Up @@ -321,6 +328,13 @@ func LikesUser(
return nil, err
}

for _, u := range um {
err = enrichRelation(connections, currentApp, origin, u)
if err != nil {
return nil, err
}
}

return &LikeFeed{
Likes: ls,
PostMap: ps.toMap(),
Expand Down

0 comments on commit 0debc5a

Please sign in to comment.