mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-07 21:58:06 -05:00
remove some build warnings
This commit is contained in:
parent
24276d8057
commit
eac9b8f150
@ -5,8 +5,17 @@ using SharedLibraryCore.Database.Models;
|
|||||||
|
|
||||||
namespace IW4MAdmin.Application.Alerts;
|
namespace IW4MAdmin.Application.Alerts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// extension method helper class to allow building of alerts
|
||||||
|
/// </summary>
|
||||||
public static class AlertExtensions
|
public static class AlertExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// builds basic alert for user with provided category
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">client to build the alert for</param>
|
||||||
|
/// <param name="type">alert category</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState BuildAlert(this EFClient client, Alert.AlertCategory? type = null)
|
public static Alert.AlertState BuildAlert(this EFClient client, Alert.AlertCategory? type = null)
|
||||||
{
|
{
|
||||||
return new Alert.AlertState
|
return new Alert.AlertState
|
||||||
@ -16,36 +25,72 @@ public static class AlertExtensions
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sets the category for an existing alert
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">existing alert</param>
|
||||||
|
/// <param name="category">new category</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState WithCategory(this Alert.AlertState state, Alert.AlertCategory category)
|
public static Alert.AlertState WithCategory(this Alert.AlertState state, Alert.AlertCategory category)
|
||||||
{
|
{
|
||||||
state.Category = category;
|
state.Category = category;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sets the alert type for an existing alert
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">existing alert</param>
|
||||||
|
/// <param name="type">new type</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState OfType(this Alert.AlertState state, string type)
|
public static Alert.AlertState OfType(this Alert.AlertState state, string type)
|
||||||
{
|
{
|
||||||
state.Type = type;
|
state.Type = type;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sets the message for an existing alert
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">existing alert</param>
|
||||||
|
/// <param name="message">new message</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState WithMessage(this Alert.AlertState state, string message)
|
public static Alert.AlertState WithMessage(this Alert.AlertState state, string message)
|
||||||
{
|
{
|
||||||
state.Message = message;
|
state.Message = message;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sets the expiration duration for an existing alert
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">existing alert</param>
|
||||||
|
/// <param name="expiration">duration before expiration</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState ExpiresIn(this Alert.AlertState state, TimeSpan expiration)
|
public static Alert.AlertState ExpiresIn(this Alert.AlertState state, TimeSpan expiration)
|
||||||
{
|
{
|
||||||
state.ExpiresAt = DateTime.Now.Add(expiration);
|
state.ExpiresAt = DateTime.Now.Add(expiration);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sets the source for an existing alert
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">existing alert</param>
|
||||||
|
/// <param name="source">new source</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState FromSource(this Alert.AlertState state, string source)
|
public static Alert.AlertState FromSource(this Alert.AlertState state, string source)
|
||||||
{
|
{
|
||||||
state.Source = source;
|
state.Source = source;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sets the alert source to the provided client
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">existing alert</param>
|
||||||
|
/// <param name="client">new client</param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Alert.AlertState FromClient(this Alert.AlertState state, EFClient client)
|
public static Alert.AlertState FromClient(this Alert.AlertState state, EFClient client)
|
||||||
{
|
{
|
||||||
state.Source = client.Name.StripColors();
|
state.Source = client.Name.StripColors();
|
||||||
|
@ -4,7 +4,6 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using SharedLibraryCore.Configuration;
|
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
|
|
||||||
namespace WebfrontCore
|
namespace WebfrontCore
|
||||||
|
@ -20,9 +20,11 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading.RateLimiting;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Data.Abstractions;
|
using Data.Abstractions;
|
||||||
using Data.Helpers;
|
using Data.Helpers;
|
||||||
|
using Microsoft.AspNetCore.RateLimiting;
|
||||||
using WebfrontCore.Controllers.API.Validation;
|
using WebfrontCore.Controllers.API.Validation;
|
||||||
using WebfrontCore.Middleware;
|
using WebfrontCore.Middleware;
|
||||||
using WebfrontCore.QueryHelpers;
|
using WebfrontCore.QueryHelpers;
|
||||||
@ -134,7 +136,14 @@ namespace WebfrontCore
|
|||||||
app.UseMiddleware<IPWhitelist>(serviceProvider.GetService<ILogger<IPWhitelist>>(), serviceProvider.GetRequiredService<ApplicationConfiguration>().WebfrontConnectionWhitelist);
|
app.UseMiddleware<IPWhitelist>(serviceProvider.GetService<ILogger<IPWhitelist>>(), serviceProvider.GetRequiredService<ApplicationConfiguration>().WebfrontConnectionWhitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseConcurrencyLimiter();
|
app.UseRateLimiter(new RateLimiterOptions()
|
||||||
|
.AddConcurrencyLimiter("concurrencyPolicy", (options) =>
|
||||||
|
{
|
||||||
|
options.PermitLimit = 2;
|
||||||
|
options.QueueLimit = 25;
|
||||||
|
options.QueueProcessingOrder = QueueProcessingOrder.NewestFirst;
|
||||||
|
}));
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseCors("AllowAll");
|
app.UseCors("AllowAll");
|
||||||
@ -146,7 +155,8 @@ namespace WebfrontCore
|
|||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
|
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}")
|
||||||
|
.RequireRateLimiting("concurrencyPolicy");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user