Skip to content

fix: exclude blocked users from follower count

Seth Falco requested to merge SethFalco/gitlab:fix/441774 into master

What does this MR do and why?

Excludes blocked accounts (blocked/banned by instance admins) from the following/followers page of user profiles. Please read the related issue for why I'm proposing this change.

TL;DR: An individual that was harassing me in the past followed me on GitLab before their account got blocked. I just don't want to see the reminder on my profile. ^-^'

I was originally thinking between two options:

  • Should a blocked user unfollow everyone upon being blocked?
  • Should blocked users just be excluded from the lists, but not otherwise be removed.

I opted for the latter, so that if the user is unblocked for whatever reason, the followers/following remain intact.

Related

Query plan

Before

QUERY

SELECT "users".* FROM "users" INNER JOIN "user_follow_users" ON "users"."id" = "user_follow_users"."follower_id" WHERE "user_follow_users"."followee_id" = 82354;
Time: 8.743 ms  
  - planning: 8.504 ms  
  - execution: 0.239 ms  
    - I/O read: 0.000 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 3 (~24.00 KiB) from the buffer pool  
  - reads: 0 from the OS file cache, including disk I/O  
  - dirtied: 0  
  - writes: 0  
  
Details and visualization: https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/26594/commands/83246.

After

explain SELECT "users".* FROM "users" INNER JOIN "user_follow_users" ON "users"."id" = "user_follow_users"."follower_id" WHERE "user_follow_users"."followee_id" = 82354 AND ("users"."state" IN ('active')) AND "users"."user_type" IN (0, 6, 4, 13);
  
Time: 11.227 ms  
  - planning: 8.616 ms  
  - execution: 2.611 ms  
    - I/O read: 2.427 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 2 (~16.00 KiB) from the buffer pool  
  - reads: 1 (~8.00 KiB) from the OS file cache, including disk I/O  
  - dirtied: 0  
  - writes: 0  
  
Details and visualization: https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/26594/commands/83245.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

backend

Screenshots or screen recordings

Before the follower page always showed all users. Now it will hide users that were blocked.

How to set up and validate locally

  1. Impersonate a random user on the instance.
  2. Follow the root user.
  3. Stop impersonating the user.
  4. Go to the root user's profile and check the followers page and menu item.
  5. In the admin dashboard, ban or block the user who followed the root user.
  6. Observe the root user's profile again.
Edited by Aboobacker MK

Merge request reports

Loading