Revert "Show ban and note count in ahelp window" (#15347)
This commit is contained in:
@@ -330,22 +330,6 @@ namespace Content.Server.Database
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned);
|
||||
|
||||
/// <summary>
|
||||
/// Counts an user's bans.
|
||||
/// This will return pardoned bans as well.
|
||||
/// One of <see cref="address"/> or <see cref="userId"/> need to not be null.
|
||||
/// </summary>
|
||||
/// <param name="address">The ip address of the user.</param>
|
||||
/// <param name="userId">The id of the user.</param>
|
||||
/// <param name="hwId">The HWId of the user.</param>
|
||||
/// <param name="includeUnbanned">Include pardoned and expired bans.</param>
|
||||
/// <returns>The user's ban history.</returns>
|
||||
public abstract Task<int> CountServerBansAsync(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned);
|
||||
|
||||
public abstract Task AddServerBanAsync(ServerBanDef serverBan);
|
||||
public abstract Task AddServerUnbanAsync(ServerUnbanDef serverUnban);
|
||||
|
||||
@@ -1012,19 +996,6 @@ namespace Content.Server.Database
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> CountAdminNotes(Guid player)
|
||||
{
|
||||
await using var db = await GetDb();
|
||||
return await db.DbContext.AdminNotes
|
||||
.Where(note => note.PlayerUserId == player)
|
||||
.Where(note => !note.Deleted)
|
||||
.Include(note => note.Round)
|
||||
.Include(note => note.CreatedBy)
|
||||
.Include(note => note.LastEditedBy)
|
||||
.Include(note => note.Player)
|
||||
.CountAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAdminNote(int id, Guid deletedBy, DateTime deletedAt)
|
||||
{
|
||||
await using var db = await GetDb();
|
||||
|
||||
@@ -82,21 +82,6 @@ namespace Content.Server.Database
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned=true);
|
||||
|
||||
/// <summary>
|
||||
/// Counts an user's bans.
|
||||
/// One of <see cref="address"/> or <see cref="userId"/> need to not be null.
|
||||
/// </summary>
|
||||
/// <param name="address">The ip address of the user.</param>
|
||||
/// <param name="userId">The id of the user.</param>
|
||||
/// <param name="hwId">The HWId of the user.</param>
|
||||
/// <param name="includeUnbanned">If true, bans that have been expired or pardoned are also included.</param>
|
||||
/// <returns>The user's ban history.</returns>
|
||||
Task<int> CountServerBansAsync(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned=true);
|
||||
|
||||
Task AddServerBanAsync(ServerBanDef serverBan);
|
||||
Task AddServerUnbanAsync(ServerUnbanDef serverBan);
|
||||
|
||||
@@ -251,7 +236,6 @@ namespace Content.Server.Database
|
||||
Task<int> AddAdminNote(int? roundId, Guid player, string message, Guid createdBy, DateTime createdAt);
|
||||
Task<AdminNote?> GetAdminNote(int id);
|
||||
Task<List<AdminNote>> GetAdminNotes(Guid player);
|
||||
Task<int> CountAdminNotes(Guid player);
|
||||
Task DeleteAdminNote(int id, Guid deletedBy, DateTime deletedAt);
|
||||
Task EditAdminNote(int id, string message, Guid editedBy, DateTime editedAt);
|
||||
|
||||
@@ -374,12 +358,6 @@ namespace Content.Server.Database
|
||||
return _db.GetServerBansAsync(address, userId, hwId, includeUnbanned);
|
||||
}
|
||||
|
||||
public Task<int> CountServerBansAsync(IPAddress? address, NetUserId? userId, ImmutableArray<byte>? hwId, bool includeUnbanned = true)
|
||||
{
|
||||
DbReadOpsMetric.Inc();
|
||||
return _db.CountServerBansAsync(address, userId, hwId, includeUnbanned);
|
||||
}
|
||||
|
||||
public Task AddServerBanAsync(ServerBanDef serverBan)
|
||||
{
|
||||
DbWriteOpsMetric.Inc();
|
||||
@@ -668,12 +646,6 @@ namespace Content.Server.Database
|
||||
return _db.GetAdminNotes(player);
|
||||
}
|
||||
|
||||
public Task<int> CountAdminNotes(Guid player)
|
||||
{
|
||||
DbReadOpsMetric.Inc();
|
||||
return _db.CountAdminNotes(player);
|
||||
}
|
||||
|
||||
public Task DeleteAdminNote(int id, Guid deletedBy, DateTime deletedAt)
|
||||
{
|
||||
DbWriteOpsMetric.Inc();
|
||||
|
||||
@@ -98,21 +98,6 @@ namespace Content.Server.Database
|
||||
return bans;
|
||||
}
|
||||
|
||||
public override async Task<int> CountServerBansAsync(IPAddress? address, NetUserId? userId, ImmutableArray<byte>? hwId, bool includeUnbanned)
|
||||
{
|
||||
if (address == null && userId == null && hwId == null)
|
||||
{
|
||||
throw new ArgumentException("Address, userId, and hwId cannot all be null");
|
||||
}
|
||||
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
var exempt = await GetBanExemptionCore(db, userId);
|
||||
var query = MakeBanLookupQuery(address, userId, hwId, db, includeUnbanned, exempt);
|
||||
|
||||
return await query.CountAsync();
|
||||
}
|
||||
|
||||
private static IQueryable<ServerBan> MakeBanLookupQuery(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
|
||||
@@ -97,22 +97,6 @@ namespace Content.Server.Database
|
||||
.ToList()!;
|
||||
}
|
||||
|
||||
public override async Task<int> CountServerBansAsync(IPAddress? address, NetUserId? userId, ImmutableArray<byte>? hwId, bool includeUnbanned)
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
var exempt = await GetBanExemptionCore(db, userId);
|
||||
|
||||
// SQLite can't do the net masking stuff we need to match IP address ranges.
|
||||
// So just pull down the whole list into memory.
|
||||
var queryBans = await GetAllBans(db.SqliteDbContext, includeUnbanned, exempt);
|
||||
|
||||
return queryBans
|
||||
.Where(b => BanMatches(b, address, userId, hwId))
|
||||
.Select(ConvertBan)
|
||||
.Count();
|
||||
}
|
||||
|
||||
private static async Task<List<ServerBan>> GetAllBans(
|
||||
SqliteServerDbContext db,
|
||||
bool includeUnbanned,
|
||||
|
||||
Reference in New Issue
Block a user