Fix missing ban reason dropped during merge

This commit is contained in:
ppeb 2025-03-02 23:45:45 -06:00
parent df1c6a83fc
commit ea56689f08
No known key found for this signature in database
GPG Key ID: CC147AD1B3D318D0
4 changed files with 9 additions and 6 deletions

View File

@ -98,7 +98,7 @@ func handleBanImpl(w http.ResponseWriter, r *http.Request) (*database.User, bool
ErrorCode: 22002,
MessageRMC: map[byte]string{
gpcm.LangEnglish: "" +
"You have been banned from Retro WFC\n" +
"You have been banned from WiiLink WFC\n" +
"Reason: " + req.Reason + "\n" +
"Error Code: %[1]d\n" +
"Support Info: NG%08[2]x",

View File

@ -76,7 +76,7 @@ func handleKickImpl(w http.ResponseWriter, r *http.Request) (*database.User, boo
MessageRMC: map[byte]string{
gpcm.LangEnglish: "" +
"You have been kicked from\n" +
"Retro WFC by a moderator.\n" +
"WiiLink WFC by a moderator.\n" +
"Reason: " + req.Reason + "\n" +
"Error Code: %[1]d",
},

View File

@ -26,7 +26,7 @@ const (
ON ng_device_id && array[dt.device_id]
) SELECT array_agg(DISTINCT device_id) FROM device_tree
)
SELECT has_ban, ban_tos, ng_device_id
SELECT has_ban, ban_tos, ng_device_id, ban_reason
FROM users
WHERE has_ban = true
AND (profile_id = $2
@ -170,8 +170,10 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, userId uint64, gsb
var banExists bool
var banTOS bool
var bannedDeviceIdList []uint32
var banReason string
timeNow := time.Now()
err = pool.QueryRow(ctx, SearchUserBan, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow).Scan(&banExists, &banTOS, &bannedDeviceIdList)
err = pool.QueryRow(ctx, SearchUserBan, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason)
if err != nil {
if err != pgx.ErrNoRows {
@ -203,12 +205,13 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, userId uint64, gsb
if banTOS {
logging.Warn("DATABASE", "Profile", aurora.Cyan(user.ProfileId), "is banned")
return User{RestrictedDeviceId: bannedDeviceId}, ErrProfileBannedTOS
return User{RestrictedDeviceId: bannedDeviceId, BanReason: banReason}, ErrProfileBannedTOS
}
logging.Warn("DATABASE", "Profile", aurora.Cyan(user.ProfileId), "is restricted")
user.Restricted = true
user.RestrictedDeviceId = bannedDeviceId
user.BanReason = banReason
}
return user, nil

View File

@ -480,7 +480,7 @@ func (g *GameSpySession) performLoginWithDatabase(userId uint64, gsbrCode string
ErrorCode: 22002,
MessageRMC: map[byte]string{
LangEnglish: "" +
"You are banned from Retro WFC\n" +
"You are banned from WiiLink WFC\n" +
"Reason: " + user.BanReason + "\n" +
"Error Code: %[1]d\n" +
"Support Info: NG%08[2]x",