// post-processes comments, hides text of all comments for blocked users,
// resets score and votes too. Also hides sensitive info for non-admin users
post-processes comments, hides text of all comments for blocked users,
resets score and votes too. Also hides sensitive info for non-admin users
// post - processes comments hides text of all comments for blocked users // resets score and votes too . Also hides sensitive info for non - admin users
func (a *admin) alterComments(comments []store.Comment, r *http.Request) (res []store.Comment) {
	res = make([]store.Comment, len(comments))
	user, err := rest.GetUserInfo(r)
	isAdmin := err == nil && user.Admin 
	for i, c := range comments {
		blocked := a.dataService.IsBlocked(c.Locator.SiteID, c.User.ID)
		if blocked {
			if !isAdmin { 
				c.SetDeleted(store.SoftDelete)
			}
			c.User.Blocked = true
			c.Deleted = true
		}
		if !blocked {
			c.User.Verified = a.dataService.IsVerified(c.Locator.SiteID, c.User.ID)
		}
		if !isAdmin {
			c.User.IP = ""
		}
		res[i] = c
	}
	return res
}
func ( a * admin ) alterComments ( comments [ ] store . Comment , r * http . Request ) ( res [ ] store . Comment ) { res = make ( [ ] store . Comment , len ( comments ) ) user , err := rest . GetUserInfo ( r ) isAdmin := err == nil && user . Admin for i , c := range comments { blocked := a . dataService . IsBlocked ( c . Locator . SiteID , c . User . ID ) if blocked { if ! isAdmin { c . SetDeleted ( store . SoftDelete ) } c . User . Blocked = true c . Deleted = true } if ! blocked { c . User . Verified = a . dataService . IsVerified ( c . Locator . SiteID , c . User . ID ) } if ! isAdmin { c . User . IP = " " } res [ i ] = c } return res }
post-processes comments, hides text of all comments for blocked users,
resets score and votes too.
post - processes comments hides text of all comments for blocked users resets score and votes too .
// make separate cache key for admins // process blocked users // reset comment to deleted for non-admins // set verified status retroactively // hide info from non-admins