VerifyCaptcha(HttpRequest request);
6 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminPanelController.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using Microsoft.AspNetCore.Mvc;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
6 |
7 | [ApiController]
8 | [Route("/admin")]
9 | public class AdminPanelController : ControllerBase
10 | {
11 | private readonly DatabaseContext database;
12 |
13 | public AdminPanelController(DatabaseContext database)
14 | {
15 | this.database = database;
16 | }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Controllers/StatusController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
4 |
5 | [ApiController]
6 | [Route("/")]
7 | [Produces("application/json")]
8 | public class StatusController : ControllerBase
9 | {
10 | [AcceptVerbs("GET", "HEAD", Route = "status")]
11 | public IActionResult GetStatus() => this.Ok();
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Admin/AdminSendNotificationPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/admin/user/{id:int}/sendNotification"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminSendNotificationPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = $"Send notification to {Model.TargetedUser!.Username}";
7 | }
8 |
9 | @await Html.PartialAsync("Partials/AdminSendNotificationPartial", Model.TargetedUser)
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Admin/AdminSetGrantedSlotsPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/admin/user/{id:int}/setGrantedSlots"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin.AdminSetGrantedSlotsPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = $"Set granted slots for {Model.TargetedUser!.Username}";
7 | }
8 |
9 | @await Html.PartialAsync("Partials/AdminSetGrantedSlotsFormPartial", Model.TargetedUser)
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/debug/filter"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug.FilterTestPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = "Debug - Filter Test";
7 | }
8 |
9 | @if (Model.FilteredText != null)
10 | {
11 | @Model.FilteredText
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | #if DEBUG
3 | using LBPUnion.ProjectLighthouse.Helpers;
4 | #endif
5 | using LBPUnion.ProjectLighthouse.Database;
6 | using LBPUnion.ProjectLighthouse.Types.Filter;
7 | using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
8 | using Microsoft.AspNetCore.Mvc;
9 |
10 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
11 |
12 | public class FilterTestPage : BaseLayout
13 | {
14 | public FilterTestPage(DatabaseContext database) : base(database)
15 | {}
16 |
17 | public string? FilteredText;
18 | public string? Text;
19 |
20 | public IActionResult OnGet(string? text = null)
21 | {
22 | #if DEBUG
23 | if (text != null) this.FilteredText = CensorHelper.FilterMessage(text, FilterLocation.Test);
24 | this.Text = text;
25 |
26 | return this.Page();
27 | #else
28 | return this.NotFound();
29 | #endif
30 | }
31 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
5 | using Microsoft.AspNetCore.Mvc;
6 | #if !DEBUG
7 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
8 | #endif
9 |
10 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
11 |
12 | public class RoomVisualizerPage : BaseLayout
13 | {
14 | public RoomVisualizerPage(DatabaseContext database) : base(database)
15 | {}
16 |
17 | public IActionResult OnGet()
18 | {
19 | #if !DEBUG
20 | UserEntity? user = this.Database.UserFromWebRequest(this.Request);
21 | if (user == null || !user.IsAdmin) return this.NotFound();
22 | #endif
23 |
24 | return this.Page();
25 | }
26 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Debug/VersionInfoPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/debug/version"
2 | @using LBPUnion.ProjectLighthouse.Helpers
3 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug.VersionInfoPage
4 |
5 | @{
6 | Layout = "Layouts/BaseLayout";
7 | Model.Title = "Debug - Version Information";
8 | Model.Description = VersionHelper.FullVersion;
9 | }
10 |
11 | Build specific information
12 | FullVersion: @VersionHelper.FullVersion
13 |
14 | Branch: @VersionHelper.Branch
15 | Build: @VersionHelper.Build
16 | CommitHash: @VersionHelper.CommitHash
17 | RepositoryUrl: @VersionHelper.RepositoryUrl
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Debug/VersionInfoPage.cshtml.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Database;
2 | using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
3 | using Microsoft.AspNetCore.Mvc;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
6 |
7 | public class VersionInfoPage : BaseLayout
8 | {
9 | public VersionInfoPage(DatabaseContext database) : base(database)
10 | {}
11 | public IActionResult OnGet() => this.Page();
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Email/CompleteEmailVerificationPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/verifyEmail"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email.CompleteEmailVerificationPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 |
7 | if (Model.Error == null)
8 | {
9 | Model.Title = "Email Address Verified";
10 | }
11 | else
12 | {
13 | Model.Title = "Couldn't verify email address";
14 | }
15 | }
16 |
17 | @if (Model.Error != null)
18 | {
19 |
20 | Reason: @Model.Error
21 |
22 | Please try again. If the error persists, please contact the instance administrator.
23 |
24 | Resend email
25 |
26 | }
27 | else
28 | {
29 | Your email has been successfully verified. You may now close this tab.
30 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Email/SendVerificationEmailPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/login/sendVerificationEmail"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email.SendVerificationEmailPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = "Verify Email Address";
7 | }
8 |
9 | @if (Model.Success)
10 | {
11 | An email address on your account has been set, but hasn't been verified yet.
12 | To verify it, check the email sent to @Model.User?.EmailAddress and click the link in the email.
13 | }
14 | else
15 | {
16 | Failed to send email, please try again later.
17 | If this issue persists please contact an Administrator
18 | }
19 |
20 |
21 | Resend email
22 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/404"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors.NotFoundPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = "Not Found";
7 | Model.Description = "Sorry, but the page you requested could not be found.";
8 | }
9 |
10 | @Model.Description
11 | Take a peek at the homepage to see if you can find what you were looking for.
12 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Errors/NotFoundPage.cshtml.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Database;
2 | using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
3 | using Microsoft.AspNetCore.Mvc;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors;
6 |
7 | public class NotFoundPage : BaseLayout
8 | {
9 | public NotFoundPage(DatabaseContext database) : base(database)
10 | {}
11 |
12 | public IActionResult OnGet() => this.Page();
13 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Login/LogoutPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/logout"
2 | @using LBPUnion.ProjectLighthouse.Localization.StringLists
3 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login.LogoutPage
4 |
5 | @{
6 | Layout = "Layouts/BaseLayout";
7 | Model.Title = Model.Translate(LoggedOutStrings.LoggedOut);
8 | }
9 |
10 | @Model.Translate(LoggedOutStrings.LoggedOutInfo)
11 |
12 |
13 | @Model.Translate(LoggedOutStrings.Redirect)
14 |
15 |
16 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Login/LogoutPage.cshtml.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Token;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
8 |
9 | public class LogoutPage : BaseLayout
10 | {
11 | public LogoutPage(DatabaseContext database) : base(database)
12 | {}
13 | public async Task OnGet()
14 | {
15 | WebTokenEntity? token = this.Database.WebTokenFromRequest(this.Request);
16 | if (token == null) return this.Redirect("~/");
17 |
18 | this.Database.WebTokens.Remove(token);
19 | await this.Database.SaveChangesAsync();
20 |
21 | this.Response.Cookies.Delete("LighthouseToken");
22 |
23 | return this.Page();
24 | }
25 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequiredPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/passwordResetRequired"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login.PasswordResetRequiredPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = "Password Reset Required";
7 | }
8 |
9 |
10 | An administrator has deemed it necessary that you reset your password. Please do so.
11 |
12 |
13 | Reset Password
14 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Login/PasswordResetRequiredPage.cshtml.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
8 |
9 | public class PasswordResetRequiredPage : BaseLayout
10 | {
11 | public PasswordResetRequiredPage(DatabaseContext database) : base(database)
12 | {}
13 |
14 | public bool WasResetRequest { get; private set; }
15 |
16 | public IActionResult OnGet()
17 | {
18 | UserEntity? user = this.Database.UserFromWebRequest(this.Request);
19 | if (user == null) return this.Redirect("~/login");
20 | if (!user.PasswordResetRequired) return this.Redirect("~/passwordReset");
21 |
22 | return this.Page();
23 | }
24 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Login/PirateSignupPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/pirate"
2 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login.PirateSignupPage
3 |
4 | @{
5 | Layout = "Layouts/BaseLayout";
6 | Model.Title = "ARRRRRRRRRR!";
7 | }
8 |
9 |
10 | @if (Model.User!.Language != "en-PT")
11 | {
12 | So, ye wanna be a pirate? Well, ye came to the right place!
13 | Just click this 'ere button, and welcome aboard!
14 | If you ever wanna walk the plank, come back 'ere.
15 |
16 |
20 | }
21 | else
22 | {
23 | Back so soon, aye?
24 | If you're gonna walk the plank, then do it!
25 |
26 |
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Moderation/ReportPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/moderation/report/{reportId:int}"
2 | @using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
3 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation.ReportPage
4 |
5 | @{
6 | Layout = "Layouts/BaseLayout";
7 | Model.Title = $"Report {Model.Report.ReportId}";
8 | string timeZone = Model.GetTimeZone();
9 | }
10 |
11 |
18 |
19 | @await Html.PartialAsync("Partials/ReportPartial", Model.Report, ViewData.WithTime(timeZone))
20 | @await Html.PartialAsync("Partials/RenderReportBoundsPartial")
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Partials/AdminPanelStatisticPartial.cshtml:
--------------------------------------------------------------------------------
1 | @model LBPUnion.ProjectLighthouse.Servers.Website.Types.AdminPanelStatistic
2 |
3 |
4 |
5 | @if (Model.ViewAllEndpoint != null)
6 | {
7 |
10 | }
11 | else
12 | {
13 |
@Model.StatisticNamePlural
14 | }
15 | @if (Model.SecondStatistic == null)
16 | {
17 |
@Model.Count
18 | }
19 | else
20 | {
21 |
@Model.Count / @Model.SecondStatistic
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Partials/AdminSendNotificationPartial.cshtml:
--------------------------------------------------------------------------------
1 | @model LBPUnion.ProjectLighthouse.Types.Entities.Profile.UserEntity
2 |
3 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Partials/AdminSetGrantedSlotsFormPartial.cshtml:
--------------------------------------------------------------------------------
1 | @model LBPUnion.ProjectLighthouse.Types.Entities.Profile.UserEntity
2 |
3 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Partials/CaptchaPartial.cshtml:
--------------------------------------------------------------------------------
1 | @using LBPUnion.ProjectLighthouse.Configuration
2 | @using LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories
3 | @if (ServerConfiguration.Instance.Captcha.CaptchaEnabled)
4 | {
5 | @switch (ServerConfiguration.Instance.Captcha.Type)
6 | {
7 | case CaptchaType.HCaptcha:
8 |
9 |
10 | break;
11 | case CaptchaType.ReCaptcha:
12 |
13 |
14 | break;
15 | default:
16 | throw new ArgumentOutOfRangeException();
17 | }
18 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/Partials/ErrorModalPartial.cshtml:
--------------------------------------------------------------------------------
1 | @model (string Title, string Message)
2 |
3 |
4 |
7 |
@Model.Message
8 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/TwoFactor/DisableTwoFactorPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/remove2fa"
2 | @using LBPUnion.ProjectLighthouse.Localization.StringLists
3 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor.DisableTwoFactorPage
4 |
5 | @{
6 | Layout = "Layouts/BaseLayout";
7 | Model.Title = Model.Translate(TwoFactorStrings.DisableTwoFactor);
8 | Model.ShowTitleInPage = false;
9 | }
10 |
11 |
12 |
13 |
@Model.Translate(TwoFactorStrings.DisableTwoFactor)
14 |
@Model.Translate(TwoFactorStrings.DisableTwoFactorDescription)
15 | @await Html.PartialAsync("Partials/TwoFactorPartial", new ViewDataDictionary(ViewData)
16 | {
17 | {
18 | "SubmitUrl", "/remove2fa"
19 | },
20 | {
21 | "Error", Model.Error
22 | },
23 | })
24 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml:
--------------------------------------------------------------------------------
1 | @page "/2fa"
2 | @using LBPUnion.ProjectLighthouse.Localization.StringLists
3 | @model LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor.TwoFactorLoginPage
4 |
5 | @{
6 | Layout = "Layouts/BaseLayout";
7 | Model.Title = Model.Translate(TwoFactorStrings.TwoFactor);
8 | Model.ShowTitleInPage = false;
9 | }
10 |
11 |
12 |
13 |
@Model.Translate(TwoFactorStrings.TwoFactor)
14 |
@Model.Translate(TwoFactorStrings.TwoFactorDescription)
15 | @await Html.PartialAsync("Partials/TwoFactorPartial", new ViewDataDictionary(ViewData)
16 | {
17 | {
18 | "SubmitUrl", "/2fa"
19 | },
20 | {
21 | "Error", Model.Error
22 | },
23 | {
24 | "CallbackUrl", Model.RedirectUrl
25 | }
26 | })
27 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Program.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse;
2 | using LBPUnion.ProjectLighthouse.Configuration;
3 | using LBPUnion.ProjectLighthouse.Logging.Loggers.AspNet;
4 | using LBPUnion.ProjectLighthouse.Servers.Website.Startup;
5 | using LBPUnion.ProjectLighthouse.Types.Misc;
6 |
7 | await StartupTasks.Run(ServerType.Website);
8 |
9 | IHostBuilder builder = Host.CreateDefaultBuilder();
10 | builder.ConfigureWebHostDefaults(webBuilder =>
11 | {
12 | webBuilder.UseStartup();
13 | webBuilder.UseUrls(ServerConfiguration.Instance.WebsiteListenUrl);
14 | webBuilder.UseWebRoot("StaticFiles");
15 | });
16 |
17 | builder.ConfigureLogging(logging =>
18 | {
19 | logging.ClearProviders();
20 | logging.AddProvider(new AspNetToLighthouseLoggerProvider());
21 | });
22 | await builder.Build().RunAsync();
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | enable
5 | enable
6 | LBPUnion.ProjectLighthouse.Servers.Website
7 | LBPUnion.ProjectLighthouse.Servers.Website
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj.DotSettings.user:
--------------------------------------------------------------------------------
1 |
2 | ..\ProjectLighthouse\StaticFiles\css
3 | css
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Startup/WebsiteTestStartup.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Middlewares;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Startup;
4 |
5 | public class WebsiteTestStartup : WebsiteStartup
6 | {
7 | public WebsiteTestStartup(IConfiguration configuration) : base(configuration)
8 | {}
9 |
10 | public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
11 | {
12 | app.UseMiddleware();
13 | base.Configure(app, env);
14 | }
15 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Types/AdminPanelStatistic.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
3 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Types;
4 |
5 | public struct AdminPanelStatistic
6 | {
7 | public AdminPanelStatistic(string statisticNamePlural, int count, string? viewAllEndpoint = null, int? secondStatistic = null)
8 | {
9 | this.StatisticNamePlural = statisticNamePlural;
10 | this.Count = count;
11 | this.SecondStatistic = secondStatistic;
12 | this.ViewAllEndpoint = viewAllEndpoint;
13 | }
14 |
15 | public readonly string StatisticNamePlural;
16 | public readonly int Count;
17 | public readonly int? SecondStatistic;
18 |
19 | public readonly string? ViewAllEndpoint;
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/Types/PageNavigationItem.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
3 | using LBPUnion.ProjectLighthouse.Localization;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Servers.Website.Types;
6 |
7 | public class PageNavigationItem
8 | {
9 | public PageNavigationItem(TranslatableString name, string url, string? icon = null, string? customColor = null)
10 | {
11 | this.Name = name;
12 | this.Url = url;
13 | this.Icon = icon;
14 | this.CustomColor = customColor;
15 | }
16 |
17 | public TranslatableString Name { get; set; }
18 | public string Url { get; set; }
19 | public string? Icon { get; set; }
20 | public string? CustomColor { get; set; }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Servers.Website/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Warning"
6 | }
7 | },
8 | "AllowedHosts": "*"
9 | }
10 |
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests.GameApiTests/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 |
3 | [assembly: CollectionBehavior(DisableTestParallelization = true)]
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests.GameApiTests/Unit/Controllers/StatusControllerTests.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
2 | using LBPUnion.ProjectLighthouse.Tests.Helpers;
3 | using Microsoft.AspNetCore.Mvc;
4 | using Xunit;
5 |
6 | namespace ProjectLighthouse.Tests.GameApiTests.Unit.Controllers;
7 |
8 | [Trait("Category", "Unit")]
9 | public class StatusControllerTests
10 | {
11 | [Fact]
12 | public void Status_ShouldReturnOk()
13 | {
14 | StatusController statusController = new()
15 | {
16 | ControllerContext = MockHelper.GetMockControllerContext(),
17 | };
18 |
19 | IActionResult result = statusController.GetStatus();
20 |
21 | Assert.IsType(result);
22 | }
23 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests.WebsiteTests/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 |
3 | [assembly: CollectionBehavior(DisableTestParallelization = true)]
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests.WebsiteTests/Extensions/WebDriverExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using OpenQA.Selenium;
3 |
4 | namespace ProjectLighthouse.Tests.WebsiteTests.Extensions;
5 |
6 | public static class WebDriverExtensions
7 | {
8 | private static Uri GetUri(this IWebDriver driver) => new(driver.Url);
9 |
10 | public static string GetPath(this IWebDriver driver) => driver.GetUri().AbsolutePath;
11 |
12 | public static string GetErrorMessage(this IWebDriver driver) => driver.FindElement(By.CssSelector("#error-message > p")).Text;
13 | }
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests/ExampleFiles/TestFarc.farc:
--------------------------------------------------------------------------------
1 | FSHbFARC
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests/ExampleFiles/TestScript.ff:
--------------------------------------------------------------------------------
1 | FSHb
2 |
3 | this is not my stuff to upload so its just gonna be a file like this for now :/
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests/ExampleFiles/TestTexture.tex:
--------------------------------------------------------------------------------
1 | TEX vq h��ʱ �0�/Zf����@�p �q4�VV��xp\)S�"�K}\ձ�8���\�֖e^�9��~�$I�$I�$I�$I�$I�$I�$I�$I�$I�$I�$I�$I�$I�$�{N�7Q
--------------------------------------------------------------------------------
/ProjectLighthouse.Tests/ProjectLighthouse.Tests.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/ProjectLighthouse/Administration/Maintenance/Commands/FlushRedisCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Logging;
4 | using LBPUnion.ProjectLighthouse.StorableLists;
5 | using LBPUnion.ProjectLighthouse.Types.Maintenance;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands;
8 |
9 | public class FlushRedisCommand : ICommand
10 | {
11 | public string Name() => "Flush Redis";
12 | public string[] Aliases() =>
13 | new[]
14 | {
15 | "flush", "flush-redis",
16 | };
17 | public string Arguments() => "";
18 | public int RequiredArgs() => 0;
19 |
20 | public async Task Run(IServiceProvider provider, string[] args, Logger logger) => await RedisDatabase.FlushAll();
21 |
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Administration/Maintenance/Commands/TestWebhookCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Helpers;
4 | using LBPUnion.ProjectLighthouse.Logging;
5 | using LBPUnion.ProjectLighthouse.Types.Maintenance;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.Commands;
8 |
9 | public class TestWebhookCommand : ICommand
10 | {
11 | public string Name() => "Test Discord Webhook";
12 | public string[] Aliases()
13 | => new[]
14 | {
15 | "testWebhook", "testDiscordWebhook",
16 | };
17 | public string Arguments() => "";
18 | public int RequiredArgs() => 0;
19 |
20 | public async Task Run(IServiceProvider provider, string[] args, Logger logger) =>
21 | await WebhookHelper.SendWebhook("Testing 123", "Someone is testing the Discord webhook from the admin panel.");
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Administration/Maintenance/MaintenanceJobs/DeleteAllTokensMaintenanceJob.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using LBPUnion.ProjectLighthouse.Extensions;
5 | using LBPUnion.ProjectLighthouse.Types.Maintenance;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.MaintenanceJobs;
8 |
9 | public class DeleteAllTokensMaintenanceJob : IMaintenanceJob
10 | {
11 | public string Name() => "Delete ALL Tokens";
12 | public string Description() => "Deletes ALL game tokens and web tokens.";
13 |
14 | public async Task Run()
15 | {
16 | await using DatabaseContext database = DatabaseContext.CreateNewInstance();
17 | await database.GameTokens.RemoveWhere(t => true);
18 | await database.WebTokens.RemoveWhere(t => true);
19 | Console.WriteLine(@"Deleted ALL tokens.");
20 | }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/CleanupRoomsTask.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using LBPUnion.ProjectLighthouse.Helpers;
5 | using LBPUnion.ProjectLighthouse.Types.Maintenance;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.RepeatingTasks;
8 |
9 | public class CleanupRoomsTask : IRepeatingTask
10 | {
11 | public string Name => "Cleanup Rooms";
12 | public TimeSpan RepeatInterval => TimeSpan.FromSeconds(10);
13 | public DateTime LastRan { get; set; }
14 | public Task Run(DatabaseContext database) => RoomHelper.CleanupRooms(database);
15 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/RemoveExpiredTokensTask.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using LBPUnion.ProjectLighthouse.Types.Maintenance;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.RepeatingTasks;
7 |
8 | public class RemoveExpiredTokensTask : IRepeatingTask
9 | {
10 | public string Name => "Remove Expired Tokens";
11 | public TimeSpan RepeatInterval => TimeSpan.FromHours(1);
12 | public DateTime LastRan { get; set; }
13 |
14 | public async Task Run(DatabaseContext database) => await database.RemoveExpiredTokens();
15 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/AuthenticationConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class AuthenticationConfiguration
4 | {
5 | public bool RegistrationEnabled { get; set; } = true;
6 | public bool AutomaticAccountCreation { get; set; } = true;
7 | public bool VerifyTickets { get; set; } = true;
8 |
9 | public bool AllowRPCNSignup { get; set; } = true;
10 |
11 | public bool AllowPSNSignup { get; set; } = true;
12 |
13 | // Require use of Zaprit's "Patchwork" prx plugin's user agent when connecting to the server
14 | // Major and minor version minimums can be left alone if patchwork is not required
15 | public bool RequirePatchworkUserAgent { get; set; } = false;
16 | public int PatchworkMajorVersionMinimum { get; set; } = 1;
17 | public int PatchworkMinorVersionMinimum { get; set; } = 0;
18 |
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/CaptchaConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | ///
4 | /// The service to be used for presenting captchas to the user.
5 | ///
6 | public enum CaptchaType
7 | {
8 | ///
9 | /// A privacy-first captcha. https://www.hcaptcha.com/
10 | ///
11 | HCaptcha,
12 |
13 | ///
14 | /// A captcha service by Google. https://developers.google.com/recaptcha/
15 | ///
16 | ReCaptcha,
17 | }
18 |
19 | public class CaptchaConfiguration
20 | {
21 | public bool CaptchaEnabled { get; set; }
22 |
23 | public CaptchaType Type { get; set; } = CaptchaType.HCaptcha;
24 |
25 | public string SiteKey { get; set; } = "";
26 |
27 | public string Secret { get; set; } = "";
28 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class CustomizationConfiguration
4 | {
5 | public string ServerName { get; set; } = "Project Lighthouse";
6 | public string EnvironmentName { get; set; } = "project-lighthouse";
7 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/DigestKeyConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class DigestKeyConfiguration
4 | {
5 | // todo: move to list?
6 | public string PrimaryDigestKey { get; set; } = "";
7 | public string AlternateDigestKey { get; set; } = "";
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/GoogleAnalyticsConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class GoogleAnalyticsConfiguration
4 | {
5 | public bool AnalyticsEnabled { get; set; }
6 |
7 | public string Id { get; set; } = "";
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/MailConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class MailConfiguration
4 | {
5 | public bool MailEnabled { get; set; }
6 |
7 | public string Host { get; set; } = "";
8 |
9 | public int Port { get; set; } = 587;
10 |
11 | public string FromAddress { get; set; } = "lighthouse@example.com";
12 |
13 | public string FromName { get; set; } = "Project Lighthouse";
14 |
15 | public string Username { get; set; } = "";
16 |
17 | public string Password { get; set; } = "";
18 |
19 | public bool UseSSL { get; set; } = true;
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/MatchmakingConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class MatchmakingConfiguration
4 | {
5 | public bool MatchmakingEnabled { get; set; } = true;
6 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/NotificationConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class NotificationConfiguration
4 | {
5 | public bool ShowServerNameInText { get; set; } = true;
6 | public bool ShowTimestampInText { get; set; } = false;
7 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/RateLimitConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
4 |
5 | public class RateLimitOptions
6 | {
7 | public bool Enabled;
8 | public int RequestsPerInterval { get; set; } = 5;
9 | public int RequestInterval { get; set; } = 15;
10 | }
11 |
12 | public class RateLimitConfiguration
13 | {
14 | public RateLimitOptions GlobalOptions { get; set; } = new();
15 |
16 | public Dictionary OverrideOptions { get; set; } = new()
17 | {
18 | {
19 | "/example/*/wildcard", new RateLimitOptions
20 | {
21 | RequestInterval = 5,
22 | RequestsPerInterval = 10,
23 | Enabled = true,
24 | }
25 | },
26 | };
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/TwoFactorConfiguration.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Types.Users;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
4 |
5 | public class TwoFactorConfiguration
6 | {
7 | public bool TwoFactorEnabled { get; set; } = true;
8 | public bool RequireTwoFactor { get; set; } = true;
9 | public PermissionLevel RequiredTwoFactorLevel { get; set; } = PermissionLevel.Moderator;
10 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/UserGeneratedContentLimitConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class UserGeneratedContentLimitConfiguration
4 | {
5 | ///
6 | /// The maximum amount of slots allowed on users' earth
7 | ///
8 | public int EntitledSlots { get; set; } = 50;
9 |
10 | public int ListsQuota { get; set; } = 50;
11 |
12 | public int PhotosQuota { get; set; } = 500;
13 |
14 | ///
15 | /// When enabled, all UGC uploads are disabled. This includes levels, photos, reviews,
16 | /// comments, and certain profile settings.
17 | ///
18 | public bool ReadOnlyMode { get; set; } = false;
19 |
20 | public bool ProfileCommentsEnabled { get; set; } = true;
21 |
22 | public bool LevelCommentsEnabled { get; set; } = true;
23 |
24 | public bool LevelReviewsEnabled { get; set; } = true;
25 |
26 | public bool BooingEnabled { get; set; } = true;
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ConfigurationCategories/WebsiteConfiguration.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2 |
3 | public class WebsiteConfiguration
4 | {
5 | public string MissingIconHash { get; set; } = "";
6 |
7 | public bool ConvertAssetsOnStartup { get; set; } = true;
8 |
9 | /*
10 | * Decides whether or not to display the Lighthouse Pride logo
11 | * during the month of June if enabled.
12 | */
13 | public bool PrideEventEnabled { get; set; } = true;
14 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Configuration/ServerStatics.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System;
3 | using System.Linq;
4 | using LBPUnion.ProjectLighthouse.Types.Misc;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Configuration;
7 |
8 | public static class ServerStatics
9 | {
10 | public const int PageSize = 20;
11 |
12 | // FIXME: This needs to go at some point.
13 | public static bool IsUnitTesting => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.FullName!.StartsWith("xunit"));
14 |
15 | public static bool IsDebug()
16 | {
17 | #if DEBUG
18 | return true;
19 | #else
20 | return false;
21 | #endif
22 | }
23 |
24 | ///
25 | /// The server type, determined on startup. Shouldn't be null unless very very early in startup.
26 | ///
27 | // The way of doing this is kinda weird, but it works.
28 | public static ServerType ServerType;
29 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Database/DatabaseContext.ApiTokens.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.Linq;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Token;
4 | using Microsoft.AspNetCore.Http;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Database;
7 |
8 | public partial class DatabaseContext
9 | {
10 | public ApiKeyEntity? ApiKeyFromWebRequest(HttpRequest request)
11 | {
12 | string? authHeader = request.Headers["Authorization"];
13 | if (string.IsNullOrWhiteSpace(authHeader)) return null;
14 |
15 | string authToken = authHeader[(authHeader.IndexOf(' ') + 1)..];
16 |
17 | ApiKeyEntity? apiKey = this.APIKeys.FirstOrDefault(k => k.Key == authToken);
18 | return apiKey ?? null;
19 | }
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Database/DatabaseContextFactory.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Design;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Database;
4 |
5 | ///
6 | /// This class is only used for the code-first migration builder to detect the DbContext
7 | ///
8 | // ReSharper disable once UnusedType.Global
9 | public class DatabaseContextFactory : IDesignTimeDbContextFactory
10 | {
11 | public DatabaseContext CreateDbContext(string[] args) => DatabaseContext.CreateNewInstance();
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Extensions/ExceptionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Extensions;
7 |
8 | // https://stackoverflow.com/a/8039737
9 | public static class ExceptionExtensions
10 | {
11 | public static string ToDetailedException(this Exception exception)
12 | {
13 | PropertyInfo[] properties = exception.GetType().GetProperties();
14 |
15 | IEnumerable fields = properties.Select
16 | (
17 | property => new
18 | {
19 | property.Name,
20 | Value = property.GetValue(exception, null),
21 | }
22 | )
23 | .Select(x => $"{x.Name} = {(x.Value != null ? x.Value.ToString() : string.Empty)}");
24 |
25 | return string.Join("\n", fields);
26 | }
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Extensions/PipeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Buffers;
2 | using System.IO.Pipelines;
3 | using System.Threading.Tasks;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Extensions;
6 |
7 | public static class PipeExtensions
8 | {
9 |
10 | public static async Task ReadAllAsync(this PipeReader reader)
11 | {
12 | do
13 | {
14 | ReadResult readResult = await reader.ReadAsync();
15 | if (readResult.IsCompleted || readResult.IsCanceled)
16 | {
17 | return readResult.Buffer.ToArray();
18 | }
19 |
20 | // consume nothing, keep reading from the pipe reader until all data is there
21 | reader.AdvanceTo(readResult.Buffer.Start, readResult.Buffer.End);
22 | }
23 | while (true);
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Extensions/RedisConnectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Logging;
4 | using LBPUnion.ProjectLighthouse.Types.Logging;
5 | using Redis.OM;
6 | using Redis.OM.Contracts;
7 |
8 | namespace LBPUnion.ProjectLighthouse.Extensions;
9 |
10 | public static class RedisConnectionExtensions
11 | {
12 | public static async Task RecreateIndexAsync(this IRedisConnection connection, Type type)
13 | {
14 | Logger.Debug("Recreating index for " + type.Name, LogArea.Redis);
15 |
16 | // TODO: use `await connection.DropIndexAndAssociatedRecordsAsync(type);` here instead when that becomes a thing
17 | bool dropped = await connection.DropIndexAsync(type);
18 | Logger.Debug("Dropped index: " + dropped, LogArea.Redis);
19 |
20 | bool created = await connection.CreateIndexAsync(type);
21 | Logger.Debug("Created index: " + created, LogArea.Redis);
22 | }
23 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Extensions/RoomExtensions.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using LBPUnion.ProjectLighthouse.Database;
6 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
7 | using LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
8 |
9 | namespace LBPUnion.ProjectLighthouse.Extensions;
10 |
11 | public static class RoomExtensions
12 | {
13 | public static List GetPlayers(this Room room, DatabaseContext database)
14 | {
15 | List players = new();
16 | foreach (int playerId in room.PlayerIds)
17 | {
18 | UserEntity? player = database.Users.FirstOrDefault(p => p.UserId == playerId);
19 | Debug.Assert(player != null, "RoomExtensions: player == null");
20 |
21 | players.Add(player);
22 | }
23 |
24 | return players;
25 | }
26 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/AdventureFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class AdventureFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => s.IsAdventurePlanet;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/AuthorLabelFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Linq.Expressions;
4 | using LBPUnion.ProjectLighthouse.Extensions;
5 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
6 | using LBPUnion.ProjectLighthouse.Types.Filter;
7 |
8 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
9 |
10 | public class AuthorLabelFilter : ISlotFilter
11 | {
12 | private readonly string[] labels;
13 |
14 | public AuthorLabelFilter(params string[] labels)
15 | {
16 | this.labels = labels;
17 | }
18 |
19 | public Expression> GetPredicate()
20 | {
21 | Expression> predicate = PredicateExtensions.True();
22 | predicate = this.labels.Aggregate(predicate,
23 | (current, label) => current.And(s => s.AuthorLabels.Contains(label)));
24 | return predicate;
25 | }
26 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/CreatorFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class CreatorFilter : ISlotFilter
9 | {
10 | private readonly int creatorId;
11 |
12 | public CreatorFilter(int creatorId)
13 | {
14 | this.creatorId = creatorId;
15 | }
16 |
17 | public Expression> GetPredicate() => s => s.CreatorId == this.creatorId;
18 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/CrossControlFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class CrossControlFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => s.CrossControllerRequired;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/ExcludeAdventureFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class ExcludeAdventureFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => !s.IsAdventurePlanet;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/ExcludeCrossControlFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class ExcludeCrossControlFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => !s.CrossControllerRequired;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/ExcludeLBP1OnlyFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 | using LBPUnion.ProjectLighthouse.Types.Users;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
8 |
9 | public class ExcludeLBP1OnlyFilter : ISlotFilter
10 | {
11 | private readonly int userId;
12 | private readonly GameVersion targetGameVersion;
13 |
14 | public ExcludeLBP1OnlyFilter(int userId, GameVersion targetGameVersion)
15 | {
16 | this.userId = userId;
17 | this.targetGameVersion = targetGameVersion;
18 | }
19 |
20 | public Expression> GetPredicate() =>
21 | s => !s.Lbp1Only || s.CreatorId == this.userId || this.targetGameVersion == GameVersion.LittleBigPlanet1;
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/ExcludeMovePackFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class ExcludeMovePackFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => !s.MoveRequired;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/FirstUploadedFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Extensions;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
5 | using LBPUnion.ProjectLighthouse.Types.Filter;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
8 |
9 | public class FirstUploadedFilter : ISlotFilter
10 | {
11 | private readonly long start;
12 | private readonly long end;
13 |
14 | public FirstUploadedFilter(long start, long end = long.MaxValue)
15 | {
16 | this.start = start;
17 | this.end = end;
18 | }
19 |
20 | public Expression> GetPredicate()
21 | {
22 | Expression> predicate = PredicateExtensions.True();
23 | predicate = predicate.And(s => s.FirstUploaded > this.start);
24 |
25 | // Exclude to optimize query
26 | if (this.end != long.MaxValue) predicate = predicate.And(s => s.FirstUploaded < this.end);
27 |
28 | return predicate;
29 | }
30 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/GameVersionFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 | using LBPUnion.ProjectLighthouse.Types.Users;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
8 |
9 | public class GameVersionFilter : ISlotFilter
10 | {
11 | private readonly GameVersion targetVersion;
12 | private readonly bool matchExactly;
13 |
14 | public GameVersionFilter(GameVersion targetVersion, bool matchExactly = false)
15 | {
16 | this.targetVersion = targetVersion;
17 | this.matchExactly = matchExactly;
18 | }
19 |
20 | public Expression> GetPredicate() =>
21 | this.matchExactly ||
22 | this.targetVersion is GameVersion.LittleBigPlanetVita or GameVersion.LittleBigPlanetPSP or GameVersion.Unknown
23 | ? s => s.GameVersion == this.targetVersion
24 | : s => s.GameVersion <= this.targetVersion;
25 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/GameVersionListFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Linq.Expressions;
4 | using LBPUnion.ProjectLighthouse.Extensions;
5 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
6 | using LBPUnion.ProjectLighthouse.Types.Filter;
7 | using LBPUnion.ProjectLighthouse.Types.Users;
8 |
9 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
10 |
11 | public class GameVersionListFilter : ISlotFilter
12 | {
13 | private readonly GameVersion[] versions;
14 |
15 | public GameVersionListFilter(params GameVersion[] versions)
16 | {
17 | this.versions = versions;
18 | }
19 |
20 | public Expression> GetPredicate() =>
21 | this.versions.Aggregate(PredicateExtensions.False(),
22 | (current, version) => current.Or(s => s.GameVersion == version));
23 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/HiddenSlotFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class HiddenSlotFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => !s.Hidden;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/LockedSlotFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class LockedSlotFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => !s.InitiallyLocked;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/MovePackFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class MovePackFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => s.MoveRequired;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/PlayerCountFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Extensions;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
5 | using LBPUnion.ProjectLighthouse.Types.Filter;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
8 |
9 | public class PlayerCountFilter : ISlotFilter
10 | {
11 | private readonly int minPlayers;
12 | private readonly int maxPlayers;
13 |
14 | public PlayerCountFilter(int minPlayers = 1, int maxPlayers = 4)
15 | {
16 | this.minPlayers = minPlayers;
17 | this.maxPlayers = maxPlayers;
18 | }
19 |
20 | public Expression> GetPredicate()
21 | {
22 | Expression> predicate = PredicateExtensions.True();
23 | predicate = predicate.And(s => s.MinimumPlayers >= this.minPlayers);
24 | predicate = predicate.And(s => s.MaximumPlayers <= this.maxPlayers);
25 |
26 | return predicate;
27 | }
28 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/ResultTypeFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Linq.Expressions;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
5 | using LBPUnion.ProjectLighthouse.Types.Filter;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
8 |
9 | public class ResultTypeFilter : ISlotFilter
10 | {
11 | private readonly string[] results;
12 |
13 | public ResultTypeFilter(params string[] results)
14 | {
15 | this.results = results;
16 | }
17 |
18 | public Expression> GetPredicate() => this.results.Contains("slot") ? s => true : s => false;
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/SlotIdFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Linq.Expressions;
5 | using LBPUnion.ProjectLighthouse.Extensions;
6 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
7 | using LBPUnion.ProjectLighthouse.Types.Filter;
8 |
9 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
10 |
11 | public class SlotIdFilter : ISlotFilter
12 | {
13 | private readonly List slotIds;
14 |
15 | public SlotIdFilter(List slotIds)
16 | {
17 | this.slotIds = slotIds;
18 | }
19 |
20 | public Expression> GetPredicate()
21 | {
22 | Expression> predicate = PredicateExtensions.False();
23 | predicate = this.slotIds.Aggregate(predicate, (current, slotId) => current.Or(s => s.SlotId == slotId));
24 | return predicate;
25 | }
26 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/SlotTypeFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 | using LBPUnion.ProjectLighthouse.Types.Levels;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
8 |
9 | public class SlotTypeFilter : ISlotFilter
10 | {
11 | private readonly SlotType slotType;
12 |
13 | public SlotTypeFilter(SlotType slotType)
14 | {
15 | this.slotType = slotType;
16 | }
17 |
18 | public Expression> GetPredicate() => s => s.Type == this.slotType;
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/SubLevelFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class SubLevelFilter : ISlotFilter
9 | {
10 | private readonly int userId;
11 |
12 | public SubLevelFilter(int userId)
13 | {
14 | this.userId = userId;
15 | }
16 |
17 | public Expression> GetPredicate() => s => !s.SubLevel || s.CreatorId == this.userId;
18 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Filters/TeamPickFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Filters;
7 |
8 | public class TeamPickFilter : ISlotFilter
9 | {
10 | public Expression> GetPredicate() => s => s.TeamPickTime != 0;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/FirstUploadedSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
7 |
8 | public class FirstUploadedSort : ISlotSort
9 | {
10 | public Expression> GetExpression() => s => s.FirstUploaded;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/LastUpdatedSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
7 |
8 | public class LastUpdatedSort : ISlotSort
9 | {
10 | public Expression> GetExpression() => s => s.LastUpdated;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/Metadata/HeartsSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
4 | using LBPUnion.ProjectLighthouse.Types.Misc;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts.Metadata;
7 |
8 | public class HeartsSort : ISort
9 | {
10 | public Expression> GetExpression() => s => s.Hearts;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/Metadata/RatingLBP1Sort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
4 | using LBPUnion.ProjectLighthouse.Types.Misc;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts.Metadata;
7 |
8 | public class RatingLBP1Sort : ISort
9 | {
10 | public Expression> GetExpression() => s => s.RatingLbp1;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/Metadata/ThumbsUpSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
4 | using LBPUnion.ProjectLighthouse.Types.Misc;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts.Metadata;
7 |
8 | public class ThumbsUpSort : ISort
9 | {
10 | public Expression> GetExpression() => s => s.ThumbsUp;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/PlaysForGameSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 | using LBPUnion.ProjectLighthouse.Types.Users;
6 | using Microsoft.EntityFrameworkCore;
7 |
8 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
9 |
10 | public class PlaysForGameSort : ISlotSort
11 | {
12 | private readonly GameVersion targetVersion;
13 |
14 | public PlaysForGameSort(GameVersion targetVersion)
15 | {
16 | this.targetVersion = targetVersion;
17 | }
18 |
19 | private string GetColName() =>
20 | this.targetVersion switch
21 | {
22 | GameVersion.LittleBigPlanet1 => "LBP1",
23 | GameVersion.LittleBigPlanet2 => "LBP2",
24 | GameVersion.LittleBigPlanet3 => "LBP3",
25 | GameVersion.LittleBigPlanetVita => "LBP2",
26 | _ => "",
27 | };
28 |
29 | public Expression> GetExpression() => s => EF.Property(s, $"Plays{this.GetColName()}");
30 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/RandomFirstUploadedSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 | using Microsoft.EntityFrameworkCore;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
8 |
9 | public class RandomFirstUploadedSort : ISlotSort
10 | {
11 | private const double biasFactor = .8f;
12 |
13 | public Expression> GetExpression() =>
14 | s => EF.Functions.Random() * (s.FirstUploaded * biasFactor);
15 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/RandomSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 | using Microsoft.EntityFrameworkCore;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
8 |
9 | public class RandomSort : ISlotSort
10 | {
11 | public Expression> GetExpression() => _ => EF.Functions.Random();
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/SlotIdSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
7 |
8 | public class SlotIdSort : ISlotSort
9 | {
10 | public Expression> GetExpression() => s => s.SlotId;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/TeamPickSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
7 |
8 | public class TeamPickSort : ISlotSort
9 | {
10 | public Expression> GetExpression() => s => s.TeamPickTime;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/TotalPlaysSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
7 |
8 | public class TotalPlaysSort : ISlotSort
9 | {
10 | public Expression> GetExpression() => s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Filter/Sorts/UniquePlaysTotalSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Filter.Sorts;
7 |
8 | public class UniquePlaysTotalSort : ISlotSort
9 | {
10 | public Expression> GetExpression() =>
11 | s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique;
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Helpers/SanitizationHelper.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Helpers;
5 |
6 | public static class SanitizationHelper
7 | {
8 | public static bool IsValidEmail(string? email) => !string.IsNullOrWhiteSpace(email) && new EmailAddressAttribute().IsValid(email);
9 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Helpers/TimeHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Helpers;
4 |
5 | public static class TimeHelper
6 | {
7 | public static long Timestamp => DateTimeOffset.UtcNow.ToUnixTimeSeconds();
8 |
9 | public static long TimestampMillis => DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
10 | }
11 |
12 | // 1397109686193
13 | // 1635389749454
--------------------------------------------------------------------------------
/ProjectLighthouse/Logging/Loggers/AspNet/AspNetToLighthouseLoggerProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.Logging;
3 | using IAspLogger = Microsoft.Extensions.Logging.ILogger;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Logging.Loggers.AspNet;
6 |
7 | [ProviderAlias("Kettu")]
8 | public class AspNetToLighthouseLoggerProvider : ILoggerProvider
9 | {
10 | public void Dispose()
11 | {
12 | GC.SuppressFinalize(this);
13 | }
14 |
15 | public IAspLogger CreateLogger(string category) => new AspNetToLighthouseLogger(category);
16 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Logging/Loggers/InMemoryLogger.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using LBPUnion.ProjectLighthouse.Types.Logging;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Logging.Loggers;
5 |
6 | public class InMemoryLogger : ILogger
7 | {
8 | public readonly List Lines = new();
9 |
10 | public void Log(LogLine line)
11 | {
12 | lock(this.Lines)
13 | {
14 | this.Lines.Add(line);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Logging/NullScope.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Logging;
4 |
5 | public class NullScope : IDisposable
6 | {
7 |
8 | private NullScope()
9 | {}
10 | public static NullScope Instance { get; } = new();
11 |
12 | public void Dispose()
13 | {
14 | GC.SuppressFinalize(this);
15 | }
16 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Mail/NullMailService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Types.Mail;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Mail;
6 |
7 | public class NullMailService : IMailService, IDisposable
8 | {
9 | public void SendEmail(string recipientAddress, string subject, string body) { }
10 | public Task SendEmailAsync(string recipientAddress, string subject, string body) => Task.FromResult(true);
11 | public void Dispose() => GC.SuppressFinalize(this);
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Mail/SmtpMailSender.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 | using System.Net.Mail;
3 | using LBPUnion.ProjectLighthouse.Configuration;
4 | using LBPUnion.ProjectLighthouse.Types.Mail;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Mail;
7 |
8 | public class SmtpMailSender : IMailSender
9 | {
10 | public async void SendEmail(MailMessage message)
11 | {
12 | using SmtpClient client = new(ServerConfiguration.Instance.Mail.Host, ServerConfiguration.Instance.Mail.Port)
13 | {
14 | EnableSsl = ServerConfiguration.Instance.Mail.UseSSL,
15 | Credentials = new NetworkCredential(ServerConfiguration.Instance.Mail.Username,
16 | ServerConfiguration.Instance.Mail.Password),
17 | };
18 | await client.SendMailAsync(message);
19 | }
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Middlewares/FakeRemoteIPAddressMiddleware.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 | using System.Threading.Tasks;
3 | using Microsoft.AspNetCore.Http;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Middlewares;
6 |
7 | public class FakeRemoteIPAddressMiddleware : Middleware
8 | {
9 | private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.0.0.1");
10 |
11 | public FakeRemoteIPAddressMiddleware(RequestDelegate next) : base(next)
12 | {}
13 |
14 | public override async Task InvokeAsync(HttpContext ctx)
15 | {
16 | ctx.Connection.RemoteIpAddress = this.fakeIpAddress;
17 |
18 | await this.next(ctx);
19 | }
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Middlewares/Middleware.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using System.Threading.Tasks;
3 | using JetBrains.Annotations;
4 | using Microsoft.AspNetCore.Http;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Middlewares;
7 |
8 | public abstract class Middleware
9 | {
10 | // this makes it consistent with typical middleware usage
11 | [SuppressMessage("ReSharper", "InconsistentNaming")]
12 | protected internal RequestDelegate next { get; init; }
13 |
14 | protected Middleware(RequestDelegate next)
15 | {
16 | this.next = next;
17 | }
18 |
19 | [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
20 | public abstract Task InvokeAsync(HttpContext ctx);
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Middlewares/MiddlewareDBContext.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 | using System.Threading.Tasks;
3 | using JetBrains.Annotations;
4 | using LBPUnion.ProjectLighthouse.Database;
5 | using Microsoft.AspNetCore.Http;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Middlewares;
8 |
9 | public abstract class MiddlewareDBContext
10 | {
11 | // this makes it consistent with typical middleware usage
12 | [SuppressMessage("ReSharper", "InconsistentNaming")]
13 | protected RequestDelegate next { get; }
14 |
15 | protected MiddlewareDBContext(RequestDelegate next)
16 | {
17 | this.next = next;
18 | }
19 |
20 | [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
21 | public abstract Task InvokeAsync(HttpContext ctx, DatabaseContext db);
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211020220840_ResourceList.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211020220840_ResourceList")]
9 | public partial class ResourceList : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.RenameColumn(
14 | name: "Resource",
15 | table: "Slots",
16 | newName: "ResourceCollection");
17 | }
18 |
19 | protected override void Down(MigrationBuilder migrationBuilder)
20 | {
21 | migrationBuilder.RenameColumn(
22 | name: "ResourceCollection",
23 | table: "Slots",
24 | newName: "Resource");
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211029213334_RemoveUsedSlotsFromDb.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211029213334_RemoveUsedSlotsFromDb")]
9 | public partial class RemoveUsedSlotsFromDb : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.DropColumn(
14 | name: "UsedSlots",
15 | table: "Users");
16 | }
17 |
18 | protected override void Down(MigrationBuilder migrationBuilder)
19 | {
20 | migrationBuilder.AddColumn(
21 | name: "UsedSlots",
22 | table: "Users",
23 | type: "int",
24 | nullable: false,
25 | defaultValue: 0);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211030203837_AddMMPickToSlot.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211030203837_AddMMPickToSlot")]
9 | public partial class AddMMPickToSlot : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.AddColumn(
14 | name: "MMPick",
15 | table: "Slots",
16 | type: "tinyint(1)",
17 | nullable: false,
18 | defaultValue: false);
19 | }
20 |
21 | protected override void Down(MigrationBuilder migrationBuilder)
22 | {
23 | migrationBuilder.DropColumn(
24 | name: "MMPick",
25 | table: "Slots");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211102215859_RenameTeamPick.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211102215859_RenameTeamPick")]
9 | public partial class RenameTeamPick : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.RenameColumn(
14 | name: "MMPick",
15 | table: "Slots",
16 | newName: "TeamPick");
17 | }
18 |
19 | protected override void Down(MigrationBuilder migrationBuilder)
20 | {
21 | migrationBuilder.RenameColumn(
22 | name: "TeamPick",
23 | table: "Slots",
24 | newName: "MMPick");
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211108013443_RemoveCommentsEnabled.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211108013443_RemoveCommentsEnabled")]
9 | public partial class RemoveCommentsEnabled : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.DropColumn(
14 | name: "CommentsEnabled",
15 | table: "Users");
16 | }
17 |
18 | protected override void Down(MigrationBuilder migrationBuilder)
19 | {
20 | migrationBuilder.AddColumn(
21 | name: "CommentsEnabled",
22 | table: "Users",
23 | type: "tinyint(1)",
24 | nullable: false,
25 | defaultValue: false);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211108015422_AddPlaysToSlot.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211108015422_AddPlaysToSlot")]
9 | public partial class AddPlaysToSlot : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.AddColumn(
14 | name: "Plays",
15 | table: "Slots",
16 | type: "int",
17 | nullable: false,
18 | defaultValue: 0);
19 | }
20 |
21 | protected override void Down(MigrationBuilder migrationBuilder)
22 | {
23 | migrationBuilder.DropColumn(
24 | name: "Plays",
25 | table: "Slots");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211109225543_AddLevelTypeToSlot.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211109225543_AddLevelTypeToSlot")]
9 | public partial class AddLevelTypeToSlot : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.AddColumn(
14 | name: "LevelType",
15 | table: "Slots",
16 | type: "longtext",
17 | nullable: true)
18 | .Annotation("MySql:CharSet", "utf8mb4");
19 | }
20 |
21 | protected override void Down(MigrationBuilder migrationBuilder)
22 | {
23 | migrationBuilder.DropColumn(
24 | name: "LevelType",
25 | table: "Slots");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211113091631_AddUserLocationToToken.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211113091631_AddUserLocationToToken")]
9 | public partial class AddUserLocationToToken : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.AddColumn(
14 | name: "UserLocation",
15 | table: "Tokens",
16 | type: "longtext",
17 | nullable: true)
18 | .Annotation("MySql:CharSet", "utf8mb4");
19 | }
20 |
21 | protected override void Down(MigrationBuilder migrationBuilder)
22 | {
23 | migrationBuilder.DropColumn(
24 | name: "UserLocation",
25 | table: "Tokens");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211113220306_VisitedLevelDropGameVersion.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | namespace ProjectLighthouse.Migrations
6 | {
7 | [DbContext(typeof(DatabaseContext))]
8 | [Migration("20211113220306_VisitedLevelDropGameVersion")]
9 | public partial class VisitedLevelDropGameVersion : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.DropColumn(
14 | name: "GameVersion",
15 | table: "VisitedLevels");
16 | }
17 |
18 | protected override void Down(MigrationBuilder migrationBuilder)
19 | {
20 | migrationBuilder.AddColumn(
21 | name: "GameVersion",
22 | table: "VisitedLevels",
23 | type: "int",
24 | nullable: false,
25 | defaultValue: 0);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211115050553_UserAddDefaultsToNullableStrings.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | #nullable disable
6 |
7 | namespace ProjectLighthouse.Migrations
8 | {
9 | [DbContext(typeof(DatabaseContext))]
10 | [Migration("20211115050553_UserAddDefaultsToNullableStrings")]
11 | public partial class UserAddDefaultsToNullableStrings : Migration
12 | {
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.Sql("UPDATE Slots SET AuthorLabels = \"\" WHERE AuthorLabels IS NULL");
16 | migrationBuilder.Sql("UPDATE Slots SET LevelType = \"\" WHERE LevelType IS NULL");
17 | }
18 |
19 | protected override void Down(MigrationBuilder migrationBuilder)
20 | {
21 |
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211123224001_AddIsAdminToUser.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 |
6 | #nullable disable
7 |
8 | namespace ProjectLighthouse.Migrations
9 | {
10 | [DbContext(typeof(DatabaseContext))]
11 | [Migration("20211123224001_AddIsAdminToUser")]
12 | public partial class AddIsAdminToUser : Migration
13 | {
14 | protected override void Up(MigrationBuilder migrationBuilder)
15 | {
16 | migrationBuilder.AddColumn(
17 | name: "IsAdmin",
18 | table: "Users",
19 | type: "tinyint(1)",
20 | nullable: false,
21 | defaultValue: false);
22 | }
23 |
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.DropColumn(
27 | name: "IsAdmin",
28 | table: "Users");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20211202235932_RenameLastMatchesToLastContacts.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Metadata;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 | using LBPUnion.ProjectLighthouse;
4 | using LBPUnion.ProjectLighthouse.Database;
5 | using Microsoft.EntityFrameworkCore.Infrastructure;
6 |
7 | #nullable disable
8 |
9 | namespace ProjectLighthouse.Migrations
10 | {
11 | [DbContext(typeof(DatabaseContext))]
12 | [Migration("20211202235932_RenameLastMatchesToLastContacts")]
13 | public partial class RenameLastMatchesToLastContacts : Migration
14 | {
15 | protected override void Up(MigrationBuilder migrationBuilder)
16 | {
17 | migrationBuilder.RenameTable(name: "LastMatches", newName: "LastContacts");
18 | }
19 |
20 | protected override void Down(MigrationBuilder migrationBuilder)
21 | {
22 | migrationBuilder.RenameTable(name: "LastContacts", newName: "LastMatches");
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20220610230647_AddExpirationDateToCases.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 |
7 | #nullable disable
8 |
9 | namespace ProjectLighthouse.Migrations
10 | {
11 | [DbContext(typeof(DatabaseContext))]
12 | [Migration("20220610230647_AddExpirationDateToCases")]
13 | public class AddExpirationDateToCases : Migration
14 | {
15 | protected override void Up(MigrationBuilder migrationBuilder)
16 | {
17 | migrationBuilder.AddColumn(
18 | name: "CaseExpires",
19 | table: "Cases",
20 | type: "datetime(6)",
21 | nullable: true);
22 | }
23 |
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.DropColumn(
27 | name: "CaseExpires",
28 | table: "Cases");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20220611012037_AddAffectedIdToCases.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse;
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Migrations;
5 |
6 | #nullable disable
7 |
8 | namespace ProjectLighthouse.Migrations
9 | {
10 | [DbContext(typeof(DatabaseContext))]
11 | [Migration("20220611012037_AddAffectedIdToCases")]
12 | public class AddAffectedIdToCases : Migration
13 | {
14 | protected override void Up(MigrationBuilder migrationBuilder)
15 | {
16 | migrationBuilder.AddColumn(
17 | name: "AffectedId",
18 | table: "Cases",
19 | type: "int",
20 | nullable: false,
21 | defaultValue: 0);
22 | }
23 |
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.DropColumn(
27 | name: "AffectedId",
28 | table: "Cases");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20220716234844_RemovedAPIKeyEnabled.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | #nullable disable
6 |
7 | namespace ProjectLighthouse.Migrations
8 | {
9 | [DbContext(typeof(DatabaseContext))]
10 | [Migration("20220716234844_RemovedAPIKeyEnabled")]
11 | public partial class RemovedAPIKeyEnabled : Migration
12 | {
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.DropColumn(
16 | name: "Enabled",
17 | table: "APIKeys");
18 | }
19 |
20 | protected override void Down(MigrationBuilder migrationBuilder)
21 | {
22 | migrationBuilder.AddColumn(
23 | name: "Enabled",
24 | table: "APIKeys",
25 | type: "tinyint(1)",
26 | nullable: false,
27 | defaultValue: false);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20220802150408_Arrrrrr.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using LBPUnion.ProjectLighthouse;
3 | using LBPUnion.ProjectLighthouse.Database;
4 | using Microsoft.EntityFrameworkCore.Infrastructure;
5 | using Microsoft.EntityFrameworkCore.Migrations;
6 |
7 | #nullable disable
8 |
9 | namespace ProjectLighthouse.Migrations
10 | {
11 | [DbContext(typeof(DatabaseContext))]
12 | [Migration("20220802150408_Arrrrrr")]
13 | public partial class Arrrrrr : Migration
14 | {
15 | protected override void Up(MigrationBuilder migrationBuilder)
16 | {
17 | migrationBuilder.AddColumn(
18 | name: "IsAPirate",
19 | table: "Users",
20 | type: "tinyint(1)",
21 | nullable: false,
22 | defaultValue: false);
23 | }
24 |
25 | protected override void Down(MigrationBuilder migrationBuilder)
26 | {
27 | migrationBuilder.DropColumn(
28 | name: "IsAPirate",
29 | table: "Users");
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20220916141401_ScoreboardAdvSlot.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse;
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Migrations;
5 |
6 | #nullable disable
7 |
8 | namespace ProjectLighthouse.Migrations
9 | {
10 | [DbContext(typeof(DatabaseContext))]
11 | [Migration("20220916141401_ScoreboardAdvSlot")]
12 | public partial class CreateScoreboardAdvSlot : Migration
13 | {
14 | protected override void Up(MigrationBuilder migrationBuilder)
15 | {
16 | migrationBuilder.AddColumn(
17 | name: "ChildSlotId",
18 | table: "Scores",
19 | type: "int",
20 | nullable: false,
21 | defaultValue: 0);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20220918154500_AddIsAdventureColumn.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse;
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Migrations;
5 |
6 | #nullable disable
7 |
8 | namespace ProjectLighthouse.Migrations
9 | {
10 | [DbContext(typeof(DatabaseContext))]
11 | [Migration("20220918154500_AddIsAdventureColumn")]
12 | public partial class AddisAdventureColumn : Migration
13 | {
14 | protected override void Up(MigrationBuilder migrationBuilder)
15 | {
16 | migrationBuilder.AddColumn(
17 | name: "IsAdventurePlanet",
18 | table: "Slots",
19 | type: "bool",
20 | nullable: false,
21 | defaultValue: false);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20221118162114_AddVerifiedToWebToken.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse;
2 | using LBPUnion.ProjectLighthouse.Database;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Migrations;
5 |
6 | #nullable disable
7 |
8 | namespace ProjectLighthouse.Migrations
9 | {
10 | [DbContext(typeof(DatabaseContext))]
11 | [Migration("20221118162114_AddVerifiedToWebToken")]
12 | public partial class AddVerifiedToWebToken : Migration
13 | {
14 | protected override void Up(MigrationBuilder migrationBuilder)
15 | {
16 | migrationBuilder.AddColumn(
17 | name: "Verified",
18 | table: "WebTokens",
19 | type: "tinyint(1)",
20 | nullable: false,
21 | defaultValue: false);
22 | }
23 |
24 | protected override void Down(MigrationBuilder migrationBuilder)
25 | {
26 | migrationBuilder.DropColumn(
27 | name: "Verified",
28 | table: "WebTokens");
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20230310075648_RemoveGameFromUser.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Database;
2 | using Microsoft.EntityFrameworkCore.Infrastructure;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | #nullable disable
6 |
7 | namespace ProjectLighthouse.Migrations
8 | {
9 | [DbContext(typeof(DatabaseContext))]
10 | [Migration("20230310075648_RemoveGameFromUser")]
11 | public partial class RemoveGameFromUser : Migration
12 | {
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.DropColumn(
16 | name: "Game",
17 | table: "Users");
18 | }
19 |
20 | protected override void Down(MigrationBuilder migrationBuilder)
21 | {
22 | migrationBuilder.AddColumn(
23 | name: "Game",
24 | table: "Users",
25 | type: "int",
26 | nullable: false,
27 | defaultValue: 0);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Migrations/20230827004014_AddProfileVanityTagsToUsers.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Database;
2 | using Microsoft.EntityFrameworkCore.Infrastructure;
3 | using Microsoft.EntityFrameworkCore.Migrations;
4 |
5 | #nullable disable
6 |
7 | namespace ProjectLighthouse.Migrations
8 | {
9 | [DbContext(typeof(DatabaseContext))]
10 | [Migration("20230827004014_AddProfileVanityTagsToUsers")]
11 | public partial class AddProfileVanityTagsToUsers : Migration
12 | {
13 | protected override void Up(MigrationBuilder migrationBuilder)
14 | {
15 | migrationBuilder.AddColumn(
16 | name: "ProfileTag",
17 | table: "Users",
18 | type: "longtext",
19 | nullable: true)
20 | .Annotation("MySql:CharSet", "utf8mb4");
21 | }
22 |
23 | protected override void Down(MigrationBuilder migrationBuilder)
24 | {
25 | migrationBuilder.DropColumn(
26 | name: "ProfileTag",
27 | table: "Users");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:43904",
8 | "sslPort": 44364
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "ProjectLighthouse": {
19 | "commandName": "Project",
20 | "dotnetRunMessages": "true",
21 | "applicationUrl": "http://localhost:10060",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development",
24 | "LIGHTHOUSE_DB_CONNECTION_STRING": "server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse"
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ProjectLighthouse/Serialization/JsonOutputFormatter.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc.Formatters;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Serialization;
4 |
5 | public class JsonOutputFormatter : StringOutputFormatter
6 | {
7 | public JsonOutputFormatter()
8 | {
9 | this.SupportedMediaTypes.Add("text/json");
10 | this.SupportedMediaTypes.Add("application/json");
11 | }
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Serialization/WriteFullClosingTagXmlWriter.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Xml;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Serialization;
5 |
6 | public class WriteFullClosingTagXmlWriter : ExcludeNamespaceXmlWriter
7 | {
8 | public WriteFullClosingTagXmlWriter(TextWriter stringWriter, XmlWriterSettings settings) : base(stringWriter, settings) { }
9 |
10 | public override void WriteEndElement()
11 | {
12 | base.WriteFullEndElement();
13 | }
14 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/android-chrome-192x192.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/android-chrome-512x512.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/apple-touch-icon.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/assets/advSlotCardMask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/assets/advSlotCardMask.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/assets/advSlotCardOverlay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/assets/advSlotCardOverlay.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/assets/slotCardBackground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/assets/slotCardBackground.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/assets/slotCardOverlay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/assets/slotCardOverlay.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #008cff
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.eot
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.ttf
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.woff
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/brand-icons.woff2
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.eot
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.ttf
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.woff
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/icons.woff2
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.eot
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.ttf
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.woff
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/fonts/outline-icons.woff2
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/css/themes/default/assets/images/flags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/css/themes/default/assets/images/flags.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/favicon-16x16.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/favicon-32x32.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/favicon.ico
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/logo-color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/logo-color.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/logo-mono.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/logo-mono.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/logo-pride.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/logo-pride.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LBPUnion/ProjectLighthouse/aeba706391746f1516b19d1ba0122b12664fe7e9/ProjectLighthouse/StaticFiles/mstile-150x150.png
--------------------------------------------------------------------------------
/ProjectLighthouse/StaticFiles/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Project Lighthouse",
3 | "short_name": "Lighthouse",
4 | "icons": [
5 | {
6 | "src": "/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "theme_color": "#008cff",
17 | "background_color": "#008cff",
18 | "display": "standalone"
19 | }
20 |
--------------------------------------------------------------------------------
/ProjectLighthouse/StorableLists/Stores/RoomStore.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.Collections.Generic;
3 | using LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
4 |
5 | namespace LBPUnion.ProjectLighthouse.StorableLists.Stores;
6 |
7 | public static class RoomStore
8 | {
9 | private static List? rooms;
10 |
11 | public static StorableList GetRooms()
12 | {
13 | if (RedisDatabase.Initialized)
14 | {
15 | return new RedisStorableList(RedisDatabase.GetRooms());
16 | }
17 |
18 | rooms ??= new List();
19 | return new NormalStorableList(rooms);
20 | }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Tickets/Parser/ITicketParser.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Tickets.Parser;
2 |
3 | public interface ITicketParser
4 | {
5 | public bool ParseTicket();
6 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Tickets/Parser/TicketParseException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Tickets.Parser;
4 |
5 | public class TicketParseException : Exception
6 | {
7 | public TicketParseException(string message)
8 | {
9 | this.Message = message;
10 | }
11 |
12 | public override string Message { get; }
13 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Tickets/Signature/NullSignatureVerifier.cs:
--------------------------------------------------------------------------------
1 | using Org.BouncyCastle.Crypto;
2 | using Org.BouncyCastle.Crypto.Parameters;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Tickets.Signature;
5 |
6 | public class NullSignatureVerifier : TicketSignatureVerifier
7 | {
8 | protected override ECPublicKeyParameters PublicKey => null;
9 | protected override string HashAlgorithm => null;
10 | protected override bool VerifySignature(ISigner signer) => false;
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Tickets/TicketVersion.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Tickets;
2 |
3 | public enum TicketVersion : ushort
4 | {
5 | V21 = 0x2101,
6 | V30 = 0x3100,
7 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/HeartedLevelEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class HeartedLevelEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int HeartedLevelId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public int SlotId { get; set; }
20 |
21 | [ForeignKey(nameof(SlotId))]
22 | public SlotEntity Slot { get; set; }
23 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/HeartedPlaylistEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class HeartedPlaylistEntity
9 | {
10 | [Key]
11 | public int HeartedPlaylistId { get; set; }
12 |
13 | public int UserId { get; set; }
14 |
15 | [ForeignKey(nameof(UserId))]
16 | public UserEntity User { get; set; }
17 |
18 | public int PlaylistId { get; set; }
19 |
20 | [ForeignKey(nameof(PlaylistId))]
21 | public PlaylistEntity Playlist { get; set; }
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/HeartedProfileEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
6 |
7 | public class HeartedProfileEntity
8 | {
9 | [Key]
10 | public int HeartedProfileId { get; set; }
11 |
12 | public int UserId { get; set; }
13 |
14 | [ForeignKey(nameof(UserId))]
15 | public UserEntity User { get; set; }
16 |
17 | public int HeartedUserId { get; set; }
18 |
19 | [ForeignKey(nameof(HeartedUserId))]
20 | public UserEntity HeartedUser { get; set; }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/QueuedLevelEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class QueuedLevelEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int QueuedLevelId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public int SlotId { get; set; }
20 |
21 | [ForeignKey(nameof(SlotId))]
22 | public SlotEntity Slot { get; set; }
23 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/RatedCommentEntity.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class RatedCommentEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int RatingId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity? User { get; set; }
18 |
19 | [ForeignKey(nameof(CommentId))]
20 | public CommentEntity? Comment { get; set; }
21 |
22 | public int CommentId { get; set; }
23 |
24 | public int Rating { get; set; }
25 |
26 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/RatedLevelEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class RatedLevelEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int RatedLevelId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public int SlotId { get; set; }
20 |
21 | [ForeignKey(nameof(SlotId))]
22 | public SlotEntity Slot { get; set; }
23 |
24 | public int Rating { get; set; }
25 |
26 | public double RatingLBP1 { get; set; }
27 |
28 | public string TagLBP1 { get; set; }
29 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/RatedReviewEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class RatedReviewEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int RatedReviewId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public int ReviewId { get; set; }
20 |
21 | [ForeignKey(nameof(ReviewId))]
22 | public ReviewEntity Review { get; set; }
23 |
24 | public int Thumb { get; set; }
25 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Interaction/VisitedLevelEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
7 |
8 | public class VisitedLevelEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int VisitedLevelId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public int SlotId { get; set; }
20 |
21 | [ForeignKey(nameof(SlotId))]
22 | public SlotEntity Slot { get; set; }
23 |
24 | public int PlaysLBP1 { get; set; }
25 | public int PlaysLBP2 { get; set; }
26 | public int PlaysLBP3 { get; set; }
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Level/DatabaseCategoryEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using System.Linq;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Level;
6 |
7 | public class DatabaseCategoryEntity
8 | {
9 | [Key]
10 | public int CategoryId { get; set; }
11 |
12 | public string Name { get; set; }
13 | public string Description { get; set; }
14 | public string IconHash { get; set; }
15 | public string Endpoint { get; set; }
16 |
17 | public string SlotIdsCollection { get; set; }
18 |
19 | [NotMapped]
20 | public int[] SlotIds {
21 | get => this.SlotIdsCollection.Split(",").Select(int.Parse).ToArray();
22 | set => this.SlotIdsCollection = string.Join(",", value);
23 | }
24 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Level/PlaylistEntity.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using System.Linq;
5 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Level;
8 |
9 | public class PlaylistEntity
10 | {
11 | [Key]
12 | public int PlaylistId { get; set; }
13 |
14 | public string Name { get; set; } = "";
15 |
16 | public string Description { get; set; } = "";
17 |
18 | public int CreatorId { get; set; }
19 |
20 | [ForeignKey(nameof(CreatorId))]
21 | public UserEntity? Creator { get; set; }
22 |
23 | public string SlotCollection { get; set; } = "";
24 |
25 | [NotMapped]
26 | public int[] SlotIds
27 | {
28 | get => this.SlotCollection.Split(",").Where(x => int.TryParse(x, out _)).Select(int.Parse).ToArray();
29 | set => this.SlotCollection = string.Join(",", value);
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Level/ScoreEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Level;
6 |
7 | public class ScoreEntity
8 | {
9 | [Key]
10 | public int ScoreId { get; set; }
11 |
12 | public int SlotId { get; set; }
13 |
14 | [ForeignKey(nameof(SlotId))]
15 | public SlotEntity Slot { get; set; }
16 |
17 | public int ChildSlotId { get; set; }
18 |
19 | public int Type { get; set; }
20 |
21 | public int UserId { get; set; }
22 |
23 | [ForeignKey(nameof(UserId))]
24 | public UserEntity User { get; set; }
25 |
26 | public int Points { get; set; }
27 |
28 | public long Timestamp { get; set; }
29 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Maintenance/CompletedMigrationEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using LBPUnion.ProjectLighthouse.Types.Maintenance;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Maintenance;
6 |
7 | ///
8 | /// A record of the completion of a .
9 | ///
10 | public class CompletedMigrationEntity
11 | {
12 | ///
13 | /// The name of the migration.
14 | ///
15 | ///
16 | /// Do not use the user-friendly name when setting this.
17 | ///
18 | [Key]
19 | public string MigrationName { get; set; }
20 |
21 | ///
22 | /// The moment the migration was ran.
23 | ///
24 | public DateTime RanAt { get; set; }
25 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Notifications/NotificationEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
4 | using LBPUnion.ProjectLighthouse.Types.Notifications;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
7 |
8 | public class NotificationEntity
9 | {
10 | [Key]
11 | public int Id { get; set; }
12 |
13 | public int UserId { get; set; }
14 |
15 | #nullable enable
16 |
17 | [ForeignKey(nameof (UserId))]
18 | public UserEntity? User { get; set; }
19 |
20 | #nullable disable
21 |
22 | public NotificationType Type { get; set; } = NotificationType.ModerationNotification;
23 |
24 | public string Text { get; set; } = "";
25 |
26 | public bool IsDismissed { get; set; }
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Profile/BlockedProfileEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | public class BlockedProfileEntity
7 | {
8 | // ReSharper disable once UnusedMember.Global
9 | [Key]
10 | public int BlockedProfileId { get; set; }
11 |
12 | public int UserId { get; set; }
13 |
14 | [ForeignKey(nameof(UserId))]
15 | public UserEntity User { get; set; }
16 |
17 | public int BlockedUserId { get; set; }
18 |
19 | [ForeignKey(nameof(BlockedUserId))]
20 | public UserEntity BlockedUser { get; set; }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Profile/LastContactEntity.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using LBPUnion.ProjectLighthouse.Types.Users;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Profile;
7 |
8 | public class LastContactEntity
9 | {
10 | [Key]
11 | public int UserId { get; set; }
12 |
13 | [ForeignKey(nameof(UserId))]
14 | public UserEntity? User { get; set; }
15 |
16 | public long Timestamp { get; set; }
17 |
18 | public GameVersion GameVersion { get; set; } = GameVersion.Unknown;
19 |
20 | public Platform Platform { get; set; } = Platform.Unknown;
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Profile/PhotoSubjectEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | public class PhotoSubjectEntity
7 | {
8 | [Key]
9 | public int PhotoSubjectId { get; set; }
10 |
11 | public int UserId { get; set; }
12 |
13 | [ForeignKey(nameof(UserId))]
14 | public UserEntity User { get; set; }
15 |
16 | public int PhotoId { get; set; }
17 |
18 | [ForeignKey(nameof(PhotoId))]
19 | public PhotoEntity Photo { get; set; }
20 |
21 | public string Bounds { get; set; }
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Profile/PlatformLinkAttemptEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Users;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Profile;
6 |
7 | public class PlatformLinkAttemptEntity
8 | {
9 | [Key]
10 | public int PlatformLinkAttemptId { get; set; }
11 |
12 | [ForeignKey(nameof(UserId))]
13 | public UserEntity User { get; set; }
14 |
15 | public int UserId { get; set; }
16 |
17 | public ulong PlatformId { get; set; }
18 |
19 | public Platform Platform { get; set; }
20 |
21 | public long Timestamp { get; set; }
22 |
23 | public string IPAddress { get; set; } = "";
24 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/ApiKeyEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
5 |
6 | public class ApiKeyEntity
7 | {
8 | [Key]
9 | public int Id { get; set; }
10 |
11 | public string Description { get; set; }
12 |
13 | public string Key { get; set; }
14 |
15 | public DateTime Created { get; set; }
16 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/EmailSetTokenEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
7 |
8 | public class EmailSetTokenEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int EmailSetTokenId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public string EmailToken { get; set; }
20 |
21 | public DateTime ExpiresAt { get; set; }
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/EmailVerificationTokenEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
7 |
8 | public class EmailVerificationTokenEntity
9 | {
10 | // ReSharper disable once UnusedMember.Global
11 | [Key]
12 | public int EmailVerificationTokenId { get; set; }
13 |
14 | public int UserId { get; set; }
15 |
16 | [ForeignKey(nameof(UserId))]
17 | public UserEntity User { get; set; }
18 |
19 | public string EmailToken { get; set; }
20 |
21 | public DateTime ExpiresAt { get; set; }
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/GameTokenEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 | using LBPUnion.ProjectLighthouse.Types.Users;
6 |
7 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
8 |
9 | public class GameTokenEntity
10 | {
11 | // ReSharper disable once UnusedMember.Global
12 | [Key]
13 | public int TokenId { get; set; }
14 |
15 | public int UserId { get; set; }
16 |
17 | [ForeignKey(nameof(UserId))]
18 | public UserEntity User { get; set; }
19 |
20 | public string UserToken { get; set; }
21 |
22 | public GameVersion GameVersion { get; set; }
23 |
24 | public Platform Platform { get; set; }
25 |
26 | [StringLength(64)]
27 | public string TicketHash { get; set; }
28 |
29 | [StringLength(64)]
30 | public string LocationHash { get; set; }
31 |
32 | public DateTime ExpiresAt { get; set; }
33 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/PasswordResetTokenEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
5 |
6 | public class PasswordResetTokenEntity
7 | {
8 | // ReSharper disable once UnusedMember.Global
9 | [Key]
10 | public int TokenId { get; set; }
11 |
12 | public int UserId { get; set; }
13 |
14 | public string ResetToken { get; set; }
15 |
16 | public DateTime Created { get; set; }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/RegistrationTokenEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
5 |
6 | public class RegistrationTokenEntity
7 | {
8 | // ReSharper disable once UnusedMember.Global
9 | [Key]
10 | public int TokenId { get; set; }
11 |
12 | public string Token { get; set; }
13 |
14 | public DateTime Created { get; set; }
15 |
16 | public string Username { get; set; }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Token/WebTokenEntity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Token;
5 |
6 | public class WebTokenEntity
7 | {
8 | // ReSharper disable once UnusedMember.Global
9 | [Key]
10 | public int TokenId { get; set; }
11 |
12 | public int UserId { get; set; }
13 |
14 | public string UserToken { get; set; }
15 |
16 | public DateTime ExpiresAt { get; set; }
17 |
18 | public bool Verified { get; set; }
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Entities/Website/WebsiteAnnouncementEntity.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Entities.Website;
6 |
7 | public class WebsiteAnnouncementEntity
8 | {
9 | [Key]
10 | public int AnnouncementId { get; set; }
11 |
12 | public string Title { get; set; }
13 |
14 | public string Content { get; set; }
15 |
16 | #nullable enable
17 |
18 | public int? PublisherId { get; set; }
19 |
20 | [ForeignKey(nameof(PublisherId))]
21 | public UserEntity? Publisher { get; set; }
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/FilterLocation.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Filter;
2 |
3 | public enum FilterLocation
4 | {
5 | SlotName = 0,
6 | SlotDescription = 1,
7 | SlotReview = 2,
8 | UserBiography = 3,
9 | UserComment = 4,
10 | ChatMessage = 5,
11 | Test = 6,
12 | None = 7,
13 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/IFilter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | public interface IFilter
7 | {
8 | public Expression> GetPredicate();
9 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/IQueryBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | public interface IQueryBuilder
7 | {
8 | public Expression> Build();
9 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/ISlotFilter.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Filter;
4 |
5 | public interface ISlotFilter : IFilter
6 | { }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/PaginationData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using LBPUnion.ProjectLighthouse.Configuration;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Filter;
5 |
6 | public struct PaginationData
7 | {
8 | public PaginationData()
9 | { }
10 |
11 | public int PageStart { get; init; } = 0;
12 | public int PageSize { get; init; } = 0;
13 | public int TotalElements { get; set; } = 0;
14 | public int MaxElements { get; set; } = ServerConfiguration.Instance.UserGeneratedContentLimits.EntitledSlots;
15 |
16 | public int HintStart => this.PageStart + Math.Min(this.PageSize, this.MaxElements);
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/Sorts/ISlotSort.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
4 |
5 | public interface ISlotSort : ISort
6 | { }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/Sorts/ISort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
5 |
6 | public interface ISort
7 | {
8 | public Expression> GetExpression();
9 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Filter/Sorts/ISortBuilder.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Filter.Sorts;
4 |
5 | public interface ISortBuilder
6 | {
7 | public IOrderedQueryable Build(IQueryable queryable);
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Levels/SlotType.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Levels;
4 |
5 | public enum SlotType
6 | {
7 | [XmlEnum("developer")]
8 | Developer = 0,
9 | [XmlEnum("user")]
10 | User = 1,
11 | [XmlEnum("moon")]
12 | Moon = 2,
13 | Unknown = 3,
14 | Unknown2 = 4,
15 | [XmlEnum("pod")]
16 | Pod = 5,
17 | [XmlEnum("local")]
18 | Local = 6,
19 | DLC = 8,
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Logging/ILogger.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Logging;
2 |
3 | public interface ILogger
4 | {
5 | public void Log(LogLine line);
6 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Logging/LogArea.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Logging;
4 |
5 | [SuppressMessage("ReSharper", "InconsistentNaming")]
6 | public enum LogArea
7 | {
8 | Login,
9 | Startup,
10 | Category,
11 | Comments,
12 | Config,
13 | Database,
14 | Filter,
15 | HTTP,
16 | Match,
17 | Photos,
18 | Resources,
19 | Logger,
20 | Redis,
21 | Command,
22 | Admin,
23 | Publish,
24 | Maintenance,
25 | Score,
26 | RateLimit,
27 | Deserialization,
28 | Email,
29 | Serialization,
30 | Synchronization,
31 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Logging/LogLevel.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Logging;
2 |
3 | public enum LogLevel
4 | {
5 | Success = 0,
6 | Info = 1,
7 | Warning = 2,
8 | Error = 3,
9 | Debug = 4,
10 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Logging/LogLine.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Logging;
2 |
3 | public struct LogLine
4 | {
5 | public LogTrace Trace;
6 | public LogLevel Level;
7 | public string Area;
8 | public string Message;
9 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Logging/LogTrace.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | namespace LBPUnion.ProjectLighthouse.Types.Logging;
3 |
4 | public struct LogTrace
5 | {
6 | public string? Name;
7 | public string? Section;
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Mail/IMailSender.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Mail;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Mail;
4 |
5 | public interface IMailSender
6 | {
7 | public void SendEmail(MailMessage message);
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Mail/IMailService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Mail;
4 |
5 | public interface IMailService
6 | {
7 | public void SendEmail(string recipientAddress, string subject, string body);
8 | public Task SendEmailAsync(string recipientAddress, string subject, string body);
9 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Maintenance/ICommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using JetBrains.Annotations;
4 | using LBPUnion.ProjectLighthouse.Logging;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Maintenance;
7 |
8 | [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
9 | public interface ICommand
10 | {
11 | public string FirstAlias => this.Aliases()[0];
12 | public Task Run(IServiceProvider provider, string[] args, Logger logger);
13 |
14 | public string Name();
15 |
16 | public string[] Aliases();
17 |
18 | public string Arguments();
19 |
20 | public int RequiredArgs();
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Maintenance/IMaintenanceJob.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using JetBrains.Annotations;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Maintenance;
5 |
6 | [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
7 | public interface IMaintenanceJob
8 | {
9 | public Task Run();
10 |
11 | public string Name();
12 |
13 | public string Description();
14 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Maintenance/IRepeatingTask.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using LBPUnion.ProjectLighthouse.Database;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Maintenance;
6 |
7 | public interface IRepeatingTask
8 | {
9 | public string Name { get; }
10 | public TimeSpan RepeatInterval { get; }
11 | public DateTime LastRan { get; set; }
12 |
13 | public Task Run(DatabaseContext database);
14 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Maintenance/MigrationTask.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using LBPUnion.ProjectLighthouse.Database;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Maintenance;
5 |
6 | public enum MigrationHook
7 | {
8 | Before,
9 | None,
10 | }
11 |
12 | public abstract class MigrationTask
13 | {
14 | ///
15 | /// The user-friendly name of a migration.
16 | ///
17 | public abstract string Name();
18 |
19 | public virtual MigrationHook HookType() => MigrationHook.None;
20 |
21 | ///
22 | /// Performs the migration.
23 | ///
24 | /// The Lighthouse database.
25 | /// True if successful, false if not.
26 | public abstract Task Run(DatabaseContext database);
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/MatchCommands/IMatchCommand.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking.MatchCommands;
2 |
3 | public interface IMatchCommand
4 | {}
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/MatchCommands/UpdateMyPlayerData.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking.MatchCommands;
5 |
6 | public class UpdateMyPlayerData : IMatchCommand
7 | {
8 | public string Player { get; set; } = null!;
9 |
10 | public RoomState? RoomState { get; set; }
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/MatchCommands/UpdatePlayersInRoom.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Diagnostics.CodeAnalysis;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking.MatchCommands;
5 |
6 | [SuppressMessage("ReSharper", "CollectionNeverUpdated.Global")]
7 | public class UpdatePlayersInRoom : IMatchCommand
8 | {
9 | public List Players { get; set; }
10 | public List Reservations { get; set; }
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/NatType.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking;
2 |
3 | public enum NatType
4 | {
5 | Open = 1,
6 | Moderate = 2,
7 | Strict = 3,
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/Player.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Text.Json.Serialization;
4 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking;
7 |
8 | [Serializable]
9 | public class Player
10 | {
11 | [JsonIgnore]
12 | public UserEntity User { get; set; }
13 |
14 | [SuppressMessage("ReSharper", "UnusedMember.Global")]
15 | public string PlayerId => this.User.Username;
16 |
17 | [JsonPropertyName("matching_res")]
18 | public int MatchingRes { get; set; }
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/Rooms/FindBestRoomResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text.Json.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
5 |
6 | public class FindBestRoomResponse
7 | {
8 | public int RoomId;
9 |
10 | public List Players { get; set; }
11 |
12 | public List> Slots { get; set; }
13 |
14 | [JsonIgnore]
15 | public IEnumerable FirstSlot => this.Slots[0];
16 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/Rooms/RoomSlot.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Types.Levels;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
4 |
5 | public class RoomSlot
6 | {
7 | public int SlotId { get; set; }
8 | public SlotType SlotType { get; set; }
9 |
10 | public static readonly RoomSlot PodSlot = new()
11 | {
12 | SlotType = SlotType.Pod,
13 | SlotId = 0,
14 | };
15 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Matchmaking/Rooms/RoomState.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics.CodeAnalysis;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Matchmaking.Rooms;
4 |
5 | [SuppressMessage("ReSharper", "UnusedMember.Global")]
6 | public enum RoomState
7 | {
8 | ///
9 | /// The room isn't doing anything in particular.
10 | ///
11 | Idle = 0,
12 |
13 | ///
14 | /// The room is hosting a room on a slot for others to join.
15 | ///
16 | PlayingLevel = 1,
17 |
18 | ///
19 | /// ???
20 | ///
21 | Unknown = 2,
22 |
23 | ///
24 | /// The room is looking for other rooms to join.
25 | ///
26 | DivingIn = 3,
27 |
28 | ///
29 | /// The room is waiting for players to join their room.
30 | ///
31 | DivingInWaiting = 4,
32 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Misc/Location.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Misc;
4 |
5 | ///
6 | /// The location of a slot on a planet.
7 | ///
8 | [XmlRoot("location")]
9 | [XmlType("location")]
10 | public class Location
11 | {
12 | [XmlElement("x")]
13 | public int X { get; set; }
14 |
15 | [XmlElement("y")]
16 | public int Y { get; set; }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Misc/ServerType.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Misc;
2 |
3 | public enum ServerType
4 | {
5 | GameServer = 0,
6 | Website = 1,
7 | Api = 2,
8 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Misc/SlotMetadata.cs:
--------------------------------------------------------------------------------
1 | using LBPUnion.ProjectLighthouse.Types.Entities.Level;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Misc;
4 |
5 | public class SlotMetadata
6 | {
7 | public required SlotEntity Slot { get; init; }
8 | public double RatingLbp1 { get; init; }
9 | public int ThumbsUp { get; init; }
10 | public int Hearts { get; init; }
11 | public bool Played { get; set; }
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Moderation/Reports/GriefType.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
4 |
5 | public enum GriefType
6 | {
7 | [XmlEnum("1")]
8 | Obscene = 1,
9 |
10 | [XmlEnum("2")]
11 | Mature = 2,
12 |
13 | [XmlEnum("3")]
14 | Offensive = 3,
15 |
16 | [XmlEnum("4")]
17 | Violence = 4,
18 |
19 | [XmlEnum("5")]
20 | Illegal = 5,
21 |
22 | [XmlEnum("6")]
23 | Unknown = 6,
24 |
25 | [XmlEnum("7")]
26 | Tos = 7,
27 |
28 | [XmlEnum("8")]
29 | Other = 8,
30 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Moderation/Reports/Marqee.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
4 |
5 | [XmlRoot("marqee")]
6 | public class Marqee
7 | {
8 | [XmlElement("rect")]
9 | public Rectangle Rect { get; set; }
10 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Moderation/Reports/Rectangle.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
4 |
5 | public class Rectangle
6 | {
7 | [XmlAttribute("t")]
8 | public int Top { get; set; }
9 |
10 | [XmlAttribute("l")]
11 | public int Left { get; set; }
12 |
13 | [XmlAttribute("b")]
14 | public int Bottom { get; set; }
15 |
16 | [XmlAttribute("r")]
17 | public int Right { get; set; }
18 |
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Moderation/Reports/ReportPlayer.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
4 |
5 | [XmlRoot("player")]
6 | public class ReportPlayer
7 | {
8 | [XmlElement("id")]
9 | public string Name { get; set; }
10 |
11 | [XmlElement("rect")]
12 | public Rectangle Location { get; set; }
13 |
14 | [XmlAttribute("reporter")]
15 | public bool Reporter { get; set; }
16 |
17 | [XmlAttribute("ingamenow")]
18 | public bool InGame { get; set; }
19 |
20 | [XmlAttribute("playerNumber")]
21 | public int PlayerNum { get; set; }
22 |
23 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Moderation/Reports/VisiblePlayer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Moderation.Reports;
5 |
6 | [XmlRoot("visibleBadge")]
7 | [Serializable]
8 | public class VisiblePlayer
9 | {
10 | [XmlElement("id")]
11 | public string Name { get; set; }
12 |
13 | [XmlElement("hash")]
14 | public string Hash { get; set; }
15 |
16 | [XmlElement("rect")]
17 | public Rectangle Bounds { get; set; }
18 |
19 | [XmlAttribute("type")]
20 | public string Type { get; set; }
21 |
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Resources/LbpFileType.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Resources;
2 |
3 | public enum LbpFileType
4 | {
5 | Script, // .ff, FSH
6 | Texture, // TEX
7 | Level, // LVL
8 | Adventure, // ADC, ADS
9 | CrossLevel, // PRF, Cross controller level
10 | FileArchive, // .farc, (ends with FARC)
11 | Plan, // PLN, uploaded with levels
12 | Voice, // VOP, voice data
13 | MotionRecording, // used in LBP2+/V for the motion recorder
14 | Painting, // PTG, paintings
15 | Jpeg, // JFIF / FIF, used in sticker switches,
16 | Png, // used in LBP Vita
17 | Quest, // A LBP3 quest, used in the organizertron
18 | StreamingChunk, // used in LBP3 dynamic thermo levels
19 | Unknown,
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/Author.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
4 |
5 | [XmlRoot("author")]
6 | public struct Author : ILbpSerializable
7 | {
8 | public Author() { }
9 |
10 | public Author(string username)
11 | {
12 | this.Username = username;
13 | }
14 |
15 | [XmlElement("npHandle")]
16 | public string Username { get; set; }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/CategoryListResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("categories")]
7 | public class CategoryListResponse : ILbpSerializable
8 | {
9 | public CategoryListResponse() { }
10 |
11 | public CategoryListResponse(List categories, GameCategory textSearch, int total, string hint, int hintStart)
12 | {
13 | this.Categories = categories;
14 | this.Search = textSearch;
15 | this.Total = total;
16 | this.Hint = hint;
17 | this.HintStart = hintStart;
18 | }
19 |
20 | [XmlAttribute("total")]
21 | public int Total { get; set; }
22 |
23 | [XmlAttribute("hint")]
24 | public string Hint { get; set; } = "";
25 |
26 | [XmlAttribute("hint_start")]
27 | public int HintStart { get; set; }
28 |
29 | [XmlElement("text_search")]
30 | public GameCategory Search { get; set; }
31 |
32 | [XmlElement("category")]
33 | public List Categories { get; set; }
34 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/CommentListResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("comments")]
7 | public struct CommentListResponse : ILbpSerializable
8 | {
9 | public CommentListResponse(List comments)
10 | {
11 | this.Comments = comments;
12 | }
13 |
14 | [XmlElement("comment")]
15 | public List Comments { get; set; }
16 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/FriendResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("npdata")]
7 | public struct FriendResponse : ILbpSerializable
8 | {
9 |
10 | public FriendResponse(List friends)
11 | {
12 | this.Friends = friends;
13 | }
14 |
15 | [XmlArray("friends")]
16 | [XmlArrayItem("npHandle")]
17 | public List Friends { get; set; }
18 |
19 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/GameDeveloperVideos.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
4 |
5 | [XmlRoot("videos")]
6 | public class GameDeveloperVideos : ILbpSerializable { }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/GameNotification.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 | using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
3 | using LBPUnion.ProjectLighthouse.Types.Notifications;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
6 |
7 | [XmlRoot("notification")]
8 | public class GameNotification : ILbpSerializable
9 | {
10 | [XmlAttribute("type")]
11 | public NotificationType Type { get; set; }
12 |
13 | [XmlElement("text")]
14 | public string Text { get; set; } = "";
15 |
16 | public static GameNotification CreateFromEntity(NotificationEntity notification) => new()
17 | {
18 | Type = notification.Type,
19 | Text = notification.Text,
20 | };
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/GamePhotoSubject.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 | using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlType("subject")]
7 | [XmlRoot("subject")]
8 | public class GamePhotoSubject : ILbpSerializable
9 | {
10 |
11 | [XmlIgnore]
12 | public int UserId { get; set; }
13 |
14 | [XmlElement("npHandle")]
15 | public string Username { get; set; }
16 |
17 | [XmlElement("displayName")]
18 | public string DisplayName => this.Username;
19 |
20 | [XmlElement("bounds")]
21 | public string Bounds { get; set; }
22 |
23 | public static GamePhotoSubject CreateFromEntity(PhotoSubjectEntity entity) =>
24 | new()
25 | {
26 | UserId = entity.UserId,
27 | Bounds = entity.Bounds,
28 | };
29 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/IHasCustomRoot.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
2 |
3 | ///
4 | /// Used for serializable classes that benefit from having a custom root
5 | /// For example: If the underlying properties of a type don't change but the root tag does
6 | ///
7 | public interface IHasCustomRoot
8 | {
9 | public string GetRoot();
10 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/ILbpSerializable.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
2 |
3 | ///
4 | /// Used to indicate that a class can be serialized
5 | ///
6 | public interface ILbpSerializable { }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/INeedsPreparationForSerialization.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
2 |
3 | ///
4 | /// Allows serializable classes to fetch other data using DI services
5 | /// Function is called using reflection so there is no required methods.
6 | /// Method signature: public async Task PrepareSerialization(list of services)
7 | ///
8 | public interface INeedsPreparationForSerialization { }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/IconList.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | public struct IconList : ILbpSerializable
7 | {
8 | public IconList() { }
9 |
10 | public IconList(List iconHashList)
11 | {
12 | this.IconHashList = iconHashList;
13 | }
14 |
15 | [XmlElement("icon")]
16 | public List IconHashList { get; set; }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/LbpCustomXml.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
2 |
3 | public class LbpCustomXml : ILbpSerializable
4 | {
5 | public required string Content { get; init; }
6 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/MinimalUserListResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("users")]
7 | public struct MinimalUserListResponse : ILbpSerializable
8 | {
9 | public MinimalUserListResponse() { }
10 |
11 | public MinimalUserListResponse(List users)
12 | {
13 | this.Users = users;
14 | }
15 |
16 | [XmlElement("user")]
17 | public List Users { get; set; }
18 | }
19 |
20 | public class MinimalUserProfile : ILbpSerializable
21 | {
22 |
23 | [XmlElement("npHandle")]
24 | public NpHandle UserHandle { get; set; } = new();
25 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/NpHandle.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | public class NpHandle : ILbpSerializable
7 | {
8 | public NpHandle() { }
9 |
10 | public NpHandle(string username, string iconHash)
11 | {
12 | this.Username = username;
13 | this.IconHash = iconHash;
14 | }
15 |
16 | [XmlText]
17 | public string Username { get; set; }
18 |
19 | [DefaultValue("")]
20 | [XmlAttribute("icon")]
21 | public string IconHash { get; set; }
22 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/PhotoListResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("photos")]
7 | public struct PhotoListResponse : ILbpSerializable
8 | {
9 | public PhotoListResponse(List photos)
10 | {
11 | this.Photos = photos;
12 | }
13 |
14 | [XmlElement("photo")]
15 | public List Photos { get; set; }
16 |
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/PhotoSlot.cs:
--------------------------------------------------------------------------------
1 | #nullable enable
2 | using System.ComponentModel;
3 | using System.Xml.Serialization;
4 | using LBPUnion.ProjectLighthouse.Types.Levels;
5 |
6 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
7 |
8 | [XmlRoot("slot")]
9 | public class PhotoSlot : ILbpSerializable
10 | {
11 | [XmlAttribute("type")]
12 | public SlotType SlotType { get; set; }
13 |
14 | [XmlElement("id")]
15 | public int SlotId { get; set; }
16 |
17 | [DefaultValue("")]
18 | [XmlElement("rootLevel")]
19 | public string? RootLevel { get; set; }
20 |
21 | [DefaultValue("")]
22 | [XmlElement("name")]
23 | public string? LevelName { get; set; }
24 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/PlanetStatsResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
4 |
5 | [XmlRoot("planetStats")]
6 | public class PlanetStatsResponse : ILbpSerializable
7 | {
8 | public PlanetStatsResponse() { }
9 |
10 | public PlanetStatsResponse(int totalSlots, int teamPicks)
11 | {
12 | this.TotalSlotCount = totalSlots;
13 | this.TeamPickCount = teamPicks;
14 | }
15 |
16 | [XmlElement("totalSlotCount")]
17 | public int TotalSlotCount { get; set; }
18 |
19 | [XmlElement("mmPicksCount")]
20 | public int TeamPickCount { get; set; }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/PlaylistResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("playlists")]
7 | public struct PlaylistResponse : ILbpSerializable
8 | {
9 | [XmlElement("playlist")]
10 | public required List Playlists { get; set; }
11 |
12 | [XmlAttribute("total")]
13 | public required int Total { get; set; }
14 |
15 | [XmlAttribute("hint_start")]
16 | public required int HintStart { get; set; }
17 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/ReviewResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel;
3 | using System.Xml.Serialization;
4 |
5 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
6 |
7 | [XmlRoot("reviews")]
8 | public struct ReviewResponse : ILbpSerializable
9 | {
10 | public ReviewResponse(List reviews, long hint, int hintStart)
11 | {
12 | this.Reviews = reviews;
13 | this.Hint = hint;
14 | this.HintStart = hintStart;
15 | }
16 |
17 | [XmlElement("review")]
18 | public List Reviews { get; set; }
19 |
20 | [DefaultValue(0)]
21 | [XmlAttribute("hint")]
22 | public long Hint { get; set; }
23 |
24 | [DefaultValue(0)]
25 | [XmlAttribute("hint_start")]
26 | public int HintStart { get; set; }
27 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/ReviewSlot.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 | using LBPUnion.ProjectLighthouse.Types.Levels;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("slot")]
7 | public class ReviewSlot : ILbpSerializable
8 | {
9 | [XmlAttribute("type")]
10 | public SlotType SlotType { get; set; }
11 |
12 | [XmlText]
13 | public int SlotId { get; set; }
14 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/SlotResourceResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Xml.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
5 |
6 | [XmlRoot("slot")]
7 | public struct SlotResourceResponse : ILbpSerializable
8 | {
9 | public SlotResourceResponse(List resources)
10 | {
11 | this.Resources = resources;
12 | }
13 |
14 | [XmlAttribute("type")]
15 | public string Type { get; set; } = "user";
16 |
17 | [XmlElement("resource")]
18 | public List Resources { get; set; }
19 |
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Serialization/TelemetryConfigResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 |
3 | namespace LBPUnion.ProjectLighthouse.Types.Serialization;
4 |
5 | //TODO what is the format for telemetry
6 | [XmlRoot("t_enable")]
7 | public class TelemetryConfigResponse : ILbpSerializable
8 | {
9 | [XmlText]
10 | public bool TelemetryEnabled { get; set; }
11 |
12 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Users/LoginResult.cs:
--------------------------------------------------------------------------------
1 | using System.Xml.Serialization;
2 | using LBPUnion.ProjectLighthouse.Types.Serialization;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Users;
5 |
6 | ///
7 | /// Response to POST /login
8 | ///
9 | [XmlRoot("loginResult")]
10 | [XmlType("loginResult")]
11 | public class LoginResult : ILbpSerializable
12 | {
13 | [XmlElement("authTicket")]
14 | public string AuthTicket { get; set; }
15 |
16 | [XmlElement("lbpEnvVer")]
17 | public string ServerBrand { get; set; }
18 |
19 | [XmlElement("titleStorageURL")]
20 | public string TitleStorageUrl { get; set; }
21 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Users/PermissionLevel.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Users;
2 |
3 | public enum PermissionLevel
4 | {
5 | Banned = -3,
6 | Restricted = -2,
7 | Silenced = -1,
8 | Default = 0,
9 | Moderator = 1,
10 | Administrator = 2,
11 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Users/Platform.cs:
--------------------------------------------------------------------------------
1 | namespace LBPUnion.ProjectLighthouse.Types.Users;
2 |
3 | public static class PlatformExtensions
4 | {
5 |
6 | public static bool IsPSN(this Platform platform)
7 | {
8 | return platform == Platform.PS3 || platform == Platform.PSP || platform == Platform.Vita;
9 | }
10 | }
11 |
12 | public enum Platform
13 | {
14 | PS3 = 0,
15 | RPCS3 = 1,
16 | Vita = 2,
17 | PSP = 3,
18 | UnitTest = 4,
19 | Unknown = -1,
20 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/Types/Users/UserFriendData.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Redis.OM.Modeling;
3 |
4 | namespace LBPUnion.ProjectLighthouse.Types.Users;
5 |
6 | [Document(StorageType = StorageType.Json, Prefixes = new[] {"UserFriendData",})]
7 | public class UserFriendData
8 | {
9 | private int userId;
10 |
11 | [Indexed]
12 | public int UserId {
13 | get => this.userId;
14 | set {
15 | this.RedisId = value.ToString();
16 | this.userId = value;
17 | }
18 | }
19 |
20 | [RedisIdField]
21 | public string RedisId { get; set; }
22 |
23 | [Indexed]
24 | public List FriendIds { get; set; }
25 |
26 | [Indexed]
27 | public List BlockedIds { get; set; }
28 | }
--------------------------------------------------------------------------------
/ProjectLighthouse/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ProjectLighthouse/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/crowdin.yml:
--------------------------------------------------------------------------------
1 | project_id_env: CROWDIN_PROJECT_ID
2 | api_token_env: CROWDIN_PERSONAL_TOKEN
3 |
4 | preserve_hierarchy: true
5 | files:
6 | - source: /ProjectLighthouse.Localization/*.resx
7 | translation: /ProjectLighthouse.Localization/%file_name%.lang-%locale%.%file_extension%
8 | ignore:
9 | - /ProjectLighthouse.Localization/%file_name%.*.%file_extension%
10 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "8.0.0",
4 | "rollForward": "latestMajor",
5 | "allowPrerelease": true
6 | }
7 | }
--------------------------------------------------------------------------------
/qodana.yaml:
--------------------------------------------------------------------------------
1 | version: "1.0"
2 | linter: jetbrains/qodana-dotnet:2024.1
3 | profile:
4 | name: qodana.recommended
5 | include:
6 | - name: CheckDependencyLicenses
7 | exclude:
8 | - name: All
9 | paths:
10 | - ProjectLighthouse.Localization
11 | - ProjectLighthouse/Migrations
12 |
--------------------------------------------------------------------------------
/scripts-and-tools/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Build script for production
3 | #
4 | # No arguments
5 | # Called manually
6 |
7 | cd project-lighthouse || (echo "Source directory not found, pls clone properly~" && exit 1)
8 |
9 | echo "Pulling latest changes..."
10 | git pull
11 |
12 | echo "Building..."
13 | dotnet build -c Release
14 |
15 | exit $? # Expose error code from build command
--------------------------------------------------------------------------------
/scripts-and-tools/create-migration.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Developer script to create EntityFramework database migrations
4 | #
5 | # $1: Name of the migration, e.g. SwitchToPermissionLevels
6 | # Invoked manually
7 |
8 | export LIGHTHOUSE_DB_CONNECTION_STRING='server=127.0.0.1;uid=root;pwd=lighthouse;database=lighthouse'
9 | dotnet ef migrations add "$1" --project ../ProjectLighthouse
--------------------------------------------------------------------------------
/scripts-and-tools/docker-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | log() {
4 | type="$1"; shift
5 | printf '%s [%s] [Entrypoint]: %s\n' "$(date -Iseconds)" "$type" "$*"
6 | }
7 |
8 | log Note "Entrypoint script for Lighthouse $SERVER started"
9 |
10 | if [ ! -d "/lighthouse/data" ]; then
11 | log Note "Creating data directory"
12 | mkdir -p "/lighthouse/data"
13 | fi
14 |
15 | owner=$(stat -c "%U %G" /lighthouse/data)
16 | if [ "$owner" != "lighthouse lighthouse" ]; then
17 | log Note "Changing ownership of data directory"
18 | chown -R lighthouse:lighthouse /lighthouse/data
19 | fi
20 |
21 | if [ -d "/lighthouse/temp" ]; then
22 | log Note "Copying temp directory to data"
23 | cp -rn /lighthouse/temp/* /lighthouse/data
24 | rm -rf /lighthouse/temp
25 | fi
26 |
27 | # Start server
28 |
29 | log Note "Startup tasks finished, starting $SERVER..."
30 | cd /lighthouse/data || exit
31 | exec su-exec lighthouse:lighthouse dotnet /lighthouse/app/LBPUnion.ProjectLighthouse.Servers."$SERVER".dll
32 |
33 | exit $? # Expose error code from dotnet command
--------------------------------------------------------------------------------
/scripts-and-tools/project-lighthouse-api.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Project Lighthouse API - a clean-room, open-source custom server for LBP
3 | Documentation=https://github.com/LBPUnion/ProjectLighthouse
4 |
5 | [Service]
6 | Type=simple
7 | ExecStart=bash -c "/srv/lighthouse/start.sh API"
8 | TimeoutStopSec=15
9 | User=lighthouse
10 | Restart=on-failure
11 |
12 | [Install]
13 | Alias=lighthouse-api
14 | WantedBy=multi-user.target
--------------------------------------------------------------------------------
/scripts-and-tools/project-lighthouse-gameserver.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Project Lighthouse GameServer - a clean-room, open-source custom server for LBP
3 | Documentation=https://github.com/LBPUnion/ProjectLighthouse
4 |
5 | [Service]
6 | Type=simple
7 | ExecStart=bash -c "/srv/lighthouse/start.sh GameServer"
8 | TimeoutStopSec=15
9 | User=lighthouse
10 | Restart=on-failure
11 |
12 | [Install]
13 | Alias=lighthouse-website
14 | WantedBy=multi-user.target
--------------------------------------------------------------------------------
/scripts-and-tools/project-lighthouse-website.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Project Lighthouse Website - a clean-room, open-source custom server for LBP
3 | Documentation=https://github.com/LBPUnion/ProjectLighthouse
4 |
5 | [Service]
6 | Type=simple
7 | ExecStart=bash -c "/srv/lighthouse/start.sh Website"
8 | TimeoutStopSec=15
9 | User=lighthouse
10 | Restart=on-failure
11 |
12 | [Install]
13 | Alias=lighthouse-website
14 | WantedBy=multi-user.target
--------------------------------------------------------------------------------
/scripts-and-tools/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Startup script for production
3 | #
4 | # $1: Server to start; case sensitive!!!!!
5 | # Called from systemd units
6 |
7 | cd "$HOME"/data || (echo "Data directory not found, pls create one~" && exit 1)
8 |
9 | echo "Running..."
10 |
11 | # Normally this requires ASPNETCORE_URLS but we override that in the configuration
12 | dotnet ../project-lighthouse/ProjectLighthouse.Servers."$1"/bin/Release/net8.0/LBPUnion.ProjectLighthouse.Servers."$1".dll
13 |
14 | exit $? # Expose error code from dotnet command
--------------------------------------------------------------------------------
/scripts-and-tools/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Update script for production
3 | #
4 | # No arguments
5 | # Called manually
6 |
7 | sudo systemctl stop project-lighthouse*
8 |
9 | cd /srv/lighthouse || return
10 | sudo -u lighthouse -i /srv/lighthouse/build.sh
11 |
12 | sudo systemctl start project-lighthouse*
--------------------------------------------------------------------------------