From ea56689f08b0ea295b7a58b7dc7ead58b0470919 Mon Sep 17 00:00:00 2001 From: ppeb Date: Sun, 2 Mar 2025 23:45:45 -0600 Subject: [PATCH] Fix missing ban reason dropped during merge --- api/ban.go | 2 +- api/kick.go | 2 +- database/login.go | 9 ++++++--- gpcm/login.go | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/ban.go b/api/ban.go index 411fcb9..b6efc0e 100644 --- a/api/ban.go +++ b/api/ban.go @@ -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", diff --git a/api/kick.go b/api/kick.go index 6990e9f..38c15f1 100644 --- a/api/kick.go +++ b/api/kick.go @@ -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", }, diff --git a/database/login.go b/database/login.go index c152987..08f51c4 100644 --- a/database/login.go +++ b/database/login.go @@ -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 diff --git a/gpcm/login.go b/gpcm/login.go index 49080ab..4c27307 100644 --- a/gpcm/login.go +++ b/gpcm/login.go @@ -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",