[feat] Разделение банов по серверам.
# Conflicts: # Content.Client/Administration/UI/BanList/BanListLine.xaml.cs # Content.Client/Administration/UI/BanList/Bans/BanListHeader.xaml # Content.Client/Administration/UI/BanList/Bans/BanListLine.xaml # Content.Client/Administration/UI/Tabs/AdminTab/BanWindow.xaml # Content.Client/Administration/UI/Tabs/AdminTab/BanWindow.xaml.cs # Content.IntegrationTests/Tests/Commands/PardonCommand.cs # Content.Server/Administration/Commands/BanCommand.cs # Content.Server/Administration/Commands/DepartmentBanCommand.cs # Content.Server/Administration/Commands/RoleBanCommand.cs # Content.Server/Administration/Managers/RoleBanManager.cs # Content.Server/Database/ServerDbManager.cs # Content.Server/Database/ServerDbPostgres.cs # Content.Server/Database/ServerDbSqlite.cs
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
public interface IServerDbManager
|
||||
{
|
||||
const string GlobalServerName = "unknown";
|
||||
void Init();
|
||||
|
||||
void Shutdown();
|
||||
@@ -68,7 +69,8 @@ namespace Content.Server.Database
|
||||
Task<ServerBanDef?> GetServerBanAsync(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId);
|
||||
ImmutableArray<byte>? hwId,
|
||||
string serverName = GlobalServerName);
|
||||
|
||||
/// <summary>
|
||||
/// Looks up an user's ban history.
|
||||
@@ -83,7 +85,8 @@ namespace Content.Server.Database
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned=true);
|
||||
bool includeUnbanned=true,
|
||||
string serverName = GlobalServerName);
|
||||
|
||||
Task AddServerBanAsync(ServerBanDef serverBan);
|
||||
Task AddServerUnbanAsync(ServerUnbanDef serverBan);
|
||||
@@ -137,7 +140,8 @@ namespace Content.Server.Database
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned = true);
|
||||
bool includeUnbanned = true,
|
||||
string serverName = GlobalServerName);
|
||||
|
||||
Task<ServerRoleBanDef> AddServerRoleBanAsync(ServerRoleBanDef serverBan);
|
||||
Task AddServerRoleUnbanAsync(ServerRoleUnbanDef serverBan);
|
||||
@@ -281,6 +285,8 @@ namespace Content.Server.Database
|
||||
|
||||
public sealed class ServerDbManager : IServerDbManager
|
||||
{
|
||||
private const string GlobalServerName = "unknown";
|
||||
|
||||
public static readonly Counter DbReadOpsMetric = Metrics.CreateCounter(
|
||||
"db_read_ops",
|
||||
"Amount of read operations processed by the database manager.");
|
||||
@@ -395,20 +401,22 @@ namespace Content.Server.Database
|
||||
public Task<ServerBanDef?> GetServerBanAsync(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId)
|
||||
ImmutableArray<byte>? hwId,
|
||||
string serverName = GlobalServerName)
|
||||
{
|
||||
DbReadOpsMetric.Inc();
|
||||
return RunDbCommand(() => _db.GetServerBanAsync(address, userId, hwId));
|
||||
return RunDbCommand(() => _db.GetServerBanAsync(address, userId, hwId, serverName));
|
||||
}
|
||||
|
||||
public Task<List<ServerBanDef>> GetServerBansAsync(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned=true)
|
||||
bool includeUnbanned=true,
|
||||
string serverName = GlobalServerName)
|
||||
{
|
||||
DbReadOpsMetric.Inc();
|
||||
return RunDbCommand(() => _db.GetServerBansAsync(address, userId, hwId, includeUnbanned));
|
||||
return RunDbCommand(() => _db.GetServerBansAsync(address, userId, hwId, includeUnbanned, serverName));
|
||||
}
|
||||
|
||||
public Task AddServerBanAsync(ServerBanDef serverBan)
|
||||
@@ -452,10 +460,11 @@ namespace Content.Server.Database
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
bool includeUnbanned = true)
|
||||
bool includeUnbanned=true,
|
||||
string serverName = GlobalServerName)
|
||||
{
|
||||
DbReadOpsMetric.Inc();
|
||||
return RunDbCommand(() => _db.GetServerRoleBansAsync(address, userId, hwId, includeUnbanned));
|
||||
return RunDbCommand(() => _db.GetServerRoleBansAsync(address, userId, hwId, includeUnbanned, serverName));
|
||||
}
|
||||
|
||||
public Task<ServerRoleBanDef> AddServerRoleBanAsync(ServerRoleBanDef serverRoleBan)
|
||||
|
||||
Reference in New Issue
Block a user