FIX: allows to query a username made of integers (#25815)

If a user had `123456789` as username, it could be passed to the query as a number and the query would fail as it expects a string.

Also applies the same fix to groups.
This commit is contained in:
Joffrey JAFFEUX
2024-02-22 14:53:47 +01:00
committed by GitHub
parent 5ea1882e17
commit 84cd621bdc
2 changed files with 14 additions and 2 deletions

View File

@ -9,8 +9,8 @@ module Chat
.where(user_options: { chat_enabled: true })
.where(
"username IN (?) OR (groups.name IN (?) AND group_users.user_id IS NOT NULL)",
usernames,
groups,
usernames&.map(&:to_s),
groups&.map(&:to_s),
)
.where.not(id: excluded_user_ids)
.distinct