Restructure extras

This commit is contained in:
Rory&
2026-01-17 02:18:03 +01:00
parent a32cc57e29
commit 8ea87873de
107 changed files with 404 additions and 266 deletions
@@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-ConfigTest-18d89c0e-df5d-447b-8429-7d526a35ab13</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spacebar.ConfigModel\Spacebar.ConfigModel.csproj" />
<ProjectReference Include="..\Spacebar.Db\Spacebar.Db.csproj" />
</ItemGroup>
</Project>
@@ -1,4 +1,4 @@
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class ApplicationModel {
public string Id { get; set; } = null!;
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class AsyncActionResult {
public AsyncActionResult() { }
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class FileMetadataModel {
public string UserId { get; set; } = null!;
@@ -1,4 +1,4 @@
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class ForceJoinRequest {
public string? UserId { get; set; } = null!;
@@ -1,4 +1,4 @@
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class GuildModel {
public string Id { get; set; } = null!;
@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public static class SpacebarRights {
[Flags]
@@ -1,4 +1,4 @@
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class StickerModel {
public string Id { get; set; } = null!;
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
namespace Spacebar.AdminApi.Models;
namespace Spacebar.Models.AdminApi;
public class UserModel {
public string Id { get; set; } = null!;
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Spacebar.Db.Models;
using Stream = Spacebar.Db.Models.Stream;
using Spacebar.Models.Db.Models;
using Stream = Spacebar.Models.Db.Models.Stream;
namespace Spacebar.Db.Contexts;
namespace Spacebar.Models.Db.Contexts;
public partial class SpacebarDbContext : DbContext
{
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("applications")]
[Index("BotUserId", Name = "REL_2ce5a55796fe4c2f77ece57a64", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("application_commands")]
public partial class ApplicationCommand
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("attachments")]
public partial class Attachment
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("audit_logs")]
public partial class AuditLog
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("automod_rules")]
public partial class AutomodRule
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("backup_codes")]
public partial class BackupCode
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("badges")]
public partial class Badge
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("bans")]
public partial class Ban
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("categories")]
public partial class Category
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("channels")]
public partial class Channel
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("client_release")]
public partial class ClientRelease
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("cloud_attachments")]
public partial class CloudAttachment
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("config")]
public partial class Config
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("connected_accounts")]
public partial class ConnectedAccount
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("connection_config")]
public partial class ConnectionConfig
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("embed_cache")]
public partial class EmbedCache
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("emojis")]
public partial class Emoji
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("guilds")]
public partial class Guild
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("instance_bans")]
[Index("OriginInstanceBanId", Name = "REL_0b02d18d0d830f160c921192a3", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("invites")]
public partial class Invite
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("members")]
[Index("Id", "GuildId", Name = "IDX_bb2bf9386ac443afbbbf9f12d3", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("messages")]
[Index("AuthorId", Name = "IDX_05535bc695e9f7ee104616459d")]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("migrations")]
public partial class Migration
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("notes")]
[Index("OwnerId", "TargetId", Name = "UQ_74e6689b9568cc965b8bfc9150b", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("rate_limits")]
public partial class RateLimit
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("read_states")]
[Index("ChannelId", "UserId", Name = "IDX_0abf8b443321bd3cf7f81ee17a", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("recipients")]
public partial class Recipient
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("relationships")]
[Index("FromId", "ToId", Name = "IDX_a0b2ff0a598df0b0d055934a17", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("roles")]
public partial class Role
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("security_keys")]
public partial class SecurityKey
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("security_settings")]
public partial class SecuritySetting
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("sessions")]
[Index("UserId", Name = "IDX_085d540d9f418cfbdc7bd55bb1")]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("stickers")]
public partial class Sticker
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("sticker_packs")]
public partial class StickerPack
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("streams")]
public partial class Stream
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("stream_sessions")]
public partial class StreamSession
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("teams")]
public partial class Team
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("team_members")]
public partial class TeamMember
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("templates")]
[Index("Code", Name = "UQ_be38737bf339baf63b1daeffb55", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("users")]
[Index("SettingsIndex", Name = "REL_0c14beb78d8c5ccba66072adbc", IsUnique = true)]
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("user_settings")]
public partial class UserSetting
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("user_settings_protos")]
public partial class UserSettingsProto
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("valid_registration_tokens")]
public partial class ValidRegistrationToken
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("voice_states")]
public partial class VoiceState
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Spacebar.Db.Models;
namespace Spacebar.Models.Db.Models;
[Table("webhooks")]
public partial class Webhook
@@ -2,10 +2,10 @@ using System.Text.Json.Nodes;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminApi.Extensions;
using Spacebar.AdminApi.Models;
using Spacebar.Models.AdminApi;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
using Spacebar.RabbitMqUtilities;
using Spacebar.ConfigModel.Extensions;
@@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using RabbitMQ.Client;
using Spacebar.AdminApi.Extensions;
using Spacebar.AdminApi.Models;
using Spacebar.Models.AdminApi;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
using Spacebar.RabbitMqUtilities;
namespace Spacebar.AdminApi.Controllers;
@@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminApi.Extensions;
using Spacebar.AdminApi.Models;
using Spacebar.Models.AdminApi;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
using Spacebar.RabbitMqUtilities;
namespace Spacebar.AdminApi.Controllers.Media;
@@ -1,10 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminApi.Extensions;
using Spacebar.AdminApi.Models;
using Spacebar.Models.AdminApi;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
using Spacebar.RabbitMqUtilities;
namespace Spacebar.AdminApi.Controllers.Media;
@@ -5,62 +5,76 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using RabbitMQ.Client;
using Spacebar.AdminApi.Extensions;
using Spacebar.AdminApi.Models;
using Spacebar.Models.AdminApi;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
using Spacebar.RabbitMqUtilities;
namespace Spacebar.AdminApi.Controllers;
[ApiController]
[Route("/users")]
public class UserController(ILogger<UserController> logger, Configuration config, RabbitMQConfiguration amqpConfig, SpacebarDbContext db, RabbitMQService mq, IServiceProvider sp, AuthenticationService auth) : ControllerBase {
public class UserController(
ILogger<UserController> logger,
Configuration config,
RabbitMQConfiguration amqpConfig,
SpacebarDbContext db,
RabbitMQService mq,
IServiceProvider sp,
AuthenticationService auth) : ControllerBase {
private readonly ILogger<UserController> _logger = logger;
[HttpGet]
public async IAsyncEnumerable<UserModel> Get() {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var results = db.Users.Select(x => new UserModel {
Id = x.Id,
Username = x.Username,
Discriminator = x.Discriminator,
Avatar = x.Avatar,
AccentColor = x.AccentColor,
Banner = x.Banner,
ThemeColors = x.ThemeColors,
Pronouns = x.Pronouns,
Phone = x.Phone,
Desktop = x.Desktop,
Mobile = x.Mobile,
Premium = x.Premium,
PremiumType = x.PremiumType,
Bot = x.Bot,
Bio = x.Bio,
System = x.System,
NsfwAllowed = x.NsfwAllowed,
MfaEnabled = x.MfaEnabled,
WebauthnEnabled = x.WebauthnEnabled,
CreatedAt = x.CreatedAt,
PremiumSince = x.PremiumSince,
Verified = x.Verified,
Disabled = x.Disabled,
Deleted = x.Deleted,
Email = x.Email,
Flags = x.Flags,
PublicFlags = x.PublicFlags,
Rights = x.Rights,
ApplicationBotUser = x.ApplicationBotUser == null ? null : new(),
ConnectedAccounts = new List<UserModel.ConnectedAccountModel>(),
MessageCount = x.MessageAuthors.Count, // This property is weirdly named due to scaffolding, might patch later
SessionCount = x.Sessions.Count,
TemplateCount = x.Templates.Count,
VoiceStateCount = x.VoiceStates.Count,
GuildCount = x.Guilds.Count,
OwnedGuildCount = x.Guilds.Count(g => g.OwnerId == x.Id)
}).AsAsyncEnumerable();
var results = db.Users
.Include(user => user.ApplicationBotUser)
.Include(user => user.MessageAuthors)
.Include(user => user.Sessions)
.Include(user => user.Templates)
.Include(user => user.VoiceStates)
.Include(user => user.Guilds)
.AsAsyncEnumerable().Select(x => new UserModel {
Id = x.Id,
Username = x.Username,
Discriminator = x.Discriminator,
Avatar = x.Avatar,
AccentColor = x.AccentColor,
Banner = x.Banner,
ThemeColors = x.ThemeColors,
Pronouns = x.Pronouns,
Phone = x.Phone,
Desktop = x.Desktop,
Mobile = x.Mobile,
Premium = x.Premium,
PremiumType = x.PremiumType,
Bot = x.Bot,
Bio = x.Bio,
System = x.System,
NsfwAllowed = x.NsfwAllowed,
MfaEnabled = x.MfaEnabled,
WebauthnEnabled = x.WebauthnEnabled,
CreatedAt = x.CreatedAt,
PremiumSince = x.PremiumSince,
Verified = x.Verified,
Disabled = x.Disabled,
Deleted = x.Deleted,
Email = x.Email,
Flags = x.Flags,
PublicFlags = x.PublicFlags,
Rights = x.Rights,
ApplicationBotUser = x.ApplicationBotUser == null ? null : new(),
ConnectedAccounts = new List<UserModel.ConnectedAccountModel>(),
MessageCount = x.MessageAuthors.Count, // This property is weirdly named due to scaffolding, might patch later
SessionCount = x.Sessions.Count,
TemplateCount = x.Templates.Count,
VoiceStateCount = x.VoiceStates.Count,
GuildCount = x.Guilds.Count,
OwnedGuildCount = x.Guilds.Count(g => g.OwnerId == x.Id)
});
await foreach (var user in results) {
yield return user;
}
@@ -150,7 +164,7 @@ public class UserController(ILogger<UserController> logger, Configuration config
[HttpGet("{id}/delete")]
public async IAsyncEnumerable<AsyncActionResult> DeleteUser(string id, [FromQuery] int messageDeleteChunkSize = 100) {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var user = await db.Users.FindAsync(id);
if (user == null) {
Console.WriteLine($"User {id} not found");
@@ -259,7 +273,7 @@ public class UserController(ILogger<UserController> logger, Configuration config
[HttpGet("duplicate")]
public async Task<IActionResult> Duplicate() {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var msg = db.Messages.First();
var channels = db.Channels.Select(x => new { x.Id, x.GuildId }).ToList();
int count = 1;
@@ -304,7 +318,7 @@ public class UserController(ILogger<UserController> logger, Configuration config
[HttpGet("duplicate/{id}")]
public async Task<IActionResult> DuplicateMessage(ulong id, [FromQuery] int count = 100) {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var msg = await db.Messages.FindAsync(id.ToString());
int createdCount = 1;
while (true) {
@@ -350,7 +364,7 @@ public class UserController(ILogger<UserController> logger, Configuration config
[HttpGet("truncate_messages")]
public async Task TruncateMessages() {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var channels = db.Channels.Select(x => new { x.Id, x.GuildId }).ToList();
var ss = new SemaphoreSlim(12, 12);
@@ -363,11 +377,11 @@ public class UserController(ILogger<UserController> logger, Configuration config
// set timeout
_db.Database.SetCommandTimeout(6000);
await _db.Database.ExecuteSqlAsync($"""
DELETE FROM messages
WHERE channel_id = '{channelId}'
AND guild_id = '{guildId}'
AND id LIKE '%{i:00}';
""");
DELETE FROM messages
WHERE channel_id = '{channelId}'
AND guild_id = '{guildId}'
AND id LIKE '%{i:00}';
""");
Console.WriteLine($"Truncated messages for {channelId} in {guildId} ending with {i}");
})).ToList();
@@ -381,7 +395,7 @@ public class UserController(ILogger<UserController> logger, Configuration config
private async IAsyncEnumerable<T> AggregateAsyncEnumerablesWithoutOrder<T>(params IEnumerable<IAsyncEnumerable<T>> enumerables) {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var enumerators = enumerables.Select(e => e.GetAsyncEnumerator()).ToList();
var tasks = enumerators.Select(e => e.MoveNextAsync().AsTask()).ToList();
@@ -434,31 +448,31 @@ public class UserController(ILogger<UserController> logger, Configuration config
}
// {
// "op": 0,
// "t": "GUILD_ROLE_UPDATE",
// "d": {
// "guild_id": "1006649183970562092",
// "role": {
// "id": "1006706520514028812",
// "guild_id": "1006649183970562092",
// "color": 16711680,
// "hoist": true,
// "managed": false,
// "mentionable": true,
// "name": "Adminstrator",
// "permissions": "9",
// "position": 5,
// "unicode_emoji": "💖",
// "flags": 0
// }
// },
// "s": 38
// "op": 0,
// "t": "GUILD_ROLE_UPDATE",
// "d": {
// "guild_id": "1006649183970562092",
// "role": {
// "id": "1006706520514028812",
// "guild_id": "1006649183970562092",
// "color": 16711680,
// "hoist": true,
// "managed": false,
// "mentionable": true,
// "name": "Adminstrator",
// "permissions": "9",
// "position": 5,
// "unicode_emoji": "💖",
// "flags": 0
// }
// },
// "s": 38
// }
[HttpGet("test")]
public async IAsyncEnumerable<string> Test() {
(await auth.GetCurrentUser(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var factory = new ConnectionFactory {
Uri = new Uri(amqpConfig.ToConnectionString())
};
@@ -511,9 +525,10 @@ public class UserController(ILogger<UserController> logger, Configuration config
await Task.Delay(10);
}
} while (!publishSuccess);
yield return $"{clr.r:X2} {clr.g:X2} {clr.b:X2} | {color:X8} | {sw.Elapsed} (waiting {Math.Max(0, (int)delay - (int)sw.ElapsedMilliseconds)} out of {delay} ms)";
await Task.Delay(Math.Max(0, (int)delay - (int)sw.ElapsedMilliseconds));
sw.Restart();
}
}
}
}
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminApi.Models;
using Spacebar.Db.Models;
using Spacebar.Models.AdminApi;
using Spacebar.Models.Db.Models;
namespace Spacebar.AdminApi.Extensions;
@@ -2,8 +2,8 @@ using System.IdentityModel.Tokens.Jwt;
using System.Security.Cryptography;
using Microsoft.IdentityModel.Tokens;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
namespace Spacebar.AdminApi.Middleware;
+1 -1
View File
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Http.Timeouts;
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminApi.Middleware;
using Spacebar.AdminApi.Services;
using Spacebar.Db.Contexts;
using Spacebar.Models.Db.Contexts;
using Spacebar.RabbitMqUtilities;
var builder = WebApplication.CreateBuilder(args);
@@ -1,8 +1,8 @@
using System.IdentityModel.Tokens.Jwt;
using System.Security.Cryptography;
using Microsoft.IdentityModel.Tokens;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.Models.Db.Contexts;
using Spacebar.Models.Db.Models;
namespace Spacebar.AdminApi.Services;
@@ -15,9 +15,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spacebar.AdminApi.Models\Spacebar.AdminApi.Models.csproj" />
<ProjectReference Include="..\Spacebar.ConfigModel\Spacebar.ConfigModel.csproj" />
<ProjectReference Include="..\Spacebar.Db\Spacebar.Db.csproj" />
<ProjectReference Include="..\Models\Spacebar.Models.AdminApi\Spacebar.Models.AdminApi.csproj" />
<ProjectReference Include="..\Models\Spacebar.Models.Config\Spacebar.Models.Config.csproj" />
<ProjectReference Include="..\Models\Spacebar.Models.Db\Spacebar.Models.Db.csproj" />
<ProjectReference Include="..\Utilities\Spacebar.RabbitMqUtilities\Spacebar.RabbitMqUtilities.csproj" />
</ItemGroup>
@@ -1,10 +1,5 @@
using System.Configuration;
using System.Net.Http.Headers;
using ArcaneLibs.Extensions.Streams;
using ImageMagick;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Build.Globbing;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata.Internal;
using Spacebar.AdminApi.TestClient.Services.Services;
namespace Spacebar.AdminApi.TestClient.Services.Controllers;
@@ -1,9 +1,5 @@
using System.Configuration;
using System.Net.Http.Headers;
using ArcaneLibs.Extensions.Streams;
using ImageMagick;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Build.Globbing;
using Spacebar.AdminApi.TestClient.Services.Services;
namespace Spacebar.AdminApi.TestClient.Services.Controllers;
@@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spacebar.Db\Spacebar.Db.csproj" />
<ProjectReference Include="..\Models\Spacebar.Models.Db\Spacebar.Models.Db.csproj" />
</ItemGroup>
</Project>
+170 -56
View File
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.Db", "Spacebar.Db\Spacebar.Db.csproj", "{524849DF-93BC-4632-B6C2-D05552C13887}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApi", "Spacebar.AdminApi\Spacebar.AdminApi.csproj", "{00E58C53-0AC1-4113-8CCF-D299861EA8D3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}"
@@ -15,76 +13,192 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApiTest", "Ut
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApi.TestClient", "Utilities\Spacebar.AdminApi.TestClient\Spacebar.AdminApi.TestClient.csproj", "{498DAD05-336E-4851-ABD8-4E7CCA8312B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApi.Models", "Spacebar.AdminApi.Models\Spacebar.AdminApi.Models.csproj", "{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApi.PrepareTestData", "Utilities\Spacebar.AdminApi.PrepareTestData\Spacebar.AdminApi.PrepareTestData.csproj", "{BCC6501C-16A7-4787-BA47-52DAE06718A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.CleanSettingsRows", "Spacebar.CleanSettingsRows\Spacebar.CleanSettingsRows.csproj", "{9B41FAC1-4427-487C-BF3F-69554848DEBF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.ConfigModel", "Spacebar.ConfigModel\Spacebar.ConfigModel.csproj", "{EC5C6A71-458A-4A1D-BE96-CCB84FF4AF1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigTest", "ConfigTest\ConfigTest.csproj", "{3BB51E17-8D3E-42FE-AAE6-C33DA5D8D323}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.Cdn", "Spacebar.Cdn\Spacebar.Cdn.csproj", "{A2B0770E-D5E6-47BC-8595-4469F5C3E993}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Models", "Models", "{259D1A9B-2927-4571-A366-68C3BB30C2B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.Models.Config", "Models\Spacebar.Models.Config\Spacebar.Models.Config.csproj", "{709BCD85-2E06-429B-A53E-95CCD286A94F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.Models.Db", "Models\Spacebar.Models.Db\Spacebar.Models.Db.csproj", "{753A55F0-A2CD-447B-8664-B06CB606CEAB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigTest", "Utilities\ConfigTest\ConfigTest.csproj", "{9B190B74-C7D0-4E60-9D73-008136A800FF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscordEmojiConverter", "Utilities\DiscordEmojiConverter\DiscordEmojiConverter.csproj", "{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.CleanSettingsRows", "Utilities\Spacebar.CleanSettingsRows\Spacebar.CleanSettingsRows.csproj", "{9AABE503-5D27-4D7F-8A01-4430422C4284}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.Models.AdminApi", "Models\Spacebar.Models.AdminApi\Spacebar.Models.AdminApi.csproj", "{F13D96E4-9C85-4853-B812-7FD35620382C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|x64.ActiveCfg = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|x64.Build.0 = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|x86.ActiveCfg = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|x86.Build.0 = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|Any CPU.Build.0 = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|x64.ActiveCfg = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|x64.Build.0 = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|x86.ActiveCfg = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|x86.Build.0 = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|x64.ActiveCfg = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|x64.Build.0 = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|x86.ActiveCfg = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|x86.Build.0 = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|Any CPU.Build.0 = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|x64.ActiveCfg = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|x64.Build.0 = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|x86.ActiveCfg = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|x86.Build.0 = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|x64.ActiveCfg = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|x64.Build.0 = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|x86.ActiveCfg = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|x86.Build.0 = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|Any CPU.Build.0 = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|x64.ActiveCfg = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|x64.Build.0 = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|x86.ActiveCfg = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|x86.Build.0 = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|x64.ActiveCfg = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|x64.Build.0 = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|x86.ActiveCfg = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|x86.Build.0 = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|Any CPU.Build.0 = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|x64.ActiveCfg = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|x64.Build.0 = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|x86.ActiveCfg = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|x86.Build.0 = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|x64.ActiveCfg = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|x64.Build.0 = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|x86.ActiveCfg = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|x86.Build.0 = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|Any CPU.Build.0 = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|x64.ActiveCfg = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|x64.Build.0 = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|x86.ActiveCfg = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|x86.Build.0 = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|x64.ActiveCfg = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|x64.Build.0 = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|x86.ActiveCfg = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|x86.Build.0 = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|Any CPU.Build.0 = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|x64.ActiveCfg = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|x64.Build.0 = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|x86.ActiveCfg = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|x86.Build.0 = Release|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Debug|x64.ActiveCfg = Debug|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Debug|x64.Build.0 = Debug|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Debug|x86.ActiveCfg = Debug|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Debug|x86.Build.0 = Debug|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Release|Any CPU.Build.0 = Release|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Release|x64.ActiveCfg = Release|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Release|x64.Build.0 = Release|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Release|x86.ActiveCfg = Release|Any CPU
{709BCD85-2E06-429B-A53E-95CCD286A94F}.Release|x86.Build.0 = Release|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Debug|x64.ActiveCfg = Debug|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Debug|x64.Build.0 = Debug|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Debug|x86.ActiveCfg = Debug|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Debug|x86.Build.0 = Debug|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Release|Any CPU.Build.0 = Release|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Release|x64.ActiveCfg = Release|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Release|x64.Build.0 = Release|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Release|x86.ActiveCfg = Release|Any CPU
{753A55F0-A2CD-447B-8664-B06CB606CEAB}.Release|x86.Build.0 = Release|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Debug|x64.ActiveCfg = Debug|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Debug|x64.Build.0 = Debug|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Debug|x86.ActiveCfg = Debug|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Debug|x86.Build.0 = Debug|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Release|Any CPU.Build.0 = Release|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Release|x64.ActiveCfg = Release|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Release|x64.Build.0 = Release|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Release|x86.ActiveCfg = Release|Any CPU
{9B190B74-C7D0-4E60-9D73-008136A800FF}.Release|x86.Build.0 = Release|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Debug|x64.ActiveCfg = Debug|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Debug|x64.Build.0 = Debug|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Debug|x86.ActiveCfg = Debug|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Debug|x86.Build.0 = Debug|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Release|Any CPU.Build.0 = Release|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Release|x64.ActiveCfg = Release|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Release|x64.Build.0 = Release|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Release|x86.ActiveCfg = Release|Any CPU
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF}.Release|x86.Build.0 = Release|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Debug|x64.ActiveCfg = Debug|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Debug|x64.Build.0 = Debug|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Debug|x86.ActiveCfg = Debug|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Debug|x86.Build.0 = Debug|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Release|Any CPU.Build.0 = Release|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Release|x64.ActiveCfg = Release|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Release|x64.Build.0 = Release|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Release|x86.ActiveCfg = Release|Any CPU
{9AABE503-5D27-4D7F-8A01-4430422C4284}.Release|x86.Build.0 = Release|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Debug|x64.ActiveCfg = Debug|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Debug|x64.Build.0 = Debug|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Debug|x86.ActiveCfg = Debug|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Debug|x86.Build.0 = Debug|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Release|Any CPU.Build.0 = Release|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Release|x64.ActiveCfg = Release|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Release|x64.Build.0 = Release|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Release|x86.ActiveCfg = Release|Any CPU
{F13D96E4-9C85-4853-B812-7FD35620382C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{524849DF-93BC-4632-B6C2-D05552C13887}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{524849DF-93BC-4632-B6C2-D05552C13887}.Debug|Any CPU.Build.0 = Debug|Any CPU
{524849DF-93BC-4632-B6C2-D05552C13887}.Release|Any CPU.ActiveCfg = Release|Any CPU
{524849DF-93BC-4632-B6C2-D05552C13887}.Release|Any CPU.Build.0 = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E58C53-0AC1-4113-8CCF-D299861EA8D3}.Release|Any CPU.Build.0 = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|Any CPU.Build.0 = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|Any CPU.Build.0 = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|Any CPU.Build.0 = Release|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Release|Any CPU.Build.0 = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|Any CPU.Build.0 = Release|Any CPU
{9B41FAC1-4427-487C-BF3F-69554848DEBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B41FAC1-4427-487C-BF3F-69554848DEBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B41FAC1-4427-487C-BF3F-69554848DEBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B41FAC1-4427-487C-BF3F-69554848DEBF}.Release|Any CPU.Build.0 = Release|Any CPU
{EC5C6A71-458A-4A1D-BE96-CCB84FF4AF1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC5C6A71-458A-4A1D-BE96-CCB84FF4AF1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC5C6A71-458A-4A1D-BE96-CCB84FF4AF1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC5C6A71-458A-4A1D-BE96-CCB84FF4AF1B}.Release|Any CPU.Build.0 = Release|Any CPU
{3BB51E17-8D3E-42FE-AAE6-C33DA5D8D323}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BB51E17-8D3E-42FE-AAE6-C33DA5D8D323}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BB51E17-8D3E-42FE-AAE6-C33DA5D8D323}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BB51E17-8D3E-42FE-AAE6-C33DA5D8D323}.Release|Any CPU.Build.0 = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2B0770E-D5E6-47BC-8595-4469F5C3E993}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{374314B2-7149-4316-8750-4E1E7BF6C3B4} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{498DAD05-336E-4851-ABD8-4E7CCA8312B0} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{BCC6501C-16A7-4787-BA47-52DAE06718A8} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{709BCD85-2E06-429B-A53E-95CCD286A94F} = {259D1A9B-2927-4571-A366-68C3BB30C2B2}
{753A55F0-A2CD-447B-8664-B06CB606CEAB} = {259D1A9B-2927-4571-A366-68C3BB30C2B2}
{9B190B74-C7D0-4E60-9D73-008136A800FF} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{BCE9DADB-4274-4190-8EA7-54F3EF6D5ECF} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{9AABE503-5D27-4D7F-8A01-4430422C4284} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{F13D96E4-9C85-4853-B812-7FD35620382C} = {259D1A9B-2927-4571-A366-68C3BB30C2B2}
EndGlobalSection
EndGlobal
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Models\Spacebar.Models.Config\Spacebar.Models.Config.csproj" />
<ProjectReference Include="..\..\Models\Spacebar.Models.Db\Spacebar.Models.Db.csproj" />
</ItemGroup>
</Project>
@@ -1,6 +1,6 @@
using ConfigTest;
using Microsoft.EntityFrameworkCore;
using Spacebar.Db.Contexts;
using Spacebar.Models.Db.Contexts;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHostedService<Worker>();
@@ -1,6 +1,6 @@
using System.Text.Json.Nodes;
using Spacebar.ConfigModel.Extensions;
using Spacebar.Db.Contexts;
using Spacebar.Models.Db.Contexts;
namespace ConfigTest;
@@ -1,6 +1,8 @@
using System.Collections.Frozen;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using ArcaneLibs.Extensions;
namespace Spacebar.AdminApi.TestClient.Classes.OpenAPI;
@@ -187,6 +189,8 @@ public class OpenApiSchemaRef {
public List<OpenApiSchemaRef>? AnyOf { get; set; }
public List<object>? Enum { get; set; }
public string? Format { get; set; }
public List<OpenApiSchemaRef>? Items { get; set; }
public Regex? Pattern { get; set; }
public OpenApiSchemaRef? GetReferencedSchema(OpenApiSchema schema) {
if (Ref == null) return null;
@@ -271,7 +275,7 @@ public class OpenApiSchemaRefConverter : JsonConverter<OpenApiSchemaRef> {
else if (property.Value.ValueKind == JsonValueKind.Null)
schemaRef.Default = null;
else if (property.Value.ValueKind == JsonValueKind.Array)
if (property.Value.GetArrayLength() > 0) throw new JsonException("Expected empty array in default");
if (property.Value.GetArrayLength() > 0) throw new JsonException($"Expected empty array in default, got: {property.Value.ToJson()}");
else schemaRef.Default = Array.Empty<object>();
else throw new JsonException($"Expected string|int|bool|null in default, got {property.Value.ValueKind}");
break;
@@ -303,8 +307,22 @@ public class OpenApiSchemaRefConverter : JsonConverter<OpenApiSchemaRef> {
case "additionalProperties": //TODO
case "patternProperties": // Side effect of using JsonValue in typescript
break;
case "items":
// Console.WriteLine($"Got 'items' property in OpenApiSchemaRef! NodeType: {property.Value.ValueKind}, Value: {property.Value.ToJson()}");
try {
schemaRef.Items = property.Value.ValueKind is JsonValueKind.Array ? property.Value.Deserialize<List<OpenApiSchemaRef>>(options) : [property.Value.Deserialize<OpenApiSchemaRef>(options)!];
} catch (Exception ex) {
throw new JsonException($"Error deserializing 'items' property: {ex.Message}\nValue: {property.Value.ToJson()}", ex);
}
break;
case "pattern":
var patternStr = property.Value.GetString();
if (patternStr != null) {
schemaRef.Pattern = new Regex(patternStr);
}
break;
default:
Console.WriteLine($"Got unexpected prop {property.Name} in OpenApiSchemaRef!");
Console.WriteLine($"Got unexpected prop {property.Name} in OpenApiSchemaRef! Value: {property.Value.ToJson()}");
break;
}
}
@@ -1,7 +1,7 @@
@page "/Guilds"
@using System.Net.Http.Headers
@using System.Reflection
@using Spacebar.AdminApi.Models
@using Spacebar.Models.AdminApi
@using Spacebar.AdminApi.TestClient.Services
@using ArcaneLibs.Blazor.Components
@using ArcaneLibs.Extensions
@@ -1,6 +1,6 @@
@page "/StickerCdnTest"
@using System.Net.Http.Headers
@using Spacebar.AdminApi.Models
@using Spacebar.Models.AdminApi
@using Spacebar.AdminApi.TestClient.Services
@inject Config Config
<h3>StickerCdnTest</h3>
@@ -1,7 +1,7 @@
@page "/Media/ByUser"
@using System.Net.Http.Headers
@using System.Reflection
@using Spacebar.AdminApi.Models
@using Spacebar.Models.AdminApi
@using Spacebar.AdminApi.TestClient.Services
@using ArcaneLibs.Blazor.Components
@inject Config Config
@@ -1,7 +1,7 @@
@page "/Users"
@using System.Net.Http.Headers
@using System.Reflection
@using Spacebar.AdminApi.Models
@using Spacebar.Models.AdminApi
@using Spacebar.AdminApi.TestClient.Services
@using ArcaneLibs.Blazor.Components
@using ArcaneLibs.Extensions
@@ -3,7 +3,7 @@
@using System.Text.Json
@using System.Text.Json.Nodes
@using ArcaneLibs.Extensions
@using Spacebar.AdminApi.Models
@using Spacebar.Models.AdminApi
@using Spacebar.AdminApi.TestClient.Services
@inject Config Config
<h3>UsersDelete - @Id</h3>
@@ -40,8 +40,8 @@
<ItemGroup>
<ProjectReference Include="..\..\Spacebar.AdminApi.Models\Spacebar.AdminApi.Models.csproj" />
<ProjectReference Include="..\..\Spacebar.ConfigModel\Spacebar.ConfigModel.csproj" />
<ProjectReference Include="..\..\Models\Spacebar.Models.AdminApi\Spacebar.Models.AdminApi.csproj" />
<ProjectReference Include="..\..\Models\Spacebar.Models.Config\Spacebar.Models.Config.csproj" />
</ItemGroup>
</Project>
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Spacebar.CleanSettingsRows;
using Spacebar.Db.Contexts;
using Spacebar.Models.Db.Contexts;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHostedService<Worker>();

Some files were not shown because too many files have changed in this diff Show More