Names on offline penalties, mobile menu close, player drawer tidy, IP-ban bypass flag

Bans and comms saved without a player name (SimpleAdmin's offline css_addban etc.) show the
player's latest name from sa_players_ips, and the panel writes that name onto new rows it claims.
The mobile sidebar closes from a Close button, the backdrop or Escape, since it covers the Menu
button. The public player drawer drops "Right now" and "Free to play and talk." and puts the
Steam profile link after the SteamID. Adds @css/bypassipban to the permission checkboxes.
This commit is contained in:
Astra 2026-09-28 11:23:14 +01:00
parent 657ead4c5a
commit 6324fc7f81
7 changed files with 45 additions and 16 deletions

View file

@ -231,6 +231,14 @@ func escapeLike(s string) string {
return strings.NewReplacer(`\`, `\\`, `%`, `\%`, `_`, `\_`).Replace(s)
}
// nameOr is a record's player_name, or when that's empty (SimpleAdmin's offline css_addban and
// css_addgag etc. save none) the player's latest name from sa_players_ips.
func nameOr(alias string) string {
return `COALESCE(NULLIF(` + alias + `.player_name,''), (SELECT i.name FROM sa_players_ips i
WHERE i.steamid = ` + alias + `.player_steamid AND i.name IS NOT NULL AND i.name <> ''
ORDER BY i.used_at DESC LIMIT 1), '')`
}
// Bans lists sa_bans, newest first, with the total matching count.
func (s *Store) Bans(ctx context.Context, q Query) ([]Penalty, int, error) {
where, args := s.where("sa_bans", q)
@ -238,7 +246,7 @@ func (s *Store) Bans(ctx context.Context, q Query) ([]Penalty, int, error) {
if err := s.db.QueryRowContext(ctx, "SELECT COUNT(*) FROM sa_bans"+where, args...).Scan(&total); err != nil {
return nil, 0, err
}
sqlq := `SELECT b.id, COALESCE(b.player_name,''), b.player_steamid, COALESCE(b.player_ip,''), b.admin_steamid,
sqlq := `SELECT b.id, ` + nameOr("b") + `, b.player_steamid, COALESCE(b.player_ip,''), b.admin_steamid,
b.admin_name, b.reason, b.duration, b.ends, b.created, b.status,
COALESCE(ua.player_name,''), COALESCE(u.reason,'')
FROM (SELECT * FROM sa_bans` + where + ` ORDER BY id DESC LIMIT ? OFFSET ?) b
@ -275,7 +283,7 @@ func (s *Store) Comms(ctx context.Context, q Query) ([]Penalty, int, error) {
if err := s.db.QueryRowContext(ctx, "SELECT COUNT(*) FROM sa_mutes"+where, args...).Scan(&total); err != nil {
return nil, 0, err
}
sqlq := `SELECT m.id, m.type, COALESCE(m.player_name,''), m.player_steamid, m.admin_steamid, m.admin_name,
sqlq := `SELECT m.id, m.type, ` + nameOr("m") + `, m.player_steamid, m.admin_steamid, m.admin_name,
m.reason, m.duration, m.passed, m.ends, m.created, m.status,
COALESCE(ua.player_name,''), COALESCE(u.reason,'')
FROM (SELECT * FROM sa_mutes` + where + ` ORDER BY id DESC LIMIT ? OFFSET ?) m
@ -873,7 +881,7 @@ func (s *Store) MaxID(ctx context.Context, table string) int64 {
// ClaimConsoleRow finds a row created after afterID for the player by "Console" (admin_steamid 0)
// and credits it to the web admin instead. SimpleAdmin writes the row asynchronously, so this polls
// for a few seconds. It returns the row id, or 0 if none appeared.
func (s *Store) ClaimConsoleRow(ctx context.Context, table string, afterID int64, steamid, commType, adminSteamID, adminName string) int64 {
func (s *Store) ClaimConsoleRow(ctx context.Context, table string, afterID int64, steamid, commType, adminSteamID, adminName, playerName string) int64 {
n, _ := parseSID(steamid)
a, _ := parseSID(adminSteamID)
q := `SELECT id FROM ` + table + ` WHERE id > ? AND player_steamid = ? AND admin_steamid = 0`
@ -886,7 +894,9 @@ func (s *Store) ClaimConsoleRow(ctx context.Context, table string, afterID int64
for range 20 {
var id int64
if err := s.db.QueryRowContext(ctx, q, args...).Scan(&id); err == nil {
_, _ = s.db.ExecContext(ctx, `UPDATE `+table+` SET admin_steamid = ?, admin_name = ? WHERE id = ?`, a, adminName, id)
// Offline penalties arrive without a player name, so fill it in from what we know.
_, _ = s.db.ExecContext(ctx, `UPDATE `+table+` SET admin_steamid = ?, admin_name = ?,
player_name = COALESCE(NULLIF(player_name, ''), NULLIF(?, '')) WHERE id = ?`, a, adminName, playerName, id)
return id
}
select {