- @if (Model.Data.Count() == 0)
+ @if (!Model.Data.Any())
{
diff --git a/CentCom.API/Views/Viewer/viewbans.cshtml b/CentCom.API/Views/Viewer/viewbans.cshtml
index 887cb56..663563c 100644
--- a/CentCom.API/Views/Viewer/viewbans.cshtml
+++ b/CentCom.API/Views/Viewer/viewbans.cshtml
@@ -5,7 +5,7 @@
var banTraits = new Dictionary>();
foreach (var b in Model.Bans)
{
- var thisBan = new List<(string title, string value)>()
+ var thisBan = new List<(string title, string value)>
{
("Banned", b.BannedOn.ToString("yyyy'-'MM'-'dd HH':'mm':'ss")),
("Admin", b.BannedBy)
diff --git a/CentCom.Bot/CentCom.Bot.csproj b/CentCom.Bot/CentCom.Bot.csproj
index 7faf3cf..e698da7 100644
--- a/CentCom.Bot/CentCom.Bot.csproj
+++ b/CentCom.Bot/CentCom.Bot.csproj
@@ -2,28 +2,28 @@
Exe
- 1.3.16
- net5.0
+ 1.4.0
+ net6.0
c8af1449-8cdf-4707-a66d-51e896551bfb
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/CentCom.Bot/Commands/AboutCommands.cs b/CentCom.Bot/Commands/AboutCommands.cs
index 4db6200..b840842 100644
--- a/CentCom.Bot/Commands/AboutCommands.cs
+++ b/CentCom.Bot/Commands/AboutCommands.cs
@@ -13,58 +13,57 @@
using Remora.Discord.Commands.Feedback.Services;
using Remora.Results;
-namespace CentCom.Bot.Commands
+namespace CentCom.Bot.Commands;
+
+public class AboutCommands : CommandGroup
{
- public class AboutCommands : CommandGroup
- {
- private readonly DatabaseContext _dbContext;
- private readonly FeedbackService _feedback;
+ private readonly DatabaseContext _dbContext;
+ private readonly FeedbackService _feedback;
- public AboutCommands(DatabaseContext dbContext, FeedbackService feedback)
- {
- _dbContext = dbContext;
- _feedback = feedback;
- }
+ public AboutCommands(DatabaseContext dbContext, FeedbackService feedback)
+ {
+ _dbContext = dbContext;
+ _feedback = feedback;
+ }
- [Command("about")]
- [Description("Get basic information about CentCom and its performance")]
- [CommandType(ApplicationCommandType.ChatInput)]
- public async Task GetAboutAsync()
+ [Command("about")]
+ [Description("Get basic information about CentCom and its performance")]
+ [CommandType(ApplicationCommandType.ChatInput)]
+ public async Task GetAboutAsync()
+ {
+ var stats = new List
{
- var stats = new List()
- {
- new EmbedField("Total Bans", (await _dbContext.Bans.CountAsync()).ToString(), true),
- new EmbedField("Total Sources", (await _dbContext.BanSources.CountAsync()).ToString(), true),
- new EmbedField("Bans in Last 24h", (await _dbContext.Bans
- .Where(x => x.BannedOn > DateTime.UtcNow.AddDays(-1))
- .CountAsync()).ToString(), true
- )
- };
- var embed = new Embed("Oh, woah, what's this?",
- Description:
- "[CentCom](https://centcom.melonmesa.com/) is a ban data aggregation service for Space Station 13. " +
- "This bot, ``CentCom.Bot``, serves as a utility to provide feedback when something is wrong. You can " +
- "find the source on GitHub [here](https://github.com/bobbahbrown/centcom).",
- Fields: stats,
- Colour: _feedback.Theme.Success,
- Timestamp: DateTimeOffset.UtcNow,
- Footer: new EmbedFooter(VersionUtility.Version));
- var result = await _feedback.SendContextualEmbedAsync(embed, CancellationToken);
- return result.IsSuccess ? Result.FromSuccess() : Result.FromError(result);
- }
+ new EmbedField("Total Bans", (await _dbContext.Bans.CountAsync()).ToString(), true),
+ new EmbedField("Total Sources", (await _dbContext.BanSources.CountAsync()).ToString(), true),
+ new EmbedField("Bans in Last 24h", (await _dbContext.Bans
+ .Where(x => x.BannedOn > DateTime.UtcNow.AddDays(-1))
+ .CountAsync()).ToString(), true
+ )
+ };
+ var embed = new Embed("Oh, woah, what's this?",
+ Description:
+ "[CentCom](https://centcom.melonmesa.com/) is a ban data aggregation service for Space Station 13. " +
+ "This bot, ``CentCom.Bot``, serves as a utility to provide feedback when something is wrong. You can " +
+ "find the source on GitHub [here](https://github.com/bobbahbrown/centcom).",
+ Fields: stats,
+ Colour: _feedback.Theme.Success,
+ Timestamp: DateTimeOffset.UtcNow,
+ Footer: new EmbedFooter(VersionUtility.Version));
+ var result = await _feedback.SendContextualEmbedAsync(embed, ct: CancellationToken);
+ return result.IsSuccess ? Result.FromSuccess() : Result.FromError(result);
+ }
- [Command("invite")]
- [Description("Get an invite link for the bot to your server")]
- [CommandType(ApplicationCommandType.ChatInput)]
- public async Task GetInviteAsync()
- {
- const string inviteLink =
- "https://discord.com/api/oauth2/authorize?client_id=878121825333293127&permissions=51264&scope=bot%20applications.commands";
- return await _feedback.SendContextualEmbedAsync(new Embed(
- Description: $"[Click here]({inviteLink}) to invite me to your server!",
- Colour: _feedback.Theme.Primary,
- Timestamp: DateTimeOffset.UtcNow,
- Footer: new EmbedFooter(VersionUtility.Version)));
- }
+ [Command("invite")]
+ [Description("Get an invite link for the bot to your server")]
+ [CommandType(ApplicationCommandType.ChatInput)]
+ public async Task GetInviteAsync()
+ {
+ const string inviteLink =
+ "https://discord.com/api/oauth2/authorize?client_id=878121825333293127&permissions=51264&scope=bot%20applications.commands";
+ return await _feedback.SendContextualEmbedAsync(new Embed(
+ Description: $"[Click here]({inviteLink}) to invite me to your server!",
+ Colour: _feedback.Theme.Primary,
+ Timestamp: DateTimeOffset.UtcNow,
+ Footer: new EmbedFooter(VersionUtility.Version)));
}
}
\ No newline at end of file
diff --git a/CentCom.Bot/Commands/SearchCommands.cs b/CentCom.Bot/Commands/SearchCommands.cs
index 7f616db..faa7bd1 100644
--- a/CentCom.Bot/Commands/SearchCommands.cs
+++ b/CentCom.Bot/Commands/SearchCommands.cs
@@ -15,51 +15,50 @@
using Remora.Discord.Commands.Feedback.Services;
using Remora.Results;
-namespace CentCom.Bot.Commands
+namespace CentCom.Bot.Commands;
+
+public class SearchCommands : CommandGroup
{
- public class SearchCommands : CommandGroup
+ private readonly DatabaseContext _dbContext;
+ private readonly FeedbackService _feedback;
+
+ public SearchCommands(DatabaseContext dbContext, FeedbackService feedback)
{
- private readonly DatabaseContext _dbContext;
- private readonly FeedbackService _feedback;
+ _dbContext = dbContext;
+ _feedback = feedback;
+ }
- public SearchCommands(DatabaseContext dbContext, FeedbackService feedback)
- {
- _dbContext = dbContext;
- _feedback = feedback;
- }
+ [Command("search")]
+ [Description("Search and view a summary for a player on CentCom")]
+ public async Task LookupCkey(string key)
+ {
+ var ckey = new CKey(key);
+ var bans = (await _dbContext.Bans
+ .Include(x => x.JobBans)
+ .Include(x => x.SourceNavigation)
+ .Where(x => x.CKey == ckey.CanonicalKey)
+ .ToListAsync())
+ .Select(BanData.FromBan);
- [Command("search")]
- [Description("Search and view a summary for a player on CentCom")]
- public async Task LookupCkey(string key)
+ // Collect statistics
+ var fields = new List
{
- var ckey = new CKey(key);
- var bans = (await _dbContext.Bans
- .Include(x => x.JobBans)
- .Include(x => x.SourceNavigation)
- .Where(x => x.CKey == ckey.CanonicalKey)
- .ToListAsync())
- .Select(BanData.FromBan);
-
- // Collect statistics
- var fields = new List()
- {
- new EmbedField("Server bans", bans.Count(x => x.Type == BanType.Server).ToString(), true),
- new EmbedField("Job bans", bans.Count(x => x.Type == BanType.Job).ToString(), true),
- new EmbedField("Active bans", bans.Count(x => x.Active).ToString(), true)
- };
+ new EmbedField("Server bans", bans.Count(x => x.Type == BanType.Server).ToString(), true),
+ new EmbedField("Job bans", bans.Count(x => x.Type == BanType.Job).ToString(), true),
+ new EmbedField("Active bans", bans.Count(x => x.Active).ToString(), true)
+ };
- // Generate embed to relay the information
- var embed = new Embed("Search Results",
- Colour: _feedback.Theme.Success,
- Description:
- $"Found the following details when searching for ``{key}``. You may be interested in viewing the " +
- $"full details of the bans on [CentCom](https://centcom.melonmesa.com/viewer/view/{key}), or viewing " +
- $"their /tg/ activity on [Scrubby](https://scrubby.melonmesa.com/ckey/{key}).",
- Fields: fields,
- Timestamp: DateTimeOffset.UtcNow,
- Footer: new EmbedFooter(VersionUtility.Version));
+ // Generate embed to relay the information
+ var embed = new Embed("Search Results",
+ Colour: _feedback.Theme.Success,
+ Description:
+ $"Found the following details when searching for ``{key}``. You may be interested in viewing the " +
+ $"full details of the bans on [CentCom](https://centcom.melonmesa.com/viewer/view/{key}), or viewing " +
+ $"their /tg/ activity on [Scrubby](https://scrubby.melonmesa.com/ckey/{key}).",
+ Fields: fields,
+ Timestamp: DateTimeOffset.UtcNow,
+ Footer: new EmbedFooter(VersionUtility.Version));
- return await _feedback.SendContextualEmbedAsync(embed);
- }
+ return await _feedback.SendContextualEmbedAsync(embed);
}
}
\ No newline at end of file
diff --git a/CentCom.Bot/Configuration/DiscordConfiguration.cs b/CentCom.Bot/Configuration/DiscordConfiguration.cs
index 2591145..7e69ecc 100644
--- a/CentCom.Bot/Configuration/DiscordConfiguration.cs
+++ b/CentCom.Bot/Configuration/DiscordConfiguration.cs
@@ -1,11 +1,10 @@
-namespace CentCom.Bot.Configuration
+namespace CentCom.Bot.Configuration;
+
+public class DiscordConfiguration
{
- public class DiscordConfiguration
- {
- public string Token { get; set; }
+ public string Token { get; set; }
- public ulong? FailureChannel { get; set; }
+ public ulong? FailureChannel { get; set; }
- public ulong? FailureMention { get; set; }
- }
+ public ulong? FailureMention { get; set; }
}
\ No newline at end of file
diff --git a/CentCom.Bot/Jobs/FailedParseJob.cs b/CentCom.Bot/Jobs/FailedParseJob.cs
index fc2054a..f261afb 100644
--- a/CentCom.Bot/Jobs/FailedParseJob.cs
+++ b/CentCom.Bot/Jobs/FailedParseJob.cs
@@ -9,93 +9,95 @@
using CentCom.Common.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
+using OneOf;
using Quartz;
+using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest;
-using Remora.Discord.Core;
+using Remora.Rest.Core;
-namespace CentCom.Bot.Jobs
+namespace CentCom.Bot.Jobs;
+
+[DisallowConcurrentExecution]
+public class FailedParseJob : IJob
{
- [DisallowConcurrentExecution]
- public class FailedParseJob : IJob
- {
- private readonly IDiscordRestChannelAPI _channelAPI;
- private readonly IOptions _config;
- private readonly DatabaseContext _dbContext;
+ private readonly IDiscordRestChannelAPI _channelAPI;
+ private readonly IOptions _config;
+ private readonly DatabaseContext _dbContext;
- public FailedParseJob(DatabaseContext dbContext, IOptions config,
- IDiscordRestChannelAPI channelAPI)
- {
- _dbContext = dbContext;
- _channelAPI = channelAPI;
- _config = config;
- }
+ public FailedParseJob(DatabaseContext dbContext, IOptions config,
+ IDiscordRestChannelAPI channelAPI)
+ {
+ _dbContext = dbContext;
+ _channelAPI = channelAPI;
+ _config = config;
+ }
- public async Task Execute(IJobExecutionContext context)
- {
- var failures = await _dbContext.CheckHistory
- .Include(x => x.Notification)
- .Where(x => !x.Success && x.Notification == null)
- .ToListAsync();
- if (failures.Count == 0)
- return;
+ public async Task Execute(IJobExecutionContext context)
+ {
+ var failures = await _dbContext.CheckHistory
+ .Include(x => x.Notification)
+ .Where(x => !x.Success && x.Notification == null)
+ .ToListAsync();
+ if (failures.Count == 0)
+ return;
- if (_config.Value == null)
- throw new Exception("Missing or invalid Discord configuration, cannot dispatch failure notifications");
+ if (_config.Value == null)
+ throw new Exception("Missing or invalid Discord configuration, cannot dispatch failure notifications");
- // Don't bother if we haven't configured a channel to use
- if (_config.Value.FailureChannel == null)
- return;
+ // Don't bother if we haven't configured a channel to use
+ if (_config.Value.FailureChannel == null)
+ return;
- // Get channel, check it exists
- var channelRequest = await _channelAPI.GetChannelAsync(new Snowflake(_config.Value.FailureChannel.Value));
- if (!channelRequest.IsSuccess || channelRequest.Entity == null)
- throw new Exception("Failed to get Discord channel to dispatch parse failure notifications into.");
+ // Get channel, check it exists
+ var channelRequest = await _channelAPI.GetChannelAsync(new Snowflake(_config.Value.FailureChannel.Value));
+ if (!channelRequest.IsSuccess || channelRequest.Entity == null)
+ throw new Exception("Failed to get Discord channel to dispatch parse failure notifications into.");
- var notified = new List();
- var channel = channelRequest.Entity;
- foreach (var failure in failures)
+ var notified = new List();
+ var channel = channelRequest.Entity;
+ foreach (var failure in failures)
+ {
+ // Attach text content of response where available
+ FileData fileData = null;
+ var messageSuffix = "The content of the response was missing or empty.";
+ if (failure.ResponseContent != null)
{
- // Attach text content of response where available
- FileData fileData = null;
- var messageSuffix = "The content of the response was missing or empty.";
- if (failure.ResponseContent != null)
- {
- var dataStream = new MemoryStream();
- var writer = new StreamWriter(dataStream);
- await writer.WriteAsync(failure.ResponseContent);
- dataStream.Seek(0, SeekOrigin.Begin);
- fileData = new FileData("response_content.txt", dataStream);
- messageSuffix = "The content of the response is attached to this message.";
- }
+ var dataStream = new MemoryStream();
+ var writer = new StreamWriter(dataStream);
+ await writer.WriteAsync(failure.ResponseContent);
+ dataStream.Seek(0, SeekOrigin.Begin);
+ fileData = new FileData("response_content.txt", dataStream);
+ messageSuffix = "The content of the response is attached to this message.";
+ }
- var message = new StringBuilder();
- if (_config.Value.FailureMention.HasValue)
- message.Append($"<@{_config.Value.FailureMention}> ");
- message.Append(
- $"Failed to parse bans for {failure.Parser} at , exception is as follows... ```");
+ var message = new StringBuilder();
+ if (_config.Value.FailureMention.HasValue)
+ message.Append($"<@{_config.Value.FailureMention}> ");
+ message.Append(
+ $"Failed to parse bans for {failure.Parser} at , exception is as follows... ```");
- // Ensure that our length fits
- var currLength = message.Length + failure.Exception.Length + messageSuffix.Length + 3;
- message.Append(currLength > 2000
- ? $"{failure.Exception[0..^(currLength - 2000 + 4)]}...```"
- : $"{failure.Exception}```");
+ // Ensure that our length fits
+ var currLength = message.Length + failure.Exception.Length + messageSuffix.Length + 3;
+ message.Append(currLength > 2000
+ ? $"{failure.Exception[..^(currLength - 2000 + 4)]}...```"
+ : $"{failure.Exception}```");
- // Add suffix
- message.Append(messageSuffix);
+ // Add suffix
+ message.Append(messageSuffix);
- // Try to send, only mark completed if successful
- var result = await _channelAPI.CreateMessageAsync(channel.ID, message.ToString(),
- file: fileData ?? new Optional());
- if (result.IsSuccess)
- notified.Add(new NotifiedFailure()
- {
- CheckHistory = failure,
- Timestamp = DateTimeOffset.UtcNow
- });
- }
-
- _dbContext.NotifiedFailures.AddRange(notified);
- await _dbContext.SaveChangesAsync();
+ // Try to send, only mark completed if successful
+ var attachments = new List> { fileData };
+ var result = await _channelAPI.CreateMessageAsync(channel.ID, message.ToString(),
+ attachments: attachments);
+ if (result.IsSuccess)
+ notified.Add(new NotifiedFailure
+ {
+ CheckHistory = failure,
+ Timestamp = DateTimeOffset.UtcNow
+ });
}
+
+ _dbContext.NotifiedFailures.AddRange(notified);
+ await _dbContext.SaveChangesAsync();
}
}
\ No newline at end of file
diff --git a/CentCom.Bot/Program.cs b/CentCom.Bot/Program.cs
index aad1659..4271d0c 100644
--- a/CentCom.Bot/Program.cs
+++ b/CentCom.Bot/Program.cs
@@ -16,108 +16,109 @@
using Remora.Discord.Hosting.Extensions;
using Serilog;
-namespace CentCom.Bot
+namespace CentCom.Bot;
+
+public class Program
{
- public class Program
+ public static Task Main(string[] args)
{
- public static Task Main(string[] args)
- {
- // Setup Serilog
- Log.Logger = new LoggerConfiguration()
- .Enrich.FromLogContext()
- .WriteTo.Logger(lc =>
- {
- lc.Filter.ByExcluding(
- "Contains(SourceContext, 'Quartz') and (@Level = 'Information')");
- lc.WriteTo.Console(
- outputTemplate:
- "[{Timestamp:HH:mm:ss} {Level:u3}] ({SourceContext}) {Message:lj}{NewLine}{Exception}");
- })
- .WriteTo.Logger(lc =>
- {
- lc.WriteTo.File(path: "centcom-discord-bot.txt",
- outputTemplate:
- "[{Timestamp:HH:mm:ss} {Level:u3}] ({SourceContext}) {Message:lj}{NewLine}{Exception}");
- })
- .CreateLogger();
-
- return CreateHostBuilder(args).RunConsoleAsync();
- }
-
- private static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
- .AddDiscordService(services =>
+ // Setup Serilog
+ Log.Logger = new LoggerConfiguration()
+ .Enrich.FromLogContext()
+ .WriteTo.Logger(lc =>
{
- var configuration = services.GetRequiredService();
- return configuration.GetValue("discord:token") ??
- throw new InvalidOperationException
- (
- "Failed to read Discord configuration, bot token not found in appsettings.json."
- );
+ lc.Filter.ByExcluding(
+ "Contains(SourceContext, 'Quartz') and (@Level = 'Information')");
+ lc.WriteTo.Console(
+ outputTemplate:
+ "[{Timestamp:HH:mm:ss} {Level:u3}] ({SourceContext}) {Message:lj}{NewLine}{Exception}");
})
- .ConfigureServices((_, services) =>
+ .WriteTo.Logger(lc =>
{
- // Add configuration
- var config = new ConfigurationBuilder()
- .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
- .AddCommandLine(args)
- .AddUserSecrets()
- .Build();
- services.AddSingleton(config);
+ lc.WriteTo.File(path: "centcom-discord-bot.txt",
+ outputTemplate:
+ "[{Timestamp:HH:mm:ss} {Level:u3}] ({SourceContext}) {Message:lj}{NewLine}{Exception}");
+ })
+ .CreateLogger();
- // Add Discord config
- services.AddOptions()
- .Bind(config.GetSection("discord"))
- .Validate(x => x.Token != null);
+ return CreateHostBuilder(args).RunConsoleAsync();
+ }
- // Get DB configuration
- var dbConfig = new DbConfig();
- config.Bind("dbConfig", dbConfig);
+ private static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
+ .AddDiscordService(services =>
+ {
+ var configuration = services.GetRequiredService();
+ return configuration.GetValue("discord:token") ??
+ throw new InvalidOperationException
+ (
+ "Failed to read Discord configuration, bot token not found in appsettings.json."
+ );
+ })
+ .ConfigureServices((_, services) =>
+ {
+ // Add configuration
+ var config = new ConfigurationBuilder()
+ .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
+ .AddCommandLine(args)
+ .AddUserSecrets()
+ .Build();
+ services.AddSingleton(config);
- // Add appropriate DB context
- if (dbConfig == null)
- {
- throw new Exception(
- "Failed to read DB configuration, please ensure you provide one in appsettings.json");
- }
+ // Add Discord config
+ services.AddOptions()
+ .Bind(config.GetSection("discord"))
+ .Validate(x => x.Token != null);
- switch (dbConfig.DbType)
- {
- case DbType.Postgres:
- services.AddDbContext();
- break;
- case DbType.MariaDB:
- services.AddDbContext();
- break;
- case DbType.MySql:
- services.AddDbContext();
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
+ // Get DB configuration
+ var dbConfig = new DbConfig();
+ config.Bind("dbConfig", dbConfig);
- // Add Quartz
- services.AddQuartz(q =>
- {
- q.UseMicrosoftDependencyInjectionJobFactory();
+ // Add appropriate DB context
+ if (dbConfig == null)
+ {
+ throw new Exception(
+ "Failed to read DB configuration, please ensure you provide one in appsettings.json");
+ }
- q.ScheduleJob(trigger =>
- trigger
- .StartNow()
- .WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()),
- job => job.WithIdentity("failed-parse"));
- });
- services.AddQuartzHostedService();
+ switch (dbConfig.DbType)
+ {
+ case DbType.Postgres:
+ services.AddDbContext();
+ break;
+ case DbType.MariaDB:
+ services.AddDbContext();
+ break;
+ case DbType.MySql:
+ services.AddDbContext();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
- // Add Quartz jobs
- services.AddTransient();
+ // Add Quartz
+ services.AddQuartz(q =>
+ {
+ q.UseMicrosoftDependencyInjectionJobFactory();
- // Add Discord commands
- services
- .AddDiscordCommands(true)
- .AddCommandGroup()
- .AddCommandGroup()
- .AddResponder();
- })
- .UseSerilog();
- }
+ q.ScheduleJob(trigger =>
+ trigger
+ .StartNow()
+ .WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()),
+ job => job.WithIdentity("failed-parse"));
+ });
+ services.AddQuartzHostedService();
+
+ // Add Quartz jobs
+ services.AddTransient();
+
+ // Add Discord commands
+ services
+ .AddDiscordCommands(true)
+ .AddCommandTree()
+ .WithCommandGroup()
+ .WithCommandGroup()
+ .Finish()
+ .AddResponder();
+ })
+ .UseSerilog();
}
\ No newline at end of file
diff --git a/CentCom.Bot/Responders/ServerJoinResponder.cs b/CentCom.Bot/Responders/ServerJoinResponder.cs
index b4130e9..fe09543 100644
--- a/CentCom.Bot/Responders/ServerJoinResponder.cs
+++ b/CentCom.Bot/Responders/ServerJoinResponder.cs
@@ -6,38 +6,37 @@
using Remora.Discord.Gateway.Responders;
using Remora.Results;
-namespace CentCom.Bot.Responders
+namespace CentCom.Bot.Responders;
+
+public class ServerJoinResponder : IResponder
{
- public class ServerJoinResponder : IResponder
+ private readonly ILogger _logger;
+ private readonly SlashService _slash;
+
+ public ServerJoinResponder(ILogger logger, SlashService slash)
{
- private readonly ILogger _logger;
- private readonly SlashService _slash;
+ _slash = slash;
+ _logger = logger;
+ }
- public ServerJoinResponder(ILogger logger, SlashService slash)
+ public async Task RespondAsync(IGuildCreate gatewayEvent,
+ CancellationToken ct = new CancellationToken())
+ {
+ var slashSupport = _slash.SupportsSlashCommands();
+ if (!slashSupport.IsSuccess)
{
- _slash = slash;
- _logger = logger;
+ _logger.LogWarning("The registered commands of the bot don't support slash commands: {Reason}",
+ slashSupport.Error?.Message);
+ return Result.FromError(slashSupport.Error);
}
-
- public async Task RespondAsync(IGuildCreate gatewayEvent,
- CancellationToken ct = new CancellationToken())
- {
- var slashSupport = _slash.SupportsSlashCommands();
- if (!slashSupport.IsSuccess)
- {
- _logger.LogWarning("The registered commands of the bot don't support slash commands: {Reason}",
- slashSupport.Error?.Message);
- return Result.FromError(slashSupport.Error);
- }
- var update = await _slash.UpdateSlashCommandsAsync(gatewayEvent.ID, ct);
- if (!update.IsSuccess)
- {
- _logger.LogWarning("Failed to update slash commands: {Reason}", update.Error?.Message);
- return Result.FromError(update.Error);
- }
-
- return Result.FromSuccess();
+ var update = await _slash.UpdateSlashCommandsAsync(gatewayEvent.ID, ct: ct);
+ if (!update.IsSuccess)
+ {
+ _logger.LogWarning("Failed to update slash commands: {Reason}", update.Error?.Message);
+ return Result.FromError(update.Error);
}
+
+ return Result.FromSuccess();
}
}
\ No newline at end of file
diff --git a/CentCom.Bot/VersionUtility.cs b/CentCom.Bot/VersionUtility.cs
index aa627c4..c7b8c68 100644
--- a/CentCom.Bot/VersionUtility.cs
+++ b/CentCom.Bot/VersionUtility.cs
@@ -1,12 +1,11 @@
using System;
using System.Reflection;
-namespace CentCom.Bot
+namespace CentCom.Bot;
+
+public static class VersionUtility
{
- public static class VersionUtility
- {
- private static Version ExecutingVersion => Assembly.GetExecutingAssembly().GetName().Version;
- public static string VersionNumber => ExecutingVersion.ToString(ExecutingVersion.Revision == 0 ? 3 : 4);
- public static string Version => $"CentCom.Bot v{VersionNumber}";
- }
+ private static Version ExecutingVersion => Assembly.GetExecutingAssembly().GetName().Version;
+ public static string VersionNumber => ExecutingVersion.ToString(ExecutingVersion.Revision == 0 ? 3 : 4);
+ public static string Version => $"CentCom.Bot v{VersionNumber}";
}
\ No newline at end of file
diff --git a/CentCom.Common/Abstract/ICKey.cs b/CentCom.Common/Abstract/ICKey.cs
index 4f37da4..865c181 100644
--- a/CentCom.Common/Abstract/ICKey.cs
+++ b/CentCom.Common/Abstract/ICKey.cs
@@ -1,13 +1,12 @@
-namespace CentCom.Common.Abstract
+namespace CentCom.Common.Abstract;
+
+///
+/// Representation of a BYOND canonical key, or ckey
+///
+public interface ICKey
{
///
- /// Representation of a BYOND canonical key, or ckey
+ /// The canonical key of the user, a sanitized string of a BYOND user's username (key)
///
- public interface ICKey
- {
- ///
- /// The canonical key of the user, a sanitized string of a BYOND user's username (key)
- ///
- public string CanonicalKey { get; }
- }
+ public string CanonicalKey { get; }
}
\ No newline at end of file
diff --git a/CentCom.Common/Abstract/IRestBan.cs b/CentCom.Common/Abstract/IRestBan.cs
index abe73d6..d0435eb 100644
--- a/CentCom.Common/Abstract/IRestBan.cs
+++ b/CentCom.Common/Abstract/IRestBan.cs
@@ -2,56 +2,55 @@
using System.Collections.Generic;
using CentCom.Common.Models;
-namespace CentCom.Common.Abstract
+namespace CentCom.Common.Abstract;
+
+///
+/// A standardized representation of a ban to be serialized
+///
+public interface IRestBan
{
///
- /// A standardized representation of a ban to be serialized
- ///
- public interface IRestBan
- {
- ///
- /// The ID of the ban in the source database
- ///
- public int Id { get; }
-
- ///
- /// The type of ban
- ///
- public BanType BanType { get; }
-
- ///
- /// The banned player's ckey
- ///
- public ICKey CKey { get; }
-
- ///
- /// The time at which the player was banned
- ///
- public DateTimeOffset BannedOn { get; }
-
- ///
- /// The player who placed the ban
- ///
- public ICKey BannedBy { get; }
-
- ///
- /// The reason for the ban
- ///
- public string Reason { get; }
-
- ///
- /// When the ban expires, permanent if absent
- ///
- public DateTimeOffset? Expires { get; }
-
- ///
- /// The player who lifted the ban
- ///
- public ICKey UnbannedBy { get; }
-
- ///
- /// The list of job bans, if present
- ///
- public IReadOnlyList JobBans { get; }
- }
+ /// The ID of the ban in the source database
+ ///
+ public int Id { get; }
+
+ ///
+ /// The type of ban
+ ///
+ public BanType BanType { get; }
+
+ ///
+ /// The banned player's ckey
+ ///
+ public ICKey CKey { get; }
+
+ ///
+ /// The time at which the player was banned
+ ///
+ public DateTimeOffset BannedOn { get; }
+
+ ///
+ /// The player who placed the ban
+ ///
+ public ICKey BannedBy { get; }
+
+ ///
+ /// The reason for the ban
+ ///
+ public string Reason { get; }
+
+ ///
+ /// When the ban expires, permanent if absent
+ ///
+ public DateTimeOffset? Expires { get; }
+
+ ///
+ /// The player who lifted the ban
+ ///
+ public ICKey UnbannedBy { get; }
+
+ ///
+ /// The list of job bans, if present
+ ///
+ public IReadOnlyList JobBans { get; }
}
\ No newline at end of file
diff --git a/CentCom.Common/Abstract/IRestJobBan.cs b/CentCom.Common/Abstract/IRestJobBan.cs
index edc5ae6..ff5a3f2 100644
--- a/CentCom.Common/Abstract/IRestJobBan.cs
+++ b/CentCom.Common/Abstract/IRestJobBan.cs
@@ -1,13 +1,12 @@
-namespace CentCom.Common.Abstract
+namespace CentCom.Common.Abstract;
+
+///
+/// A standardized representation of a job ban to be serialized
+///
+public interface IRestJobBan
{
///
- /// A standardized representation of a job ban to be serialized
+ /// The job from which the player was banned
///
- public interface IRestJobBan
- {
- ///
- /// The job from which the player was banned
- ///
- public string Job { get; }
- }
+ public string Job { get; }
}
\ No newline at end of file
diff --git a/CentCom.Common/CentCom.Common.csproj b/CentCom.Common/CentCom.Common.csproj
index 3204a65..c5dcc4f 100644
--- a/CentCom.Common/CentCom.Common.csproj
+++ b/CentCom.Common/CentCom.Common.csproj
@@ -1,20 +1,20 @@
- net5.0
- 1.3.16
+ net6.0
+ 1.4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/CentCom.Common/Configuration/DbConfig.cs b/CentCom.Common/Configuration/DbConfig.cs
index 3ba02d1..3807be0 100644
--- a/CentCom.Common/Configuration/DbConfig.cs
+++ b/CentCom.Common/Configuration/DbConfig.cs
@@ -1,25 +1,24 @@
-namespace CentCom.Common.Configuration
+namespace CentCom.Common.Configuration;
+
+public enum DbType
{
- public enum DbType
- {
- Postgres,
- MySql,
- MariaDB
- }
+ Postgres,
+ MySql,
+ MariaDB
+}
+///
+/// Configuration for a database to be used
+///
+public class DbConfig
+{
///
- /// Configuration for a database to be used
+ /// The SQL connection string for the database
///
- public class DbConfig
- {
- ///
- /// The SQL connection string for the database
- ///
- public string ConnectionString { get; set; }
+ public string ConnectionString { get; set; }
- ///
- /// The type of database, used for initializing data contexts
- ///
- public DbType DbType { get; set; }
- }
-}
+ ///
+ /// The type of database, used for initializing data contexts
+ ///
+ public DbType DbType { get; set; }
+}
\ No newline at end of file
diff --git a/CentCom.Common/Data/DatabaseContext.cs b/CentCom.Common/Data/DatabaseContext.cs
index 4740f99..fa2f563 100644
--- a/CentCom.Common/Data/DatabaseContext.cs
+++ b/CentCom.Common/Data/DatabaseContext.cs
@@ -6,100 +6,96 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data
+namespace CentCom.Common.Data;
+
+public abstract class DatabaseContext : DbContext
{
- public abstract class DatabaseContext : DbContext
+ protected readonly IConfiguration Configuration;
+
+ public DatabaseContext(IConfiguration configuration)
{
- protected readonly IConfiguration Configuration;
+ Configuration = configuration;
+ }
- public DatabaseContext(IConfiguration configuration)
- {
- Configuration = configuration;
- }
+ public DbSet Bans { get; set; }
+ public DbSet BanSources { get; set; }
+ public DbSet JobBans { get; set; }
+ public DbSet FlatBansVersion { get; set; }
+ public DbSet CheckHistory { get; set; }
+ public DbSet NotifiedFailures { get; set; }
- public DbSet Bans { get; set; }
- public DbSet BanSources { get; set; }
- public DbSet JobBans { get; set; }
- public DbSet FlatBansVersion { get; set; }
- public DbSet CheckHistory { get; set; }
- public DbSet NotifiedFailures { get; set; }
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
- protected override void OnModelCreating(ModelBuilder modelBuilder)
+ modelBuilder.Entity(entity =>
{
- base.OnModelCreating(modelBuilder);
-
- modelBuilder.Entity(entity =>
- {
- entity.HasKey(e => e.Id);
- entity.Property(e => e.Id).UseIdentityAlwaysColumn();
- entity.Property(e => e.CKey).IsRequired().HasMaxLength(32);
- entity.Property(e => e.Source).IsRequired();
- entity.Property(e => e.BannedOn).IsRequired()
- .HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc));
- entity.Property(e => e.Expires).HasConversion(v => v,
- v => v.HasValue ? DateTime.SpecifyKind(v.Value, DateTimeKind.Utc) : (DateTime?)null);
- entity.Property(e => e.BannedBy).IsRequired().HasMaxLength(32);
- entity.Property(e => e.UnbannedBy).HasMaxLength(32);
- entity.Property(e => e.BanType).IsRequired();
- entity.HasIndex(e => e.CKey);
- entity.HasMany(e => e.JobBans)
- .WithOne(b => b.BanNavigation)
- .HasForeignKey(b => b.BanId)
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity(entity =>
- {
- entity.HasKey(e => e.Id);
- entity.Property(e => e.Id).UseIdentityAlwaysColumn();
- entity.HasMany(e => e.Bans)
- .WithOne(b => b.SourceNavigation)
- .HasForeignKey(b => b.Source)
- .OnDelete(DeleteBehavior.Cascade);
- entity.HasIndex(e => e.Name).IsUnique(); // Force unique source names
- });
+ entity.HasKey(e => e.Id);
+ entity.Property(e => e.Id).UseIdentityAlwaysColumn();
+ entity.Property(e => e.CKey).IsRequired().HasMaxLength(32);
+ entity.Property(e => e.Source).IsRequired();
+ entity.Property(e => e.BannedOn).IsRequired();
+ entity.Property(e => e.Expires);
+ entity.Property(e => e.BannedBy).IsRequired().HasMaxLength(32);
+ entity.Property(e => e.UnbannedBy).HasMaxLength(32);
+ entity.Property(e => e.BanType).IsRequired();
+ entity.HasIndex(e => e.CKey);
+ entity.HasMany(e => e.JobBans)
+ .WithOne(b => b.BanNavigation)
+ .HasForeignKey(b => b.BanId)
+ .OnDelete(DeleteBehavior.Cascade);
+ });
- modelBuilder.Entity(entity => { entity.HasKey(e => new { e.BanId, e.Job }); });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id);
+ entity.Property(e => e.Id).UseIdentityAlwaysColumn();
+ entity.HasMany(e => e.Bans)
+ .WithOne(b => b.SourceNavigation)
+ .HasForeignKey(b => b.Source)
+ .OnDelete(DeleteBehavior.Cascade);
+ entity.HasIndex(e => e.Name).IsUnique(); // Force unique source names
+ });
- modelBuilder.Entity(entity =>
- {
- entity.HasKey(e => e.Id);
- entity.Property(e => e.Id).UseIdentityAlwaysColumn();
- entity.Property(e => e.Name).IsRequired();
- entity.Property(e => e.PerformedAt).IsRequired()
- .HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc));
- entity.Property(e => e.Version).IsRequired();
- entity.HasIndex(e => new { e.Name, e.Version }).IsUnique();
- });
+ modelBuilder.Entity(entity => { entity.HasKey(e => new { e.BanId, e.Job }); });
- modelBuilder.Entity(entity =>
- {
- entity.HasKey(e => e.Id);
- entity.Property(e => e.Id).UseIdentityAlwaysColumn();
- entity.Property(e => e.Parser).IsRequired();
- entity.HasIndex(e => new { e.Parser, e.Started });
- });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id);
+ entity.Property(e => e.Id).UseIdentityAlwaysColumn();
+ entity.Property(e => e.Name).IsRequired();
+ entity.Property(e => e.PerformedAt).IsRequired();
+ entity.Property(e => e.Version).IsRequired();
+ entity.HasIndex(e => new { e.Name, e.Version }).IsUnique();
+ });
- modelBuilder.Entity(entity =>
- {
- entity.HasKey(e => e.Id);
- entity.Property(e => e.Id).UseIdentityAlwaysColumn();
- entity.HasOne(e => e.CheckHistory)
- .WithOne(e => e.Notification)
- .HasForeignKey(e => e.CheckHistoryId);
- });
- }
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(e => e.Id);
+ entity.Property(e => e.Id).UseIdentityAlwaysColumn();
+ entity.Property(e => e.Parser).IsRequired();
+ entity.HasIndex(e => new { e.Parser, e.Started });
+ });
- public async Task Migrate(CancellationToken cancellationToken)
+ modelBuilder.Entity(entity =>
{
- var migrations = await Database.GetAppliedMigrationsAsync(cancellationToken);
- var wasEmpty = !migrations.Any();
- if (wasEmpty || (await Database.GetPendingMigrationsAsync(cancellationToken)).Any())
- {
- await Database.MigrateAsync(cancellationToken);
- }
+ entity.HasKey(e => e.Id);
+ entity.Property(e => e.Id).UseIdentityAlwaysColumn();
+ entity.HasOne(e => e.CheckHistory)
+ .WithOne(e => e.Notification)
+ .HasForeignKey(e => e.CheckHistoryId);
+ });
+ }
- return wasEmpty;
+ public async Task Migrate(CancellationToken cancellationToken)
+ {
+ var migrations = await Database.GetAppliedMigrationsAsync(cancellationToken);
+ var wasEmpty = !migrations.Any();
+ if (wasEmpty || (await Database.GetPendingMigrationsAsync(cancellationToken)).Any())
+ {
+ await Database.MigrateAsync(cancellationToken);
}
+
+ return wasEmpty;
}
}
\ No newline at end of file
diff --git a/CentCom.Common/Data/DesignTime/MariaDbContextFactory.cs b/CentCom.Common/Data/DesignTime/MariaDbContextFactory.cs
index afffe2f..9d05c4d 100644
--- a/CentCom.Common/Data/DesignTime/MariaDbContextFactory.cs
+++ b/CentCom.Common/Data/DesignTime/MariaDbContextFactory.cs
@@ -2,20 +2,19 @@
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data.DesignTime
+namespace CentCom.Common.Data.DesignTime;
+
+public class MariaDbContextFactory : IDesignTimeDbContextFactory
{
- public class MariaDbContextFactory : IDesignTimeDbContextFactory
+ public MariaDbContext CreateDbContext(string[] args)
{
- public MariaDbContext CreateDbContext(string[] args)
+ var conf = new Dictionary
{
- var conf = new Dictionary
- {
- { "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
- { "dbConfig:dbType", "MariaDb" },
- { "dbConfig:efcoreBuild", "any-value" }
- };
- IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
- return new MariaDbContext(spoofedConfig);
- }
+ { "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
+ { "dbConfig:dbType", "MariaDb" },
+ { "dbConfig:efcoreBuild", "any-value" }
+ };
+ IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
+ return new MariaDbContext(spoofedConfig);
}
}
\ No newline at end of file
diff --git a/CentCom.Common/Data/DesignTime/MySqlDbContextFactory.cs b/CentCom.Common/Data/DesignTime/MySqlDbContextFactory.cs
index fa4b6a0..c7ad86e 100644
--- a/CentCom.Common/Data/DesignTime/MySqlDbContextFactory.cs
+++ b/CentCom.Common/Data/DesignTime/MySqlDbContextFactory.cs
@@ -2,20 +2,19 @@
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data.DesignTime
+namespace CentCom.Common.Data.DesignTime;
+
+class MySqlDbContextFactory : IDesignTimeDbContextFactory
{
- class MySqlDbContextFactory : IDesignTimeDbContextFactory
+ public MySqlDbContext CreateDbContext(string[] args)
{
- public MySqlDbContext CreateDbContext(string[] args)
+ var conf = new Dictionary
{
- var conf = new Dictionary
- {
- { "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
- { "dbConfig:dbType", "MySql" },
- { "dbConfig:efcoreBuild", "any-value" }
- };
- IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
- return new MySqlDbContext(spoofedConfig);
- }
+ { "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
+ { "dbConfig:dbType", "MySql" },
+ { "dbConfig:efcoreBuild", "any-value" }
+ };
+ IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
+ return new MySqlDbContext(spoofedConfig);
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Data/DesignTime/NpgsqlDbContextFactory.cs b/CentCom.Common/Data/DesignTime/NpgsqlDbContextFactory.cs
index 1adcaae..d3e60c6 100644
--- a/CentCom.Common/Data/DesignTime/NpgsqlDbContextFactory.cs
+++ b/CentCom.Common/Data/DesignTime/NpgsqlDbContextFactory.cs
@@ -2,19 +2,18 @@
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data.DesignTime
+namespace CentCom.Common.Data.DesignTime;
+
+public class NpgsqlDbContextFactory : IDesignTimeDbContextFactory
{
- public class NpgsqlDbContextFactory : IDesignTimeDbContextFactory
+ public NpgsqlDbContext CreateDbContext(string[] args)
{
- public NpgsqlDbContext CreateDbContext(string[] args)
+ var conf = new Dictionary
{
- var conf = new Dictionary
- {
- { "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
- { "dbConfig:dbType", "Postgres" }
- };
- IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
- return new NpgsqlDbContext(spoofedConfig);
- }
+ { "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
+ { "dbConfig:dbType", "Postgres" }
+ };
+ IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
+ return new NpgsqlDbContext(spoofedConfig);
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Data/MariaDbContext.cs b/CentCom.Common/Data/MariaDbContext.cs
index b7b7a90..624c09f 100644
--- a/CentCom.Common/Data/MariaDbContext.cs
+++ b/CentCom.Common/Data/MariaDbContext.cs
@@ -1,21 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data
+namespace CentCom.Common.Data;
+
+public class MariaDbContext : DatabaseContext
{
- public class MariaDbContext : DatabaseContext
+ public MariaDbContext(IConfiguration configuration) : base(configuration)
{
- public MariaDbContext(IConfiguration configuration) : base(configuration)
- {
- }
+ }
- protected override void OnConfiguring(DbContextOptionsBuilder options)
- {
- var connStr = Configuration.GetSection("dbConfig")["connectionString"];
- var efcoreBuild =
- Configuration.GetSection("dbConfig")["efcoreBuild"] != null; // Used for building migrations
- options.UseMySql(connStr,
- efcoreBuild ? MariaDbServerVersion.LatestSupportedServerVersion : ServerVersion.AutoDetect(connStr));
- }
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ {
+ var connStr = Configuration.GetSection("dbConfig")["connectionString"];
+ var efcoreBuild =
+ Configuration.GetSection("dbConfig")["efcoreBuild"] != null; // Used for building migrations
+ options.UseMySql(connStr,
+ efcoreBuild ? MariaDbServerVersion.LatestSupportedServerVersion : ServerVersion.AutoDetect(connStr));
}
}
\ No newline at end of file
diff --git a/CentCom.Common/Data/MySqlDbContext.cs b/CentCom.Common/Data/MySqlDbContext.cs
index e136f48..fafd988 100644
--- a/CentCom.Common/Data/MySqlDbContext.cs
+++ b/CentCom.Common/Data/MySqlDbContext.cs
@@ -1,21 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data
+namespace CentCom.Common.Data;
+
+public sealed class MySqlDbContext : DatabaseContext
{
- public sealed class MySqlDbContext : DatabaseContext
+ public MySqlDbContext(IConfiguration configuration) : base(configuration)
{
- public MySqlDbContext(IConfiguration configuration) : base(configuration)
- {
- }
+ }
- protected override void OnConfiguring(DbContextOptionsBuilder options)
- {
- var connStr = Configuration.GetSection("dbConfig")["connectionString"];
- var efcoreBuild =
- Configuration.GetSection("dbConfig")["efcoreBuild"] != null; // Used for building migrations
- options.UseMySql(connStr,
- efcoreBuild ? MySqlServerVersion.LatestSupportedServerVersion : ServerVersion.AutoDetect(connStr));
- }
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ {
+ var connStr = Configuration.GetSection("dbConfig")["connectionString"];
+ var efcoreBuild =
+ Configuration.GetSection("dbConfig")["efcoreBuild"] != null; // Used for building migrations
+ options.UseMySql(connStr,
+ efcoreBuild ? MySqlServerVersion.LatestSupportedServerVersion : ServerVersion.AutoDetect(connStr));
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Data/NpgsqlDbContext.cs b/CentCom.Common/Data/NpgsqlDbContext.cs
index 4c0dcfe..00acb1f 100644
--- a/CentCom.Common/Data/NpgsqlDbContext.cs
+++ b/CentCom.Common/Data/NpgsqlDbContext.cs
@@ -1,19 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
-namespace CentCom.Common.Data
+namespace CentCom.Common.Data;
+
+public sealed class NpgsqlDbContext : DatabaseContext
{
- public sealed class NpgsqlDbContext : DatabaseContext
+ public NpgsqlDbContext(IConfiguration configuration) : base(configuration)
{
- public NpgsqlDbContext(IConfiguration configuration) : base(configuration)
- {
- }
+ }
- protected override void OnConfiguring(DbContextOptionsBuilder options)
- {
- options.UseNpgsql(Configuration.GetSection("dbConfig")["connectionString"])
- .UseSnakeCaseNamingConvention();
- }
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ {
+ options.UseNpgsql(Configuration.GetSection("dbConfig")["connectionString"])
+ .UseSnakeCaseNamingConvention();
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Extensions/BanExtensions.cs b/CentCom.Common/Extensions/BanExtensions.cs
index ad89bce..88a13de 100644
--- a/CentCom.Common/Extensions/BanExtensions.cs
+++ b/CentCom.Common/Extensions/BanExtensions.cs
@@ -1,51 +1,50 @@
using System.Collections.Generic;
using CentCom.Common.Models;
-namespace CentCom.Common.Extensions
+namespace CentCom.Common.Extensions;
+
+public static class BanExtensions
{
- public static class BanExtensions
+ public static void MakeKeysCanonical(this Ban ban)
{
- public static void MakeKeysCanonical(this Ban ban)
- {
- ban.CKey = ban.CKey == null ? null : KeyUtilities.GetCanonicalKey(ban.CKey);
- ban.BannedBy = ban.BannedBy == null ? null : KeyUtilities.GetCanonicalKey(ban.BannedBy);
- ban.UnbannedBy = ban.UnbannedBy == null ? null : KeyUtilities.GetCanonicalKey(ban.UnbannedBy);
- }
+ ban.CKey = ban.CKey == null ? null : KeyUtilities.GetCanonicalKey(ban.CKey);
+ ban.BannedBy = ban.BannedBy == null ? null : KeyUtilities.GetCanonicalKey(ban.BannedBy);
+ ban.UnbannedBy = ban.UnbannedBy == null ? null : KeyUtilities.GetCanonicalKey(ban.UnbannedBy);
+ }
- public static string CleanJob(string job)
- {
- return job.ToLower();
- }
+ public static string CleanJob(string job)
+ {
+ return job.ToLower();
+ }
- public static bool AddJob(this Ban ban, string job)
- {
- return ban.JobBans.Add(new JobBan() { Job = CleanJob(job), BanId = ban.Id, BanNavigation = ban });
- }
+ public static bool AddJob(this Ban ban, string job)
+ {
+ return ban.JobBans.Add(new JobBan { Job = CleanJob(job), BanId = ban.Id, BanNavigation = ban });
+ }
- public static void AddJobRange(this Ban ban, IEnumerable jobs)
+ public static void AddJobRange(this Ban ban, IEnumerable jobs)
+ {
+ foreach (var job in jobs)
{
- foreach (var job in jobs)
- {
- ban.AddJob(job);
- }
+ ban.AddJob(job);
}
+ }
- public static void AddAttribute(this Ban ban, BanAttribute attribute)
- {
- ban.BanAttributes |= attribute;
- }
+ public static void AddAttribute(this Ban ban, BanAttribute attribute)
+ {
+ ban.BanAttributes |= attribute;
+ }
- public static void AddAttributeRange(this Ban ban, IEnumerable attributes)
+ public static void AddAttributeRange(this Ban ban, IEnumerable attributes)
+ {
+ foreach (var attribute in attributes)
{
- foreach (var attribute in attributes)
- {
- ban.BanAttributes |= attribute;
- }
+ ban.BanAttributes |= attribute;
}
+ }
- public static void RemoveAttribute(this Ban ban, BanAttribute attribute)
- {
- ban.BanAttributes &= ~attribute;
- }
+ public static void RemoveAttribute(this Ban ban, BanAttribute attribute)
+ {
+ ban.BanAttributes &= ~attribute;
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Extensions/CentComSerializationExtensions.cs b/CentCom.Common/Extensions/CentComSerializationExtensions.cs
index 4b7dde8..45b177c 100644
--- a/CentCom.Common/Extensions/CentComSerializationExtensions.cs
+++ b/CentCom.Common/Extensions/CentComSerializationExtensions.cs
@@ -3,31 +3,30 @@
using CentCom.Common.Json;
using CentCom.Common.Models.Rest;
using Microsoft.Extensions.DependencyInjection;
-using Remora.Discord.API.Extensions;
+using Remora.Rest.Extensions;
-namespace CentCom.Common.Extensions
-{
- ///
- /// Extension methods used to add JSON serialization options to support serialization of ICKey, IRestBan, and
- /// IRestJobBan objects
- ///
- public static class CentComSerializationExtensions
- {
- public static IServiceCollection AddCentComSerialization(this IServiceCollection services)
- => services.Configure(options =>
- {
- options.AddCentComOptions();
- options.AddDataObjectConverter();
- options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
- });
+namespace CentCom.Common.Extensions;
- public static JsonSerializerOptions AddCentComOptions(this JsonSerializerOptions options)
+///
+/// Extension methods used to add JSON serialization options to support serialization of ICKey, IRestBan, and
+/// IRestJobBan objects
+///
+public static class CentComSerializationExtensions
+{
+ public static IServiceCollection AddCentComSerialization(this IServiceCollection services)
+ => services.Configure(options =>
{
- options
- .AddConverter()
- .AddConverter();
+ options.AddCentComOptions();
+ options.AddDataObjectConverter();
+ options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
+ });
+
+ public static JsonSerializerOptions AddCentComOptions(this JsonSerializerOptions options)
+ {
+ options
+ .AddConverter()
+ .AddConverter();
- return options;
- }
+ return options;
}
}
\ No newline at end of file
diff --git a/CentCom.Common/Json/CKeyStringConverter.cs b/CentCom.Common/Json/CKeyStringConverter.cs
index 441c733..61f041d 100644
--- a/CentCom.Common/Json/CKeyStringConverter.cs
+++ b/CentCom.Common/Json/CKeyStringConverter.cs
@@ -4,21 +4,20 @@
using CentCom.Common.Abstract;
using CentCom.Common.Models.Byond;
-namespace CentCom.Common.Json
+namespace CentCom.Common.Json;
+
+///
+/// Converter to serialize and deserialize ckeys as strings
+///
+public class CKeyStringConverter : JsonConverter
{
- ///
- /// Converter to serialize and deserialize ckeys as strings
- ///
- public class CKeyStringConverter : JsonConverter
+ public override ICKey Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
- public override ICKey Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- return (CKey)reader.GetString();
- }
+ return (CKey)reader.GetString();
+ }
- public override void Write(Utf8JsonWriter writer, ICKey value, JsonSerializerOptions options)
- {
- writer.WriteStringValue(value.CanonicalKey);
- }
+ public override void Write(Utf8JsonWriter writer, ICKey value, JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value.CanonicalKey);
}
}
\ No newline at end of file
diff --git a/CentCom.Common/Json/JobBanCollectionConverter.cs b/CentCom.Common/Json/JobBanCollectionConverter.cs
index a102dcd..793ce8e 100644
--- a/CentCom.Common/Json/JobBanCollectionConverter.cs
+++ b/CentCom.Common/Json/JobBanCollectionConverter.cs
@@ -5,47 +5,46 @@
using CentCom.Common.Abstract;
using CentCom.Common.Models.Rest;
-namespace CentCom.Common.Json
+namespace CentCom.Common.Json;
+
+///
+/// Converter to serialize and deserialize collections of job bans into arrays of strings
+///
+public class JobBanCollectionConverter : JsonConverter>
{
- ///
- /// Converter to serialize and deserialize collections of job bans into arrays of strings
- ///
- public class JobBanCollectionConverter : JsonConverter>
+ public override IReadOnlyList Read(ref Utf8JsonReader reader, Type typeToConvert,
+ JsonSerializerOptions options)
{
- public override IReadOnlyList Read(ref Utf8JsonReader reader, Type typeToConvert,
- JsonSerializerOptions options)
+ var toReturn = new List();
+ do
{
- var toReturn = new List();
- do
- {
- if (reader.TokenType == JsonTokenType.StartArray)
- continue;
- if (reader.TokenType == JsonTokenType.EndArray || reader.TokenType == JsonTokenType.Null)
- break;
- RestJobBan job = reader.GetString();
- if (job != null)
- toReturn.Add(job);
- } while (reader.Read());
+ if (reader.TokenType == JsonTokenType.StartArray)
+ continue;
+ if (reader.TokenType == JsonTokenType.EndArray || reader.TokenType == JsonTokenType.Null)
+ break;
+ RestJobBan job = reader.GetString();
+ if (job != null)
+ toReturn.Add(job);
+ } while (reader.Read());
- return toReturn;
- }
+ return toReturn;
+ }
- public override void Write(Utf8JsonWriter writer, IReadOnlyList value,
- JsonSerializerOptions options)
+ public override void Write(Utf8JsonWriter writer, IReadOnlyList value,
+ JsonSerializerOptions options)
+ {
+ if (value == null)
{
- if (value == null)
- {
- writer.WriteNullValue();
- return;
- }
-
- writer.WriteStartArray();
- foreach (var job in value)
- {
- writer.WriteStringValue(job.Job);
- }
+ writer.WriteNullValue();
+ return;
+ }
- writer.WriteEndArray();
+ writer.WriteStartArray();
+ foreach (var job in value)
+ {
+ writer.WriteStringValue(job.Job);
}
+
+ writer.WriteEndArray();
}
}
\ No newline at end of file
diff --git a/CentCom.Common/KeyUtilities.cs b/CentCom.Common/KeyUtilities.cs
index 70ffadf..2f84538 100644
--- a/CentCom.Common/KeyUtilities.cs
+++ b/CentCom.Common/KeyUtilities.cs
@@ -1,29 +1,28 @@
using System;
using System.Text.RegularExpressions;
-namespace CentCom.Common
+namespace CentCom.Common;
+
+///
+/// Contains utilities for interacting with BYOND keys
+///
+public static class KeyUtilities
{
+ private static readonly Regex KeyReplacePattern = new Regex(@"[^a-z0-9]", RegexOptions.Compiled);
+
///
- /// Contains utilities for interacting with BYOND keys
+ /// Sanitizes a BYOND key into a valid ckey
///
- public static class KeyUtilities
+ /// The raw key to be sanitized
+ /// A sanitized BYOND canonical key
+ /// Null key provided
+ public static string GetCanonicalKey(string raw)
{
- private static readonly Regex KeyReplacePattern = new Regex(@"[^a-z0-9]", RegexOptions.Compiled);
-
- ///
- /// Sanitizes a BYOND key into a valid ckey
- ///
- /// The raw key to be sanitized
- /// A sanitized BYOND canonical key
- /// Null key provided
- public static string GetCanonicalKey(string raw)
+ if (raw == null)
{
- if (raw == null)
- {
- throw new ArgumentNullException(nameof(raw));
- }
-
- return KeyReplacePattern.Replace(raw.ToLower(), "");
+ throw new ArgumentNullException(nameof(raw));
}
+
+ return KeyReplacePattern.Replace(raw.ToLower(), "");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MariaDb/20210819220930_AddCheckHistory.cs b/CentCom.Common/Migrations/MariaDb/20210819220930_AddCheckHistory.cs
index fb0c0b6..1b0b6c0 100644
--- a/CentCom.Common/Migrations/MariaDb/20210819220930_AddCheckHistory.cs
+++ b/CentCom.Common/Migrations/MariaDb/20210819220930_AddCheckHistory.cs
@@ -2,16 +2,16 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MariaDb
+namespace CentCom.Common.Migrations.MariaDb;
+
+public partial class AddCheckHistory : Migration
{
- public partial class AddCheckHistory : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterDatabase()
- .Annotation("MySql:CharSet", "utf8mb4");
+ migrationBuilder.AlterDatabase()
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "BanSources",
columns: table => new
{
@@ -27,9 +27,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
table.PrimaryKey("PK_BanSources", x => x.Id);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "CheckHistory",
columns: table => new
{
@@ -54,9 +54,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
table.PrimaryKey("PK_CheckHistory", x => x.Id);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "FlatBansVersion",
columns: table => new
{
@@ -71,9 +71,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
table.PrimaryKey("PK_FlatBansVersion", x => x.Id);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "Bans",
columns: table => new
{
@@ -105,9 +105,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "JobBans",
columns: table => new
{
@@ -125,46 +125,45 @@ protected override void Up(MigrationBuilder migrationBuilder)
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
- .Annotation("MySql:CharSet", "utf8mb4");
-
- migrationBuilder.CreateIndex(
- name: "IX_Bans_CKey",
- table: "Bans",
- column: "CKey");
-
- migrationBuilder.CreateIndex(
- name: "IX_Bans_Source",
- table: "Bans",
- column: "Source");
-
- migrationBuilder.CreateIndex(
- name: "IX_CheckHistory_Parser_Started",
- table: "CheckHistory",
- columns: new[] { "Parser", "Started" });
-
- migrationBuilder.CreateIndex(
- name: "IX_FlatBansVersion_Name_Version",
- table: "FlatBansVersion",
- columns: new[] { "Name", "Version" },
- unique: true);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "CheckHistory");
-
- migrationBuilder.DropTable(
- name: "FlatBansVersion");
-
- migrationBuilder.DropTable(
- name: "JobBans");
-
- migrationBuilder.DropTable(
- name: "Bans");
-
- migrationBuilder.DropTable(
- name: "BanSources");
- }
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Bans_CKey",
+ table: "Bans",
+ column: "CKey");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Bans_Source",
+ table: "Bans",
+ column: "Source");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_CheckHistory_Parser_Started",
+ table: "CheckHistory",
+ columns: new[] { "Parser", "Started" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_FlatBansVersion_Name_Version",
+ table: "FlatBansVersion",
+ columns: new[] { "Name", "Version" },
+ unique: true);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "CheckHistory");
+
+ migrationBuilder.DropTable(
+ name: "FlatBansVersion");
+
+ migrationBuilder.DropTable(
+ name: "JobBans");
+
+ migrationBuilder.DropTable(
+ name: "Bans");
+
+ migrationBuilder.DropTable(
+ name: "BanSources");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MariaDb/20210820052648_AddBotNotifications.cs b/CentCom.Common/Migrations/MariaDb/20210820052648_AddBotNotifications.cs
index 155f31d..206c105 100644
--- a/CentCom.Common/Migrations/MariaDb/20210820052648_AddBotNotifications.cs
+++ b/CentCom.Common/Migrations/MariaDb/20210820052648_AddBotNotifications.cs
@@ -2,13 +2,13 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MariaDb
+namespace CentCom.Common.Migrations.MariaDb;
+
+public partial class AddBotNotifications : Migration
{
- public partial class AddBotNotifications : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "NotifiedFailures",
columns: table => new
{
@@ -27,19 +27,18 @@ protected override void Up(MigrationBuilder migrationBuilder)
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateIndex(
- name: "IX_NotifiedFailures_CheckHistoryId",
- table: "NotifiedFailures",
- column: "CheckHistoryId",
- unique: true);
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_NotifiedFailures_CheckHistoryId",
+ table: "NotifiedFailures",
+ column: "CheckHistoryId",
+ unique: true);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "NotifiedFailures");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "NotifiedFailures");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MariaDb/20210820072851_AddExceptionDetails.cs b/CentCom.Common/Migrations/MariaDb/20210820072851_AddExceptionDetails.cs
index e01f938..3e413a6 100644
--- a/CentCom.Common/Migrations/MariaDb/20210820072851_AddExceptionDetails.cs
+++ b/CentCom.Common/Migrations/MariaDb/20210820072851_AddExceptionDetails.cs
@@ -1,24 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MariaDb
+namespace CentCom.Common.Migrations.MariaDb;
+
+public partial class AddExceptionDetails : Migration
{
- public partial class AddExceptionDetails : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "ExceptionDetailed",
table: "CheckHistory",
type: "longtext",
nullable: true)
- .Annotation("MySql:CharSet", "utf8mb4");
- }
+ .Annotation("MySql:CharSet", "utf8mb4");
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "ExceptionDetailed",
- table: "CheckHistory");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "ExceptionDetailed",
+ table: "CheckHistory");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MariaDb/20210821145930_UniqueSourceNames.cs b/CentCom.Common/Migrations/MariaDb/20210821145930_UniqueSourceNames.cs
index 4262a0f..7c1542d 100644
--- a/CentCom.Common/Migrations/MariaDb/20210821145930_UniqueSourceNames.cs
+++ b/CentCom.Common/Migrations/MariaDb/20210821145930_UniqueSourceNames.cs
@@ -1,12 +1,12 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MariaDb
+namespace CentCom.Common.Migrations.MariaDb;
+
+public partial class UniqueSourceNames : Migration
{
- public partial class UniqueSourceNames : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Name",
table: "BanSources",
type: "varchar(255)",
@@ -14,23 +14,23 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateIndex(
- name: "IX_BanSources_Name",
- table: "BanSources",
- column: "Name",
- unique: true);
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_BanSources_Name",
+ table: "BanSources",
+ column: "Name",
+ unique: true);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropIndex(
- name: "IX_BanSources_Name",
- table: "BanSources");
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_BanSources_Name",
+ table: "BanSources");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Name",
table: "BanSources",
type: "longtext",
@@ -38,8 +38,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "varchar(255)",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
- }
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MariaDb/20210823002811_FailedResponseContent.cs b/CentCom.Common/Migrations/MariaDb/20210823002811_FailedResponseContent.cs
index 9d8198b..7660dc6 100644
--- a/CentCom.Common/Migrations/MariaDb/20210823002811_FailedResponseContent.cs
+++ b/CentCom.Common/Migrations/MariaDb/20210823002811_FailedResponseContent.cs
@@ -1,24 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MariaDb
+namespace CentCom.Common.Migrations.MariaDb;
+
+public partial class FailedResponseContent : Migration
{
- public partial class FailedResponseContent : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "ResponseContent",
table: "CheckHistory",
type: "longtext",
nullable: true)
- .Annotation("MySql:CharSet", "utf8mb4");
- }
+ .Annotation("MySql:CharSet", "utf8mb4");
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "ResponseContent",
- table: "CheckHistory");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "ResponseContent",
+ table: "CheckHistory");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MariaDb/MariaDbContextModelSnapshot.cs b/CentCom.Common/Migrations/MariaDb/MariaDbContextModelSnapshot.cs
index e6f3275..943e58b 100644
--- a/CentCom.Common/Migrations/MariaDb/MariaDbContextModelSnapshot.cs
+++ b/CentCom.Common/Migrations/MariaDb/MariaDbContextModelSnapshot.cs
@@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+#nullable disable
+
namespace CentCom.Common.Migrations.MariaDb
{
[DbContext(typeof(MariaDbContext))]
@@ -15,8 +17,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("Relational:MaxIdentifierLength", 64)
- .HasAnnotation("ProductVersion", "5.0.9");
+ .HasAnnotation("ProductVersion", "6.0.6")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("CentCom.Common.Models.Ban", b =>
{
diff --git a/CentCom.Common/Migrations/MySql/20200729172826_InitialCreate.cs b/CentCom.Common/Migrations/MySql/20200729172826_InitialCreate.cs
index d5bd7a4..c8ef020 100644
--- a/CentCom.Common/Migrations/MySql/20200729172826_InitialCreate.cs
+++ b/CentCom.Common/Migrations/MySql/20200729172826_InitialCreate.cs
@@ -2,95 +2,94 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class InitialCreate : Migration
{
- public partial class InitialCreate : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "BanSources",
- columns: table => new
- {
- Id = table.Column(nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- Name = table.Column(nullable: true),
- Display = table.Column(nullable: true),
- RoleplayLevel = table.Column(nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_BanSources", x => x.Id);
- });
+ migrationBuilder.CreateTable(
+ name: "BanSources",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(nullable: true),
+ Display = table.Column(nullable: true),
+ RoleplayLevel = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_BanSources", x => x.Id);
+ });
- migrationBuilder.CreateTable(
- name: "Bans",
- columns: table => new
- {
- Id = table.Column(nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- Source = table.Column(nullable: false),
- BanType = table.Column(nullable: false),
- CKey = table.Column(maxLength: 32, nullable: false),
- BannedOn = table.Column(nullable: false),
- BannedBy = table.Column(maxLength: 32, nullable: false),
- Reason = table.Column(nullable: true),
- Expires = table.Column(nullable: true),
- UnbannedBy = table.Column(maxLength: 32, nullable: true),
- IP = table.Column(nullable: true),
- CID = table.Column(nullable: true),
- BanID = table.Column(nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Bans", x => x.Id);
- table.ForeignKey(
- name: "FK_Bans_BanSources_Source",
- column: x => x.Source,
- principalTable: "BanSources",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- });
+ migrationBuilder.CreateTable(
+ name: "Bans",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ Source = table.Column(nullable: false),
+ BanType = table.Column(nullable: false),
+ CKey = table.Column(maxLength: 32, nullable: false),
+ BannedOn = table.Column(nullable: false),
+ BannedBy = table.Column(maxLength: 32, nullable: false),
+ Reason = table.Column(nullable: true),
+ Expires = table.Column(nullable: true),
+ UnbannedBy = table.Column(maxLength: 32, nullable: true),
+ IP = table.Column(nullable: true),
+ CID = table.Column(nullable: true),
+ BanID = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Bans", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Bans_BanSources_Source",
+ column: x => x.Source,
+ principalTable: "BanSources",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
- migrationBuilder.CreateTable(
- name: "JobBans",
- columns: table => new
- {
- BanId = table.Column(nullable: false),
- Job = table.Column(nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_JobBans", x => new { x.BanId, x.Job });
- table.ForeignKey(
- name: "FK_JobBans_Bans_BanId",
- column: x => x.BanId,
- principalTable: "Bans",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
+ migrationBuilder.CreateTable(
+ name: "JobBans",
+ columns: table => new
+ {
+ BanId = table.Column(nullable: false),
+ Job = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_JobBans", x => new { x.BanId, x.Job });
+ table.ForeignKey(
+ name: "FK_JobBans_Bans_BanId",
+ column: x => x.BanId,
+ principalTable: "Bans",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
- migrationBuilder.CreateIndex(
- name: "IX_Bans_CKey",
- table: "Bans",
- column: "CKey");
+ migrationBuilder.CreateIndex(
+ name: "IX_Bans_CKey",
+ table: "Bans",
+ column: "CKey");
- migrationBuilder.CreateIndex(
- name: "IX_Bans_Source",
- table: "Bans",
- column: "Source");
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_Bans_Source",
+ table: "Bans",
+ column: "Source");
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "JobBans");
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "JobBans");
- migrationBuilder.DropTable(
- name: "Bans");
+ migrationBuilder.DropTable(
+ name: "Bans");
- migrationBuilder.DropTable(
- name: "BanSources");
- }
+ migrationBuilder.DropTable(
+ name: "BanSources");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20200730015336_UpdateBanSourceDeleteCascading.cs b/CentCom.Common/Migrations/MySql/20200730015336_UpdateBanSourceDeleteCascading.cs
index 029c313..2a41d98 100644
--- a/CentCom.Common/Migrations/MySql/20200730015336_UpdateBanSourceDeleteCascading.cs
+++ b/CentCom.Common/Migrations/MySql/20200730015336_UpdateBanSourceDeleteCascading.cs
@@ -1,37 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class UpdateBanSourceDeleteCascading : Migration
{
- public partial class UpdateBanSourceDeleteCascading : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Bans_BanSources_Source",
- table: "Bans");
+ migrationBuilder.DropForeignKey(
+ name: "FK_Bans_BanSources_Source",
+ table: "Bans");
- migrationBuilder.AddForeignKey(
- name: "FK_Bans_BanSources_Source",
- table: "Bans",
- column: "Source",
- principalTable: "BanSources",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
+ migrationBuilder.AddForeignKey(
+ name: "FK_Bans_BanSources_Source",
+ table: "Bans",
+ column: "Source",
+ principalTable: "BanSources",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropForeignKey(
- name: "FK_Bans_BanSources_Source",
- table: "Bans");
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Bans_BanSources_Source",
+ table: "Bans");
- migrationBuilder.AddForeignKey(
- name: "FK_Bans_BanSources_Source",
- table: "Bans",
- column: "Source",
- principalTable: "BanSources",
- principalColumn: "Id",
- onDelete: ReferentialAction.Restrict);
- }
+ migrationBuilder.AddForeignKey(
+ name: "FK_Bans_BanSources_Source",
+ table: "Bans",
+ column: "Source",
+ principalTable: "BanSources",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20200801000735_AddFlatFileVersioning.cs b/CentCom.Common/Migrations/MySql/20200801000735_AddFlatFileVersioning.cs
index 9864b95..a4d146d 100644
--- a/CentCom.Common/Migrations/MySql/20200801000735_AddFlatFileVersioning.cs
+++ b/CentCom.Common/Migrations/MySql/20200801000735_AddFlatFileVersioning.cs
@@ -2,38 +2,37 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class AddFlatFileVersioning : Migration
{
- public partial class AddFlatFileVersioning : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "FlatBansVersion",
- columns: table => new
- {
- Id = table.Column(nullable: false)
- .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
- Name = table.Column(nullable: false),
- Version = table.Column(nullable: false),
- PerformedAt = table.Column(nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_FlatBansVersion", x => x.Id);
- });
+ migrationBuilder.CreateTable(
+ name: "FlatBansVersion",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ Name = table.Column(nullable: false),
+ Version = table.Column(nullable: false),
+ PerformedAt = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_FlatBansVersion", x => x.Id);
+ });
- migrationBuilder.CreateIndex(
- name: "IX_FlatBansVersion_Name_Version",
- table: "FlatBansVersion",
- columns: new[] { "Name", "Version" },
- unique: true);
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_FlatBansVersion_Name_Version",
+ table: "FlatBansVersion",
+ columns: new[] { "Name", "Version" },
+ unique: true);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "FlatBansVersion");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "FlatBansVersion");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20200816155107_RemoveCIDAndIP.cs b/CentCom.Common/Migrations/MySql/20200816155107_RemoveCIDAndIP.cs
index f267334..e2c3dad 100644
--- a/CentCom.Common/Migrations/MySql/20200816155107_RemoveCIDAndIP.cs
+++ b/CentCom.Common/Migrations/MySql/20200816155107_RemoveCIDAndIP.cs
@@ -1,37 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class RemoveCIDAndIP : Migration
{
- public partial class RemoveCIDAndIP : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "CID",
- table: "Bans");
+ migrationBuilder.DropColumn(
+ name: "CID",
+ table: "Bans");
- migrationBuilder.DropColumn(
- name: "IP",
- table: "Bans");
+ migrationBuilder.DropColumn(
+ name: "IP",
+ table: "Bans");
- migrationBuilder.Sql("UPDATE BanSources SET RoleplayLevel = 2 WHERE Name = 'fulp'");
- }
+ migrationBuilder.Sql("UPDATE BanSources SET RoleplayLevel = 2 WHERE Name = 'fulp'");
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
- name: "CID",
- table: "Bans",
- type: "bigint",
- nullable: true);
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "CID",
+ table: "Bans",
+ type: "bigint",
+ nullable: true);
- migrationBuilder.AddColumn(
- name: "IP",
- table: "Bans",
- type: "longtext CHARACTER SET utf8mb4",
- nullable: true);
+ migrationBuilder.AddColumn(
+ name: "IP",
+ table: "Bans",
+ type: "longtext CHARACTER SET utf8mb4",
+ nullable: true);
- migrationBuilder.Sql("UPDATE BanSources SET RoleplayLevel = 1 WHERE Name = 'fulp'");
- }
+ migrationBuilder.Sql("UPDATE BanSources SET RoleplayLevel = 1 WHERE Name = 'fulp'");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20200914041057_AddBanAttribute.cs b/CentCom.Common/Migrations/MySql/20200914041057_AddBanAttribute.cs
index 52914c4..b4062cc 100644
--- a/CentCom.Common/Migrations/MySql/20200914041057_AddBanAttribute.cs
+++ b/CentCom.Common/Migrations/MySql/20200914041057_AddBanAttribute.cs
@@ -1,23 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class AddBanAttribute : Migration
{
- public partial class AddBanAttribute : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
- name: "BanAttributes",
- table: "Bans",
- nullable: false,
- defaultValue: 0);
- }
+ migrationBuilder.AddColumn(
+ name: "BanAttributes",
+ table: "Bans",
+ nullable: false,
+ defaultValue: 0);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "BanAttributes",
- table: "Bans");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "BanAttributes",
+ table: "Bans");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20210819220926_AddCheckHistory.cs b/CentCom.Common/Migrations/MySql/20210819220926_AddCheckHistory.cs
index 10bfaec..bb8d33e 100644
--- a/CentCom.Common/Migrations/MySql/20210819220926_AddCheckHistory.cs
+++ b/CentCom.Common/Migrations/MySql/20210819220926_AddCheckHistory.cs
@@ -2,13 +2,13 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class AddCheckHistory : Migration
{
- public partial class AddCheckHistory : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Name",
table: "BanSources",
type: "longtext",
@@ -16,10 +16,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext CHARACTER SET utf8mb4",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Display",
table: "BanSources",
type: "longtext",
@@ -27,10 +27,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext CHARACTER SET utf8mb4",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Reason",
table: "Bans",
type: "longtext",
@@ -38,10 +38,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext CHARACTER SET utf8mb4",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "BanID",
table: "Bans",
type: "longtext",
@@ -49,10 +49,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext CHARACTER SET utf8mb4",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "CheckHistory",
columns: table => new
{
@@ -77,20 +77,20 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
table.PrimaryKey("PK_CheckHistory", x => x.Id);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateIndex(
- name: "IX_CheckHistory_Parser_Started",
- table: "CheckHistory",
- columns: new[] { "Parser", "Started" });
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_CheckHistory_Parser_Started",
+ table: "CheckHistory",
+ columns: new[] { "Parser", "Started" });
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "CheckHistory");
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "CheckHistory");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Name",
table: "BanSources",
type: "longtext CHARACTER SET utf8mb4",
@@ -98,10 +98,10 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Display",
table: "BanSources",
type: "longtext CHARACTER SET utf8mb4",
@@ -109,10 +109,10 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Reason",
table: "Bans",
type: "longtext CHARACTER SET utf8mb4",
@@ -120,10 +120,10 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "BanID",
table: "Bans",
type: "longtext CHARACTER SET utf8mb4",
@@ -131,8 +131,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
- }
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20210820052645_AddBotNotifications.cs b/CentCom.Common/Migrations/MySql/20210820052645_AddBotNotifications.cs
index bd655db..0e485e3 100644
--- a/CentCom.Common/Migrations/MySql/20210820052645_AddBotNotifications.cs
+++ b/CentCom.Common/Migrations/MySql/20210820052645_AddBotNotifications.cs
@@ -2,13 +2,13 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class AddBotNotifications : Migration
{
- public partial class AddBotNotifications : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "NotifiedFailures",
columns: table => new
{
@@ -27,19 +27,18 @@ protected override void Up(MigrationBuilder migrationBuilder)
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
- .Annotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateIndex(
- name: "IX_NotifiedFailures_CheckHistoryId",
- table: "NotifiedFailures",
- column: "CheckHistoryId",
- unique: true);
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_NotifiedFailures_CheckHistoryId",
+ table: "NotifiedFailures",
+ column: "CheckHistoryId",
+ unique: true);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "NotifiedFailures");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "NotifiedFailures");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20210820072848_AddExceptionDetails.cs b/CentCom.Common/Migrations/MySql/20210820072848_AddExceptionDetails.cs
index 1caa599..399c4b0 100644
--- a/CentCom.Common/Migrations/MySql/20210820072848_AddExceptionDetails.cs
+++ b/CentCom.Common/Migrations/MySql/20210820072848_AddExceptionDetails.cs
@@ -1,24 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class AddExceptionDetails : Migration
{
- public partial class AddExceptionDetails : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "ExceptionDetailed",
table: "CheckHistory",
type: "longtext",
nullable: true)
- .Annotation("MySql:CharSet", "utf8mb4");
- }
+ .Annotation("MySql:CharSet", "utf8mb4");
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropColumn(
- name: "ExceptionDetailed",
- table: "CheckHistory");
- }
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "ExceptionDetailed",
+ table: "CheckHistory");
}
-}
+}
\ No newline at end of file
diff --git a/CentCom.Common/Migrations/MySql/20210821145927_UniqueSourceNames.cs b/CentCom.Common/Migrations/MySql/20210821145927_UniqueSourceNames.cs
index 44c7c9c..ae85cab 100644
--- a/CentCom.Common/Migrations/MySql/20210821145927_UniqueSourceNames.cs
+++ b/CentCom.Common/Migrations/MySql/20210821145927_UniqueSourceNames.cs
@@ -1,12 +1,12 @@
using Microsoft.EntityFrameworkCore.Migrations;
-namespace CentCom.Common.Migrations.MySql
+namespace CentCom.Common.Migrations.MySql;
+
+public partial class UniqueSourceNames : Migration
{
- public partial class UniqueSourceNames : Migration
+ protected override void Up(MigrationBuilder migrationBuilder)
{
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn(
+ migrationBuilder.AlterColumn(
name: "Name",
table: "BanSources",
type: "varchar(255)",
@@ -14,23 +14,23 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
- .Annotation("MySql:CharSet", "utf8mb4")
- .OldAnnotation("MySql:CharSet", "utf8mb4");
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
- migrationBuilder.CreateIndex(
- name: "IX_BanSources_Name",
- table: "BanSources",
- column: "Name",
- unique: true);
- }
+ migrationBuilder.CreateIndex(
+ name: "IX_BanSources_Name",
+ table: "BanSources",
+ column: "Name",
+ unique: true);
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropIndex(
- name: "IX_BanSources_Name",
- table: "BanSources");
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_BanSources_Name",
+ table: "BanSources");
- migrationBuilder.AlterColumn