diff --git a/app/rest/api/rest.go b/app/rest/api/rest.go index cfef028b..24a0bd95 100644 --- a/app/rest/api/rest.go +++ b/app/rest/api/rest.go @@ -238,3 +238,12 @@ func renderJSONFromBytes(w http.ResponseWriter, r *http.Request, data []byte) { log.Printf("[WARN] failed to send response to %s, %s", r.RemoteAddr, err) } } + +func filterComments(comments []store.Comment, fn func(c store.Comment) bool) (filtered []store.Comment) { + for _, c := range comments { + if fn(c) { + filtered = append(filtered, c) + } + } + return filtered +} diff --git a/app/rest/api/rest_public.go b/app/rest/api/rest_public.go index bb3268ca..655268be 100644 --- a/app/rest/api/rest_public.go +++ b/app/rest/api/rest_public.go @@ -185,7 +185,7 @@ func (s *Rest) findUserCommentsCtrl(w http.ResponseWriter, r *http.Request) { return nil, e } comments = s.adminService.alterComments(comments, r) - + comments = filterComments(comments, func(c store.Comment) bool { return !c.Deleted }) count, e := s.DataService.UserCount(siteID, userID) if e != nil { return nil, e