mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Author Controls
This commit is contained in:
parent
8b998586f7
commit
779e178bfe
@ -15,7 +15,7 @@ using Wabbajack.DTOs.GitHub;
|
||||
using Wabbajack.DTOs.JsonConverters;
|
||||
using Wabbajack.Networking.GitHub;
|
||||
using Wabbajack.Paths.IO;
|
||||
using Wabbajack.Server.DataLayer;
|
||||
using Wabbajack.Server.DataModels;
|
||||
using Wabbajack.Server.Services;
|
||||
|
||||
namespace Wabbajack.BuildServer.Controllers;
|
||||
@ -30,19 +30,19 @@ public class AuthorControls : ControllerBase
|
||||
private readonly QuickSync _quickSync;
|
||||
private readonly AppSettings _settings;
|
||||
private readonly ILogger<AuthorControls> _logger;
|
||||
private readonly SqlService _sql;
|
||||
private readonly AuthorFiles _authorFiles;
|
||||
|
||||
public AuthorControls(ILogger<AuthorControls> logger, SqlService sql, QuickSync quickSync, HttpClient client,
|
||||
AppSettings settings, DTOSerializer dtos,
|
||||
public AuthorControls(ILogger<AuthorControls> logger, QuickSync quickSync, HttpClient client,
|
||||
AppSettings settings, DTOSerializer dtos, AuthorFiles authorFiles,
|
||||
Client gitHubClient)
|
||||
{
|
||||
_logger = logger;
|
||||
_sql = sql;
|
||||
_quickSync = quickSync;
|
||||
_client = client;
|
||||
_settings = settings;
|
||||
_dtos = dtos;
|
||||
_gitHubClient = gitHubClient;
|
||||
_authorFiles = authorFiles;
|
||||
}
|
||||
|
||||
[Route("login/{authorKey}")]
|
||||
@ -75,7 +75,6 @@ public class AuthorControls : ControllerBase
|
||||
try
|
||||
{
|
||||
await _gitHubClient.UpdateList(user, data);
|
||||
await _quickSync.Notify<ModListDownloader>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -99,15 +98,15 @@ public class AuthorControls : ControllerBase
|
||||
public async Task<IActionResult> HomePage()
|
||||
{
|
||||
var user = User.FindFirstValue(ClaimTypes.Name);
|
||||
var files = (await _sql.AllAuthoredFiles())
|
||||
.Where(af => af.Author == user)
|
||||
var files = (await _authorFiles.AllAuthoredFiles())
|
||||
.Where(af => af.Definition.Author == user)
|
||||
.Select(af => new
|
||||
{
|
||||
Size = af.Size.FileSizeToString(),
|
||||
OriginalSize = af.Size,
|
||||
Name = af.OriginalFileName,
|
||||
MangledName = af.MungedName,
|
||||
UploadedDate = af.LastTouched
|
||||
Size = af.Definition.Size.FileSizeToString(),
|
||||
OriginalSize = af.Definition.Size,
|
||||
Name = af.Definition.OriginalFileName,
|
||||
MangledName = af.Definition.MungedName,
|
||||
UploadedDate = af.Updated
|
||||
})
|
||||
.OrderBy(f => f.Name)
|
||||
.ThenBy(f => f.UploadedDate)
|
||||
|
@ -12,8 +12,10 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using Octokit;
|
||||
using Wabbajack.BuildServer;
|
||||
using Wabbajack.DTOs.JsonConverters;
|
||||
using Wabbajack.Networking.GitHub;
|
||||
using Wabbajack.Server.DataModels;
|
||||
using Wabbajack.Server.Services;
|
||||
|
||||
@ -60,6 +62,8 @@ public class Startup
|
||||
services.AddSingleton<HttpClient>();
|
||||
services.AddSingleton<AuthorFiles>();
|
||||
services.AddSingleton<AuthorKeys>();
|
||||
services.AddSingleton<Client>();
|
||||
services.AddSingleton(s => new GitHubClient(new ProductHeaderValue("wabbajack")));
|
||||
services.AddDTOSerializer();
|
||||
services.AddDTOConverters();
|
||||
services.AddResponseCompression(options =>
|
||||
|
@ -56,7 +56,6 @@
|
||||
<Compile Remove="Services\ListValidator.cs" />
|
||||
<Compile Remove="Controllers\ModFiles.cs" />
|
||||
<Compile Remove="Controllers\Users.cs" />
|
||||
<Compile Remove="Controllers\AuthorControls.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user