mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-05 18:22:27 +00:00
The Great Formatting of 2022
This commit is contained in:
parent
59cc7f02fb
commit
35f50f5f8c
162 changed files with 6609 additions and 6809 deletions
|
@ -6,8 +6,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.GameApiTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.GameApiTests;
|
||||
|
||||
public class AuthenticationTests : LighthouseServerTest
|
||||
{
|
||||
[Fact]
|
||||
|
@ -64,4 +64,3 @@ namespace ProjectLighthouse.Tests.GameApiTests
|
|||
Assert.True(response.StatusCode == HttpStatusCode.Forbidden);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using LBPUnion.ProjectLighthouse.Tests;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.GameApiTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.GameApiTests;
|
||||
|
||||
public class DatabaseTests : LighthouseServerTest
|
||||
{
|
||||
[DatabaseFact]
|
||||
|
@ -25,4 +25,3 @@ namespace ProjectLighthouse.Tests.GameApiTests
|
|||
await database.RemoveUser(userA); // Only remove userA since userA and userB are the same user
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ using LBPUnion.ProjectLighthouse.Tests;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.GameApiTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.GameApiTests;
|
||||
|
||||
public class MatchTests : LighthouseServerTest
|
||||
{
|
||||
private static readonly SemaphoreSlim semaphore = new(1, 1);
|
||||
|
@ -59,4 +59,3 @@ namespace ProjectLighthouse.Tests.GameApiTests
|
|||
Assert.Equal(oldPlayerCount + 1, playerCount);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.GameApiTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.GameApiTests;
|
||||
|
||||
public class SlotTests : LighthouseServerTest
|
||||
{
|
||||
[DatabaseFact]
|
||||
|
@ -90,4 +90,3 @@ namespace ProjectLighthouse.Tests.GameApiTests
|
|||
await database.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using System.Threading.Tasks;
|
|||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.GameApiTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.GameApiTests;
|
||||
|
||||
public class UploadTests : LighthouseServerTest
|
||||
{
|
||||
public UploadTests()
|
||||
|
@ -56,4 +56,3 @@ namespace ProjectLighthouse.Tests.GameApiTests
|
|||
Assert.True(response.IsSuccessStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using OpenQA.Selenium;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests;
|
||||
|
||||
public class AdminTests : LighthouseWebTest
|
||||
{
|
||||
public const string AdminPanelButtonXPath = "/html/body/div/header/div/div/div/a[2]";
|
||||
|
@ -61,4 +61,3 @@ namespace ProjectLighthouse.Tests.WebsiteTests
|
|||
Assert.DoesNotContain("Admin Panel", this.Driver.FindElement(By.XPath(AdminPanelButtonXPath)).Text);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@ using Microsoft.EntityFrameworkCore;
|
|||
using OpenQA.Selenium;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests;
|
||||
|
||||
public class AuthenticationTests : LighthouseWebTest
|
||||
{
|
||||
[DatabaseFact]
|
||||
|
@ -103,4 +103,3 @@ namespace ProjectLighthouse.Tests.WebsiteTests
|
|||
await database.RemoveUser(user);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,21 +7,21 @@ using OpenQA.Selenium;
|
|||
using OpenQA.Selenium.Chrome;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests;
|
||||
|
||||
[Collection(nameof(LighthouseWebTest))]
|
||||
public class LighthouseWebTest : IDisposable
|
||||
{
|
||||
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestStartup>().UseWebRoot("StaticFiles").Build();
|
||||
public readonly string BaseAddress;
|
||||
|
||||
public readonly IWebDriver Driver;
|
||||
public readonly IWebHost WebHost = new WebHostBuilder().UseKestrel().UseStartup<TestStartup>().UseWebRoot("StaticFiles").Build();
|
||||
|
||||
public LighthouseWebTest()
|
||||
{
|
||||
this.WebHost.Start();
|
||||
|
||||
IServerAddressesFeature? serverAddressesFeature = WebHost.ServerFeatures.Get<IServerAddressesFeature>();
|
||||
IServerAddressesFeature? serverAddressesFeature = this.WebHost.ServerFeatures.Get<IServerAddressesFeature>();
|
||||
if (serverAddressesFeature == null) throw new ArgumentNullException();
|
||||
|
||||
this.BaseAddress = serverAddressesFeature.Addresses.First();
|
||||
|
@ -47,4 +47,3 @@ namespace ProjectLighthouse.Tests.WebsiteTests
|
|||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@ using Microsoft.EntityFrameworkCore;
|
|||
using OpenQA.Selenium;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests
|
||||
{
|
||||
namespace ProjectLighthouse.Tests.WebsiteTests;
|
||||
|
||||
public class RegisterTests : LighthouseWebTest
|
||||
{
|
||||
[DatabaseFact]
|
||||
|
@ -81,4 +81,3 @@ namespace ProjectLighthouse.Tests.WebsiteTests
|
|||
Assert.Contains("The username you've chosen is already taken.", this.Driver.PageSource);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Tests
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Tests;
|
||||
|
||||
public sealed class DatabaseFactAttribute : FactAttribute
|
||||
{
|
||||
private static readonly object migrateLock = new();
|
||||
|
@ -12,12 +12,8 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
{
|
||||
ServerSettings.Instance = new ServerSettings();
|
||||
ServerSettings.Instance.DbConnectionString = "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse";
|
||||
if (!ServerStatics.DbConnected)
|
||||
{
|
||||
this.Skip = "Database not available";
|
||||
}
|
||||
if (!ServerStatics.DbConnected) this.Skip = "Database not available";
|
||||
else
|
||||
{
|
||||
lock(migrateLock)
|
||||
{
|
||||
using Database database = new();
|
||||
|
@ -25,5 +21,3 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using System.Text;
|
|||
using LBPUnion.ProjectLighthouse.Types.Files;
|
||||
using Xunit;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Tests
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Tests;
|
||||
|
||||
public class FileTypeTests
|
||||
{
|
||||
[Fact]
|
||||
|
@ -58,4 +58,3 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
Assert.True(file.FileType == LbpFileType.Unknown);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Tests
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Tests;
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public class LighthouseServerTest
|
||||
{
|
||||
|
@ -26,10 +26,7 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
}
|
||||
public async Task<HttpResponseMessage> AuthenticateResponse(int number = -1, bool createUser = true)
|
||||
{
|
||||
if (number == -1)
|
||||
{
|
||||
number = new Random().Next();
|
||||
}
|
||||
if (number == -1) number = new Random().Next();
|
||||
|
||||
const string username = "unitTestUser";
|
||||
if (createUser)
|
||||
|
@ -77,8 +74,7 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
public async Task<HttpResponseMessage> UploadFileRequest(string endpoint, string filePath)
|
||||
=> await this.Client.PostAsync(endpoint, new StringContent(await File.ReadAllTextAsync(filePath)));
|
||||
|
||||
public async Task<HttpResponseMessage> UploadDataRequest(string endpoint, byte[] data)
|
||||
=> await this.Client.PostAsync(endpoint, new ByteArrayContent(data));
|
||||
public async Task<HttpResponseMessage> UploadDataRequest(string endpoint, byte[] data) => await this.Client.PostAsync(endpoint, new ByteArrayContent(data));
|
||||
|
||||
public async Task<HttpResponseMessage> AuthenticatedUploadFileRequest(string endpoint, string filePath, string mmAuth)
|
||||
{
|
||||
|
@ -96,4 +92,3 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
return await this.Client.SendAsync(requestMessage);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System.Collections.Generic;
|
|||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Tests
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Tests;
|
||||
|
||||
public class SerializerTests
|
||||
{
|
||||
[Fact]
|
||||
|
@ -40,4 +40,3 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/plain")]
|
||||
|
@ -45,4 +45,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(ps.Serialize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types.Categories;
|
|||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -117,4 +117,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types.Profiles;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -80,4 +80,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
public class DeveloperController : Controller
|
||||
|
@ -9,4 +9,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpGet("/developer_videos")]
|
||||
public IActionResult DeveloperVideos() => this.Ok();
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
// [Produces("text/plain")]
|
||||
|
@ -126,4 +126,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types.Profiles;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
public class FriendsController : ControllerBase
|
||||
|
@ -95,4 +95,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(LbpSerializer.StringElement("myFriends", friends));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System;
|
|||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/tags")]
|
||||
[Produces("text/plain")]
|
||||
|
@ -24,4 +24,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(string.Join(",", tags));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -214,4 +214,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/login")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -151,4 +151,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,8 +14,8 @@ using LBPUnion.ProjectLighthouse.Types.Match;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -140,4 +140,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok("[{\"StatusCode\":200}]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/plain")]
|
||||
|
@ -86,4 +86,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(loggedText);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using LBPUnion.ProjectLighthouse.Serialization;
|
|||
using LBPUnion.ProjectLighthouse.Types.News;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/news")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -34,4 +34,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(LbpSerializer.StringElement("news", newsEntry));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -53,10 +53,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
photo.CreatorId = user.UserId;
|
||||
photo.Creator = user;
|
||||
|
||||
if (photo.Subjects.Count > 4)
|
||||
{
|
||||
return this.BadRequest();
|
||||
}
|
||||
if (photo.Subjects.Count > 4) return this.BadRequest();
|
||||
|
||||
foreach (PhotoSubject subject in photo.Subjects)
|
||||
{
|
||||
|
@ -76,10 +73,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
List<int> subjectUserIds = new(4);
|
||||
foreach (PhotoSubject subject in photo.Subjects)
|
||||
{
|
||||
if (subjectUserIds.Contains(subject.UserId))
|
||||
{
|
||||
return this.BadRequest();
|
||||
}
|
||||
if (subjectUserIds.Contains(subject.UserId)) return this.BadRequest();
|
||||
|
||||
subjectUserIds.Add(subject.UserId);
|
||||
}
|
||||
|
||||
|
@ -157,4 +152,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -191,4 +191,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types.Files;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using IOFile = System.IO.File;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Produces("text/xml")]
|
||||
[Route("LITTLEBIGPLANETPS3_XML")]
|
||||
|
@ -86,4 +86,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,8 @@ using LBPUnion.ProjectLighthouse.Types.Reviews;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/plain")]
|
||||
|
@ -328,4 +328,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return review;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -120,10 +120,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
);
|
||||
|
||||
// Find your score, since even if you aren't in the top list your score is pinned
|
||||
var myScore = rankedScores.Where
|
||||
(rs => rs.Score.PlayerIdCollection.Contains(user.Username))
|
||||
.OrderByDescending(rs => rs.Score.Points)
|
||||
.FirstOrDefault();
|
||||
var myScore = rankedScores.Where(rs => rs.Score.PlayerIdCollection.Contains(user.Username)).OrderByDescending(rs => rs.Score.Points).FirstOrDefault();
|
||||
|
||||
// Paginated viewing: if not requesting pageStart, get results around user
|
||||
var pagedScores = rankedScores.Skip(pageStart != -1 || myScore == null ? pageStart - 1 : myScore.Rank - 3).Take(Math.Min(pageSize, 30));
|
||||
|
@ -162,4 +159,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return res;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -51,4 +51,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", dbQuery.Count()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -93,7 +93,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
public async Task<IActionResult> Lbp1CoolSlots([FromQuery] int page)
|
||||
{
|
||||
const int pageSize = 30;
|
||||
return await CoolSlots((page - 1) * pageSize, pageSize);
|
||||
return await this.CoolSlots((page - 1) * pageSize, pageSize);
|
||||
}
|
||||
|
||||
[HttpGet("slots/lbp2cool")]
|
||||
|
@ -110,7 +110,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
int _pageStart = pageStart;
|
||||
if (page != null) _pageStart = (int)page * 30;
|
||||
// bit of a better placeholder until we can track average user interaction with /stream endpoint
|
||||
return await ThumbsSlots(_pageStart, Math.Min(pageSize, 30), gameFilterType, players, move, "thisWeek");
|
||||
return await this.ThumbsSlots(_pageStart, Math.Min(pageSize, 30), gameFilterType, players, move, "thisWeek");
|
||||
}
|
||||
|
||||
[HttpGet("slots")]
|
||||
|
@ -232,7 +232,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
{
|
||||
Random rand = new();
|
||||
|
||||
IEnumerable<Slot> slots = FilterByRequest(gameFilterType, dateFilterType)
|
||||
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType)
|
||||
.AsEnumerable()
|
||||
.OrderByDescending(s => s.Thumbsup)
|
||||
.ThenBy(_ => rand.Next())
|
||||
|
@ -257,14 +257,14 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
{
|
||||
Random rand = new();
|
||||
|
||||
IEnumerable<Slot> slots = FilterByRequest(gameFilterType, dateFilterType)
|
||||
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType)
|
||||
.AsEnumerable()
|
||||
.OrderByDescending
|
||||
(
|
||||
s =>
|
||||
{
|
||||
// probably not the best way to do this?
|
||||
return GetGameFilter(gameFilterType) switch
|
||||
return this.GetGameFilter(gameFilterType) switch
|
||||
{
|
||||
GameVersion.LittleBigPlanet1 => s.PlaysLBP1Unique,
|
||||
GameVersion.LittleBigPlanet2 => s.PlaysLBP2Unique,
|
||||
|
@ -296,7 +296,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
{
|
||||
Random rand = new();
|
||||
|
||||
IEnumerable<Slot> slots = FilterByRequest(gameFilterType, dateFilterType)
|
||||
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType)
|
||||
.AsEnumerable()
|
||||
.OrderByDescending(s => s.Hearts)
|
||||
.ThenBy(_ => rand.Next())
|
||||
|
@ -332,24 +332,19 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
_ => 0,
|
||||
};
|
||||
|
||||
GameVersion gameVersion = GetGameFilter(gameFilterType);
|
||||
GameVersion gameVersion = this.GetGameFilter(gameFilterType);
|
||||
|
||||
IQueryable<Slot> whereSlots;
|
||||
|
||||
// ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
|
||||
if (gameFilterType == "both")
|
||||
{
|
||||
// Get game versions less than the current version
|
||||
// Needs support for LBP3 ("both" = LBP1+2)
|
||||
whereSlots = this.database.Slots.Where(s => s.GameVersion <= gameVersion && s.FirstUploaded >= oldestTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get game versions exactly equal to gamefiltertype
|
||||
whereSlots = this.database.Slots.Where(s => s.GameVersion == gameVersion && s.FirstUploaded >= oldestTime);
|
||||
}
|
||||
|
||||
return whereSlots.Include(s => s.Creator).Include(s => s.Location);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ using LBPUnion.ProjectLighthouse.Helpers;
|
|||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/plain")]
|
||||
|
@ -36,4 +36,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpGet("planetStats/totalLevelCount")]
|
||||
public async Task<IActionResult> TotalLevelCount() => this.Ok((await StatisticsHelper.SlotCount()).ToString());
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -10,4 +10,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpGet("promotions")]
|
||||
public IActionResult Promotions() => this.Ok();
|
||||
}
|
||||
}
|
|
@ -12,8 +12,8 @@ using LBPUnion.ProjectLighthouse.Types.Profiles;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
|
@ -189,4 +189,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok("[{\"StatusCode\":200}]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.Admin
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.Admin;
|
||||
|
||||
[ApiController]
|
||||
[Route("admin/slot/{id:int}")]
|
||||
public class AdminSlotController : ControllerBase
|
||||
|
@ -70,4 +70,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website.Admin
|
|||
return this.Ok();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.Admin
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.Admin;
|
||||
|
||||
[ApiController]
|
||||
[Route("admin/user/{id:int}")]
|
||||
public class AdminUserController : ControllerBase
|
||||
|
@ -34,4 +34,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website.Admin
|
|||
return this.Redirect($"/user/{targetedUser.UserId}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.Debug;
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.ExternalAuth
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.ExternalAuth;
|
||||
|
||||
[ApiController]
|
||||
[Route("/authentication")]
|
||||
public class AuthenticationController : ControllerBase
|
||||
|
@ -88,4 +88,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website.ExternalAuth
|
|||
return this.Redirect("~/authentication");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.ExternalAuth
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.ExternalAuth;
|
||||
|
||||
[ApiController]
|
||||
[Route("/authentication")]
|
||||
public class AutoApprovalController : ControllerBase
|
||||
|
@ -64,4 +64,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website.ExternalAuth
|
|||
return this.Redirect("/authentication/autoApprovals");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore;
|
|||
// TODO: Clean up this file
|
||||
// - jvyden
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website;
|
||||
|
||||
[ApiController]
|
||||
[Route("slot/{id:int}")]
|
||||
public class SlotPageController : ControllerBase
|
||||
|
@ -87,4 +87,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website
|
|||
return this.Redirect(callbackUrl);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website;
|
||||
|
||||
[ApiController]
|
||||
[Route("user/{id:int}")]
|
||||
public class UserPageController : ControllerBase
|
||||
|
@ -45,4 +45,3 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website
|
|||
return this.Redirect("~/user/" + id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse;
|
||||
|
||||
public class Database : DbContext
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
@ -97,8 +97,7 @@ namespace LBPUnion.ProjectLighthouse
|
|||
|
||||
public async Task HeartUser(User user, User heartedUser)
|
||||
{
|
||||
HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync
|
||||
(q => q.UserId == user.UserId && q.HeartedUserId == heartedUser.UserId);
|
||||
HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.HeartedUserId == heartedUser.UserId);
|
||||
if (heartedProfile != null) return;
|
||||
|
||||
this.HeartedProfiles.Add
|
||||
|
@ -115,8 +114,7 @@ namespace LBPUnion.ProjectLighthouse
|
|||
|
||||
public async Task UnheartUser(User user, User heartedUser)
|
||||
{
|
||||
HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync
|
||||
(q => q.UserId == user.UserId && q.HeartedUserId == heartedUser.UserId);
|
||||
HeartedProfile? heartedProfile = await this.HeartedProfiles.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.HeartedUserId == heartedUser.UserId);
|
||||
if (heartedProfile != null) this.HeartedProfiles.Remove(heartedProfile);
|
||||
|
||||
await this.SaveChangesAsync();
|
||||
|
@ -296,4 +294,3 @@ namespace LBPUnion.ProjectLighthouse
|
|||
}
|
||||
#nullable disable
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System.Net;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse;
|
||||
|
||||
public class FakeRemoteIPAddressMiddleware
|
||||
{
|
||||
private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.0.0.1");
|
||||
|
@ -21,4 +21,3 @@ namespace LBPUnion.ProjectLighthouse
|
|||
await this.next(httpContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using System.IO.Pipelines;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class BinaryHelper
|
||||
{
|
||||
public static string ReadString(BinaryReader reader)
|
||||
|
@ -62,4 +62,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
return data.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using LBPUnion.ProjectLighthouse.Types.Categories;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class CollectionHelper
|
||||
{
|
||||
public static readonly List<Category> Categories = new();
|
||||
|
@ -18,4 +18,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
foreach (DatabaseCategory category in database.CustomCategories) Categories.Add(new CustomCategory(category));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class DeniedAuthenticationHelper
|
||||
{
|
||||
public static readonly Dictionary<string, long> IPAddressAndNameDeniedAt = new();
|
||||
|
@ -35,4 +35,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
return attempts;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class EulaHelper
|
||||
{
|
||||
public const string License = @"
|
||||
|
@ -16,4 +16,3 @@ GNU Affero General Public License for more details.
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers.Extensions
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
||||
|
||||
// https://stackoverflow.com/a/8039737
|
||||
public static class ExceptionExtensions
|
||||
{
|
||||
|
@ -25,4 +25,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers.Extensions
|
|||
return string.Join("\n", fields);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System.Text.RegularExpressions;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers.Extensions
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
||||
|
||||
// yoinked and adapted from https://stackoverflow.com/a/68641796
|
||||
public static class RequestExtensions
|
||||
{
|
||||
|
@ -12,4 +12,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers.Extensions
|
|||
|
||||
public static bool IsMobile(this HttpRequest request) => mobileCheck.IsMatch(request.Headers[HeaderNames.UserAgent].ToString());
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers.Extensions
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
||||
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string ToFileName(this string text) => Path.GetInvalidFileNameChars().Aggregate(text, (current, c) => current.Replace(c.ToString(), ""));
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using System.Text;
|
|||
using LBPUnion.ProjectLighthouse.Types.Files;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class FileHelper
|
||||
{
|
||||
public static readonly string ResourcePath = Path.Combine(Environment.CurrentDirectory, "r");
|
||||
|
@ -100,4 +100,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
|
||||
public static string[] ResourcesNotUploaded(params string[] hashes) => hashes.Where(hash => !ResourceExists(hash)).ToArray();
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
[NotMapped]
|
||||
[SuppressMessage("ReSharper", "CollectionNeverQueried.Global")]
|
||||
public static class FriendHelper
|
||||
|
@ -11,4 +11,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
public static readonly Dictionary<int, int[]> FriendIdsByUserId = new();
|
||||
public static readonly Dictionary<int, int[]> BlockedIdsByUserId = new();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using System.Linq;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public class GameVersionHelper
|
||||
{
|
||||
// https://www.serialstation.com/games/b89b4eb4-4e4c-4e54-b72b-f7f9dbfac125
|
||||
|
@ -99,4 +99,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
return GameVersion.LittleBigPlanet1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using System.Security.Cryptography;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public static class HashHelper
|
||||
{
|
||||
|
@ -80,4 +80,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using Kettu;
|
|||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class InfluxHelper
|
||||
{
|
||||
public static readonly InfluxDBClient Client = InfluxDBClientFactory.Create(ServerSettings.Instance.InfluxUrl, ServerSettings.Instance.InfluxToken);
|
||||
|
@ -47,4 +47,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class LastContactHelper
|
||||
{
|
||||
private static readonly Database database = new();
|
||||
|
@ -32,4 +32,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
await database.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using System.Reflection;
|
|||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Maintenance;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class MaintenanceHelper
|
||||
{
|
||||
|
||||
|
@ -33,10 +33,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
{
|
||||
if (args.Length < 1)
|
||||
throw new Exception
|
||||
(
|
||||
"This should never happen. " +
|
||||
"If it did, its because you tried to run a command before validating that the user actually wants to run one."
|
||||
);
|
||||
("This should never happen. " + "If it did, its because you tried to run a command before validating that the user actually wants to run one.");
|
||||
|
||||
string baseCmd = args[0];
|
||||
args = args.Skip(1).ToArray();
|
||||
|
@ -67,4 +64,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
await job.Run();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ using System.Text.Json;
|
|||
using System.Text.RegularExpressions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Match;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class MatchHelper
|
||||
{
|
||||
public static readonly Dictionary<int, string?> UserLocations = new();
|
||||
|
@ -73,4 +73,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using LBPUnion.ProjectLighthouse.Types.Match;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public class RoomHelper
|
||||
{
|
||||
public static readonly List<Room> Rooms = new();
|
||||
|
@ -87,7 +87,6 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
response.Players.Add
|
||||
(
|
||||
new Player
|
||||
|
@ -96,12 +95,8 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
User = user,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (location == null)
|
||||
{
|
||||
response.Locations.Add(location);
|
||||
}
|
||||
if (location == null) response.Locations.Add(location);
|
||||
|
||||
response.Slots = new List<List<int>>
|
||||
{
|
||||
|
@ -151,9 +146,8 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
public static Room? FindRoomByUser(User user, GameVersion roomVersion, bool createIfDoesNotExist = false)
|
||||
{
|
||||
lock(Rooms)
|
||||
{
|
||||
foreach (Room room in Rooms.Where(room => room.Players.Any(player => user == player))) return room;
|
||||
}
|
||||
foreach (Room room in Rooms.Where(room => room.Players.Any(player => user == player)))
|
||||
return room;
|
||||
|
||||
return createIfDoesNotExist ? CreateRoom(user, roomVersion) : null;
|
||||
}
|
||||
|
@ -188,4 +182,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class StatisticsHelper
|
||||
{
|
||||
private static readonly Database database = new();
|
||||
|
@ -16,4 +16,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
|
||||
public static async Task<int> PhotoCount() => await database.Photos.CountAsync();
|
||||
}
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class TimeHelper
|
||||
{
|
||||
public static long UnixTimeMilliseconds() => DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
public static long UnixTimeSeconds() => DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
}
|
||||
}
|
||||
|
||||
// 1397109686193
|
||||
// 1635389749454
|
|
@ -1,11 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class TimestampHelper
|
||||
{
|
||||
public static long Timestamp => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
|
||||
public static long TimestampMillis => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using Kettu;
|
|||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
||||
public static class VersionHelper
|
||||
{
|
||||
static VersionHelper()
|
||||
|
@ -80,4 +80,3 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
|||
"Unknown";
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ using Kettu;
|
|||
using LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Logging
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Logging;
|
||||
|
||||
public class AspNetToKettuLogger : ILogger
|
||||
{
|
||||
public IDisposable BeginScope<TState>(TState state) => NullScope.Instance;
|
||||
|
@ -21,4 +21,3 @@ namespace LBPUnion.ProjectLighthouse.Logging
|
|||
foreach (string line in lines) Logger.Log(line, loggerLevel);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Logging
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Logging;
|
||||
|
||||
[ProviderAlias("Kettu")]
|
||||
public class AspNetToKettuLoggerProvider : ILoggerProvider, IDisposable
|
||||
{
|
||||
|
@ -13,4 +13,3 @@ namespace LBPUnion.ProjectLighthouse.Logging
|
|||
|
||||
public ILogger CreateLogger(string categoryName) => new AspNetToKettuLogger();
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using Kettu;
|
|||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Logging
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Logging;
|
||||
|
||||
public class InfluxLogger : LoggerBase
|
||||
{
|
||||
public override bool AllowMultiple => false;
|
||||
|
@ -24,4 +24,3 @@ namespace LBPUnion.ProjectLighthouse.Logging
|
|||
writeApi.WritePoint(ServerSettings.Instance.InfluxBucket, ServerSettings.Instance.InfluxOrg, point);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using Kettu;
|
|||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Helpers.Extensions;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Logging
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Logging;
|
||||
|
||||
public class LighthouseFileLogger : LoggerBase
|
||||
{
|
||||
private static readonly string logsDirectory = Path.Combine(Environment.CurrentDirectory, "logs");
|
||||
|
@ -29,4 +29,3 @@ namespace LBPUnion.ProjectLighthouse.Logging
|
|||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using Kettu;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Logging
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Logging;
|
||||
|
||||
public class LoggerLevelStartup : LoggerLevel
|
||||
{
|
||||
public static readonly LoggerLevelStartup Instance = new();
|
||||
|
@ -78,4 +78,3 @@ namespace LBPUnion.ProjectLighthouse.Logging
|
|||
public static readonly LoggerLevelCategory Instance = new();
|
||||
public override string Name => "Category";
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Logging
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Logging;
|
||||
|
||||
public class NullScope : IDisposable
|
||||
{
|
||||
|
||||
|
@ -14,4 +14,3 @@ namespace LBPUnion.ProjectLighthouse.Logging
|
|||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ using LBPUnion.ProjectLighthouse.Logging;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class CreateUserCommand : ICommand
|
||||
{
|
||||
|
@ -51,4 +51,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
|||
|
||||
public int RequiredArgs() => 2;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using JetBrains.Annotations;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class DeleteUserCommand : ICommand
|
||||
{
|
||||
|
@ -37,4 +37,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
|||
await this.database.RemoveUser(user);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using JetBrains.Annotations;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class MakeUserAdminCommand : ICommand
|
||||
{
|
||||
|
@ -42,4 +42,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
|||
Console.WriteLine($"The user {user.Username} (id: {user.UserId}) is now an admin.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using LBPUnion.ProjectLighthouse.Helpers;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class ResetPasswordCommand : ICommand
|
||||
{
|
||||
|
@ -46,4 +46,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
|||
Console.WriteLine($"The password for user {user.Username} (id: {user.UserId}) has been reset.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using System.Threading.Tasks;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands;
|
||||
|
||||
public class WipeTokensForUserCommand : ICommand
|
||||
{
|
||||
private readonly Database database = new();
|
||||
|
@ -42,4 +42,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
|
|||
Console.WriteLine($"Deleted all tokens for {user.Username} (id: {user.UserId}).");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance;
|
||||
|
||||
public interface ICommand
|
||||
{
|
||||
|
||||
|
@ -16,4 +16,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance
|
|||
|
||||
public int RequiredArgs();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance;
|
||||
|
||||
public interface IMaintenanceJob
|
||||
{
|
||||
public Task Run();
|
||||
|
@ -10,4 +10,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance
|
|||
|
||||
public string Description();
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ using LBPUnion.ProjectLighthouse.Helpers;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Files;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs;
|
||||
|
||||
public class CleanupBrokenPhotosMaintenanceJob : IMaintenanceJob
|
||||
{
|
||||
private readonly Database database = new();
|
||||
|
@ -89,4 +89,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
|||
await this.database.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs;
|
||||
|
||||
public class CleanupUnusedLocationsMaintenanceJob : IMaintenanceJob
|
||||
{
|
||||
private readonly Database database = new();
|
||||
|
@ -30,4 +30,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
|||
await this.database.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs;
|
||||
|
||||
public class DeleteAllTokensMaintenanceJob : IMaintenanceJob
|
||||
{
|
||||
private readonly Database database = new();
|
||||
|
@ -19,4 +19,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
|||
Console.WriteLine("Deleted ALL tokens.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System;
|
|||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs;
|
||||
|
||||
public class FixAllBrokenPlayerRequirementsMaintenanceJob : IMaintenanceJob
|
||||
{
|
||||
private readonly Database database = new();
|
||||
|
@ -28,4 +28,3 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.MaintenanceJobs
|
|||
Console.WriteLine($"Fixed {count} broken player requirements.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,10 +10,10 @@ namespace LBPUnion.ProjectLighthouse.Pages.Admin;
|
|||
|
||||
public class AdminBanUserPage : BaseLayout
|
||||
{
|
||||
public AdminBanUserPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public User? TargetedUser;
|
||||
public AdminBanUserPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int id)
|
||||
{
|
||||
|
|
|
@ -11,12 +11,12 @@ namespace LBPUnion.ProjectLighthouse.Pages.Admin;
|
|||
|
||||
public class AdminPanelUsersPage : BaseLayout
|
||||
{
|
||||
public AdminPanelUsersPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public int UserCount;
|
||||
|
||||
public List<User> Users;
|
||||
public AdminPanelUsersPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
|
|
|
@ -9,8 +9,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth;
|
||||
|
||||
public class AuthenticationPage : BaseLayout
|
||||
{
|
||||
|
||||
|
@ -36,4 +36,3 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,14 +7,14 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth;
|
||||
|
||||
public class ManageUserApprovedIpAddressesPage : BaseLayout
|
||||
{
|
||||
public ManageUserApprovedIpAddressesPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public List<UserApprovedIpAddress> ApprovedIpAddresses;
|
||||
public ManageUserApprovedIpAddressesPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
|
@ -26,4 +26,3 @@ namespace LBPUnion.ProjectLighthouse.Pages.ExternalAuth
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,15 +9,15 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class LandingPage : BaseLayout
|
||||
{
|
||||
|
||||
public int AuthenticationAttemptsCount;
|
||||
public List<User> PlayersOnline;
|
||||
|
||||
public int PlayersOnlineCount;
|
||||
|
||||
public int AuthenticationAttemptsCount;
|
||||
public LandingPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
|
@ -30,11 +30,9 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
this.PlayersOnlineCount = await StatisticsHelper.RecentMatches();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
this.AuthenticationAttemptsCount = await this.Database.AuthenticationAttempts.Include
|
||||
(a => a.GameToken)
|
||||
.CountAsync(a => a.GameToken.UserId == user.UserId);
|
||||
}
|
||||
|
||||
List<int> userIds = await this.Database.LastContacts.Where(l => TimestampHelper.Timestamp - l.Timestamp < 300).Select(l => l.UserId).ToListAsync();
|
||||
|
||||
|
@ -42,4 +40,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,16 +3,10 @@ using System.Collections.Generic;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
|
||||
public class BaseLayout : PageModel
|
||||
{
|
||||
public BaseLayout(Database database)
|
||||
{
|
||||
this.Database = database;
|
||||
}
|
||||
|
||||
public bool IsMobile;
|
||||
|
||||
public readonly Database Database;
|
||||
|
||||
|
@ -24,13 +18,19 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
|||
};
|
||||
|
||||
public readonly List<PageNavigationItem> NavigationItemsRight = new();
|
||||
public string Description = string.Empty;
|
||||
|
||||
public bool IsMobile;
|
||||
|
||||
public bool ShowTitleInPage = true;
|
||||
|
||||
public string Title = string.Empty;
|
||||
public string Description = string.Empty;
|
||||
|
||||
private User? user;
|
||||
public BaseLayout(Database database)
|
||||
{
|
||||
this.Database = database;
|
||||
}
|
||||
|
||||
public new User? User {
|
||||
get {
|
||||
|
@ -41,4 +41,3 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
|||
set => this.user = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@ using LBPUnion.ProjectLighthouse.Types;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class LoginForm : BaseLayout
|
||||
{
|
||||
public LoginForm(Database database) : base(database)
|
||||
|
@ -80,4 +80,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class LogoutPage : BaseLayout
|
||||
{
|
||||
public LogoutPage(Database database) : base(database)
|
||||
|
@ -23,4 +23,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class PasswordResetPage : BaseLayout
|
||||
{
|
||||
public PasswordResetPage(Database database) : base(database)
|
||||
|
@ -50,4 +50,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,8 +5,8 @@ using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
|||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class PasswordResetRequiredPage : BaseLayout
|
||||
{
|
||||
public PasswordResetRequiredPage([NotNull] Database database) : base(database)
|
||||
|
@ -23,4 +23,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,17 +10,17 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class PhotosPage : BaseLayout
|
||||
{
|
||||
|
||||
public int PageAmount;
|
||||
|
||||
public int PageNumber;
|
||||
|
||||
public int PhotoCount;
|
||||
|
||||
public int PageAmount;
|
||||
|
||||
public List<Photo> Photos;
|
||||
public PhotosPage([NotNull] Database database) : base(database)
|
||||
{}
|
||||
|
@ -32,10 +32,7 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = (int)Math.Ceiling((double)this.PhotoCount / ServerStatics.PageSize);
|
||||
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
|
||||
{
|
||||
return this.Redirect($"/photos/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
}
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/photos/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
|
||||
this.Photos = await this.Database.Photos.Include
|
||||
(p => p.Creator)
|
||||
|
@ -47,4 +44,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class RegisterForm : BaseLayout
|
||||
{
|
||||
public RegisterForm(Database database) : base(database)
|
||||
|
@ -75,4 +75,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ using LBPUnion.ProjectLighthouse.Types.Levels;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class SlotPage : BaseLayout
|
||||
{
|
||||
|
||||
|
@ -25,4 +25,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,17 +10,17 @@ using LBPUnion.ProjectLighthouse.Types.Settings;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class SlotsPage : BaseLayout
|
||||
{
|
||||
|
||||
public int PageAmount;
|
||||
|
||||
public int PageNumber;
|
||||
|
||||
public int SlotCount;
|
||||
|
||||
public int PageAmount;
|
||||
|
||||
public List<Slot> Slots;
|
||||
public SlotsPage([NotNull] Database database) : base(database)
|
||||
{}
|
||||
|
@ -32,10 +32,7 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
this.PageNumber = pageNumber;
|
||||
this.PageAmount = (int)Math.Ceiling((double)this.SlotCount / ServerStatics.PageSize);
|
||||
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount)
|
||||
{
|
||||
return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
}
|
||||
if (this.PageNumber < 0 || this.PageNumber >= this.PageAmount) return this.Redirect($"/slots/{Math.Clamp(this.PageNumber, 0, this.PageAmount - 1)}");
|
||||
|
||||
this.Slots = await this.Database.Slots.Include
|
||||
(p => p.Creator)
|
||||
|
@ -47,4 +44,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -125,9 +125,9 @@
|
|||
@foreach (Comment comment in Model.Comments!)
|
||||
{
|
||||
DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000);
|
||||
StringWriter messageWriter = new StringWriter();
|
||||
StringWriter messageWriter = new();
|
||||
HttpUtility.HtmlDecode(comment.Message, messageWriter);
|
||||
String decodedMessage = messageWriter.ToString();
|
||||
string decodedMessage = messageWriter.ToString();
|
||||
<div>
|
||||
<b><a href="/user/@comment.PosterUserId">@comment.Poster.Username</a>: </b>
|
||||
<span>@decodedMessage</span>
|
||||
|
|
|
@ -8,8 +8,8 @@ using LBPUnion.ProjectLighthouse.Types.Profiles;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Pages
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Pages;
|
||||
|
||||
public class UserPage : BaseLayout
|
||||
{
|
||||
public List<Comment>? Comments;
|
||||
|
@ -44,4 +44,3 @@ namespace LBPUnion.ProjectLighthouse.Pages
|
|||
return this.Page();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,8 +12,8 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
|||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
|
@ -113,4 +113,3 @@ namespace LBPUnion.ProjectLighthouse
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Serialization
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
||||
public class JsonOutputFormatter : StringOutputFormatter
|
||||
{
|
||||
public JsonOutputFormatter()
|
||||
|
@ -10,4 +10,3 @@ namespace LBPUnion.ProjectLighthouse.Serialization
|
|||
this.SupportedMediaTypes.Add("application/json");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Serialization
|
||||
{
|
||||
namespace LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
||||
/// <summary>
|
||||
/// LBP doesn't like the XML serializer by C# that much, and it cant be controlled that much (cant have two root
|
||||
/// elements),
|
||||
|
@ -33,4 +33,3 @@ namespace LBPUnion.ProjectLighthouse.Serialization
|
|||
(params KeyValuePair<string, object>[] pairs)
|
||||
=> pairs.Aggregate(string.Empty, (current, pair) => current + StringElement(pair));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue