Skip to content

Commit

Permalink
allow proposal owners to see replies
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Aug 12, 2020
1 parent fac450c commit 181d3ad
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions politeiawww/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -1632,20 +1632,34 @@ func (p *politeiawww) processInvoiceComments(token string, u *user.User) (*www.G
return nil, err
}

validComments := c[:0]
userOwnedComments := make([]www.Comment, 0, 1048)
commentsToDisplay := make([]www.Comment, 0, 1048)
// Check to see if it's a proposal owner, then show them only threads
// they started. Admins and invoice owners can see everything.
if !u.Admin && (ir.Username != u.Username) {
for _, comment := range c {
// Add any comments that are top level and owned by the requesting
// Add any comments that are owned by the requesting
// user.
if comment.ParentID == "0" && comment.UserID == u.ID.String() {
validComments = append(validComments, comment)
if comment.UserID == u.ID.String() {
userOwnedComments = append(userOwnedComments, comment)
}
// Add any replies to a top level comment that is owned by the
// requesting user. ??
}
c = validComments
// Now go through again and check for any replies to a proposal owner
// comment.
for _, comment := range c {
addToComments := false
for _, userComment := range userOwnedComments {
if userComment.ParentID == comment.CommentID {
addToComments = true
break
}
}
if addToComments {
commentsToDisplay = append(commentsToDisplay, comment)
}
}
commentsToDisplay = append(commentsToDisplay, userOwnedComments...)
c = commentsToDisplay
}
// Get the last time the user accessed these comments. This is
// a public route so a user may not exist.
Expand Down

0 comments on commit 181d3ad

Please sign in to comment.