Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

fix: exclude email

goenning5d04d290977c
diff --git a/app/handlers/apiv1/post.go b/app/handlers/apiv1/post.go
index 1682f3280..46dfddd20 100644
--- a/app/handlers/apiv1/post.go
+++ b/app/handlers/apiv1/post.go
@@ -355,7 +355,7 @@ func ListVotes() web.HandlerFunc {
return c.Failure(err)
}
- listVotes := &query.ListPostVotes{PostID: getPost.Result.ID}
+ listVotes := &query.ListPostVotes{PostID: getPost.Result.ID, IncludeEmail: true}
err = bus.Dispatch(c, listVotes)
if err != nil {
return c.Failure(err)
diff --git a/app/handlers/post.go b/app/handlers/post.go
index 946432a1f..21fad5c00 100644
--- a/app/handlers/post.go
+++ b/app/handlers/post.go
@@ -67,7 +67,7 @@ func PostDetails() web.HandlerFunc {
isSubscribed := &query.UserSubscribedTo{PostID: getPost.Result.ID}
getComments := &query.GetCommentsByPost{Post: getPost.Result}
getAllTags := &query.GetAllTags{}
- listVotes := &query.ListPostVotes{PostID: getPost.Result.ID, Limit: 6}
+ listVotes := &query.ListPostVotes{PostID: getPost.Result.ID, Limit: 6, IncludeEmail: false}
getAttachments := &query.GetAttachments{Post: getPost.Result}
if err := bus.Dispatch(c, getAllTags, getComments, listVotes, isSubscribed, getAttachments); err != nil {
return c.Failure(err)
diff --git a/app/models/query/vote.go b/app/models/query/vote.go
index a4b0a47d3..291748c6e 100644
--- a/app/models/query/vote.go
+++ b/app/models/query/vote.go
@@ -3,8 +3,9 @@ package query
import "github.com/getfider/fider/app/models"
type ListPostVotes struct {
- PostID int
- Limit int
+ PostID int
+ Limit int
+ IncludeEmail bool
Result []*models.Vote
}
diff --git a/app/services/sqlstore/postgres/vote.go b/app/services/sqlstore/postgres/vote.go
index 33ab70911..14ab6492a 100644
--- a/app/services/sqlstore/postgres/vote.go
+++ b/app/services/sqlstore/postgres/vote.go
@@ -79,13 +79,18 @@ func listPostVotes(ctx context.Context, q *query.ListPostVotes) error {
sqlLimit = strconv.Itoa(q.Limit)
}
+ emailColumn := "''"
+ if q.IncludeEmail {
+ emailColumn = "u.email"
+ }
+
votes := []*dbVote{}
err := trx.Select(&votes, `
SELECT
pv.created_at,
u.id AS user_id,
u.name AS user_name,
- u.email AS user_email,
+ `+emailColumn+` AS user_email,
u.avatar_type AS user_avatar_type,
u.avatar_bkey AS user_avatar_bkey
FROM post_votes pv