1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

implement metaservice v2

This commit is contained in:
RaidMax
2022-03-23 08:43:57 -05:00
parent cde42c78ff
commit bae415c81b
21 changed files with 919 additions and 120 deletions

View File

@ -8,6 +8,7 @@ using SharedLibraryCore.QueryHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Data.Models;
using Stats.Config;
@ -17,16 +18,16 @@ namespace WebfrontCore.Controllers
{
public class ClientController : BaseController
{
private readonly IMetaService _metaService;
private readonly IMetaServiceV2 _metaService;
private readonly StatsConfiguration _config;
public ClientController(IManager manager, IMetaService metaService, StatsConfiguration config) : base(manager)
public ClientController(IManager manager, IMetaServiceV2 metaService, StatsConfiguration config) : base(manager)
{
_metaService = metaService;
_config = config;
}
public async Task<IActionResult> ProfileAsync(int id, MetaType? metaFilterType)
public async Task<IActionResult> ProfileAsync(int id, MetaType? metaFilterType, CancellationToken token = default)
{
var client = await Manager.GetClientService().Get(id);
@ -40,17 +41,17 @@ namespace WebfrontCore.Controllers
var persistentMetaTask = new[]
{
_metaService.GetPersistentMeta(EFMeta.ClientTag, client),
_metaService.GetPersistentMeta("GravatarEmail", client)
_metaService.GetPersistentMetaByLookup(EFMeta.ClientTagV2, EFMeta.ClientTagNameV2, client.ClientId, token),
_metaService.GetPersistentMeta("GravatarEmail", client.ClientId, token)
};
var persistentMeta = await Task.WhenAll(persistentMetaTask);
var tag = persistentMeta[0];
var gravatar = persistentMeta[1];
if (tag?.LinkedMeta != null)
if (tag?.Value != null)
{
client.SetAdditionalProperty(EFMeta.ClientTag, tag.LinkedMeta.Value);
client.SetAdditionalProperty(EFMeta.ClientTagV2, tag.Value);
}
// even though we haven't set their level to "banned" yet

View File

@ -116,13 +116,14 @@ namespace WebfrontCore
// todo: this needs to be handled more gracefully
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<DefaultSettings>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<ILoggerFactory>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IConfigurationHandlerFactory>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IDatabaseContextFactory>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IAuditInformationRepository>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<ITranslationLookup>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IEnumerable<IManagerCommand>>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<IMetaService>());
services.AddSingleton(Program.ApplicationServiceProvider.GetService<ApplicationConfiguration>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<IConfigurationHandlerFactory>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<IDatabaseContextFactory>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<IAuditInformationRepository>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<ITranslationLookup>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<IEnumerable<IManagerCommand>>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<IMetaService>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<IMetaServiceV2>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<ApplicationConfiguration>());
services.AddSingleton(Program.ApplicationServiceProvider.GetRequiredService<ClientService>());
services.AddSingleton(
Program.ApplicationServiceProvider.GetRequiredService<IServerDistributionCalculator>());

View File

@ -13,9 +13,9 @@ namespace WebfrontCore.ViewComponents
{
public class ProfileMetaListViewComponent : ViewComponent
{
private readonly IMetaService _metaService;
private readonly IMetaServiceV2 _metaService;
public ProfileMetaListViewComponent(IMetaService metaService)
public ProfileMetaListViewComponent(IMetaServiceV2 metaService)
{
_metaService = metaService;
}
@ -38,7 +38,7 @@ namespace WebfrontCore.ViewComponents
return View("_List", meta);
}
public static async Task<IEnumerable<IClientMeta>> GetClientMeta(IMetaService metaService, MetaType? metaType,
public static async Task<IEnumerable<IClientMeta>> GetClientMeta(IMetaServiceV2 metaService, MetaType? metaType,
EFClient.Permission level, ClientPaginationRequest request)
{
IEnumerable<IClientMeta> meta = null;