Rewrite access tokens, initial admin api
This commit is contained in:
parent
ccf9afe57e
commit
a632666203
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,4 +19,5 @@ build
|
||||
*.tmp
|
||||
tmp/
|
||||
dump/
|
||||
result
|
||||
result
|
||||
jwt.key*
|
||||
55
.idea/workspace.xml
generated
55
.idea/workspace.xml
generated
@ -26,32 +26,32 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"NIXITCH_NIXPKGS_CONFIG": "/etc/nix/nixpkgs-config.nix",
|
||||
"NIXITCH_NIX_CONF_DIR": "",
|
||||
"NIXITCH_NIX_OTHER_STORES": "",
|
||||
"NIXITCH_NIX_PATH": "/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source",
|
||||
"NIXITCH_NIX_PROFILES": "/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile",
|
||||
"NIXITCH_NIX_REMOTE": "",
|
||||
"NIXITCH_NIX_USER_PROFILE_DIR": "/nix/var/nix/profiles/per-user/Rory",
|
||||
"Node.js.Server.ts.executor": "Debug",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"javascript.nodejs.core.library.configured.version": "20.17.0",
|
||||
"javascript.nodejs.core.library.typings.version": "20.17.10",
|
||||
"last_opened_file_path": "/home/Rory/git/spacebar/server/src/admin-api/routes/v0",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_interpreter_path": "/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0/bin/node",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"npm.build.executor": "Run",
|
||||
"npm.start.executor": "Debug",
|
||||
"prettierjs.PrettierConfiguration.Package": "/home/Rory/git/spacebar/server/node_modules/prettier",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"ts.external.directory.path": "/home/Rory/git/spacebar/server/node_modules/typescript/lib"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"NIXITCH_NIXPKGS_CONFIG": "/etc/nix/nixpkgs-config.nix",
|
||||
"NIXITCH_NIX_CONF_DIR": "",
|
||||
"NIXITCH_NIX_OTHER_STORES": "",
|
||||
"NIXITCH_NIX_PATH": "/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source",
|
||||
"NIXITCH_NIX_PROFILES": "/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile",
|
||||
"NIXITCH_NIX_REMOTE": "",
|
||||
"NIXITCH_NIX_USER_PROFILE_DIR": "/nix/var/nix/profiles/per-user/Rory",
|
||||
"Node.js.Server.ts.executor": "Debug",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"javascript.nodejs.core.library.configured.version": "20.17.0",
|
||||
"javascript.nodejs.core.library.typings.version": "20.17.10",
|
||||
"last_opened_file_path": "/home/Rory/git/spacebar/server/src/admin-api/routes/v0",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_interpreter_path": "/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0/bin/node",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"npm.build.executor": "Run",
|
||||
"npm.start.executor": "Debug",
|
||||
"prettierjs.PrettierConfiguration.Package": "/home/Rory/git/spacebar/server/node_modules/prettier",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"ts.external.directory.path": "/home/Rory/git/spacebar/server/node_modules/typescript/lib"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/src/admin-api/routes/v0" />
|
||||
@ -88,7 +88,9 @@
|
||||
<workItem from="1735162864847" duration="110000" />
|
||||
<workItem from="1735162995609" duration="261000" />
|
||||
<workItem from="1735163422404" duration="28000" />
|
||||
<workItem from="1735163530041" duration="14264000" />
|
||||
<workItem from="1735163530041" duration="25785000" />
|
||||
<workItem from="1735256039333" duration="390000" />
|
||||
<workItem from="1735256441657" duration="15485000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -106,7 +108,6 @@
|
||||
<line-breakpoint enabled="true" type="javascript">
|
||||
<url>file://$PROJECT_DIR$/src/admin-api/Server.ts</url>
|
||||
<line>140</line>
|
||||
<properties lambdaOrdinal="-1" />
|
||||
<option name="timeStamp" value="3" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
|
||||
1806
extra/admin-api/.editorconfig
Normal file
1806
extra/admin-api/.editorconfig
Normal file
File diff suppressed because one or more lines are too long
9
extra/admin-api/.gitignore
vendored
Normal file
9
extra/admin-api/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
**/bin/
|
||||
**/obj/
|
||||
/patches/
|
||||
appsettings.Local*.json
|
||||
*.DotSettings.user
|
||||
/*.patch
|
||||
|
||||
Spacebar.Db/**/*.orig
|
||||
Spacebar.Db/**/*.rej
|
||||
13
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/.gitignore
generated
vendored
Normal file
13
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/projectSettingsUpdater.xml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/.idea.SpacebarAdminAPI.iml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
1
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/.name
generated
Normal file
1
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
SpacebarAdminAPI
|
||||
4
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/encodings.xml
generated
Normal file
4
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/encodings.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/indexLayout.xml
generated
Normal file
8
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/indexLayout.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/vcs.xml
generated
Normal file
6
extra/admin-api/.idea/.idea.SpacebarAdminAPI/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,17 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Spacebar.Db.Contexts;
|
||||
using Spacebar.Db.Models;
|
||||
|
||||
namespace Spacebar.AdminAPI.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("/users")]
|
||||
public class UserController(ILogger<UserController> logger, SpacebarDbContext db) : ControllerBase {
|
||||
private readonly ILogger<UserController> _logger = logger;
|
||||
|
||||
[HttpGet(Name = "/")]
|
||||
public IAsyncEnumerable<User> Get() {
|
||||
return db.Users.AsAsyncEnumerable();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Spacebar.Db.Models;
|
||||
|
||||
namespace Spacebar.AdminAPI.Extensions;
|
||||
|
||||
public static class DbExtensions {
|
||||
public static string? GetString(this DbSet<Config> config, string key) => config.Find(key)?.Value;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
using System.Buffers.Text;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using ArcaneLibs.Extensions;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Spacebar.AdminAPI.Extensions;
|
||||
using Spacebar.Db.Contexts;
|
||||
|
||||
namespace Spacebar.AdminAPI.Middleware;
|
||||
|
||||
public class AuthenticationMiddleware(RequestDelegate next) {
|
||||
public async Task Invoke(HttpContext context) {
|
||||
if(Environment.GetEnvironmentVariable("SB_ADMIN_API_DISABLE_AUTH") == "true") {
|
||||
await next(context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.Request.Headers.ContainsKey("Authorization")) {
|
||||
context.Response.StatusCode = 401;
|
||||
await context.Response.WriteAsync("Authorization header is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
var token = context.Request.Headers["Authorization"].ToString().Split(' ').Last();
|
||||
|
||||
var handler = new JwtSecurityTokenHandler();
|
||||
var secretFile = File.ReadAllText("../../../jwt.key.pub");
|
||||
var key = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
key.ImportFromPem(secretFile);
|
||||
|
||||
var res = await handler.ValidateTokenAsync(token, new TokenValidationParameters {
|
||||
IssuerSigningKey = new ECDsaSecurityKey(key),
|
||||
ValidAlgorithms = new[] { "ES512" },
|
||||
LogValidationExceptions = true,
|
||||
// These are required to be false for the token to be valid as they aren't provided by the token
|
||||
ValidateIssuer = false,
|
||||
ValidateLifetime = false,
|
||||
ValidateAudience = false,
|
||||
});
|
||||
|
||||
if (!res.IsValid) {
|
||||
context.Response.StatusCode = 401;
|
||||
await context.Response.WriteAsync("Invalid token");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine(res.ClaimsIdentity.Claims.Select(x => $"{x.Type} : {x.Value}").ToJson());
|
||||
|
||||
await next(context);
|
||||
}
|
||||
}
|
||||
58
extra/admin-api/Spacebar.AdminAPI/Program.cs
Normal file
58
extra/admin-api/Spacebar.AdminAPI/Program.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Http.Timeouts;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Spacebar.AdminAPI.Middleware;
|
||||
using Spacebar.Db.Contexts;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers(options => {
|
||||
options.MaxValidationDepth = null;
|
||||
options.MaxIAsyncEnumerableBufferLimit = 100;
|
||||
}).AddJsonOptions(options => {
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||
options.JsonSerializerOptions.WriteIndented = true;
|
||||
});
|
||||
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddDbContextPool<SpacebarDbContext>(options => {
|
||||
options
|
||||
.UseNpgsql(builder.Configuration.GetConnectionString("Spacebar"))
|
||||
.EnableDetailedErrors();
|
||||
});
|
||||
|
||||
builder.Services.AddRequestTimeouts(x => {
|
||||
x.DefaultPolicy = new RequestTimeoutPolicy {
|
||||
Timeout = TimeSpan.FromMinutes(10),
|
||||
WriteTimeoutResponse = async context => {
|
||||
context.Response.StatusCode = 504;
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.StartAsync();
|
||||
await context.Response.WriteAsJsonAsync(new { error = "Unknown error" });
|
||||
await context.Response.CompleteAsync();
|
||||
}
|
||||
};
|
||||
});
|
||||
builder.Services.AddCors(options => {
|
||||
options.AddPolicy(
|
||||
"Open",
|
||||
policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseCors("Open");
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment()) {
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.UseMiddleware<AuthenticationMiddleware>();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"Development": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5112",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Local": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5112",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Local"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
extra/admin-api/Spacebar.AdminAPI/Spacebar.AdminAPI.csproj
Normal file
20
extra/admin-api/Spacebar.AdminAPI/Spacebar.AdminAPI.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ArcaneLibs" Version="1.0.0-preview.20241210-161342" />
|
||||
<PackageReference Include="ArcaneLibs.StringNormalisation" Version="1.0.0-preview.20241210-161342" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0"/>
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Spacebar.Db\Spacebar.Db.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
6
extra/admin-api/Spacebar.AdminAPI/Spacebar.AdminAPI.http
Normal file
6
extra/admin-api/Spacebar.AdminAPI/Spacebar.AdminAPI.http
Normal file
@ -0,0 +1,6 @@
|
||||
@Spacebar.AdminAPI_HostAddress = http://localhost:5112
|
||||
|
||||
GET {{Spacebar.AdminAPI_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Spacebar": "Host=127.0.0.1; Username=postgres; Database=spacebar"
|
||||
}
|
||||
}
|
||||
9
extra/admin-api/Spacebar.AdminAPI/appsettings.json
Normal file
9
extra/admin-api/Spacebar.AdminAPI/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
617
extra/admin-api/Spacebar.Db/Contexts/SpacebarDbContext.cs
Normal file
617
extra/admin-api/Spacebar.Db/Contexts/SpacebarDbContext.cs
Normal file
@ -0,0 +1,617 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Spacebar.Db.Models;
|
||||
|
||||
namespace Spacebar.Db.Contexts;
|
||||
|
||||
public partial class SpacebarDbContext : DbContext
|
||||
{
|
||||
public SpacebarDbContext(DbContextOptions<SpacebarDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Application> Applications { get; set; }
|
||||
|
||||
public virtual DbSet<Attachment> Attachments { get; set; }
|
||||
|
||||
public virtual DbSet<AuditLog> AuditLogs { get; set; }
|
||||
|
||||
public virtual DbSet<BackupCode> BackupCodes { get; set; }
|
||||
|
||||
public virtual DbSet<Badge> Badges { get; set; }
|
||||
|
||||
public virtual DbSet<Ban> Bans { get; set; }
|
||||
|
||||
public virtual DbSet<Category> Categories { get; set; }
|
||||
|
||||
public virtual DbSet<Channel> Channels { get; set; }
|
||||
|
||||
public virtual DbSet<ClientRelease> ClientReleases { get; set; }
|
||||
|
||||
public virtual DbSet<Config> Configs { get; set; }
|
||||
|
||||
public virtual DbSet<ConnectedAccount> ConnectedAccounts { get; set; }
|
||||
|
||||
public virtual DbSet<ConnectionConfig> ConnectionConfigs { get; set; }
|
||||
|
||||
public virtual DbSet<EmbedCache> EmbedCaches { get; set; }
|
||||
|
||||
public virtual DbSet<Emoji> Emojis { get; set; }
|
||||
|
||||
public virtual DbSet<Guild> Guilds { get; set; }
|
||||
|
||||
public virtual DbSet<Invite> Invites { get; set; }
|
||||
|
||||
public virtual DbSet<Member> Members { get; set; }
|
||||
|
||||
public virtual DbSet<Message> Messages { get; set; }
|
||||
|
||||
public virtual DbSet<Migration> Migrations { get; set; }
|
||||
|
||||
public virtual DbSet<Note> Notes { get; set; }
|
||||
|
||||
public virtual DbSet<RateLimit> RateLimits { get; set; }
|
||||
|
||||
public virtual DbSet<ReadState> ReadStates { get; set; }
|
||||
|
||||
public virtual DbSet<Recipient> Recipients { get; set; }
|
||||
|
||||
public virtual DbSet<Relationship> Relationships { get; set; }
|
||||
|
||||
public virtual DbSet<Role> Roles { get; set; }
|
||||
|
||||
public virtual DbSet<SecurityKey> SecurityKeys { get; set; }
|
||||
|
||||
public virtual DbSet<SecuritySetting> SecuritySettings { get; set; }
|
||||
|
||||
public virtual DbSet<Session> Sessions { get; set; }
|
||||
|
||||
public virtual DbSet<Sticker> Stickers { get; set; }
|
||||
|
||||
public virtual DbSet<StickerPack> StickerPacks { get; set; }
|
||||
|
||||
public virtual DbSet<Team> Teams { get; set; }
|
||||
|
||||
public virtual DbSet<TeamMember> TeamMembers { get; set; }
|
||||
|
||||
public virtual DbSet<Template> Templates { get; set; }
|
||||
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
|
||||
public virtual DbSet<UserSetting> UserSettings { get; set; }
|
||||
|
||||
public virtual DbSet<ValidRegistrationToken> ValidRegistrationTokens { get; set; }
|
||||
|
||||
public virtual DbSet<VoiceState> VoiceStates { get; set; }
|
||||
|
||||
public virtual DbSet<Webhook> Webhooks { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Application>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_938c0a27255637bde919591888f");
|
||||
|
||||
entity.HasOne(d => d.BotUser).WithOne(p => p.ApplicationBotUser)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_2ce5a55796fe4c2f77ece57a647");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Applications).HasConstraintName("FK_e5bf78cdbbe9ba91062d74c5aba");
|
||||
|
||||
entity.HasOne(d => d.Owner).WithMany(p => p.ApplicationOwners)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_e57508958bf92b9d9d25231b5e8");
|
||||
|
||||
entity.HasOne(d => d.Team).WithMany(p => p.Applications)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_a36ed02953077f408d0f3ebc424");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Attachment>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_5e1f050bcff31e3084a1d662412");
|
||||
|
||||
entity.HasOne(d => d.Message).WithMany(p => p.Attachments)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_623e10eec51ada466c5038979e3");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AuditLog>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_1bb179d048bbc581caa3b013439");
|
||||
|
||||
entity.HasOne(d => d.Target).WithMany(p => p.AuditLogTargets).HasConstraintName("FK_3cd01cd3ae7aab010310d96ac8e");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.AuditLogUsers).HasConstraintName("FK_bd2726fd31b35443f2245b93ba0");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<BackupCode>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_34ab957382dbc57e8fb53f1638f");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.BackupCodes)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_70066ea80d2f4b871beda32633b");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Badge>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_8a651318b8de577e8e217676466");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Ban>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_a4d6f261bffa4615c62d756566a");
|
||||
|
||||
entity.HasOne(d => d.Executor).WithMany(p => p.BanExecutors).HasConstraintName("FK_07ad88c86d1f290d46748410d58");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Bans)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_9d3ab7dd180ebdd245cdb66ecad");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.BanUsers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_5999e8e449f80a236ff72023559");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Category>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_24dbc6126a28ff948da33e97d3b");
|
||||
|
||||
entity.Property(e => e.Id).ValueGeneratedNever();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Channel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_bc603823f3f741359c2339389f9");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Channels)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_c253dafe5f3a03ec00cd8fb4581");
|
||||
|
||||
entity.HasOne(d => d.Owner).WithMany(p => p.Channels).HasConstraintName("FK_3873ed438575cce703ecff4fc7b");
|
||||
|
||||
entity.HasOne(d => d.Parent).WithMany(p => p.InverseParent).HasConstraintName("FK_3274522d14af40540b1a883fc80");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ClientRelease>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_4c4ea258342d2d6ba1be0a71a43");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Config>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Key).HasName("PK_26489c99ddbb4c91631ef5cc791");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ConnectedAccount>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_70416f1da0be645bb31da01c774");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.ConnectedAccounts)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_f47244225a6a1eac04a3463dd90");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ConnectionConfig>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Key).HasName("PK_bc0554f736ad71dde346549488a");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<EmbedCache>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_0abb7581d4efc5a8b1361389c5e");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Emoji>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_9adb96a675f555c6169bad7ba62");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Emojis).HasConstraintName("FK_4b988e0db89d94cebcf07f598cc");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.Emojis).HasConstraintName("FK_fa7ddd5f9a214e28ce596548421");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Guild>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_e7e7f2a51bd6d96a9ac2aa560f9");
|
||||
|
||||
entity.HasOne(d => d.AfkChannel).WithMany(p => p.GuildAfkChannels).HasConstraintName("FK_f591a66b8019d87b0fe6c12dad6");
|
||||
|
||||
entity.HasOne(d => d.Owner).WithMany(p => p.Guilds).HasConstraintName("FK_fc1a451727e3643ca572a3bb394");
|
||||
|
||||
entity.HasOne(d => d.PublicUpdatesChannel).WithMany(p => p.GuildPublicUpdatesChannels).HasConstraintName("FK_8d450b016dc8bec35f36729e4b0");
|
||||
|
||||
entity.HasOne(d => d.RulesChannel).WithMany(p => p.GuildRulesChannels).HasConstraintName("FK_95828668aa333460582e0ca6396");
|
||||
|
||||
entity.HasOne(d => d.SystemChannel).WithMany(p => p.GuildSystemChannels).HasConstraintName("FK_cfc3d3ad260f8121c95b31a1fce");
|
||||
|
||||
entity.HasOne(d => d.Template).WithMany(p => p.Guilds).HasConstraintName("FK_e2a2f873a64a5cf62526de42325");
|
||||
|
||||
entity.HasOne(d => d.WidgetChannel).WithMany(p => p.GuildWidgetChannels).HasConstraintName("FK_9d1d665379eefde7876a17afa99");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Invite>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Code).HasName("PK_33fd8a248db1cd832baa8aa25bf");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.Invites)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_6a15b051fe5050aa00a4b9ff0f6");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Invites)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_3f4939aa1461e8af57fea3fb05d");
|
||||
|
||||
entity.HasOne(d => d.Inviter).WithMany(p => p.InviteInviters)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_15c35422032e0b22b4ada95f48f");
|
||||
|
||||
entity.HasOne(d => d.TargetUser).WithMany(p => p.InviteTargetUsers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_11a0d394f8fc649c19ce5f16b59");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Member>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Index).HasName("PK_b4a6b8c2478e5df990909c6cf6a");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Members).HasConstraintName("FK_16aceddd5b89825b8ed6029ad1c");
|
||||
|
||||
entity.HasOne(d => d.IdNavigation).WithMany(p => p.Members).HasConstraintName("FK_28b53062261b996d9c99fa12404");
|
||||
|
||||
entity.HasMany(d => d.Roles).WithMany(p => p.Indices)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"MemberRole",
|
||||
r => r.HasOne<Role>().WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.HasConstraintName("FK_e9080e7a7997a0170026d5139c1"),
|
||||
l => l.HasOne<Member>().WithMany()
|
||||
.HasForeignKey("Index")
|
||||
.HasConstraintName("FK_5d7ddc8a5f9c167f548625e772e"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("Index", "RoleId").HasName("PK_951c1d72a0fd1da8760b4a1fd66");
|
||||
j.ToTable("member_roles");
|
||||
j.HasIndex(new[] { "Index" }, "IDX_5d7ddc8a5f9c167f548625e772");
|
||||
j.HasIndex(new[] { "RoleId" }, "IDX_e9080e7a7997a0170026d5139c");
|
||||
j.IndexerProperty<int>("Index").HasColumnName("index");
|
||||
j.IndexerProperty<string>("RoleId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("role_id");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Message>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_18325f38ae6de43878487eff986");
|
||||
|
||||
entity.Property(e => e.Flags).HasDefaultValue(0);
|
||||
entity.Property(e => e.Timestamp).HasDefaultValueSql("now()");
|
||||
|
||||
entity.HasOne(d => d.Application).WithMany(p => p.Messages).HasConstraintName("FK_5d3ec1cb962de6488637fd779d6");
|
||||
|
||||
entity.HasOne(d => d.Author).WithMany(p => p.MessageAuthors)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_05535bc695e9f7ee104616459d3");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.Messages)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_86b9109b155eb70c0a2ca3b4b6d");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Messages)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_b193588441b085352a4c0109423");
|
||||
|
||||
entity.HasOne(d => d.Member).WithMany(p => p.MessageMembers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_b0525304f2262b7014245351c76");
|
||||
|
||||
entity.HasOne(d => d.MessageReferenceNavigation).WithMany(p => p.InverseMessageReferenceNavigation).HasConstraintName("FK_61a92bb65b302a76d9c1fcd3174");
|
||||
|
||||
entity.HasOne(d => d.Webhook).WithMany(p => p.Messages).HasConstraintName("FK_f83c04bcf1df4e5c0e7a52ed348");
|
||||
|
||||
entity.HasMany(d => d.Channels).WithMany(p => p.MessagesNavigation)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"MessageChannelMention",
|
||||
r => r.HasOne<Channel>().WithMany()
|
||||
.HasForeignKey("ChannelsId")
|
||||
.HasConstraintName("FK_bdb8c09e1464cabf62105bf4b9d"),
|
||||
l => l.HasOne<Message>().WithMany()
|
||||
.HasForeignKey("MessagesId")
|
||||
.HasConstraintName("FK_2a27102ecd1d81b4582a4360921"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("MessagesId", "ChannelsId").HasName("PK_85cb45351497cd9d06a79ced65e");
|
||||
j.ToTable("message_channel_mentions");
|
||||
j.HasIndex(new[] { "MessagesId" }, "IDX_2a27102ecd1d81b4582a436092");
|
||||
j.HasIndex(new[] { "ChannelsId" }, "IDX_bdb8c09e1464cabf62105bf4b9");
|
||||
j.IndexerProperty<string>("MessagesId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("messagesId");
|
||||
j.IndexerProperty<string>("ChannelsId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("channelsId");
|
||||
});
|
||||
|
||||
entity.HasMany(d => d.Roles).WithMany(p => p.Messages)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"MessageRoleMention",
|
||||
r => r.HasOne<Role>().WithMany()
|
||||
.HasForeignKey("RolesId")
|
||||
.HasConstraintName("FK_29d63eb1a458200851bc37d074b"),
|
||||
l => l.HasOne<Message>().WithMany()
|
||||
.HasForeignKey("MessagesId")
|
||||
.HasConstraintName("FK_a8242cf535337a490b0feaea0b4"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("MessagesId", "RolesId").HasName("PK_74dba92cc300452a6e14b83ed44");
|
||||
j.ToTable("message_role_mentions");
|
||||
j.HasIndex(new[] { "RolesId" }, "IDX_29d63eb1a458200851bc37d074");
|
||||
j.HasIndex(new[] { "MessagesId" }, "IDX_a8242cf535337a490b0feaea0b");
|
||||
j.IndexerProperty<string>("MessagesId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("messagesId");
|
||||
j.IndexerProperty<string>("RolesId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("rolesId");
|
||||
});
|
||||
|
||||
entity.HasMany(d => d.Stickers).WithMany(p => p.Messages)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"MessageSticker",
|
||||
r => r.HasOne<Sticker>().WithMany()
|
||||
.HasForeignKey("StickersId")
|
||||
.HasConstraintName("FK_e22a70819d07659c7a71c112a1f"),
|
||||
l => l.HasOne<Message>().WithMany()
|
||||
.HasForeignKey("MessagesId")
|
||||
.HasConstraintName("FK_40bb6f23e7cc133292e92829d28"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("MessagesId", "StickersId").HasName("PK_ed820c4093d0b8cd1d2bcf66087");
|
||||
j.ToTable("message_stickers");
|
||||
j.HasIndex(new[] { "MessagesId" }, "IDX_40bb6f23e7cc133292e92829d2");
|
||||
j.HasIndex(new[] { "StickersId" }, "IDX_e22a70819d07659c7a71c112a1");
|
||||
j.IndexerProperty<string>("MessagesId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("messagesId");
|
||||
j.IndexerProperty<string>("StickersId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("stickersId");
|
||||
});
|
||||
|
||||
entity.HasMany(d => d.Users).WithMany(p => p.Messages)
|
||||
.UsingEntity<Dictionary<string, object>>(
|
||||
"MessageUserMention",
|
||||
r => r.HasOne<User>().WithMany()
|
||||
.HasForeignKey("UsersId")
|
||||
.HasConstraintName("FK_b831eb18ceebd28976239b1e2f8"),
|
||||
l => l.HasOne<Message>().WithMany()
|
||||
.HasForeignKey("MessagesId")
|
||||
.HasConstraintName("FK_a343387fc560ef378760681c236"),
|
||||
j =>
|
||||
{
|
||||
j.HasKey("MessagesId", "UsersId").HasName("PK_9b9b6e245ad47a48dbd7605d4fb");
|
||||
j.ToTable("message_user_mentions");
|
||||
j.HasIndex(new[] { "MessagesId" }, "IDX_a343387fc560ef378760681c23");
|
||||
j.HasIndex(new[] { "UsersId" }, "IDX_b831eb18ceebd28976239b1e2f");
|
||||
j.IndexerProperty<string>("MessagesId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("messagesId");
|
||||
j.IndexerProperty<string>("UsersId")
|
||||
.HasColumnType("character varying")
|
||||
.HasColumnName("usersId");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Migration>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_8c82d7f526340ab734260ea46be");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Note>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_af6206538ea96c4e77e9f400c3d");
|
||||
|
||||
entity.HasOne(d => d.Owner).WithMany(p => p.NoteOwners)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_f9e103f8ae67cb1787063597925");
|
||||
|
||||
entity.HasOne(d => d.Target).WithMany(p => p.NoteTargets)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_23e08e5b4481711d573e1abecdc");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<RateLimit>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_3b4449f1f5fc167d921ee619f65");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ReadState>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_e6956a804978f01b713b1ed58e2");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.ReadStates).HasConstraintName("FK_40da2fca4e0eaf7a23b5bfc5d34");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.ReadStates).HasConstraintName("FK_195f92e4dd1254a4e348c043763");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Recipient>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_de8fc5a9c364568f294798fe1e9");
|
||||
|
||||
entity.Property(e => e.Closed).HasDefaultValue(false);
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.Recipients).HasConstraintName("FK_2f18ee1ba667f233ae86c0ea60e");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.Recipients).HasConstraintName("FK_6157e8b6ba4e6e3089616481fe2");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Relationship>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_ba20e2f5cf487408e08e4dcecaf");
|
||||
|
||||
entity.HasOne(d => d.From).WithMany(p => p.RelationshipFroms).HasConstraintName("FK_9af4194bab1250b1c584ae4f1d7");
|
||||
|
||||
entity.HasOne(d => d.To).WithMany(p => p.RelationshipTos).HasConstraintName("FK_9c7f6b98a9843b76dce1b0c878b");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Role>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_c1433d71a4838793a49dcad46ab");
|
||||
|
||||
entity.Property(e => e.Flags).HasDefaultValue(0);
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Roles).HasConstraintName("FK_c32c1ab1c4dc7dcb0278c4b1b8b");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<SecurityKey>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_6e95cdd91779e7cca06d1fff89c");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.SecurityKeys)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_24c97d0771cafedce6d7163eaad");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<SecuritySetting>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_4aec436cf81177ae97a1bcec3c7");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Session>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_3238ef96f18b355b671619111bc");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.Sessions)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_085d540d9f418cfbdc7bd55bb19");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Sticker>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_e1dafa4063a5532645cc2810374");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.Stickers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_193d551d852aca5347ef5c9f205");
|
||||
|
||||
entity.HasOne(d => d.Pack).WithMany(p => p.Stickers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_e7cfa5cefa6661b3fb8fda8ce69");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.Stickers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_8f4ee73f2bb2325ff980502e158");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<StickerPack>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_a27381efea0f876f5d3233af655");
|
||||
|
||||
entity.HasOne(d => d.CoverStickerId1Navigation).WithMany(p => p.StickerPacks).HasConstraintName("FK_448fafba4355ee1c837bbc865f1");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Team>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_7e5523774a38b08a6236d322403");
|
||||
|
||||
entity.HasOne(d => d.OwnerUser).WithMany(p => p.Teams).HasConstraintName("FK_13f00abf7cb6096c43ecaf8c108");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TeamMember>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_ca3eae89dcf20c9fd95bf7460aa");
|
||||
|
||||
entity.HasOne(d => d.Team).WithMany(p => p.TeamMembers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_fdad7d5768277e60c40e01cdcea");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.TeamMembers)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_c2bf4967c8c2a6b845dadfbf3d4");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Template>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_515948649ce0bbbe391de702ae5");
|
||||
|
||||
entity.HasOne(d => d.Creator).WithMany(p => p.Templates).HasConstraintName("FK_d7374b7f8f5fbfdececa4fb62e1");
|
||||
|
||||
entity.HasOne(d => d.SourceGuild).WithMany(p => p.Templates)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_445d00eaaea0e60a017a5ed0c11");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<User>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_a3ffb1c0c8416b9fc6f907b7433");
|
||||
|
||||
entity.Property(e => e.WebauthnEnabled).HasDefaultValue(false);
|
||||
|
||||
entity.HasOne(d => d.SettingsIndexNavigation).WithOne(p => p.User).HasConstraintName("FK_0c14beb78d8c5ccba66072adbc7");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<UserSetting>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Index).HasName("PK_e81f8bb92802737337d35c00981");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ValidRegistrationToken>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Token).HasName("PK_e0f5c8e3fcefe3134a092c50485");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<VoiceState>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_ada09a50c134fad1369b510e3ce");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.VoiceStates)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_9f8d389866b40b6657edd026dd4");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.VoiceStates)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_03779ef216d4b0358470d9cb748");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.VoiceStates)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_5fe1d5f931a67e85039c640001b");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Webhook>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_9e8795cfc899ab7bdaa831e8527");
|
||||
|
||||
entity.HasOne(d => d.Application).WithMany(p => p.Webhooks)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_c3e5305461931763b56aa905f1c");
|
||||
|
||||
entity.HasOne(d => d.Channel).WithMany(p => p.WebhookChannels)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_df528cf77e82f8032230e7e37d8");
|
||||
|
||||
entity.HasOne(d => d.Guild).WithMany(p => p.WebhookGuilds)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_487a7af59d189f744fe394368fc");
|
||||
|
||||
entity.HasOne(d => d.SourceChannel).WithMany(p => p.WebhookSourceChannels)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_4495b7032a33c6b8b605d030398");
|
||||
|
||||
entity.HasOne(d => d.SourceGuild).WithMany(p => p.WebhookSourceGuilds)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_3a285f4f49c40e0706d3018bc9f");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.Webhooks)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("FK_0d523f6f997c86e052c49b1455f");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
125
extra/admin-api/Spacebar.Db/Models/Application.cs
Normal file
125
extra/admin-api/Spacebar.Db/Models/Application.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("applications")]
|
||||
[Index("BotUserId", Name = "REL_2ce5a55796fe4c2f77ece57a64", IsUnique = true)]
|
||||
public partial class Application
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("icon", TypeName = "character varying")]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
[Column("description", TypeName = "character varying")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column("summary", TypeName = "character varying")]
|
||||
public string? Summary { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public string? Type { get; set; }
|
||||
|
||||
[Column("hook")]
|
||||
public bool Hook { get; set; }
|
||||
|
||||
[Column("bot_public")]
|
||||
public bool BotPublic { get; set; }
|
||||
|
||||
[Column("bot_require_code_grant")]
|
||||
public bool BotRequireCodeGrant { get; set; }
|
||||
|
||||
[Column("verify_key", TypeName = "character varying")]
|
||||
public string VerifyKey { get; set; } = null!;
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[Column("redirect_uris")]
|
||||
public string? RedirectUris { get; set; }
|
||||
|
||||
[Column("rpc_application_state")]
|
||||
public int? RpcApplicationState { get; set; }
|
||||
|
||||
[Column("store_application_state")]
|
||||
public int? StoreApplicationState { get; set; }
|
||||
|
||||
[Column("verification_state")]
|
||||
public int? VerificationState { get; set; }
|
||||
|
||||
[Column("interactions_endpoint_url", TypeName = "character varying")]
|
||||
public string? InteractionsEndpointUrl { get; set; }
|
||||
|
||||
[Column("integration_public")]
|
||||
public bool? IntegrationPublic { get; set; }
|
||||
|
||||
[Column("integration_require_code_grant")]
|
||||
public bool? IntegrationRequireCodeGrant { get; set; }
|
||||
|
||||
[Column("discoverability_state")]
|
||||
public int? DiscoverabilityState { get; set; }
|
||||
|
||||
[Column("discovery_eligibility_flags")]
|
||||
public int? DiscoveryEligibilityFlags { get; set; }
|
||||
|
||||
[Column("tags")]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
[Column("cover_image", TypeName = "character varying")]
|
||||
public string? CoverImage { get; set; }
|
||||
|
||||
[Column("install_params")]
|
||||
public string? InstallParams { get; set; }
|
||||
|
||||
[Column("terms_of_service_url", TypeName = "character varying")]
|
||||
public string? TermsOfServiceUrl { get; set; }
|
||||
|
||||
[Column("privacy_policy_url", TypeName = "character varying")]
|
||||
public string? PrivacyPolicyUrl { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("custom_install_url", TypeName = "character varying")]
|
||||
public string? CustomInstallUrl { get; set; }
|
||||
|
||||
[Column("owner_id", TypeName = "character varying")]
|
||||
public string? OwnerId { get; set; }
|
||||
|
||||
[Column("bot_user_id", TypeName = "character varying")]
|
||||
public string? BotUserId { get; set; }
|
||||
|
||||
[Column("team_id", TypeName = "character varying")]
|
||||
public string? TeamId { get; set; }
|
||||
|
||||
[ForeignKey("BotUserId")]
|
||||
[InverseProperty("ApplicationBotUser")]
|
||||
public virtual User? BotUser { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Applications")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[InverseProperty("Application")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
|
||||
[ForeignKey("OwnerId")]
|
||||
[InverseProperty("ApplicationOwners")]
|
||||
public virtual User? Owner { get; set; }
|
||||
|
||||
[ForeignKey("TeamId")]
|
||||
[InverseProperty("Applications")]
|
||||
public virtual Team? Team { get; set; }
|
||||
|
||||
[InverseProperty("Application")]
|
||||
public virtual ICollection<Webhook> Webhooks { get; set; } = new List<Webhook>();
|
||||
}
|
||||
43
extra/admin-api/Spacebar.Db/Models/Attachment.cs
Normal file
43
extra/admin-api/Spacebar.Db/Models/Attachment.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("attachments")]
|
||||
public partial class Attachment
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("filename", TypeName = "character varying")]
|
||||
public string Filename { get; set; } = null!;
|
||||
|
||||
[Column("size")]
|
||||
public int Size { get; set; }
|
||||
|
||||
[Column("url", TypeName = "character varying")]
|
||||
public string Url { get; set; } = null!;
|
||||
|
||||
[Column("proxy_url", TypeName = "character varying")]
|
||||
public string ProxyUrl { get; set; } = null!;
|
||||
|
||||
[Column("height")]
|
||||
public int? Height { get; set; }
|
||||
|
||||
[Column("width")]
|
||||
public int? Width { get; set; }
|
||||
|
||||
[Column("content_type", TypeName = "character varying")]
|
||||
public string? ContentType { get; set; }
|
||||
|
||||
[Column("message_id", TypeName = "character varying")]
|
||||
public string? MessageId { get; set; }
|
||||
|
||||
[ForeignKey("MessageId")]
|
||||
[InverseProperty("Attachments")]
|
||||
public virtual Message? Message { get; set; }
|
||||
}
|
||||
41
extra/admin-api/Spacebar.Db/Models/AuditLog.cs
Normal file
41
extra/admin-api/Spacebar.Db/Models/AuditLog.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("audit_logs")]
|
||||
public partial class AuditLog
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("action_type")]
|
||||
public int ActionType { get; set; }
|
||||
|
||||
[Column("options")]
|
||||
public string? Options { get; set; }
|
||||
|
||||
[Column("changes")]
|
||||
public string Changes { get; set; } = null!;
|
||||
|
||||
[Column("reason", TypeName = "character varying")]
|
||||
public string? Reason { get; set; }
|
||||
|
||||
[Column("target_id", TypeName = "character varying")]
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
[ForeignKey("TargetId")]
|
||||
[InverseProperty("AuditLogTargets")]
|
||||
public virtual User? Target { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("AuditLogUsers")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
31
extra/admin-api/Spacebar.Db/Models/BackupCode.cs
Normal file
31
extra/admin-api/Spacebar.Db/Models/BackupCode.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("backup_codes")]
|
||||
public partial class BackupCode
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("code", TypeName = "character varying")]
|
||||
public string Code { get; set; } = null!;
|
||||
|
||||
[Column("consumed")]
|
||||
public bool Consumed { get; set; }
|
||||
|
||||
[Column("expired")]
|
||||
public bool Expired { get; set; }
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("BackupCodes")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
24
extra/admin-api/Spacebar.Db/Models/Badge.cs
Normal file
24
extra/admin-api/Spacebar.Db/Models/Badge.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("badges")]
|
||||
public partial class Badge
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("description", TypeName = "character varying")]
|
||||
public string Description { get; set; } = null!;
|
||||
|
||||
[Column("icon", TypeName = "character varying")]
|
||||
public string Icon { get; set; } = null!;
|
||||
|
||||
[Column("link", TypeName = "character varying")]
|
||||
public string? Link { get; set; }
|
||||
}
|
||||
42
extra/admin-api/Spacebar.Db/Models/Ban.cs
Normal file
42
extra/admin-api/Spacebar.Db/Models/Ban.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("bans")]
|
||||
public partial class Ban
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("executor_id", TypeName = "character varying")]
|
||||
public string? ExecutorId { get; set; }
|
||||
|
||||
[Column("ip", TypeName = "character varying")]
|
||||
public string Ip { get; set; } = null!;
|
||||
|
||||
[Column("reason", TypeName = "character varying")]
|
||||
public string? Reason { get; set; }
|
||||
|
||||
[ForeignKey("ExecutorId")]
|
||||
[InverseProperty("BanExecutors")]
|
||||
public virtual User? Executor { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Bans")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("BanUsers")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
27
extra/admin-api/Spacebar.Db/Models/Category.cs
Normal file
27
extra/admin-api/Spacebar.Db/Models/Category.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("categories")]
|
||||
public partial class Category
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[Column("localizations")]
|
||||
public string Localizations { get; set; } = null!;
|
||||
|
||||
[Column("is_primary")]
|
||||
public bool? IsPrimary { get; set; }
|
||||
|
||||
[Column("icon", TypeName = "character varying")]
|
||||
public string? Icon { get; set; }
|
||||
}
|
||||
130
extra/admin-api/Spacebar.Db/Models/Channel.cs
Normal file
130
extra/admin-api/Spacebar.Db/Models/Channel.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("channels")]
|
||||
public partial class Channel
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("created_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[Column("icon")]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
[Column("last_message_id", TypeName = "character varying")]
|
||||
public string? LastMessageId { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("parent_id", TypeName = "character varying")]
|
||||
public string? ParentId { get; set; }
|
||||
|
||||
[Column("owner_id", TypeName = "character varying")]
|
||||
public string? OwnerId { get; set; }
|
||||
|
||||
[Column("last_pin_timestamp")]
|
||||
public int? LastPinTimestamp { get; set; }
|
||||
|
||||
[Column("default_auto_archive_duration")]
|
||||
public int? DefaultAutoArchiveDuration { get; set; }
|
||||
|
||||
[Column("permission_overwrites")]
|
||||
public string? PermissionOverwrites { get; set; }
|
||||
|
||||
[Column("video_quality_mode")]
|
||||
public int? VideoQualityMode { get; set; }
|
||||
|
||||
[Column("bitrate")]
|
||||
public int? Bitrate { get; set; }
|
||||
|
||||
[Column("user_limit")]
|
||||
public int? UserLimit { get; set; }
|
||||
|
||||
[Column("nsfw")]
|
||||
public bool Nsfw { get; set; }
|
||||
|
||||
[Column("rate_limit_per_user")]
|
||||
public int? RateLimitPerUser { get; set; }
|
||||
|
||||
[Column("topic", TypeName = "character varying")]
|
||||
public string? Topic { get; set; }
|
||||
|
||||
[Column("retention_policy_id", TypeName = "character varying")]
|
||||
public string? RetentionPolicyId { get; set; }
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[Column("default_thread_rate_limit_per_user")]
|
||||
public int DefaultThreadRateLimitPerUser { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Channels")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[InverseProperty("AfkChannel")]
|
||||
public virtual ICollection<Guild> GuildAfkChannels { get; set; } = new List<Guild>();
|
||||
|
||||
[InverseProperty("PublicUpdatesChannel")]
|
||||
public virtual ICollection<Guild> GuildPublicUpdatesChannels { get; set; } = new List<Guild>();
|
||||
|
||||
[InverseProperty("RulesChannel")]
|
||||
public virtual ICollection<Guild> GuildRulesChannels { get; set; } = new List<Guild>();
|
||||
|
||||
[InverseProperty("SystemChannel")]
|
||||
public virtual ICollection<Guild> GuildSystemChannels { get; set; } = new List<Guild>();
|
||||
|
||||
[InverseProperty("WidgetChannel")]
|
||||
public virtual ICollection<Guild> GuildWidgetChannels { get; set; } = new List<Guild>();
|
||||
|
||||
[InverseProperty("Parent")]
|
||||
public virtual ICollection<Channel> InverseParent { get; set; } = new List<Channel>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<Invite> Invites { get; set; } = new List<Invite>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
|
||||
[ForeignKey("OwnerId")]
|
||||
[InverseProperty("Channels")]
|
||||
public virtual User? Owner { get; set; }
|
||||
|
||||
[ForeignKey("ParentId")]
|
||||
[InverseProperty("InverseParent")]
|
||||
public virtual Channel? Parent { get; set; }
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<ReadState> ReadStates { get; set; } = new List<ReadState>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<Recipient> Recipients { get; set; } = new List<Recipient>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<VoiceState> VoiceStates { get; set; } = new List<VoiceState>();
|
||||
|
||||
[InverseProperty("Channel")]
|
||||
public virtual ICollection<Webhook> WebhookChannels { get; set; } = new List<Webhook>();
|
||||
|
||||
[InverseProperty("SourceChannel")]
|
||||
public virtual ICollection<Webhook> WebhookSourceChannels { get; set; } = new List<Webhook>();
|
||||
|
||||
[ForeignKey("ChannelsId")]
|
||||
[InverseProperty("Channels")]
|
||||
public virtual ICollection<Message> MessagesNavigation { get; set; } = new List<Message>();
|
||||
}
|
||||
33
extra/admin-api/Spacebar.Db/Models/ClientRelease.cs
Normal file
33
extra/admin-api/Spacebar.Db/Models/ClientRelease.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("client_release")]
|
||||
public partial class ClientRelease
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("pub_date", TypeName = "timestamp without time zone")]
|
||||
public DateTime PubDate { get; set; }
|
||||
|
||||
[Column("url", TypeName = "character varying")]
|
||||
public string Url { get; set; } = null!;
|
||||
|
||||
[Column("platform", TypeName = "character varying")]
|
||||
public string Platform { get; set; } = null!;
|
||||
|
||||
[Column("enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
[Column("notes", TypeName = "character varying")]
|
||||
public string? Notes { get; set; }
|
||||
}
|
||||
18
extra/admin-api/Spacebar.Db/Models/Config.cs
Normal file
18
extra/admin-api/Spacebar.Db/Models/Config.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("config")]
|
||||
public partial class Config
|
||||
{
|
||||
[Key]
|
||||
[Column("key", TypeName = "character varying")]
|
||||
public string Key { get; set; } = null!;
|
||||
|
||||
[Column("value")]
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
61
extra/admin-api/Spacebar.Db/Models/ConnectedAccount.cs
Normal file
61
extra/admin-api/Spacebar.Db/Models/ConnectedAccount.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("connected_accounts")]
|
||||
public partial class ConnectedAccount
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("external_id", TypeName = "character varying")]
|
||||
public string ExternalId { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("friend_sync")]
|
||||
public bool FriendSync { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("revoked")]
|
||||
public bool Revoked { get; set; }
|
||||
|
||||
[Column("show_activity")]
|
||||
public int ShowActivity { get; set; }
|
||||
|
||||
[Column("type", TypeName = "character varying")]
|
||||
public string Type { get; set; } = null!;
|
||||
|
||||
[Column("verified")]
|
||||
public bool Verified { get; set; }
|
||||
|
||||
[Column("visibility")]
|
||||
public int Visibility { get; set; }
|
||||
|
||||
[Column("integrations")]
|
||||
public string Integrations { get; set; } = null!;
|
||||
|
||||
[Column("metadata")]
|
||||
public string? Metadata { get; set; }
|
||||
|
||||
[Column("metadata_visibility")]
|
||||
public int MetadataVisibility { get; set; }
|
||||
|
||||
[Column("two_way_link")]
|
||||
public bool TwoWayLink { get; set; }
|
||||
|
||||
[Column("token_data")]
|
||||
public string? TokenData { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("ConnectedAccounts")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
18
extra/admin-api/Spacebar.Db/Models/ConnectionConfig.cs
Normal file
18
extra/admin-api/Spacebar.Db/Models/ConnectionConfig.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("connection_config")]
|
||||
public partial class ConnectionConfig
|
||||
{
|
||||
[Key]
|
||||
[Column("key", TypeName = "character varying")]
|
||||
public string Key { get; set; } = null!;
|
||||
|
||||
[Column("value")]
|
||||
public string? Value { get; set; }
|
||||
}
|
||||
21
extra/admin-api/Spacebar.Db/Models/EmbedCache.cs
Normal file
21
extra/admin-api/Spacebar.Db/Models/EmbedCache.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("embed_cache")]
|
||||
public partial class EmbedCache
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("url", TypeName = "character varying")]
|
||||
public string Url { get; set; } = null!;
|
||||
|
||||
[Column("embed")]
|
||||
public string Embed { get; set; } = null!;
|
||||
}
|
||||
50
extra/admin-api/Spacebar.Db/Models/Emoji.cs
Normal file
50
extra/admin-api/Spacebar.Db/Models/Emoji.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("emojis")]
|
||||
public partial class Emoji
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("animated")]
|
||||
public bool Animated { get; set; }
|
||||
|
||||
[Column("available")]
|
||||
public bool Available { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string GuildId { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("managed")]
|
||||
public bool Managed { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("require_colons")]
|
||||
public bool RequireColons { get; set; }
|
||||
|
||||
[Column("roles")]
|
||||
public string Roles { get; set; } = null!;
|
||||
|
||||
[Column("groups")]
|
||||
public string? Groups { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Emojis")]
|
||||
public virtual Guild Guild { get; set; } = null!;
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("Emojis")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
199
extra/admin-api/Spacebar.Db/Models/Guild.cs
Normal file
199
extra/admin-api/Spacebar.Db/Models/Guild.cs
Normal file
@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("guilds")]
|
||||
public partial class Guild
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("afk_channel_id", TypeName = "character varying")]
|
||||
public string? AfkChannelId { get; set; }
|
||||
|
||||
[Column("afk_timeout")]
|
||||
public int? AfkTimeout { get; set; }
|
||||
|
||||
[Column("banner", TypeName = "character varying")]
|
||||
public string? Banner { get; set; }
|
||||
|
||||
[Column("default_message_notifications")]
|
||||
public int? DefaultMessageNotifications { get; set; }
|
||||
|
||||
[Column("description", TypeName = "character varying")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column("discovery_splash", TypeName = "character varying")]
|
||||
public string? DiscoverySplash { get; set; }
|
||||
|
||||
[Column("explicit_content_filter")]
|
||||
public int? ExplicitContentFilter { get; set; }
|
||||
|
||||
[Column("features")]
|
||||
public string Features { get; set; } = null!;
|
||||
|
||||
[Column("primary_category_id", TypeName = "character varying")]
|
||||
public string? PrimaryCategoryId { get; set; }
|
||||
|
||||
[Column("icon", TypeName = "character varying")]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
[Column("large")]
|
||||
public bool Large { get; set; }
|
||||
|
||||
[Column("max_members")]
|
||||
public int? MaxMembers { get; set; }
|
||||
|
||||
[Column("max_presences")]
|
||||
public int? MaxPresences { get; set; }
|
||||
|
||||
[Column("max_video_channel_users")]
|
||||
public int? MaxVideoChannelUsers { get; set; }
|
||||
|
||||
[Column("member_count")]
|
||||
public int? MemberCount { get; set; }
|
||||
|
||||
[Column("presence_count")]
|
||||
public int? PresenceCount { get; set; }
|
||||
|
||||
[Column("template_id", TypeName = "character varying")]
|
||||
public string? TemplateId { get; set; }
|
||||
|
||||
[Column("mfa_level")]
|
||||
public int? MfaLevel { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("owner_id", TypeName = "character varying")]
|
||||
public string? OwnerId { get; set; }
|
||||
|
||||
[Column("preferred_locale", TypeName = "character varying")]
|
||||
public string? PreferredLocale { get; set; }
|
||||
|
||||
[Column("premium_subscription_count")]
|
||||
public int? PremiumSubscriptionCount { get; set; }
|
||||
|
||||
[Column("premium_tier")]
|
||||
public int PremiumTier { get; set; }
|
||||
|
||||
[Column("public_updates_channel_id", TypeName = "character varying")]
|
||||
public string? PublicUpdatesChannelId { get; set; }
|
||||
|
||||
[Column("rules_channel_id", TypeName = "character varying")]
|
||||
public string? RulesChannelId { get; set; }
|
||||
|
||||
[Column("region", TypeName = "character varying")]
|
||||
public string? Region { get; set; }
|
||||
|
||||
[Column("splash", TypeName = "character varying")]
|
||||
public string? Splash { get; set; }
|
||||
|
||||
[Column("system_channel_id", TypeName = "character varying")]
|
||||
public string? SystemChannelId { get; set; }
|
||||
|
||||
[Column("system_channel_flags")]
|
||||
public int? SystemChannelFlags { get; set; }
|
||||
|
||||
[Column("unavailable")]
|
||||
public bool Unavailable { get; set; }
|
||||
|
||||
[Column("verification_level")]
|
||||
public int? VerificationLevel { get; set; }
|
||||
|
||||
[Column("welcome_screen")]
|
||||
public string WelcomeScreen { get; set; } = null!;
|
||||
|
||||
[Column("widget_channel_id", TypeName = "character varying")]
|
||||
public string? WidgetChannelId { get; set; }
|
||||
|
||||
[Column("widget_enabled")]
|
||||
public bool WidgetEnabled { get; set; }
|
||||
|
||||
[Column("nsfw_level")]
|
||||
public int? NsfwLevel { get; set; }
|
||||
|
||||
[Column("nsfw")]
|
||||
public bool Nsfw { get; set; }
|
||||
|
||||
[Column("parent", TypeName = "character varying")]
|
||||
public string? Parent { get; set; }
|
||||
|
||||
[Column("premium_progress_bar_enabled")]
|
||||
public bool? PremiumProgressBarEnabled { get; set; }
|
||||
|
||||
[Column("channel_ordering")]
|
||||
public string ChannelOrdering { get; set; } = null!;
|
||||
|
||||
[ForeignKey("AfkChannelId")]
|
||||
[InverseProperty("GuildAfkChannels")]
|
||||
public virtual Channel? AfkChannel { get; set; }
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Application> Applications { get; set; } = new List<Application>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Ban> Bans { get; set; } = new List<Ban>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Channel> Channels { get; set; } = new List<Channel>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Emoji> Emojis { get; set; } = new List<Emoji>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Invite> Invites { get; set; } = new List<Invite>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Member> Members { get; set; } = new List<Member>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
|
||||
[ForeignKey("OwnerId")]
|
||||
[InverseProperty("Guilds")]
|
||||
public virtual User? Owner { get; set; }
|
||||
|
||||
[ForeignKey("PublicUpdatesChannelId")]
|
||||
[InverseProperty("GuildPublicUpdatesChannels")]
|
||||
public virtual Channel? PublicUpdatesChannel { get; set; }
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Role> Roles { get; set; } = new List<Role>();
|
||||
|
||||
[ForeignKey("RulesChannelId")]
|
||||
[InverseProperty("GuildRulesChannels")]
|
||||
public virtual Channel? RulesChannel { get; set; }
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Sticker> Stickers { get; set; } = new List<Sticker>();
|
||||
|
||||
[ForeignKey("SystemChannelId")]
|
||||
[InverseProperty("GuildSystemChannels")]
|
||||
public virtual Channel? SystemChannel { get; set; }
|
||||
|
||||
[ForeignKey("TemplateId")]
|
||||
[InverseProperty("Guilds")]
|
||||
public virtual Template? Template { get; set; }
|
||||
|
||||
[InverseProperty("SourceGuild")]
|
||||
public virtual ICollection<Template> Templates { get; set; } = new List<Template>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<VoiceState> VoiceStates { get; set; } = new List<VoiceState>();
|
||||
|
||||
[InverseProperty("Guild")]
|
||||
public virtual ICollection<Webhook> WebhookGuilds { get; set; } = new List<Webhook>();
|
||||
|
||||
[InverseProperty("SourceGuild")]
|
||||
public virtual ICollection<Webhook> WebhookSourceGuilds { get; set; } = new List<Webhook>();
|
||||
|
||||
[ForeignKey("WidgetChannelId")]
|
||||
[InverseProperty("GuildWidgetChannels")]
|
||||
public virtual Channel? WidgetChannel { get; set; }
|
||||
}
|
||||
70
extra/admin-api/Spacebar.Db/Models/Invite.cs
Normal file
70
extra/admin-api/Spacebar.Db/Models/Invite.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("invites")]
|
||||
public partial class Invite
|
||||
{
|
||||
[Key]
|
||||
[Column("code", TypeName = "character varying")]
|
||||
public string Code { get; set; } = null!;
|
||||
|
||||
[Column("temporary")]
|
||||
public bool Temporary { get; set; }
|
||||
|
||||
[Column("uses")]
|
||||
public int Uses { get; set; }
|
||||
|
||||
[Column("max_uses")]
|
||||
public int MaxUses { get; set; }
|
||||
|
||||
[Column("max_age")]
|
||||
public int MaxAge { get; set; }
|
||||
|
||||
[Column("created_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[Column("expires_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime? ExpiresAt { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[Column("inviter_id", TypeName = "character varying")]
|
||||
public string? InviterId { get; set; }
|
||||
|
||||
[Column("target_user_id", TypeName = "character varying")]
|
||||
public string? TargetUserId { get; set; }
|
||||
|
||||
[Column("target_user_type")]
|
||||
public int? TargetUserType { get; set; }
|
||||
|
||||
[Column("vanity_url")]
|
||||
public bool? VanityUrl { get; set; }
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("Invites")]
|
||||
public virtual Channel? Channel { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Invites")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[ForeignKey("InviterId")]
|
||||
[InverseProperty("InviteInviters")]
|
||||
public virtual User? Inviter { get; set; }
|
||||
|
||||
[ForeignKey("TargetUserId")]
|
||||
[InverseProperty("InviteTargetUsers")]
|
||||
public virtual User? TargetUser { get; set; }
|
||||
}
|
||||
79
extra/admin-api/Spacebar.Db/Models/Member.cs
Normal file
79
extra/admin-api/Spacebar.Db/Models/Member.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("members")]
|
||||
[Index("Id", "GuildId", Name = "IDX_bb2bf9386ac443afbbbf9f12d3", IsUnique = true)]
|
||||
public partial class Member
|
||||
{
|
||||
[Key]
|
||||
[Column("index")]
|
||||
public int Index { get; set; }
|
||||
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string GuildId { get; set; } = null!;
|
||||
|
||||
[Column("nick", TypeName = "character varying")]
|
||||
public string? Nick { get; set; }
|
||||
|
||||
[Column("joined_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime JoinedAt { get; set; }
|
||||
|
||||
[Column("premium_since")]
|
||||
public long? PremiumSince { get; set; }
|
||||
|
||||
[Column("deaf")]
|
||||
public bool Deaf { get; set; }
|
||||
|
||||
[Column("mute")]
|
||||
public bool Mute { get; set; }
|
||||
|
||||
[Column("pending")]
|
||||
public bool Pending { get; set; }
|
||||
|
||||
[Column("settings")]
|
||||
public string Settings { get; set; } = null!;
|
||||
|
||||
[Column("last_message_id", TypeName = "character varying")]
|
||||
public string? LastMessageId { get; set; }
|
||||
|
||||
[Column("joined_by", TypeName = "character varying")]
|
||||
public string? JoinedBy { get; set; }
|
||||
|
||||
[Column("avatar", TypeName = "character varying")]
|
||||
public string? Avatar { get; set; }
|
||||
|
||||
[Column("banner", TypeName = "character varying")]
|
||||
public string? Banner { get; set; }
|
||||
|
||||
[Column("bio", TypeName = "character varying")]
|
||||
public string Bio { get; set; } = null!;
|
||||
|
||||
[Column("theme_colors")]
|
||||
public string? ThemeColors { get; set; }
|
||||
|
||||
[Column("pronouns", TypeName = "character varying")]
|
||||
public string? Pronouns { get; set; }
|
||||
|
||||
[Column("communication_disabled_until", TypeName = "timestamp without time zone")]
|
||||
public DateTime? CommunicationDisabledUntil { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Members")]
|
||||
public virtual Guild Guild { get; set; } = null!;
|
||||
|
||||
[ForeignKey("Id")]
|
||||
[InverseProperty("Members")]
|
||||
public virtual User IdNavigation { get; set; } = null!;
|
||||
|
||||
[ForeignKey("Index")]
|
||||
[InverseProperty("Indices")]
|
||||
public virtual ICollection<Role> Roles { get; set; } = new List<Role>();
|
||||
}
|
||||
143
extra/admin-api/Spacebar.Db/Models/Message.cs
Normal file
143
extra/admin-api/Spacebar.Db/Models/Message.cs
Normal file
@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("messages")]
|
||||
[Index("AuthorId", Name = "IDX_05535bc695e9f7ee104616459d")]
|
||||
[Index("ChannelId", "Id", Name = "IDX_3ed7a60fb7dbe04e1ba9332a8b", IsUnique = true)]
|
||||
[Index("ChannelId", Name = "IDX_86b9109b155eb70c0a2ca3b4b6")]
|
||||
public partial class Message
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("author_id", TypeName = "character varying")]
|
||||
public string? AuthorId { get; set; }
|
||||
|
||||
[Column("member_id", TypeName = "character varying")]
|
||||
public string? MemberId { get; set; }
|
||||
|
||||
[Column("webhook_id", TypeName = "character varying")]
|
||||
public string? WebhookId { get; set; }
|
||||
|
||||
[Column("application_id", TypeName = "character varying")]
|
||||
public string? ApplicationId { get; set; }
|
||||
|
||||
[Column("content", TypeName = "character varying")]
|
||||
public string? Content { get; set; }
|
||||
|
||||
[Column("timestamp", TypeName = "timestamp without time zone")]
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
[Column("edited_timestamp", TypeName = "timestamp without time zone")]
|
||||
public DateTime? EditedTimestamp { get; set; }
|
||||
|
||||
[Column("tts")]
|
||||
public bool? Tts { get; set; }
|
||||
|
||||
[Column("mention_everyone")]
|
||||
public bool? MentionEveryone { get; set; }
|
||||
|
||||
[Column("embeds")]
|
||||
public string Embeds { get; set; } = null!;
|
||||
|
||||
[Column("reactions")]
|
||||
public string Reactions { get; set; } = null!;
|
||||
|
||||
[Column("nonce")]
|
||||
public string? Nonce { get; set; }
|
||||
|
||||
[Column("pinned")]
|
||||
public bool? Pinned { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
[Column("activity")]
|
||||
public string? Activity { get; set; }
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[Column("message_reference")]
|
||||
public string? MessageReference { get; set; }
|
||||
|
||||
[Column("interaction")]
|
||||
public string? Interaction { get; set; }
|
||||
|
||||
[Column("components")]
|
||||
public string? Components { get; set; }
|
||||
|
||||
[Column("poll")]
|
||||
public string? Poll { get; set; }
|
||||
|
||||
[Column("username", TypeName = "character varying")]
|
||||
public string? Username { get; set; }
|
||||
|
||||
[Column("avatar", TypeName = "character varying")]
|
||||
public string? Avatar { get; set; }
|
||||
|
||||
[Column("message_reference_id", TypeName = "character varying")]
|
||||
public string? MessageReferenceId { get; set; }
|
||||
|
||||
[ForeignKey("ApplicationId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual Application? Application { get; set; }
|
||||
|
||||
[InverseProperty("Message")]
|
||||
public virtual ICollection<Attachment> Attachments { get; set; } = new List<Attachment>();
|
||||
|
||||
[ForeignKey("AuthorId")]
|
||||
[InverseProperty("MessageAuthors")]
|
||||
public virtual User? Author { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual Channel? Channel { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[InverseProperty("MessageReferenceNavigation")]
|
||||
public virtual ICollection<Message> InverseMessageReferenceNavigation { get; set; } = new List<Message>();
|
||||
|
||||
[ForeignKey("MemberId")]
|
||||
[InverseProperty("MessageMembers")]
|
||||
public virtual User? Member { get; set; }
|
||||
|
||||
[ForeignKey("MessageReferenceId")]
|
||||
[InverseProperty("InverseMessageReferenceNavigation")]
|
||||
public virtual Message? MessageReferenceNavigation { get; set; }
|
||||
|
||||
[ForeignKey("WebhookId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual Webhook? Webhook { get; set; }
|
||||
|
||||
[ForeignKey("MessagesId")]
|
||||
[InverseProperty("MessagesNavigation")]
|
||||
public virtual ICollection<Channel> Channels { get; set; } = new List<Channel>();
|
||||
|
||||
[ForeignKey("MessagesId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual ICollection<Role> Roles { get; set; } = new List<Role>();
|
||||
|
||||
[ForeignKey("MessagesId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual ICollection<Sticker> Stickers { get; set; } = new List<Sticker>();
|
||||
|
||||
[ForeignKey("MessagesId")]
|
||||
[InverseProperty("Messages")]
|
||||
public virtual ICollection<User> Users { get; set; } = new List<User>();
|
||||
}
|
||||
21
extra/admin-api/Spacebar.Db/Models/Migration.cs
Normal file
21
extra/admin-api/Spacebar.Db/Models/Migration.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("migrations")]
|
||||
public partial class Migration
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("timestamp")]
|
||||
public long Timestamp { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
}
|
||||
33
extra/admin-api/Spacebar.Db/Models/Note.cs
Normal file
33
extra/admin-api/Spacebar.Db/Models/Note.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("notes")]
|
||||
[Index("OwnerId", "TargetId", Name = "UQ_74e6689b9568cc965b8bfc9150b", IsUnique = true)]
|
||||
public partial class Note
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("content", TypeName = "character varying")]
|
||||
public string Content { get; set; } = null!;
|
||||
|
||||
[Column("owner_id", TypeName = "character varying")]
|
||||
public string? OwnerId { get; set; }
|
||||
|
||||
[Column("target_id", TypeName = "character varying")]
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
[ForeignKey("OwnerId")]
|
||||
[InverseProperty("NoteOwners")]
|
||||
public virtual User? Owner { get; set; }
|
||||
|
||||
[ForeignKey("TargetId")]
|
||||
[InverseProperty("NoteTargets")]
|
||||
public virtual User? Target { get; set; }
|
||||
}
|
||||
27
extra/admin-api/Spacebar.Db/Models/RateLimit.cs
Normal file
27
extra/admin-api/Spacebar.Db/Models/RateLimit.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("rate_limits")]
|
||||
public partial class RateLimit
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("executor_id", TypeName = "character varying")]
|
||||
public string ExecutorId { get; set; } = null!;
|
||||
|
||||
[Column("hits")]
|
||||
public int Hits { get; set; }
|
||||
|
||||
[Column("blocked")]
|
||||
public bool Blocked { get; set; }
|
||||
|
||||
[Column("expires_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
}
|
||||
45
extra/admin-api/Spacebar.Db/Models/ReadState.cs
Normal file
45
extra/admin-api/Spacebar.Db/Models/ReadState.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("read_states")]
|
||||
[Index("ChannelId", "UserId", Name = "IDX_0abf8b443321bd3cf7f81ee17a", IsUnique = true)]
|
||||
public partial class ReadState
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string ChannelId { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
[Column("last_message_id", TypeName = "character varying")]
|
||||
public string? LastMessageId { get; set; }
|
||||
|
||||
[Column("public_ack", TypeName = "character varying")]
|
||||
public string? PublicAck { get; set; }
|
||||
|
||||
[Column("notifications_cursor", TypeName = "character varying")]
|
||||
public string? NotificationsCursor { get; set; }
|
||||
|
||||
[Column("last_pin_timestamp", TypeName = "timestamp without time zone")]
|
||||
public DateTime? LastPinTimestamp { get; set; }
|
||||
|
||||
[Column("mention_count")]
|
||||
public int? MentionCount { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("ReadStates")]
|
||||
public virtual Channel Channel { get; set; } = null!;
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("ReadStates")]
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
32
extra/admin-api/Spacebar.Db/Models/Recipient.cs
Normal file
32
extra/admin-api/Spacebar.Db/Models/Recipient.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("recipients")]
|
||||
public partial class Recipient
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string ChannelId { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
[Column("closed")]
|
||||
public bool Closed { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("Recipients")]
|
||||
public virtual Channel Channel { get; set; } = null!;
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("Recipients")]
|
||||
public virtual User User { get; set; } = null!;
|
||||
}
|
||||
36
extra/admin-api/Spacebar.Db/Models/Relationship.cs
Normal file
36
extra/admin-api/Spacebar.Db/Models/Relationship.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("relationships")]
|
||||
[Index("FromId", "ToId", Name = "IDX_a0b2ff0a598df0b0d055934a17", IsUnique = true)]
|
||||
public partial class Relationship
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("from_id", TypeName = "character varying")]
|
||||
public string FromId { get; set; } = null!;
|
||||
|
||||
[Column("to_id", TypeName = "character varying")]
|
||||
public string ToId { get; set; } = null!;
|
||||
|
||||
[Column("nickname", TypeName = "character varying")]
|
||||
public string? Nickname { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
[ForeignKey("FromId")]
|
||||
[InverseProperty("RelationshipFroms")]
|
||||
public virtual User From { get; set; } = null!;
|
||||
|
||||
[ForeignKey("ToId")]
|
||||
[InverseProperty("RelationshipTos")]
|
||||
public virtual User To { get; set; } = null!;
|
||||
}
|
||||
63
extra/admin-api/Spacebar.Db/Models/Role.cs
Normal file
63
extra/admin-api/Spacebar.Db/Models/Role.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("roles")]
|
||||
public partial class Role
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string GuildId { get; set; } = null!;
|
||||
|
||||
[Column("color")]
|
||||
public int Color { get; set; }
|
||||
|
||||
[Column("hoist")]
|
||||
public bool Hoist { get; set; }
|
||||
|
||||
[Column("managed")]
|
||||
public bool Managed { get; set; }
|
||||
|
||||
[Column("mentionable")]
|
||||
public bool Mentionable { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("permissions", TypeName = "character varying")]
|
||||
public string Permissions { get; set; } = null!;
|
||||
|
||||
[Column("position")]
|
||||
public int Position { get; set; }
|
||||
|
||||
[Column("icon", TypeName = "character varying")]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
[Column("unicode_emoji", TypeName = "character varying")]
|
||||
public string? UnicodeEmoji { get; set; }
|
||||
|
||||
[Column("tags")]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
[Column("flags")]
|
||||
public int Flags { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Roles")]
|
||||
public virtual Guild Guild { get; set; } = null!;
|
||||
|
||||
[ForeignKey("RoleId")]
|
||||
[InverseProperty("Roles")]
|
||||
public virtual ICollection<Member> Indices { get; set; } = new List<Member>();
|
||||
|
||||
[ForeignKey("RolesId")]
|
||||
[InverseProperty("Roles")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
}
|
||||
34
extra/admin-api/Spacebar.Db/Models/SecurityKey.cs
Normal file
34
extra/admin-api/Spacebar.Db/Models/SecurityKey.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("security_keys")]
|
||||
public partial class SecurityKey
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("key_id", TypeName = "character varying")]
|
||||
public string KeyId { get; set; } = null!;
|
||||
|
||||
[Column("public_key", TypeName = "character varying")]
|
||||
public string PublicKey { get; set; } = null!;
|
||||
|
||||
[Column("counter")]
|
||||
public int Counter { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("SecurityKeys")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
33
extra/admin-api/Spacebar.Db/Models/SecuritySetting.cs
Normal file
33
extra/admin-api/Spacebar.Db/Models/SecuritySetting.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("security_settings")]
|
||||
public partial class SecuritySetting
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[Column("encryption_permission_mask")]
|
||||
public int EncryptionPermissionMask { get; set; }
|
||||
|
||||
[Column("allowed_algorithms")]
|
||||
public string AllowedAlgorithms { get; set; } = null!;
|
||||
|
||||
[Column("current_algorithm", TypeName = "character varying")]
|
||||
public string CurrentAlgorithm { get; set; } = null!;
|
||||
|
||||
[Column("used_since_message", TypeName = "character varying")]
|
||||
public string? UsedSinceMessage { get; set; }
|
||||
}
|
||||
37
extra/admin-api/Spacebar.Db/Models/Session.cs
Normal file
37
extra/admin-api/Spacebar.Db/Models/Session.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("sessions")]
|
||||
public partial class Session
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("session_id", TypeName = "character varying")]
|
||||
public string SessionId { get; set; } = null!;
|
||||
|
||||
[Column("activities")]
|
||||
public string? Activities { get; set; }
|
||||
|
||||
[Column("client_info")]
|
||||
public string ClientInfo { get; set; } = null!;
|
||||
|
||||
[Column("client_status")]
|
||||
public string ClientStatus { get; set; } = null!;
|
||||
|
||||
[Column("status", TypeName = "character varying")]
|
||||
public string Status { get; set; } = null!;
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("Sessions")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
61
extra/admin-api/Spacebar.Db/Models/Sticker.cs
Normal file
61
extra/admin-api/Spacebar.Db/Models/Sticker.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("stickers")]
|
||||
public partial class Sticker
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("description", TypeName = "character varying")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column("available")]
|
||||
public bool? Available { get; set; }
|
||||
|
||||
[Column("tags", TypeName = "character varying")]
|
||||
public string? Tags { get; set; }
|
||||
|
||||
[Column("pack_id", TypeName = "character varying")]
|
||||
public string? PackId { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
[Column("format_type")]
|
||||
public int FormatType { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("Stickers")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[ForeignKey("PackId")]
|
||||
[InverseProperty("Stickers")]
|
||||
public virtual StickerPack? Pack { get; set; }
|
||||
|
||||
[InverseProperty("CoverStickerId1Navigation")]
|
||||
public virtual ICollection<StickerPack> StickerPacks { get; set; } = new List<StickerPack>();
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("Stickers")]
|
||||
public virtual User? User { get; set; }
|
||||
|
||||
[ForeignKey("StickersId")]
|
||||
[InverseProperty("Stickers")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
}
|
||||
37
extra/admin-api/Spacebar.Db/Models/StickerPack.cs
Normal file
37
extra/admin-api/Spacebar.Db/Models/StickerPack.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("sticker_packs")]
|
||||
public partial class StickerPack
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("description", TypeName = "character varying")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column("banner_asset_id", TypeName = "character varying")]
|
||||
public string? BannerAssetId { get; set; }
|
||||
|
||||
[Column("cover_sticker_id", TypeName = "character varying")]
|
||||
public string? CoverStickerId { get; set; }
|
||||
|
||||
[Column("coverStickerId", TypeName = "character varying")]
|
||||
public string? CoverStickerId1 { get; set; }
|
||||
|
||||
[ForeignKey("CoverStickerId1")]
|
||||
[InverseProperty("StickerPacks")]
|
||||
public virtual Sticker? CoverStickerId1Navigation { get; set; }
|
||||
|
||||
[InverseProperty("Pack")]
|
||||
public virtual ICollection<Sticker> Stickers { get; set; } = new List<Sticker>();
|
||||
}
|
||||
34
extra/admin-api/Spacebar.Db/Models/Team.cs
Normal file
34
extra/admin-api/Spacebar.Db/Models/Team.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("teams")]
|
||||
public partial class Team
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("icon", TypeName = "character varying")]
|
||||
public string? Icon { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("owner_user_id", TypeName = "character varying")]
|
||||
public string? OwnerUserId { get; set; }
|
||||
|
||||
[InverseProperty("Team")]
|
||||
public virtual ICollection<Application> Applications { get; set; } = new List<Application>();
|
||||
|
||||
[ForeignKey("OwnerUserId")]
|
||||
[InverseProperty("Teams")]
|
||||
public virtual User? OwnerUser { get; set; }
|
||||
|
||||
[InverseProperty("Team")]
|
||||
public virtual ICollection<TeamMember> TeamMembers { get; set; } = new List<TeamMember>();
|
||||
}
|
||||
38
extra/admin-api/Spacebar.Db/Models/TeamMember.cs
Normal file
38
extra/admin-api/Spacebar.Db/Models/TeamMember.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("team_members")]
|
||||
public partial class TeamMember
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("membership_state")]
|
||||
public int MembershipState { get; set; }
|
||||
|
||||
[Column("permissions")]
|
||||
public string Permissions { get; set; } = null!;
|
||||
|
||||
[Column("role", TypeName = "character varying")]
|
||||
public string Role { get; set; } = null!;
|
||||
|
||||
[Column("team_id", TypeName = "character varying")]
|
||||
public string? TeamId { get; set; }
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[ForeignKey("TeamId")]
|
||||
[InverseProperty("TeamMembers")]
|
||||
public virtual Team? Team { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("TeamMembers")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
54
extra/admin-api/Spacebar.Db/Models/Template.cs
Normal file
54
extra/admin-api/Spacebar.Db/Models/Template.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("templates")]
|
||||
[Index("Code", Name = "UQ_be38737bf339baf63b1daeffb55", IsUnique = true)]
|
||||
public partial class Template
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("code", TypeName = "character varying")]
|
||||
public string Code { get; set; } = null!;
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("description", TypeName = "character varying")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Column("usage_count")]
|
||||
public int? UsageCount { get; set; }
|
||||
|
||||
[Column("creator_id", TypeName = "character varying")]
|
||||
public string? CreatorId { get; set; }
|
||||
|
||||
[Column("created_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[Column("updated_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
[Column("source_guild_id", TypeName = "character varying")]
|
||||
public string? SourceGuildId { get; set; }
|
||||
|
||||
[Column("serialized_source_guild")]
|
||||
public string SerializedSourceGuild { get; set; } = null!;
|
||||
|
||||
[ForeignKey("CreatorId")]
|
||||
[InverseProperty("Templates")]
|
||||
public virtual User? Creator { get; set; }
|
||||
|
||||
[InverseProperty("Template")]
|
||||
public virtual ICollection<Guild> Guilds { get; set; } = new List<Guild>();
|
||||
|
||||
[ForeignKey("SourceGuildId")]
|
||||
[InverseProperty("Templates")]
|
||||
public virtual Guild? SourceGuild { get; set; }
|
||||
}
|
||||
222
extra/admin-api/Spacebar.Db/Models/User.cs
Normal file
222
extra/admin-api/Spacebar.Db/Models/User.cs
Normal file
@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("users")]
|
||||
[Index("SettingsIndex", Name = "REL_0c14beb78d8c5ccba66072adbc", IsUnique = true)]
|
||||
public partial class User
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("username", TypeName = "character varying")]
|
||||
public string Username { get; set; } = null!;
|
||||
|
||||
[Column("discriminator", TypeName = "character varying")]
|
||||
public string Discriminator { get; set; } = null!;
|
||||
|
||||
[Column("avatar", TypeName = "character varying")]
|
||||
public string? Avatar { get; set; }
|
||||
|
||||
[Column("accent_color")]
|
||||
public int? AccentColor { get; set; }
|
||||
|
||||
[Column("banner", TypeName = "character varying")]
|
||||
public string? Banner { get; set; }
|
||||
|
||||
[Column("theme_colors")]
|
||||
public string? ThemeColors { get; set; }
|
||||
|
||||
[Column("pronouns", TypeName = "character varying")]
|
||||
public string? Pronouns { get; set; }
|
||||
|
||||
[Column("phone", TypeName = "character varying")]
|
||||
public string? Phone { get; set; }
|
||||
|
||||
[Column("desktop")]
|
||||
public bool Desktop { get; set; }
|
||||
|
||||
[Column("mobile")]
|
||||
public bool Mobile { get; set; }
|
||||
|
||||
[Column("premium")]
|
||||
public bool Premium { get; set; }
|
||||
|
||||
[Column("premium_type")]
|
||||
public int PremiumType { get; set; }
|
||||
|
||||
[Column("bot")]
|
||||
public bool Bot { get; set; }
|
||||
|
||||
[Column("bio", TypeName = "character varying")]
|
||||
public string Bio { get; set; } = null!;
|
||||
|
||||
[Column("system")]
|
||||
public bool System { get; set; }
|
||||
|
||||
[Column("nsfw_allowed")]
|
||||
public bool NsfwAllowed { get; set; }
|
||||
|
||||
[Column("mfa_enabled")]
|
||||
public bool MfaEnabled { get; set; }
|
||||
|
||||
[Column("webauthn_enabled")]
|
||||
public bool WebauthnEnabled { get; set; }
|
||||
|
||||
[Column("totp_secret", TypeName = "character varying")]
|
||||
public string? TotpSecret { get; set; }
|
||||
|
||||
[Column("totp_last_ticket", TypeName = "character varying")]
|
||||
public string? TotpLastTicket { get; set; }
|
||||
|
||||
[Column("created_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[Column("premium_since", TypeName = "timestamp without time zone")]
|
||||
public DateTime? PremiumSince { get; set; }
|
||||
|
||||
[Column("verified")]
|
||||
public bool Verified { get; set; }
|
||||
|
||||
[Column("disabled")]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Column("deleted")]
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
[Column("email", TypeName = "character varying")]
|
||||
public string? Email { get; set; }
|
||||
|
||||
[Column("flags", TypeName = "character varying")]
|
||||
public string Flags { get; set; }
|
||||
|
||||
[Column("public_flags")]
|
||||
public int PublicFlags { get; set; }
|
||||
|
||||
[Column("purchased_flags")]
|
||||
public int PurchasedFlags { get; set; }
|
||||
|
||||
[Column("premium_usage_flags")]
|
||||
public int PremiumUsageFlags { get; set; }
|
||||
|
||||
[Column("rights")]
|
||||
public long Rights { get; set; }
|
||||
|
||||
[Column("data")]
|
||||
public string Data { get; set; } = null!;
|
||||
|
||||
[Column("fingerprints")]
|
||||
public string Fingerprints { get; set; } = null!;
|
||||
|
||||
[Column("extended_settings")]
|
||||
public string ExtendedSettings { get; set; } = null!;
|
||||
|
||||
[Column("badge_ids")]
|
||||
public string? BadgeIds { get; set; }
|
||||
|
||||
[Column("settingsIndex")]
|
||||
public int? SettingsIndex { get; set; }
|
||||
|
||||
[InverseProperty("BotUser")]
|
||||
public virtual Application? ApplicationBotUser { get; set; }
|
||||
|
||||
[InverseProperty("Owner")]
|
||||
public virtual ICollection<Application> ApplicationOwners { get; set; } = new List<Application>();
|
||||
|
||||
[InverseProperty("Target")]
|
||||
public virtual ICollection<AuditLog> AuditLogTargets { get; set; } = new List<AuditLog>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<AuditLog> AuditLogUsers { get; set; } = new List<AuditLog>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<BackupCode> BackupCodes { get; set; } = new List<BackupCode>();
|
||||
|
||||
[InverseProperty("Executor")]
|
||||
public virtual ICollection<Ban> BanExecutors { get; set; } = new List<Ban>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Ban> BanUsers { get; set; } = new List<Ban>();
|
||||
|
||||
[InverseProperty("Owner")]
|
||||
public virtual ICollection<Channel> Channels { get; set; } = new List<Channel>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<ConnectedAccount> ConnectedAccounts { get; set; } = new List<ConnectedAccount>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Emoji> Emojis { get; set; } = new List<Emoji>();
|
||||
|
||||
[InverseProperty("Owner")]
|
||||
public virtual ICollection<Guild> Guilds { get; set; } = new List<Guild>();
|
||||
|
||||
[InverseProperty("Inviter")]
|
||||
public virtual ICollection<Invite> InviteInviters { get; set; } = new List<Invite>();
|
||||
|
||||
[InverseProperty("TargetUser")]
|
||||
public virtual ICollection<Invite> InviteTargetUsers { get; set; } = new List<Invite>();
|
||||
|
||||
[InverseProperty("IdNavigation")]
|
||||
public virtual ICollection<Member> Members { get; set; } = new List<Member>();
|
||||
|
||||
[InverseProperty("Author")]
|
||||
public virtual ICollection<Message> MessageAuthors { get; set; } = new List<Message>();
|
||||
|
||||
[InverseProperty("Member")]
|
||||
public virtual ICollection<Message> MessageMembers { get; set; } = new List<Message>();
|
||||
|
||||
[InverseProperty("Owner")]
|
||||
public virtual ICollection<Note> NoteOwners { get; set; } = new List<Note>();
|
||||
|
||||
[InverseProperty("Target")]
|
||||
public virtual ICollection<Note> NoteTargets { get; set; } = new List<Note>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<ReadState> ReadStates { get; set; } = new List<ReadState>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Recipient> Recipients { get; set; } = new List<Recipient>();
|
||||
|
||||
[InverseProperty("From")]
|
||||
public virtual ICollection<Relationship> RelationshipFroms { get; set; } = new List<Relationship>();
|
||||
|
||||
[InverseProperty("To")]
|
||||
public virtual ICollection<Relationship> RelationshipTos { get; set; } = new List<Relationship>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<SecurityKey> SecurityKeys { get; set; } = new List<SecurityKey>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Session> Sessions { get; set; } = new List<Session>();
|
||||
|
||||
[ForeignKey("SettingsIndex")]
|
||||
[InverseProperty("User")]
|
||||
public virtual UserSetting? SettingsIndexNavigation { get; set; }
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Sticker> Stickers { get; set; } = new List<Sticker>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<TeamMember> TeamMembers { get; set; } = new List<TeamMember>();
|
||||
|
||||
[InverseProperty("OwnerUser")]
|
||||
public virtual ICollection<Team> Teams { get; set; } = new List<Team>();
|
||||
|
||||
[InverseProperty("Creator")]
|
||||
public virtual ICollection<Template> Templates { get; set; } = new List<Template>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<VoiceState> VoiceStates { get; set; } = new List<VoiceState>();
|
||||
|
||||
[InverseProperty("User")]
|
||||
public virtual ICollection<Webhook> Webhooks { get; set; } = new List<Webhook>();
|
||||
|
||||
[ForeignKey("UsersId")]
|
||||
[InverseProperty("Users")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
}
|
||||
117
extra/admin-api/Spacebar.Db/Models/UserSetting.cs
Normal file
117
extra/admin-api/Spacebar.Db/Models/UserSetting.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("user_settings")]
|
||||
public partial class UserSetting
|
||||
{
|
||||
[Key]
|
||||
[Column("index")]
|
||||
public int Index { get; set; }
|
||||
|
||||
[Column("afk_timeout")]
|
||||
public int? AfkTimeout { get; set; }
|
||||
|
||||
[Column("allow_accessibility_detection")]
|
||||
public bool? AllowAccessibilityDetection { get; set; }
|
||||
|
||||
[Column("animate_emoji")]
|
||||
public bool? AnimateEmoji { get; set; }
|
||||
|
||||
[Column("animate_stickers")]
|
||||
public int? AnimateStickers { get; set; }
|
||||
|
||||
[Column("contact_sync_enabled")]
|
||||
public bool? ContactSyncEnabled { get; set; }
|
||||
|
||||
[Column("convert_emoticons")]
|
||||
public bool? ConvertEmoticons { get; set; }
|
||||
|
||||
[Column("custom_status")]
|
||||
public string? CustomStatus { get; set; }
|
||||
|
||||
[Column("default_guilds_restricted")]
|
||||
public bool? DefaultGuildsRestricted { get; set; }
|
||||
|
||||
[Column("detect_platform_accounts")]
|
||||
public bool? DetectPlatformAccounts { get; set; }
|
||||
|
||||
[Column("developer_mode")]
|
||||
public bool? DeveloperMode { get; set; }
|
||||
|
||||
[Column("disable_games_tab")]
|
||||
public bool? DisableGamesTab { get; set; }
|
||||
|
||||
[Column("enable_tts_command")]
|
||||
public bool? EnableTtsCommand { get; set; }
|
||||
|
||||
[Column("explicit_content_filter")]
|
||||
public int? ExplicitContentFilter { get; set; }
|
||||
|
||||
[Column("friend_discovery_flags")]
|
||||
public int? FriendDiscoveryFlags { get; set; }
|
||||
|
||||
[Column("friend_source_flags")]
|
||||
public string? FriendSourceFlags { get; set; }
|
||||
|
||||
[Column("gateway_connected")]
|
||||
public bool? GatewayConnected { get; set; }
|
||||
|
||||
[Column("gif_auto_play")]
|
||||
public bool? GifAutoPlay { get; set; }
|
||||
|
||||
[Column("guild_folders")]
|
||||
public string? GuildFolders { get; set; }
|
||||
|
||||
[Column("guild_positions")]
|
||||
public string? GuildPositions { get; set; }
|
||||
|
||||
[Column("inline_attachment_media")]
|
||||
public bool? InlineAttachmentMedia { get; set; }
|
||||
|
||||
[Column("inline_embed_media")]
|
||||
public bool? InlineEmbedMedia { get; set; }
|
||||
|
||||
[Column("locale", TypeName = "character varying")]
|
||||
public string? Locale { get; set; }
|
||||
|
||||
[Column("message_display_compact")]
|
||||
public bool? MessageDisplayCompact { get; set; }
|
||||
|
||||
[Column("native_phone_integration_enabled")]
|
||||
public bool? NativePhoneIntegrationEnabled { get; set; }
|
||||
|
||||
[Column("render_embeds")]
|
||||
public bool? RenderEmbeds { get; set; }
|
||||
|
||||
[Column("render_reactions")]
|
||||
public bool? RenderReactions { get; set; }
|
||||
|
||||
[Column("restricted_guilds")]
|
||||
public string? RestrictedGuilds { get; set; }
|
||||
|
||||
[Column("show_current_game")]
|
||||
public bool? ShowCurrentGame { get; set; }
|
||||
|
||||
[Column("status", TypeName = "character varying")]
|
||||
public string? Status { get; set; }
|
||||
|
||||
[Column("stream_notifications_enabled")]
|
||||
public bool? StreamNotificationsEnabled { get; set; }
|
||||
|
||||
[Column("theme", TypeName = "character varying")]
|
||||
public string? Theme { get; set; }
|
||||
|
||||
[Column("timezone_offset")]
|
||||
public int? TimezoneOffset { get; set; }
|
||||
|
||||
[Column("view_nsfw_guilds")]
|
||||
public bool? ViewNsfwGuilds { get; set; }
|
||||
|
||||
[InverseProperty("SettingsIndexNavigation")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
21
extra/admin-api/Spacebar.Db/Models/ValidRegistrationToken.cs
Normal file
21
extra/admin-api/Spacebar.Db/Models/ValidRegistrationToken.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("valid_registration_tokens")]
|
||||
public partial class ValidRegistrationToken
|
||||
{
|
||||
[Key]
|
||||
[Column("token", TypeName = "character varying")]
|
||||
public string Token { get; set; } = null!;
|
||||
|
||||
[Column("created_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[Column("expires_at", TypeName = "timestamp without time zone")]
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
}
|
||||
66
extra/admin-api/Spacebar.Db/Models/VoiceState.cs
Normal file
66
extra/admin-api/Spacebar.Db/Models/VoiceState.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("voice_states")]
|
||||
public partial class VoiceState
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("session_id", TypeName = "character varying")]
|
||||
public string SessionId { get; set; } = null!;
|
||||
|
||||
[Column("token", TypeName = "character varying")]
|
||||
public string? Token { get; set; }
|
||||
|
||||
[Column("deaf")]
|
||||
public bool Deaf { get; set; }
|
||||
|
||||
[Column("mute")]
|
||||
public bool Mute { get; set; }
|
||||
|
||||
[Column("self_deaf")]
|
||||
public bool SelfDeaf { get; set; }
|
||||
|
||||
[Column("self_mute")]
|
||||
public bool SelfMute { get; set; }
|
||||
|
||||
[Column("self_stream")]
|
||||
public bool? SelfStream { get; set; }
|
||||
|
||||
[Column("self_video")]
|
||||
public bool SelfVideo { get; set; }
|
||||
|
||||
[Column("suppress")]
|
||||
public bool Suppress { get; set; }
|
||||
|
||||
[Column("request_to_speak_timestamp", TypeName = "timestamp without time zone")]
|
||||
public DateTime? RequestToSpeakTimestamp { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("VoiceStates")]
|
||||
public virtual Channel? Channel { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("VoiceStates")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("VoiceStates")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
72
extra/admin-api/Spacebar.Db/Models/Webhook.cs
Normal file
72
extra/admin-api/Spacebar.Db/Models/Webhook.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Spacebar.Db.Models;
|
||||
|
||||
[Table("webhooks")]
|
||||
public partial class Webhook
|
||||
{
|
||||
[Key]
|
||||
[Column("id", TypeName = "character varying")]
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
[Column("type")]
|
||||
public int Type { get; set; }
|
||||
|
||||
[Column("name", TypeName = "character varying")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[Column("avatar", TypeName = "character varying")]
|
||||
public string? Avatar { get; set; }
|
||||
|
||||
[Column("token", TypeName = "character varying")]
|
||||
public string? Token { get; set; }
|
||||
|
||||
[Column("guild_id", TypeName = "character varying")]
|
||||
public string? GuildId { get; set; }
|
||||
|
||||
[Column("channel_id", TypeName = "character varying")]
|
||||
public string? ChannelId { get; set; }
|
||||
|
||||
[Column("application_id", TypeName = "character varying")]
|
||||
public string? ApplicationId { get; set; }
|
||||
|
||||
[Column("user_id", TypeName = "character varying")]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
[Column("source_guild_id", TypeName = "character varying")]
|
||||
public string? SourceGuildId { get; set; }
|
||||
|
||||
[Column("source_channel_id", TypeName = "character varying")]
|
||||
public string? SourceChannelId { get; set; }
|
||||
|
||||
[ForeignKey("ApplicationId")]
|
||||
[InverseProperty("Webhooks")]
|
||||
public virtual Application? Application { get; set; }
|
||||
|
||||
[ForeignKey("ChannelId")]
|
||||
[InverseProperty("WebhookChannels")]
|
||||
public virtual Channel? Channel { get; set; }
|
||||
|
||||
[ForeignKey("GuildId")]
|
||||
[InverseProperty("WebhookGuilds")]
|
||||
public virtual Guild? Guild { get; set; }
|
||||
|
||||
[InverseProperty("Webhook")]
|
||||
public virtual ICollection<Message> Messages { get; set; } = new List<Message>();
|
||||
|
||||
[ForeignKey("SourceChannelId")]
|
||||
[InverseProperty("WebhookSourceChannels")]
|
||||
public virtual Channel? SourceChannel { get; set; }
|
||||
|
||||
[ForeignKey("SourceGuildId")]
|
||||
[InverseProperty("WebhookSourceGuilds")]
|
||||
public virtual Guild? SourceGuild { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
[InverseProperty("Webhooks")]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
14
extra/admin-api/Spacebar.Db/Spacebar.Db.csproj
Normal file
14
extra/admin-api/Spacebar.Db/Spacebar.Db.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="*" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
28
extra/admin-api/SpacebarAdminAPI.sln
Normal file
28
extra/admin-api/SpacebarAdminAPI.sln
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
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
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = 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
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
15
extra/admin-api/db-patches/db-00-fix-flags.patch
Normal file
15
extra/admin-api/db-patches/db-00-fix-flags.patch
Normal file
@ -0,0 +1,15 @@
|
||||
diff --git a/extra/admin-api/Spacebar.Db/Models/User.cs b/extra/admin-api/Spacebar.Db/Models/User.cs
|
||||
index 7825bd17..ca140dbc 100644
|
||||
--- a/extra/admin-api/Spacebar.Db/Models/User.cs
|
||||
+++ b/extra/admin-api/Spacebar.Db/Models/User.cs
|
||||
@@ -92,8 +92,8 @@ public partial class User
|
||||
[Column("email", TypeName = "character varying")]
|
||||
public string? Email { get; set; }
|
||||
|
||||
- [Column("flags")]
|
||||
- public int Flags { get; set; }
|
||||
+ [Column("flags", TypeName = "character varying")]
|
||||
+ public string Flags { get; set; }
|
||||
|
||||
[Column("public_flags")]
|
||||
public int PublicFlags { get; set; }
|
||||
92
extra/admin-api/flake.nix
Normal file
92
extra/admin-api/flake.nix
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
description = "Spacebar Admin API, written in C#.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachSystem flake-utils.lib.allSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
hashesFile = builtins.fromJSON (builtins.readFile ./hashes.json);
|
||||
lib = pkgs.lib;
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
default = pkgs.buildNpmPackage {
|
||||
pname = "spacebar-server-ts";
|
||||
name = "spacebar-server-ts";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Spacebar server, a FOSS reimplementation of the Discord backend.";
|
||||
homepage = "https://github.com/spacebarchat/server";
|
||||
license = licenses.agpl3Plus;
|
||||
platforms = platforms.all;
|
||||
mainProgram = "start-bundle";
|
||||
};
|
||||
|
||||
src = ./.;
|
||||
nativeBuildInputs = with pkgs; [ python3 ];
|
||||
npmDepsHash = hashesFile.npmDepsHash;
|
||||
makeCacheWritable = true;
|
||||
postPatch = ''
|
||||
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
set -x
|
||||
#remove packages not needed for production, or at least try to...
|
||||
npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
|
||||
find node_modules -maxdepth 1 -type d -empty -delete
|
||||
|
||||
mkdir -p $out
|
||||
cp -r assets dist node_modules package.json $out/
|
||||
for i in dist/**/start.js
|
||||
do
|
||||
makeWrapper ${pkgs.nodejs}/bin/node $out/bin/start-`dirname ''${i/dist\//}` --prefix NODE_PATH : $out/node_modules --add-flags $out/$i
|
||||
done
|
||||
|
||||
set +x
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
update-nix = pkgs.writeShellApplication {
|
||||
name = "update-nix";
|
||||
runtimeInputs = with pkgs; [
|
||||
prefetch-npm-deps
|
||||
nix
|
||||
jq
|
||||
];
|
||||
text = ''
|
||||
nix flake update --extra-experimental-features 'nix-command flakes'
|
||||
DEPS_HASH=$(prefetch-npm-deps package-lock.json)
|
||||
TMPFILE=$(mktemp)
|
||||
jq '.npmDepsHash = "'"$DEPS_HASH"'"' hashes.json > "$TMPFILE"
|
||||
mv -- "$TMPFILE" hashes.json
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nodejs
|
||||
nodePackages.typescript
|
||||
nodePackages.ts-node
|
||||
nodePackages.patch-package
|
||||
nodePackages.prettier
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
1
extra/admin-api/result-man
Symbolic link
1
extra/admin-api/result-man
Symbolic link
@ -0,0 +1 @@
|
||||
/nix/store/0q9yki1d9czy7i7mly8gy3ffjvc3hkqv-postgresql-16.5-man
|
||||
33
extra/admin-api/scaffold-db
Executable file
33
extra/admin-api/scaffold-db
Executable file
@ -0,0 +1,33 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i nix -p nix
|
||||
#! nix shell nixpkgs#bash nixpkgs#dotnet-ef nixpkgs#postgresql --command bash
|
||||
|
||||
set -ex
|
||||
rm -rfv Spacebar.Db
|
||||
|
||||
# prep temporary db
|
||||
# - Update collation version for template1 just incase!
|
||||
psql -U postgres -c 'ALTER DATABASE template1 REFRESH COLLATION VERSION;'
|
||||
dropdb -U postgres sb-server-scaffold --if-exists --force || true
|
||||
createdb -U postgres sb-server-scaffold
|
||||
DATABASE=postgres://postgres@127.0.0.1/sb-server-scaffold nix shell nixpkgs#nodejs ../.. --command npm run sync:db
|
||||
|
||||
# Create new project
|
||||
dotnet new classlib --no-restore -o Spacebar.Db
|
||||
cd Spacebar.Db
|
||||
rm Class1.cs
|
||||
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL -n -f net9.0
|
||||
dotnet add package Microsoft.EntityFrameworkCore.Design -n -f net9.0
|
||||
|
||||
dotnet-ef dbcontext scaffold "Host=127.0.0.1; Username=postgres; Database=sb-server-scaffold" \
|
||||
Npgsql.EntityFrameworkCore.PostgreSQL \
|
||||
-o Models \
|
||||
-c SpacebarDbContext \
|
||||
--context-dir Contexts \
|
||||
--force \
|
||||
--no-onconfiguring \
|
||||
--data-annotations
|
||||
|
||||
for patch in db-patches/*.patch; do
|
||||
patch -p3 < $patch
|
||||
done
|
||||
@ -19,17 +19,21 @@
|
||||
import jwt, { VerifyOptions } from "jsonwebtoken";
|
||||
import { Config } from "./Config";
|
||||
import { User } from "../entities";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "fs/promises";
|
||||
import { existsSync } from "fs";
|
||||
// TODO: dont use deprecated APIs lol
|
||||
import {
|
||||
FindOptionsRelationByString,
|
||||
FindOptionsSelectByString,
|
||||
} from "typeorm";
|
||||
import * as console from "node:console";
|
||||
|
||||
export const JWTOptions: VerifyOptions = { algorithms: ["HS256"] };
|
||||
|
||||
export type UserTokenData = {
|
||||
user: User;
|
||||
decoded: { id: string; iat: number; email?: string };
|
||||
decoded: { id: string; iat: number };
|
||||
};
|
||||
|
||||
export const checkToken = (
|
||||
@ -43,56 +47,70 @@ export const checkToken = (
|
||||
token = token.replace("Bot ", ""); // there is no bot distinction in sb
|
||||
token = token.replace("Bearer ", ""); // allow bearer tokens
|
||||
|
||||
jwt.verify(
|
||||
token,
|
||||
Config.get().security.jwtSecret,
|
||||
JWTOptions,
|
||||
async (err, out) => {
|
||||
const decoded = out as UserTokenData["decoded"];
|
||||
if (err || !decoded) return reject("Invalid Token");
|
||||
const validateUser: jwt.VerifyCallback = async (err, out) => {
|
||||
const decoded = out as UserTokenData["decoded"];
|
||||
if (err || !decoded) return reject("Invalid Token meow " + err);
|
||||
|
||||
const user = await User.findOne({
|
||||
where: decoded.email
|
||||
? { email: decoded.email }
|
||||
: { id: decoded.id },
|
||||
select: [
|
||||
...(opts?.select || []),
|
||||
"bot",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"rights",
|
||||
"data",
|
||||
],
|
||||
relations: opts?.relations,
|
||||
});
|
||||
const user = await User.findOne({
|
||||
where: { id: decoded.id },
|
||||
select: [
|
||||
...(opts?.select || []),
|
||||
"bot",
|
||||
"disabled",
|
||||
"deleted",
|
||||
"rights",
|
||||
"data",
|
||||
],
|
||||
relations: opts?.relations,
|
||||
});
|
||||
|
||||
if (!user) return reject("User not found");
|
||||
if (!user) return reject("User not found");
|
||||
|
||||
// we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds
|
||||
if (
|
||||
decoded.iat * 1000 <
|
||||
new Date(user.data.valid_tokens_since).setSeconds(0, 0)
|
||||
)
|
||||
return reject("Invalid Token");
|
||||
// we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds
|
||||
if (
|
||||
decoded.iat * 1000 <
|
||||
new Date(user.data.valid_tokens_since).setSeconds(0, 0)
|
||||
)
|
||||
return reject("Invalid Token");
|
||||
|
||||
if (user.disabled) return reject("User disabled");
|
||||
if (user.deleted) return reject("User not found");
|
||||
if (user.disabled) return reject("User disabled");
|
||||
if (user.deleted) return reject("User not found");
|
||||
|
||||
return resolve({ decoded, user });
|
||||
},
|
||||
);
|
||||
return resolve({ decoded, user });
|
||||
};
|
||||
|
||||
const dec = jwt.decode(token, { complete: true });
|
||||
if (!dec) return reject("Could not parse token");
|
||||
|
||||
if (dec.header.alg == "HS256") {
|
||||
jwt.verify(
|
||||
token,
|
||||
Config.get().security.jwtSecret,
|
||||
JWTOptions,
|
||||
validateUser,
|
||||
);
|
||||
} else if (dec.header.alg == "ES512") {
|
||||
loadOrGenerateKeypair().then((keyPair) => {
|
||||
jwt.verify(
|
||||
token,
|
||||
keyPair.publicKey,
|
||||
{ algorithms: ["ES512"] },
|
||||
validateUser,
|
||||
);
|
||||
});
|
||||
} else return reject("Invalid token algorithm");
|
||||
});
|
||||
|
||||
export async function generateToken(id: string, email?: string) {
|
||||
export async function generateToken(id: string) {
|
||||
const iat = Math.floor(Date.now() / 1000);
|
||||
const algorithm = "HS256";
|
||||
const keyPair = await loadOrGenerateKeypair();
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
jwt.sign(
|
||||
{ id, iat, email },
|
||||
Config.get().security.jwtSecret,
|
||||
{ id, iat, kid: keyPair.fingerprint },
|
||||
keyPair.privateKey,
|
||||
{
|
||||
algorithm,
|
||||
algorithm: "ES512",
|
||||
},
|
||||
(err, token) => {
|
||||
if (err) return rej(err);
|
||||
@ -101,3 +119,44 @@ export async function generateToken(id: string, email?: string) {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Get ECDSA keypair from file or generate it
|
||||
export async function loadOrGenerateKeypair() {
|
||||
let privateKey: crypto.KeyObject;
|
||||
let publicKey: crypto.KeyObject;
|
||||
|
||||
if (existsSync("jwt.key") && existsSync("jwt.key.pub")) {
|
||||
const [loadedPrivateKey, loadedPublicKey] = await Promise.all([
|
||||
fs.readFile("jwt.key"),
|
||||
fs.readFile("jwt.key.pub"),
|
||||
]);
|
||||
|
||||
privateKey = crypto.createPrivateKey(loadedPrivateKey);
|
||||
publicKey = crypto.createPublicKey(loadedPublicKey);
|
||||
} else {
|
||||
console.log("[JWT] Generating new keypair");
|
||||
const res = crypto.generateKeyPairSync("ec", {
|
||||
namedCurve: "secp521r1",
|
||||
});
|
||||
privateKey = res.privateKey;
|
||||
publicKey = res.publicKey;
|
||||
|
||||
await Promise.all([
|
||||
fs.writeFile(
|
||||
"jwt.key",
|
||||
privateKey.export({ format: "pem", type: "sec1" }),
|
||||
),
|
||||
fs.writeFile(
|
||||
"jwt.key.pub",
|
||||
publicKey.export({ format: "pem", type: "spki" }),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
const fingerprint = crypto
|
||||
.createHash("sha256")
|
||||
.update(publicKey.export({ format: "pem", type: "spki" }))
|
||||
.digest("hex");
|
||||
|
||||
return { privateKey, publicKey, fingerprint };
|
||||
}
|
||||
|
||||
@ -48,7 +48,6 @@ export const Email: {
|
||||
generateLink: (
|
||||
type: Omit<MailTypes, "changePassword">,
|
||||
id: string,
|
||||
email: string,
|
||||
) => Promise<string>;
|
||||
sendMail: (
|
||||
type: MailTypes,
|
||||
@ -145,10 +144,9 @@ export const Email: {
|
||||
/**
|
||||
*
|
||||
* @param id user id
|
||||
* @param email user email
|
||||
*/
|
||||
generateLink: async function (type, id, email) {
|
||||
const token = (await generateToken(id, email)) as string;
|
||||
generateLink: async function (type, id) {
|
||||
const token = (await generateToken(id)) as string;
|
||||
// puyodead1: this is set to api endpoint because the verification page is on the server since no clients have one, and not all 3rd party clients will have one
|
||||
const instanceUrl =
|
||||
Config.get().api.endpointPublic?.replace("/api", "") ||
|
||||
@ -204,7 +202,7 @@ export const Email: {
|
||||
user,
|
||||
// password change emails don't have links
|
||||
type != MailTypes.changePassword
|
||||
? await this.generateLink(type, user.id, email)
|
||||
? await this.generateLink(type, user.id)
|
||||
: undefined,
|
||||
);
|
||||
|
||||
@ -213,7 +211,7 @@ export const Email: {
|
||||
user,
|
||||
// password change emails don't have links
|
||||
type != MailTypes.changePassword
|
||||
? await this.generateLink(type, user.id, email)
|
||||
? await this.generateLink(type, user.id)
|
||||
: undefined,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user