fix: hide suspended account
This commit is contained in:
@@ -345,7 +345,8 @@ func (r *UserRepo) Search(ctx context.Context, q string, limit, offset int) ([]m
|
||||
// enough at our user-table scale; revisit alongside the pg_trgm switch.
|
||||
var total int
|
||||
if err := r.pg.Pool.QueryRow(ctx,
|
||||
`SELECT COUNT(*) FROM users WHERE name ILIKE $1 OR handle::text ILIKE $1`,
|
||||
`SELECT COUNT(*) FROM users
|
||||
WHERE (name ILIKE $1 OR handle::text ILIKE $1) AND banned_at IS NULL`,
|
||||
substring).Scan(&total); err != nil {
|
||||
return nil, 0, fmt.Errorf("count search users: %w", err)
|
||||
}
|
||||
@@ -358,7 +359,13 @@ func (r *UserRepo) Search(ctx context.Context, q string, limit, offset int) ([]m
|
||||
// and name could reshuffle between pages.
|
||||
sql := `SELECT ` + userColumns + `
|
||||
FROM users
|
||||
WHERE name ILIKE $1 OR handle::text ILIKE $1
|
||||
WHERE (name ILIKE $1 OR handle::text ILIKE $1)
|
||||
-- Suspended accounts are unsearchable. This one query backs the
|
||||
-- people search page, the mention autocomplete AND both chat member
|
||||
-- pickers, so a banned account appearing here is offered as someone
|
||||
-- to @mention or add to a group. ResolveHandles already refuses them
|
||||
-- on the way in, which without this makes "Add" silently do nothing.
|
||||
AND banned_at IS NULL
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN handle::text ILIKE $2 THEN 0
|
||||
@@ -455,6 +462,10 @@ func (r *UserRepo) RecentlyJoined(ctx context.Context, viewerID string, since ti
|
||||
FROM users u
|
||||
WHERE u.created_at >= $2
|
||||
AND u.id <> $1
|
||||
-- Suspended accounts are not discoverable. A ban hides someone from
|
||||
-- the app; surfacing them in the welcome strip would be the most
|
||||
-- prominent placement on the home page.
|
||||
AND u.banned_at IS NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM follows f
|
||||
WHERE f.follower_id = $1 AND f.following_id = u.id
|
||||
|
||||
Reference in New Issue
Block a user