diff --git a/pkg/models/user.go b/pkg/models/user.go index 511c1f2..f14fa41 100644 --- a/pkg/models/user.go +++ b/pkg/models/user.go @@ -320,13 +320,29 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er if search.AgeMin > 0 { date := time.Now().AddDate(-search.AgeMin, 0, 0) - wheres = append(wheres, "birthdate <= ?") + wheres = append(wheres, ` + birthdate <= ? AND NOT EXISTS ( + SELECT 1 + FROM profile_fields + WHERE user_id = users.id + AND name = 'hide_age' + AND value = 'true' + ) + `) placeholders = append(placeholders, date) } if search.AgeMax > 0 { date := time.Now().AddDate(-search.AgeMax-1, 0, 0) - wheres = append(wheres, "birthdate >= ?") + wheres = append(wheres, ` + birthdate >= ? AND NOT EXISTS ( + SELECT 1 + FROM profile_fields + WHERE user_id = users.id + AND name = 'hide_age' + AND value = 'true' + ) + `) placeholders = append(placeholders, date) }