chore: clean up backend code, fix most inspections
This commit is contained in:
parent
49b2902d6d
commit
11257ae069
21 changed files with 86 additions and 27 deletions
|
@ -12,6 +12,8 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Foxnouns.Backend;
|
||||
|
@ -20,8 +22,8 @@ public class Config
|
|||
{
|
||||
public string Host { get; init; } = "localhost";
|
||||
public int Port { get; init; } = 3000;
|
||||
public string BaseUrl { get; set; } = null!;
|
||||
public string MediaBaseUrl { get; set; } = null!;
|
||||
public string BaseUrl { get; init; } = null!;
|
||||
public string MediaBaseUrl { get; init; } = null!;
|
||||
|
||||
public string Address => $"http://{Host}:{Port}";
|
||||
public string MetricsAddress => $"http://{Host}:{Logging.MetricsPort}";
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright (C) 2023-present sam/u1f320 (vulpine.solutions)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using EntityFramework.Exceptions.Common;
|
||||
|
|
|
@ -73,7 +73,7 @@ public class FlagsController(
|
|||
await db.SaveChangesAsync();
|
||||
|
||||
queue.QueueInvocableWithPayload<CreateFlagInvocable, CreateFlagPayload>(
|
||||
new CreateFlagPayload(flag.Id, CurrentUser!.Id, req.Name, req.Image, req.Description)
|
||||
new CreateFlagPayload(flag.Id, CurrentUser!.Id, req.Image)
|
||||
);
|
||||
|
||||
return Accepted(userRenderer.RenderPrideFlag(flag));
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -89,5 +91,5 @@ public enum PreferenceSize
|
|||
|
||||
public class UserSettings
|
||||
{
|
||||
public bool? DarkMode { get; set; } = null;
|
||||
public bool? DarkMode { get; set; }
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Utils;
|
||||
|
||||
|
@ -23,8 +24,6 @@ public record PrideFlagResponse(Snowflake Id, string? ImageUrl, string Name, str
|
|||
|
||||
public record CreateFlagRequest(string Name, string Image, string? Description);
|
||||
|
||||
public record CreateFlagResponse(Snowflake Id, string Name, string? Description);
|
||||
|
||||
public class UpdateFlagRequest : PatchRequest
|
||||
{
|
||||
public string? Name { get; init; }
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Utils;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
// ReSharper disable NotAccessedPositionalProperty.Global
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Utils;
|
||||
|
|
|
@ -57,7 +57,7 @@ public static class WebApplicationExtensions
|
|||
|
||||
if (config.Logging.SeqLogUrl != null)
|
||||
{
|
||||
logCfg.WriteTo.Seq(config.Logging.SeqLogUrl, LogEventLevel.Verbose);
|
||||
logCfg.WriteTo.Seq(config.Logging.SeqLogUrl);
|
||||
}
|
||||
|
||||
// AddSerilog doesn't seem to add an ILogger to the service collection, so add that manually.
|
||||
|
|
|
@ -18,12 +18,6 @@ namespace Foxnouns.Backend.Jobs;
|
|||
|
||||
public record AvatarUpdatePayload(Snowflake Id, string? NewAvatar);
|
||||
|
||||
public record CreateFlagPayload(
|
||||
Snowflake Id,
|
||||
Snowflake UserId,
|
||||
string Name,
|
||||
string ImageData,
|
||||
string? Description
|
||||
);
|
||||
public record CreateFlagPayload(Snowflake Id, Snowflake UserId, string ImageData);
|
||||
|
||||
public record CreateDataExportPayload(Snowflake UserId);
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright (C) 2023-present sam/u1f320 (vulpine.solutions)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using Coravel.Mailer.Mail;
|
||||
|
||||
namespace Foxnouns.Backend.Mailables;
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright (C) 2023-present sam/u1f320 (vulpine.solutions)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using Coravel.Mailer.Mail;
|
||||
|
||||
namespace Foxnouns.Backend.Mailables;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
namespace Foxnouns.Backend.Middleware;
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using System.Net;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Web;
|
||||
using Foxnouns.Backend.Database;
|
||||
using Foxnouns.Backend.Database.Models;
|
||||
using Foxnouns.Backend.Extensions;
|
||||
|
||||
namespace Foxnouns.Backend.Services.Auth;
|
||||
|
||||
|
@ -120,8 +118,7 @@ public partial class FediverseAuthService
|
|||
|
||||
private async Task<string> GenerateMisskeyAuthUrlAsync(
|
||||
FediverseApplication app,
|
||||
bool forceRefresh,
|
||||
string? state = null
|
||||
bool forceRefresh
|
||||
)
|
||||
{
|
||||
if (forceRefresh)
|
||||
|
|
|
@ -131,8 +131,7 @@ public partial class FediverseAuthService
|
|||
),
|
||||
FediverseInstanceType.MisskeyApi => await GenerateMisskeyAuthUrlAsync(
|
||||
app,
|
||||
forceRefresh,
|
||||
state
|
||||
forceRefresh
|
||||
),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(app), app.InstanceType, null),
|
||||
};
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright (C) 2023-present sam/u1f320 (vulpine.solutions)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.RateLimiting;
|
||||
using NodaTime;
|
||||
|
|
|
@ -17,7 +17,6 @@ using Foxnouns.Backend.Database.Models;
|
|||
using Foxnouns.Backend.Dto;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Foxnouns.Backend.Services;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class MetricsCollectionService(ILogger logger, IServiceProvider services,
|
|||
// ReSharper disable once SuggestVarOrType_SimpleTypes
|
||||
await using var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||
|
||||
List<Instant>? users = await db
|
||||
List<Instant> users = await db
|
||||
.Users.Where(u => !u.Deleted)
|
||||
.Select(u => u.LastActive)
|
||||
.ToListAsync(ct);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using Minio;
|
||||
using Minio.DataModel;
|
||||
using Minio.DataModel.Args;
|
||||
using Minio.Exceptions;
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ using Foxnouns.Backend.Database.Models;
|
|||
using Foxnouns.Backend.Dto;
|
||||
using Foxnouns.Backend.Utils;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using NodaTime;
|
||||
|
||||
namespace Foxnouns.Backend.Services;
|
||||
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright (C) 2023-present sam/u1f320 (vulpine.solutions)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using Foxnouns.Backend.Database;
|
||||
using Microsoft.AspNetCore.OpenApi;
|
||||
using Microsoft.OpenApi.Any;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
using Foxnouns.Backend.Controllers;
|
||||
using Foxnouns.Backend.Dto;
|
||||
|
||||
namespace Foxnouns.Backend.Utils;
|
||||
|
|
Loading…
Reference in a new issue