Skip to content

Exclude banned users from search

Marcelo Rivera requested to merge fix/exclude-banned-users-from-search into master

Summary

This MR makes it so banned users don't appear in searches. In order to achieve that, I've:

  1. Included a new 'banned' field in minds_badger. While this is not necessary for now, it will make the document more representative of said user's state, and we may use it in the future for filtering elsewhere.
  2. Removed the ban check in UserMapping, so you can re-index banned channels
  3. Added a isBanned() check to UserMapping::suggestMap() so it returns an empty array if the user's banned.

IMPORTANT

IF we're going ahead with the schema change, it is important that we update it. I've already applied the following query on the review sites, but we'll need to also execute it on production:

curl -X PUT "localhost:9200/minds_badger/user/_mapping?pretty" -H 'Content-Type: application/json' -d'
{
  "user": {
    "properties": {
      "banned": {
        "type": "text"
      }
    }
  }
 }
'

Closes #1286 (closed)

How to Test

  1. Create user1
  2. Log in with user2, look for the first user in search. It should appear normally.
  3. Ban user1 (if you don't want to play around with the jury system, ping me with the username and I'll do it from the console)
  4. Wait a bit; the reindex has to go through a queue.
  5. Log back in with user2, search for the user1's username in the topbar; it should not appear anymore.

Estimated Regression Scope

Could break search

Edited by Mark Harding

Merge request reports