Ban by device id for nand players and csnum for all

This commit is contained in:
ppeb 2025-03-20 19:26:21 -05:00
parent 50138d6afc
commit 5820cce487
No known key found for this signature in database
GPG Key ID: CC147AD1B3D318D0

View File

@ -18,7 +18,7 @@ const (
WITH RECURSIVE device_tree AS (
SELECT unnest(ng_device_id) AS device_id
FROM users
WHERE ng_device_id && $1
WHERE ng_device_id && $2
UNION
SELECT unnest(ng_device_id)
FROM users
@ -29,10 +29,13 @@ const (
SELECT has_ban, ban_tos, ng_device_id, ban_reason
FROM users
WHERE has_ban = true
AND (profile_id = $2
OR last_ip_address = $3
OR ($4 != '' AND last_ip_address = $4))
AND (ban_expires IS NULL OR ban_expires > $5)
AND (profile_id = $3
OR (ng_device_id && (SELECT * FROM known_ng_device_ids)
AND $1 != 67349608)
OR last_ip_address = $4
OR ($4 != '' AND last_ip_address = $5)
OR $7 && csnum)
AND (ban_expires IS NULL OR ban_expires > $6)
ORDER BY ban_tos DESC LIMIT 1`
)
@ -226,7 +229,7 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, userId uint64, gsb
var banReason string
timeNow := time.Now()
err = pool.QueryRow(ctx, SearchUserBan, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason)
err = pool.QueryRow(ctx, SearchUserBan, ngDeviceId, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow, user.Csnum).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason)
if err != nil {
if err != pgx.ErrNoRows {