Merge remote-tracking branch 'origin/dev/admin-api'

This commit is contained in:
Rory& 2025-10-05 21:48:43 +02:00
commit 3843a6e7b1
135 changed files with 8081 additions and 48 deletions

3
.gitignore vendored
View File

@ -19,4 +19,5 @@ build
*.tmp *.tmp
tmp/ tmp/
dump/ dump/
result result
jwt.key*

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

2
.idea/modules.xml generated
View File

@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/server-cdn-auth.iml" filepath="$PROJECT_DIR$/.idea/server-cdn-auth.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/server.iml" filepath="$PROJECT_DIR$/.idea/server.iml" />
</modules> </modules>
</component> </component>
</project> </project>

27
.idea/runConfigurations/Start_API.xml generated Normal file
View File

@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start API" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start:api" />
</scripts>
<node-interpreter value="/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0/bin/node" />
<package-manager value="npm" />
<envs />
<EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.NodeRunConfiguration">
<option name="DIRENV_ENABLED" value="false" />
<option name="DIRENV_TRUSTED" value="false" />
</EXTENSION>
<method v="2">
<option name="NpmBeforeRunTask" enabled="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
</option>
</method>
</configuration>
</component>

27
.idea/runConfigurations/Start_CDN.xml generated Normal file
View File

@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start CDN" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start:cdn" />
</scripts>
<node-interpreter value="/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0/bin/node" />
<package-manager value="npm" />
<envs />
<EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.NodeRunConfiguration">
<option name="DIRENV_ENABLED" value="false" />
<option name="DIRENV_TRUSTED" value="false" />
</EXTENSION>
<method v="2">
<option name="NpmBeforeRunTask" enabled="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
</option>
</method>
</configuration>
</component>

View File

@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start Gateway" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start:gateway" />
</scripts>
<node-interpreter value="/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0/bin/node" />
<package-manager value="npm" />
<envs />
<EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.NodeRunConfiguration">
<option name="DIRENV_ENABLED" value="false" />
<option name="DIRENV_TRUSTED" value="false" />
</EXTENSION>
<method v="2">
<option name="NpmBeforeRunTask" enabled="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
</option>
</method>
</configuration>
</component>

27
.idea/runConfigurations/Start_bundle.xml generated Normal file
View File

@ -0,0 +1,27 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start bundle" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start" />
</scripts>
<node-interpreter value="/nix/store/dcdc33kdjdhjnzg6rkmd0cx4kpwl8cac-nodejs-20.17.0/bin/node" />
<package-manager value="npm" />
<envs />
<EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.NodeRunConfiguration">
<option name="DIRENV_ENABLED" value="false" />
<option name="DIRENV_TRUSTED" value="false" />
</EXTENSION>
<method v="2">
<option name="NpmBeforeRunTask" enabled="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
</option>
</method>
</configuration>
</component>

View File

@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start separated" type="CompoundRunConfigurationType">
<toRun name="Start API" type="js.build_tools.npm" />
<toRun name="Start CDN" type="js.build_tools.npm" />
<toRun name="Start Gateway" type="js.build_tools.npm" />
<method v="2" />
</configuration>
</component>

12
.idea/server.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

133
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="bf10e7c6-8c33-4385-b571-3e96ac86a389" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$USER_HOME$/.cache/JetBrains/WebStorm2024.3/javascript/typings/node/20.17.10/node_modules/@types/node/crypto.d.ts" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/node_modules/@types/amqplib/index.d.ts" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/node_modules/@types/jsonwebtoken/index.d.ts" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/node_modules/@types/node/events.d.ts" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/result/node_modules/lambert-server/src/Server.ts" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/result/node_modules/lambert-server/src/Utils.ts" root0="SKIP_INSPECTION" />
</component>
<component name="ProblemsViewState">
<option name="selectedTabId" value="ProjectErrors" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2oJ9u2nkEFq1qQW1NFF69ECjiYu" />
<component name="ProjectViewState">
<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.Start API.executor": "Run",
"npm.Start CDN.executor": "Run",
"npm.Start Gateway.executor": "Run",
"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 name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/admin-api/routes/v0" />
<recent name="$PROJECT_DIR$/src" />
<recent name="$PROJECT_DIR$/src/api/routes/channels/#channel_id/messages" />
</key>
</component>
<component name="RunDashboard">
<option name="configurationTypes">
<set>
<option value="js.build_tools.npm" />
</set>
</option>
</component>
<component name="RunManager" selected="Compound.Start separated">
<list>
<item itemvalue="Compound.Start separated" />
<item itemvalue="npm.Start bundle" />
<item itemvalue="npm.Start API" />
<item itemvalue="npm.Start CDN" />
<item itemvalue="npm.Start Gateway" />
</list>
</component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-d6986cc7102b-deb605915726-JavaScript-WS-243.22562.112" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="bf10e7c6-8c33-4385-b571-3e96ac86a389" name="Changes" comment="" />
<created>1730577031233</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1730577031233</updated>
<workItem from="1730577032815" duration="15455000" />
<workItem from="1731866740403" duration="7103000" />
<workItem from="1735155585128" duration="5684000" />
<workItem from="1735162677624" duration="131000" />
<workItem from="1735162864847" duration="110000" />
<workItem from="1735162995609" duration="261000" />
<workItem from="1735163422404" duration="28000" />
<workItem from="1735163530041" duration="25785000" />
<workItem from="1735256039333" duration="390000" />
<workItem from="1735256441657" duration="58156000" />
<workItem from="1735848116134" duration="80763000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="javascript">
<url>file://$PROJECT_DIR$/src/admin-api/Server.ts</url>
<line>142</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" type="javascript">
<url>file://$PROJECT_DIR$/src/admin-api/Server.ts</url>
<line>140</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

View File

@ -25,6 +25,7 @@ This repository contains:
- [WebSocket Gateway Server](/src/gateway) - [WebSocket Gateway Server](/src/gateway)
- [HTTP CDN Server](/src/cdn) - [HTTP CDN Server](/src/cdn)
- [Utility and Database Models](/src/util) - [Utility and Database Models](/src/util)
- [Spacebar Admin API](/extra/admin-api) (Emma [it/its]@Rory& was here)
## [Documentation](https://docs.spacebar.chat) ## [Documentation](https://docs.spacebar.chat)

File diff suppressed because one or more lines are too long

9
extra/admin-api/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
bin/
obj/
/patches/
appsettings.Local*.json
*.DotSettings.user
/*.patch
Spacebar.Db/**/*.orig
Spacebar.Db/**/*.rej

View 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

View File

@ -0,0 +1 @@
SpacebarAdminAPI

View 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>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/Spacebar.AdminAPI/Controllers/UserController.cs" dialect="GenericSQL" />
<file url="PROJECT" dialect="PostgreSQL" />
</component>
</project>

View 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>

View File

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminApi.Models;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.RabbitMqUtilities;
namespace Spacebar.AdminAPI.Controllers.Media;
[ApiController]
[Route("/media/user")]
public class UserMediaController(ILogger<UserMediaController> logger, SpacebarDbContext db, RabbitMQService mq, IServiceProvider sp) : ControllerBase {
[HttpGet("{userId}/attachments")]
public async IAsyncEnumerable<Attachment> GetAttachmentsByUser(string userId) {
var db2 = sp.CreateScope().ServiceProvider.GetService<SpacebarDbContext>();
var attachments = db.Attachments
// .IgnoreAutoIncludes()
.Where(x => x.Message!.AuthorId == userId)
.AsAsyncEnumerable();
await foreach (var attachment in attachments) {
attachment.Message = await db2.Messages.FindAsync(attachment.MessageId);
// attachment.Message.Author = await db2.Users.FindAsync(attachment.Message.AuthorId);
yield return attachment;
}
}
}

View File

@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using Spacebar.AdminAPI.Services;
namespace Spacebar.AdminAPI.Controllers;
[ApiController]
[Route("/")]
public class PingController(ILogger<PingController> logger, IServiceProvider sp, AuthenticationService auth) : ControllerBase {
private readonly ILogger<PingController> _logger = logger;
[HttpGet("ping")]
public async Task<object> Ping() {
return new {
ok = true
};
}
[HttpGet("whoami")]
public async Task<object> WhoAmI() {
var user = await auth.GetCurrentUser(Request);
return new {
user.Id,
user.Username,
user.Discriminator,
user.Bot,
user.Flags,
user.Rights,
user.MfaEnabled,
user.WebauthnEnabled,
};
}
}

View File

@ -0,0 +1,503 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using ArcaneLibs;
using ArcaneLibs.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
using Spacebar.AdminApi.Models;
using Spacebar.AdminAPI.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
using Spacebar.RabbitMqUtilities;
namespace Spacebar.AdminAPI.Controllers;
[ApiController]
[Route("/Users")]
public class UserController(ILogger<UserController> logger, Configuration config, RabbitMQConfiguration amqpConfig, SpacebarDbContext db, RabbitMQService mq, IServiceProvider sp) : ControllerBase {
private readonly ILogger<UserController> _logger = logger;
[HttpGet]
public IAsyncEnumerable<UserModel> Get() {
return db.Users.Select(x => new UserModel {
Id = x.Id,
Username = x.Username,
Discriminator = x.Discriminator,
Avatar = x.Avatar,
AccentColor = x.AccentColor,
Banner = x.Banner,
ThemeColors = x.ThemeColors,
Pronouns = x.Pronouns,
Phone = x.Phone,
Desktop = x.Desktop,
Mobile = x.Mobile,
Premium = x.Premium,
PremiumType = x.PremiumType,
Bot = x.Bot,
Bio = x.Bio,
System = x.System,
NsfwAllowed = x.NsfwAllowed,
MfaEnabled = x.MfaEnabled,
WebauthnEnabled = x.WebauthnEnabled,
CreatedAt = x.CreatedAt,
PremiumSince = x.PremiumSince,
Verified = x.Verified,
Disabled = x.Disabled,
Deleted = x.Deleted,
Email = x.Email,
Flags = x.Flags,
PublicFlags = x.PublicFlags,
Rights = x.Rights,
ApplicationBotUser = x.ApplicationBotUser == null ? null : new() { },
ConnectedAccounts = new List<UserModel.ConnectedAccountModel>(),
MessageCount = x.MessageAuthors.Count, // This property is weirdly named due to scaffolding, might patch later
SessionCount = x.Sessions.Count,
TemplateCount = x.Templates.Count,
VoiceStateCount = x.VoiceStates.Count,
GuildCount = x.Guilds.Count,
OwnedGuildCount = x.Guilds.Count(g => g.OwnerId == x.Id)
}).AsAsyncEnumerable();
}
[HttpGet("meow")]
public async Task Meow() {
Console.WriteLine("meow");
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = new Uri("amqp://guest:guest@127.0.0.1/");
using var connection = await factory.CreateConnectionAsync();
using var channel = await connection.CreateChannelAsync();
// await using var channel = mq.CreateChannel();
// var channel2 = await channel.CreateChannelAsync();
var body =
$$"""
{
"id": "{{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}}",
"channel_id": "1322343566206308390",
"guild_id": "1322343566084673571",
"author": {
"username": "test",
"discriminator": "9177",
"id": "1322329228934500382",
"public_flags": 0,
"avatar": null,
"accent_color": null,
"banner": null,
"bio": "",
"bot": false,
"premium_since": "2024-12-27T22:24:15.867Z",
"premium_type": 2,
"theme_colors": null,
"pronouns": null,
"badge_ids": null
},
"member": {
"index": 2,
"id": "1322329228934500382",
"guild_id": "1322343566084673571",
"nick": null,
"joined_at": "2024-12-27T23:21:14.396Z",
"premium_since": null,
"deaf": false,
"mute": false,
"pending": false,
"last_message_id": "1322346635635753061",
"joined_by": null,
"avatar": null,
"banner": null,
"bio": "",
"theme_colors": null,
"pronouns": null,
"communication_disabled_until": null,
"roles": []
},
"content": "{{Random.Shared.NextInt64()}}",
"timestamp": "{{DateTime.UtcNow:O}}",
"edited_timestamp": null,
"tts": false,
"mention_everyone": false,
"mentions": [],
"mention_roles": [],
"attachments": [],
"embeds": [],
"reactions": [],
"nonce": "{{Random.Shared.NextInt64()}}",
"pinned": false,
"type": 0
}
"""
.AsBytes().ToArray();
await channel.ExchangeDeclareAsync(exchange: "1322343566206308390", type: ExchangeType.Fanout, durable: false);
var props = new BasicProperties() { Type = "MESSAGE_CREATE" };
await channel.BasicPublishAsync(exchange: "1322343566206308390", routingKey: "", mandatory: true, basicProperties: props, body: body);
await channel.CloseAsync();
await connection.CloseAsync();
Console.WriteLine("meowww");
}
[HttpGet("{id}/delete")]
public async IAsyncEnumerable<AsyncActionResult> DeleteUser(string id, [FromQuery] int messageDeleteChunkSize = 100) {
var user = await db.Users.FindAsync(id);
if (user == null) {
Console.WriteLine($"User {id} not found");
yield return new AsyncActionResult("ERROR", new { entity = "User", id, message = "User not found" });
yield break;
}
user.Data = "{}";
user.Deleted = true;
user.Disabled = true;
user.Rights = 0;
db.Users.Update(user);
await db.SaveChangesAsync();
var factory = new ConnectionFactory {
Uri = new Uri("amqp://guest:guest@127.0.0.1/")
};
await using var mqConnection = await factory.CreateConnectionAsync();
await using var mqChannel = await mqConnection.CreateChannelAsync();
var messages = db.Messages
.AsNoTracking()
.Where(m => m.AuthorId == id);
var channels = messages
.Select(m => new { m.ChannelId, m.GuildId })
.Distinct()
.ToList();
yield return new("STATS",
new {
total_messages = messages.Count(), total_channels = channels.Count,
messages_per_channel = channels.ToDictionary(c => c.ChannelId, c => messages.Count(m => m.ChannelId == c.ChannelId))
});
var results = channels
.Select(ctx => DeleteMessagesForChannel(ctx.GuildId, ctx.ChannelId!, id, mqChannel, messageDeleteChunkSize))
.ToList();
var a = AggregateAsyncEnumerablesWithoutOrder(results);
await foreach (var result in a) {
yield return result;
}
await db.Database.ExecuteSqlRawAsync("VACUUM FULL messages");
await db.Database.ExecuteSqlRawAsync("REINDEX TABLE messages");
}
private async IAsyncEnumerable<AsyncActionResult> DeleteMessagesForChannel(
// context
string? guildId, string channelId, string authorId,
// connections
IChannel mqChannel,
// options
int messageDeleteChunkSize = 100
) {
{
await using var ctx = sp.CreateAsyncScope();
await using var _db = ctx.ServiceProvider.GetRequiredService<SpacebarDbContext>();
await mqChannel.ExchangeDeclareAsync(exchange: channelId!, type: ExchangeType.Fanout, durable: false);
var messagesInChannel = _db.Messages.AsNoTracking().Count(m => m.AuthorId == authorId && m.ChannelId == channelId && m.GuildId == guildId);
var remaining = messagesInChannel;
while (true) {
var messageIds = _db.Database.SqlQuery<string>($"""
DELETE FROM messages
WHERE id IN (
SELECT id FROM messages
WHERE author_id = {authorId}
AND channel_id = {channelId}
AND guild_id = {guildId}
LIMIT {messageDeleteChunkSize}
) RETURNING id;
""").ToList();
if (messageIds.Count == 0) {
break;
}
var props = new BasicProperties() { Type = "MESSAGE_BULK_DELETE" };
var publishSuccess = false;
do {
try {
await mqChannel.BasicPublishAsync(exchange: channelId!, routingKey: "", mandatory: true, basicProperties: props, body: new {
ids = messageIds,
channel_id = channelId,
guild_id = guildId,
}.ToJson().AsBytes().ToArray());
publishSuccess = true;
}
catch (Exception e) {
Console.WriteLine($"[RabbitMQ] Error publishing bulk delete: {e.Message}");
await Task.Delay(10);
}
} while (!publishSuccess);
yield return new("BULK_DELETED", new {
channel_id = channelId,
total = messagesInChannel,
deleted = messageIds.Count,
remaining = remaining -= messageIds.Count,
});
await Task.Yield();
}
}
}
[HttpGet("duplicate")]
public async Task<IActionResult> Duplicate() {
var msg = db.Messages.First();
var channels = db.Channels.Select(x => new { x.Id, x.GuildId }).ToList();
int count = 1;
while (true) {
foreach (var channel in channels) {
var newMsg = new Message {
Id = $"{Random.Shared.NextInt64()}",
ChannelId = channel.Id,
GuildId = channel.GuildId,
AuthorId = msg.AuthorId,
Content = msg.Content,
MemberId = msg.MemberId,
Timestamp = msg.Timestamp,
EditedTimestamp = msg.EditedTimestamp,
Tts = msg.Tts,
MentionEveryone = msg.MentionEveryone,
Attachments = msg.Attachments,
Embeds = msg.Embeds,
Reactions = msg.Reactions,
Nonce = msg.Nonce,
Pinned = msg.Pinned,
Type = msg.Type,
};
db.Messages.Add(newMsg);
count++;
}
if (count % 100 == 0) {
await db.SaveChangesAsync();
await db.Database.ExecuteSqlRawAsync("VACUUM FULL messages");
}
if (count >= 100_000) {
await db.SaveChangesAsync();
await db.Database.ExecuteSqlRawAsync("VACUUM FULL messages");
await db.Database.ExecuteSqlRawAsync("REINDEX TABLE messages");
return Ok();
}
}
}
[HttpGet("duplicate/{id}")]
public async Task<IActionResult> DuplicateMessage(ulong id, [FromQuery] int count = 100) {
var msg = await db.Messages.FindAsync(id.ToString());
int createdCount = 1;
while (true) {
var newMsg = new Message {
Id = $"{Random.Shared.NextInt64()}",
ChannelId = msg.ChannelId,
GuildId = msg.GuildId,
AuthorId = msg.AuthorId,
Content = msg.Content,
MemberId = msg.MemberId,
Timestamp = msg.Timestamp,
EditedTimestamp = msg.EditedTimestamp,
Tts = msg.Tts,
MentionEveryone = msg.MentionEveryone,
Attachments = msg.Attachments,
Embeds = msg.Embeds,
Reactions = msg.Reactions,
Nonce = msg.Nonce,
Pinned = msg.Pinned,
Type = msg.Type,
};
db.Messages.Add(newMsg);
createdCount++;
if (createdCount % 100 == 0) {
await db.SaveChangesAsync();
}
if (createdCount >= count) {
await db.SaveChangesAsync();
await db.Database.ExecuteSqlRawAsync("VACUUM FULL messages");
await db.Database.ExecuteSqlRawAsync("REINDEX TABLE messages");
return Ok();
}
}
await db.SaveChangesAsync();
await db.Database.ExecuteSqlRawAsync("VACUUM FULL messages");
return Ok();
}
[HttpGet("truncate_messages")]
public async Task TruncateMessages() {
var channels = db.Channels.Select(x => new { x.Id, x.GuildId }).ToList();
var ss = new SemaphoreSlim(12, 12);
async Task TruncateChannelMessages(string channelId, string guildId) {
await ss.WaitAsync();
var tasks = Enumerable.Range(0, 99).Select(i => Task.Run(async () => {
await using var scope = sp.CreateAsyncScope();
await using var _db = scope.ServiceProvider.GetRequiredService<SpacebarDbContext>();
// set timeout
_db.Database.SetCommandTimeout(6000);
await _db.Database.ExecuteSqlRawAsync($"""
DELETE FROM messages
WHERE channel_id = '{channelId}'
AND guild_id = '{guildId}'
AND id LIKE '%{i:00}';
""");
Console.WriteLine($"Truncated messages for {channelId} in {guildId} ending with {i}");
})).ToList();
await Task.WhenAll(tasks);
ss.Release();
}
var tasks = channels.Select(c => TruncateChannelMessages(c.Id, c.GuildId)).ToList();
await Task.WhenAll(tasks);
}
private async IAsyncEnumerable<T> AggregateAsyncEnumerablesWithoutOrder<T>(params IEnumerable<IAsyncEnumerable<T>> enumerables) {
var enumerators = enumerables.Select(e => e.GetAsyncEnumerator()).ToList();
var tasks = enumerators.Select(e => e.MoveNextAsync().AsTask()).ToList();
try {
while (tasks.Count > 0) {
var completedTask = await Task.WhenAny(tasks);
var completedTaskIndex = tasks.IndexOf(completedTask);
if (completedTask.IsCanceled) {
try {
await enumerators[completedTaskIndex].DisposeAsync();
}
catch {
// ignored
}
enumerators.RemoveAt(completedTaskIndex);
tasks.RemoveAt(completedTaskIndex);
continue;
}
if (await completedTask) {
var enumerator = enumerators[completedTaskIndex];
yield return enumerator.Current;
tasks[completedTaskIndex] = enumerator.MoveNextAsync().AsTask();
}
else {
try {
await enumerators[completedTaskIndex].DisposeAsync();
}
catch {
// ignored
}
enumerators.RemoveAt(completedTaskIndex);
tasks.RemoveAt(completedTaskIndex);
}
}
}
finally {
foreach (var enumerator in enumerators) {
try {
await enumerator.DisposeAsync();
}
catch {
// ignored
}
}
}
}
// {
// "op": 0,
// "t": "GUILD_ROLE_UPDATE",
// "d": {
// "guild_id": "1006649183970562092",
// "role": {
// "id": "1006706520514028812",
// "guild_id": "1006649183970562092",
// "color": 16711680,
// "hoist": true,
// "managed": false,
// "mentionable": true,
// "name": "Adminstrator",
// "permissions": "9",
// "position": 5,
// "unicode_emoji": "💖",
// "flags": 0
// }
// },
// "s": 38
// }
[HttpGet("test")]
public async IAsyncEnumerable<string> Test() {
var factory = new ConnectionFactory {
Uri = new Uri(amqpConfig.ToConnectionString())
};
await using var mqConnection = await factory.CreateConnectionAsync();
await using var mqChannel = await mqConnection.CreateChannelAsync();
var guildId = "1006649183970562092";
// var roleId = "1006706520514028812"; //Administrator
var roleId = "1391303296148639051"; //Spacebar Maintainer
// int color = 16711680; //Administrator
int color = 99839; //Spacebar Maintainer
await mqChannel.ExchangeDeclareAsync(exchange: guildId, type: ExchangeType.Fanout, durable: false);
var props = new BasicProperties() { Type = "GUILD_ROLE_UPDATE" };
int framerate = 30;
float delay = 1000f / framerate;
var secondsPerRotation = 6.243f;
// use delay, 255f = one rotation, lengthFactor = iterations to make a full rotation
var lengthFactor = (secondsPerRotation * 1000f / delay);
Console.WriteLine("Length factor: {0}, RPS: {1}", lengthFactor, 0);
var re = new RainbowEnumerator(lengthFactor: lengthFactor, offset: color, skip: 1);
var sw = Stopwatch.StartNew();
while (true) {
var clr = re.Next();
color = clr.r << 16 | clr.g << 8 | clr.b;
var publishSuccess = false;
do {
try {
await mqChannel.BasicPublishAsync(exchange: guildId, routingKey: "", mandatory: false, basicProperties: props, body: new {
guild_id = guildId,
role = new {
id = roleId,
guild_id = guildId,
color,
hoist = false,
managed = false,
mentionable = true,
name = "Spacebar Maintainer",
permissions = "8",
position = 5,
unicode_emoji = "",
flags = 0
}
}.ToJson().AsBytes().ToArray());
publishSuccess = true;
}
catch (Exception e) {
Console.WriteLine($"[RabbitMQ] Error publishing bulk delete: {e.Message}");
await Task.Delay(10);
}
} while (!publishSuccess);
yield return $"{clr.r:X2} {clr.g:X2} {clr.b:X2} | {color:X8} | {sw.Elapsed} (waiting {Math.Max(0, (int)delay - (int)sw.ElapsedMilliseconds)} out of {delay} ms)";
await Task.Delay(Math.Max(0, (int)delay - (int)sw.ElapsedMilliseconds));
sw.Restart();
}
}
}

View File

@ -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;
}

View File

@ -0,0 +1,80 @@
using System.IdentityModel.Tokens.Jwt;
using System.Security.Cryptography;
using ArcaneLibs.Extensions;
using Microsoft.IdentityModel.Tokens;
using Spacebar.AdminAPI.Services;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
namespace Spacebar.AdminAPI.Middleware;
public class AuthenticationMiddleware(RequestDelegate next) {
private static Dictionary<string, User> _userCache = new();
private static Dictionary<string, DateTime> _userCacheExpiry = new();
public async Task InvokeAsync(HttpContext context, IServiceProvider sp) {
var config = sp.GetRequiredService<Configuration>();
if (context.Request.Path.StartsWithSegments("/ping") || config.DisableAuthentication) {
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;
}
User user;
if (_userCacheExpiry.ContainsKey(token) && _userCacheExpiry[token] < DateTime.Now) {
_userCache.Remove(token);
_userCacheExpiry.Remove(token);
}
if (!_userCache.ContainsKey(token)) {
var db = sp.GetRequiredService<SpacebarDbContext>();
user = await db.Users.FindAsync(config.OverrideUid ?? res.ClaimsIdentity.Claims.First(x => x.Type == "id").Value)
?? throw new InvalidOperationException();
_userCache[token] = user;
_userCacheExpiry[token] = DateTime.Now.AddMinutes(5);
}
user = _userCache[token];
if (user.Disabled) {
context.Response.StatusCode = 403;
await context.Response.WriteAsync("User is disabled");
return;
}
if (user.Deleted) {
context.Response.StatusCode = 403;
await context.Response.WriteAsync("User is deleted");
return;
}
await next(context);
}
}

View File

@ -0,0 +1,68 @@
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http.Timeouts;
using Microsoft.EntityFrameworkCore;
using Spacebar.AdminAPI.Middleware;
using Spacebar.AdminAPI.Services;
using Spacebar.Db.Contexts;
using Spacebar.RabbitMqUtilities;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers(options => {
options.MaxValidationDepth = null;
// options.MaxIAsyncEnumerableBufferLimit = 1;
}).AddJsonOptions(options => {
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
options.JsonSerializerOptions.WriteIndented = true;
// options.JsonSerializerOptions.DefaultBufferSize = ;
}).AddMvcOptions(o=> {
o.SuppressOutputFormatterBuffering = 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.AddScoped<AuthenticationService>();
builder.Services.AddScoped<Configuration>();
builder.Services.AddSingleton<RabbitMQConfiguration>();
builder.Services.AddSingleton<RabbitMQService>();
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.UsePathBase("/_spacebar/admin");
app.UseCors("Open");
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment()) {
app.MapOpenApi();
}
app.UseMiddleware<AuthenticationMiddleware>();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -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"
}
}
}
}

View File

@ -0,0 +1,42 @@
using System.IdentityModel.Tokens.Jwt;
using System.Security.Cryptography;
using ArcaneLibs.Extensions;
using Microsoft.IdentityModel.Tokens;
using Spacebar.Db.Contexts;
using Spacebar.Db.Models;
namespace Spacebar.AdminAPI.Services;
public class AuthenticationService(SpacebarDbContext db, Configuration config) {
private static Dictionary<string, User> _userCache = new();
private static Dictionary<string, DateTime> _userCacheExpiry = new();
public async Task<User> GetCurrentUser(HttpRequest request) {
if (!request.Headers.ContainsKey("Authorization")) {
throw new UnauthorizedAccessException();
}
var token = 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) {
throw new UnauthorizedAccessException();
}
return await db.Users.FindAsync(config.OverrideUid ?? res.ClaimsIdentity.Claims.First(x => x.Type == "id").Value) ?? throw new InvalidOperationException();
}
}

View File

@ -0,0 +1,11 @@
namespace Spacebar.AdminAPI.Services;
public class Configuration {
public Configuration(IConfiguration configuration) {
configuration.GetRequiredSection("SpacebarAdminApi").Bind(this);
}
public string? OverrideUid { get; set; }
public bool DisableAuthentication { get; set; } = false;
public bool Enforce2FA { get; set; } = true;
}

View File

@ -0,0 +1,23 @@
<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="RabbitMQ.Client" Version="7.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spacebar.AdminApi.Models\Spacebar.AdminApi.Models.csproj" />
<ProjectReference Include="..\Spacebar.Db\Spacebar.Db.csproj" />
<ProjectReference Include="..\Utilities\Spacebar.RabbitMqUtilities\Spacebar.RabbitMqUtilities.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"Spacebar": "Host=127.0.0.1; Username=postgres; Database=spacebar"
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,33 @@
namespace Spacebar.AdminApi.Models;
public class ApplicationModel {
public string Id { get; set; } = null!;
public string Name { get; set; } = null!;
public string? Icon { get; set; }
public string? Description { get; set; }
public string? Summary { get; set; }
public string? Type { get; set; }
public bool Hook { get; set; }
public bool BotPublic { get; set; }
public bool BotRequireCodeGrant { get; set; }
public int Flags { get; set; }
public string? RedirectUris { get; set; }
public int? RpcApplicationState { get; set; }
public int? StoreApplicationState { get; set; }
public int? VerificationState { get; set; }
public string? InteractionsEndpointUrl { get; set; }
public bool? IntegrationPublic { get; set; }
public bool? IntegrationRequireCodeGrant { get; set; }
public int? DiscoverabilityState { get; set; }
public int? DiscoveryEligibilityFlags { get; set; }
public string? Tags { get; set; }
public string? CoverImage { get; set; }
public string? InstallParams { get; set; }
public string? TermsOfServiceUrl { get; set; }
public string? PrivacyPolicyUrl { get; set; }
public string? GuildId { get; set; }
public string? CustomInstallUrl { get; set; }
public string? OwnerId { get; set; }
public string? BotUserId { get; set; }
public string? TeamId { get; set; }
}

View File

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
namespace Spacebar.AdminApi.Models;
public class AsyncActionResult {
public AsyncActionResult() { }
public AsyncActionResult(string type, object? data) {
MessageType = type;
Data = data;
}
[JsonPropertyName("type")]
public string MessageType { get; set; }
[JsonPropertyName("data")]
public object Data { get; set; }
}

View File

@ -0,0 +1,23 @@
using System.Text.Json.Serialization;
namespace Spacebar.AdminApi.Models;
public class FileMetadataModel {
public string UserId { get; set; } = null!;
public string Id { get; set; } = null!;
[JsonConverter(typeof(JsonStringEnumConverter<FileUploadType>))]
public FileUploadType Type { get; set; }
public enum FileUploadType {
Attachment,
Avatar,
Banner,
GuildIcon,
GuildSplash,
GuildCover,
Emoji,
Sticker
}
}

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,57 @@
namespace Spacebar.AdminApi.Models;
public class UserModel {
public string Id { get; set; } = null!;
public string Username { get; set; } = null!;
public string Discriminator { get; set; } = null!;
public string? Avatar { get; set; }
public int? AccentColor { get; set; }
public string? Banner { get; set; }
public string? ThemeColors { get; set; }
public string? Pronouns { get; set; }
public string? Phone { get; set; }
public bool Desktop { get; set; }
public bool Mobile { get; set; }
public bool Premium { get; set; }
public int PremiumType { get; set; }
public bool Bot { get; set; }
public string Bio { get; set; } = null!;
public bool System { get; set; }
public bool NsfwAllowed { get; set; }
public bool MfaEnabled { get; set; }
public bool WebauthnEnabled { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? PremiumSince { get; set; }
public bool Verified { get; set; }
public bool Disabled { get; set; }
public bool Deleted { get; set; }
public string? Email { get; set; }
public ulong Flags { get; set; }
public ulong PublicFlags { get; set; }
public ulong Rights { get; set; }
public ApplicationModel? ApplicationBotUser { get; set; }
public List<ConnectedAccountModel> ConnectedAccounts { get; set; } = new();
public int GuildCount { get; set; }
public int OwnedGuildCount { get; set; }
public int SessionCount { get; set; }
public int TemplateCount { get; set; }
public int VoiceStateCount { get; set; }
public int MessageCount { get; set; }
public class ConnectedAccountModel {
public string Id { get; set; } = null!;
public string ExternalId { get; set; } = null!;
public string? UserId { get; set; }
public bool FriendSync { get; set; }
public string Name { get; set; } = null!;
public bool Revoked { get; set; }
public int ShowActivity { get; set; }
public string Type { get; set; } = null!;
public bool Verified { get; set; }
public int Visibility { get; set; }
public string Integrations { get; set; } = null!;
public string? Metadata { get; set; }
public int MetadataVisibility { get; set; }
public bool TwoWayLink { get; set; }
}
}

View File

@ -0,0 +1,615 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Spacebar.Db.Models;
namespace Spacebar.Db.Contexts;
public partial class SpacebarDbContext(DbContextOptions<SpacebarDbContext> options) : DbContext(options) {
public SpacebarDbContext Clone() {
return new SpacebarDbContext(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);
}

View 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>();
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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>();
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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!;
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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>();
}

View 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>();
}

View 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!;
}

View 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; }
}

View 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; }
}

View 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!;
}

View 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!;
}

View 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!;
}

View 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>();
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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>();
}

View 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>();
}

View 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>();
}

View 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; }
}

View 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; }
}

View 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 = "text")]
public ulong Flags { get; set; }
[Column("public_flags")]
public ulong PublicFlags { get; set; }
[Column("purchased_flags")]
public int PurchasedFlags { get; set; }
[Column("premium_usage_flags")]
public int PremiumUsageFlags { get; set; }
[Column("rights")]
public ulong 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>();
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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; }
}

View 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>

View File

@ -0,0 +1,66 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.Db", "Spacebar.Db\Spacebar.Db.csproj", "{524849DF-93BC-4632-B6C2-D05552C13887}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminAPI", "Spacebar.AdminAPI\Spacebar.AdminAPI.csproj", "{00E58C53-0AC1-4113-8CCF-D299861EA8D3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.RabbitMqUtilities", "Utilities\Spacebar.RabbitMqUtilities\Spacebar.RabbitMqUtilities.csproj", "{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminAPITest", "Utilities\Spacebar.AdminAPITest\Spacebar.AdminAPITest.csproj", "{374314B2-7149-4316-8750-4E1E7BF6C3B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminAPI.TestClient", "Utilities\Spacebar.AdminAPI.TestClient\Spacebar.AdminAPI.TestClient.csproj", "{498DAD05-336E-4851-ABD8-4E7CCA8312B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApi.Models", "Spacebar.AdminApi.Models\Spacebar.AdminApi.Models.csproj", "{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spacebar.AdminApi.PrepareTestData", "Utilities\Spacebar.AdminApi.PrepareTestData\Spacebar.AdminApi.PrepareTestData.csproj", "{BCC6501C-16A7-4787-BA47-52DAE06718A8}"
EndProject
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
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2}.Release|Any CPU.Build.0 = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{374314B2-7149-4316-8750-4E1E7BF6C3B4}.Release|Any CPU.Build.0 = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{498DAD05-336E-4851-ABD8-4E7CCA8312B0}.Release|Any CPU.Build.0 = Release|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F138C70-EAFA-4C7C-8B90-EFB9624B235C}.Release|Any CPU.Build.0 = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCC6501C-16A7-4787-BA47-52DAE06718A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F4E179D1-A3EB-4A1D-9C11-E7019F4B1EE2} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{374314B2-7149-4316-8750-4E1E7BF6C3B4} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{498DAD05-336E-4851-ABD8-4E7CCA8312B0} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
{BCC6501C-16A7-4787-BA47-52DAE06718A8} = {04787943-EBB6-4DE4-96D5-4CFB4A2CEE99}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

View File

@ -0,0 +1,16 @@
@inherits LayoutComponentBase
<div class="page">
<div class="sidebar">
<NavMenu/>
</div>
<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>

View File

@ -0,0 +1,77 @@
.page {
position: relative;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
.sidebar {
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}
.top-row {
background-color: #333333;
border-bottom: 1px solid #444444;
justify-content: flex-end;
height: 3.5rem;
display: flex;
align-items: center;
}
.top-row ::deep a, .top-row ::deep .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
text-decoration: none;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}
.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px) {
.top-row {
justify-content: space-between;
}
.top-row ::deep a, .top-row ::deep .btn-link {
margin-left: 0;
}
}
@media (min-width: 641px) {
.page {
flex-direction: row;
}
.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.top-row {
position: sticky;
top: 0;
z-index: 1;
}
.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}
.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}

View File

@ -0,0 +1,44 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">Spacebar.AdminAPI.TestClient</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="nav flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Users">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Users
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Guilds">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Guilds
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="Media">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Media
</NavLink>
</div>
</nav>
</div>
@code {
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu() {
collapseNavMenu = !collapseNavMenu;
}
}

View File

@ -0,0 +1,83 @@
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}
.top-row {
min-height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.bi {
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
margin-right: 0.75rem;
top: -1px;
background-size: cover;
}
.bi-house-door-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
}
.bi-plus-square-fill-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
}
.bi-list-nested-nav-menu {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.37);
color: white;
}
.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
}
.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
.nav-scrollable {
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
overflow-y: auto;
}
}

View File

@ -0,0 +1,107 @@
@page "/"
@using System.Net.Http.Headers
@using Spacebar.AdminAPI.TestClient.Services
@inject Config Config
@inject ILocalStorageService LocalStorage
<PageTitle>Home</PageTitle>
<span style="@($"color: {(IsApiUrlValid ? "green" : "red")};")">Spacebar API URL: </span>
<InputText @bind-Value:get="Config.ApiUrl" @bind-Value:set="@(async (v) => {
Config.ApiUrl = v!;
await ValidateAndSaveConfig();
})"/>
<br/>
<!-- <span style="@($"color: {(IsGatewayUrlValid ? "green" : "red")};")">Spacebar Gateway URL: </span> -->
<!-- <InputText @bind-Value="GatewayUrl" /> -->
<!-- <br /> -->
<span style="@($"color: {(IsCdnUrlValid ? "green" : "red")};")">Spacebar CDN URL: </span>
<InputText @bind-Value:get="Config.CdnUrl" @bind-Value:set="@(async (v) => {
Config.CdnUrl = v!;
await ValidateAndSaveConfig();
})"/>
<br/>
<span style="@($"color: {(IsAdminApiUrlValid ? "green" : "red")};")">Spacebar Admin API URL: </span>
<InputText @bind-Value:get="Config.AdminUrl" @bind-Value:set="@(async (v) => {
Config.AdminUrl = v!;
await ValidateAndSaveConfig();
})"/>
<br/>
<span style="@($"color: {(IsAccessTokenValid ? "green" : "red")};")">Access Token: </span>
<InputText @bind-Value:get="Config.AccessToken" @bind-Value:set="@(async (v) => {
Config.AccessToken = v!;
await ValidateAndSaveConfig();
})"/>
<a href="/login">New access token</a>
<br/>
@code {
private bool IsApiUrlValid { get; set; }
// private bool IsGatewayUrlValid { get; set; }
private bool IsCdnUrlValid { get; set; }
private bool IsAdminApiUrlValid { get; set; }
private bool IsAccessTokenValid { get; set; }
protected override async Task OnInitializedAsync() {
await ValidateAndSaveConfig();
}
private async Task ValidateAndSaveConfig() {
await LocalStorage.SetItemAsync("sb_admin_tc_config", Config);
using var hc = new HttpClient();
HttpResponseMessage response;
try {
response = await hc.GetAsync(Config.ApiUrl + "/api/v9/policies/instance/domains");
IsApiUrlValid = response.IsSuccessStatusCode;
}
catch {
IsApiUrlValid = false;
}
StateHasChanged();
// response = await hc.GetAsync(Config.GatewayUrl + "/api/v9/policies/instance");
// IsGatewayUrlValid = response.IsSuccessStatusCode;
// StateHasChanged();
try {
response = await hc.GetAsync(Config.CdnUrl + "/ping");
IsCdnUrlValid = response.IsSuccessStatusCode;
}
catch {
IsCdnUrlValid = false;
}
StateHasChanged();
try {
response = await hc.GetAsync(Config.AdminUrl + "/_spacebar/admin/ping");
IsAdminApiUrlValid = response.IsSuccessStatusCode;
}
catch {
IsAdminApiUrlValid = false;
}
StateHasChanged();
try {
var request = new HttpRequestMessage(HttpMethod.Get, Config.AdminUrl + "/_spacebar/admin/whoami");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Config.AccessToken);
response = await hc.SendAsync(request);
IsAccessTokenValid = response.IsSuccessStatusCode;
}
catch {
IsAccessTokenValid = false;
}
StateHasChanged();
}
}

View File

@ -0,0 +1,57 @@
@page "/Login"
@using System.Text.Json.Nodes
@using Spacebar.AdminAPI.TestClient.Services
@inject ILocalStorageService LocalStorage
@inject Config Config
@inject NavigationManager Navigation
<h3>Login</h3>
<span>Email: </span>
<InputText @bind-Value="Email"/>
<br/>
<span>Password: </span>
<InputText type="password" @bind-Value="Password"/>
<br/>
<button @onclick="DoLogin">Login</button>
<br/>
<pre style="color: red; font-family: 'JetBrains Mono',monospace">@Error</pre>
@code {
private string Email { get; set; }
private string Password { get; set; }
private string Error { get; set; }
private async Task DoLogin() {
HttpResponseMessage response;
using var hc = new HttpClient();
try {
response = await hc.PostAsJsonAsync(Config.ApiUrl + "/api/v9/auth/login", new {
login = Email,
password = Password,
login_source = "Spacebar Admin API Test Client",
undelete = false
});
}
catch (Exception e) {
Error = e.ToString();
return;
}
if (!response.IsSuccessStatusCode) {
Error = await response.Content.ReadAsStringAsync();
return;
}
var content = await response.Content.ReadFromJsonAsync<JsonObject>();
var accessToken = content!["token"].ToString();
Config.AccessToken = accessToken;
await LocalStorage.SetItemAsync("sb_admin_tc_config", Config);
Navigation.NavigateTo("/", true, true);
}
}

View File

@ -0,0 +1,7 @@
@page "/Media"
<h3>Index of /Media</h3>
<hr/>
@code {
}

View File

@ -0,0 +1,106 @@
@page "/Media/ByUser"
@using System.Net.Http.Headers
@using System.Reflection
@using Spacebar.AdminApi.Models
@using Spacebar.AdminAPI.TestClient.Services
@using ArcaneLibs.Blazor.Components
@inject Config Config
@inject ILocalStorageService LocalStorage
<PageTitle>Uploaded media by user</PageTitle>
<details>
<summary>Displayed columns</summary>
@foreach (var column in DisplayedColumns) {
var value = column.Value;
<span>
<InputCheckbox @bind-Value:get="@(value)" @bind-Value:set="@(b => {
DisplayedColumns[column.Key] = b;
StateHasChanged();
})"/>
@column.Key.Name
</span>
<br/>
}
</details>
<InputSelect @bind-Value="@SelectedUserId">
<option value="">All users</option>
@if (UserList is { Count: > 0 }) {
@foreach (var user in UserList.OrderByDescending(u => u.Id).Where(x => !x.Deleted)) {
<option value="@user.Id">@user.Username</option>
}
}
</InputSelect>
<table class="table table-bordered">
@{
var columns = DisplayedColumns.Where(kvp => kvp.Value).Select(kvp => kvp.Key).ToList();
}
<thead>
<tr>
@foreach (var column in columns) {
<th>@column.Name</th>
}
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var user in UserMedia) {
<tr>
@foreach (var column in columns) {
<td>@column.GetValue(user)</td>
}
<td>
<LinkButton href="@($"/Users/Delete/{user.Id}")" Color="#ff0000">Delete</LinkButton>
</td>
</tr>
}
</tbody>
</table>
@code {
private Dictionary<PropertyInfo, bool> DisplayedColumns { get; set; } = typeof(FileMetadataModel).GetProperties()
.ToDictionary(p => p, p => p.Name == "Username" || p.Name == "Id" || p.Name == "MessageCount");
private List<UserModel> UserList { get; set; } = new();
private List<FileMetadataModel> UserMedia { get; set; } = new();
[SupplyParameterFromQuery(Name = "UserId")]
public string? SelectedUserId {
get;
set {
field = value;
if (string.IsNullOrWhiteSpace(field))
UserMedia.Clear();
else _ = GetMediaForUser(value!);
}
}
protected override async Task OnInitializedAsync() {
using var hc = new HttpClient();
hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config.AccessToken);
var response = await hc.GetAsync(Config.AdminUrl + "/_spacebar/admin/users/");
if (!response.IsSuccessStatusCode) throw new Exception(await response.Content.ReadAsStringAsync());
var content = response.Content.ReadFromJsonAsAsyncEnumerable<UserModel>();
await foreach (var user in content) {
UserList.Add(user!);
StateHasChanged();
}
}
private async Task GetMediaForUser(string userId) {
using var hc = new HttpClient();
hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config.AccessToken);
var response = await hc.GetAsync(Config.AdminUrl + $"/_spacebar/admin/media/user/{userId}/attachments");
if (!response.IsSuccessStatusCode) throw new Exception(await response.Content.ReadAsStringAsync());
var content = response.Content.ReadFromJsonAsAsyncEnumerable<FileMetadataModel>();
await foreach (var media in content) {
UserMedia.Add(media!);
StateHasChanged();
}
}
}

View File

@ -0,0 +1,80 @@
@page "/Users"
@using System.Net.Http.Headers
@using System.Reflection
@using Spacebar.AdminApi.Models
@using Spacebar.AdminAPI.TestClient.Services
@using ArcaneLibs.Blazor.Components
@using ArcaneLibs.Extensions
@inject Config Config
@inject ILocalStorageService LocalStorage
<PageTitle>Users</PageTitle>
<details>
<summary>Displayed columns</summary>
@foreach (var column in DisplayedColumns) {
var value = column.Value;
<span>
<InputCheckbox @bind-Value:get="@(value)" @bind-Value:set="@(b => {
DisplayedColumns[column.Key] = b;
StateHasChanged();
})"/>
@column.Key.Name
</span>
<br/>
}
</details>
<p>Got @UserList.Count users.</p>
<table class="table table-bordered">
@{
var columns = DisplayedColumns.Where(kvp => kvp.Value).Select(kvp => kvp.Key).ToList();
}
<thead>
<tr>
@foreach (var column in columns) {
<th>@column.Name</th>
}
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var user in UserList.Where(x => !x.Deleted).OrderByDescending(x=>x.MessageCount)) {
<tr>
@foreach (var column in columns) {
<td>@column.GetValue(user)</td>
}
<td>
<LinkButton href="@($"/Users/Delete/{user.Id}")" Color="#ff0000">Delete</LinkButton>
</td>
</tr>
}
</tbody>
</table>
@code {
private Dictionary<PropertyInfo, bool> DisplayedColumns { get; set; } = typeof(UserModel).GetProperties()
.ToDictionary(p => p, p => p.Name == "Username" || p.Name == "Id" || p.Name == "MessageCount");
private List<UserModel> UserList { get; set; } = new();
protected override async Task OnInitializedAsync() {
var hc = new StreamingHttpClient();
hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config.AccessToken);
// var request = new HttpRequestMessage(HttpMethod.Get, Config.AdminUrl + "/_spacebar/admin/users/");
var response = hc.GetAsyncEnumerableFromJsonAsync<UserModel>(Config.AdminUrl + "/_spacebar/admin/users/");
// if (!response.IsSuccessStatusCode) throw new Exception(await response.Content.ReadAsStringAsync());
// var content = response.Content.ReadFromJsonAsAsyncEnumerable<UserModel>();
await foreach (var user in response) {
// Console.WriteLine(user.ToJson(indent: false, ignoreNull: true));
UserList.Add(user!);
if(UserList.Count % 1000 == 0)
StateHasChanged();
}
StateHasChanged();
}
}

View File

@ -0,0 +1,70 @@
@page "/Users/Delete/{Id}"
@using System.Net.Http.Headers
@using System.Text.Json
@using System.Text.Json.Nodes
@using ArcaneLibs.Extensions
@using Spacebar.AdminApi.Models
@using Spacebar.AdminAPI.TestClient.Services
@inject Config Config
<h3>UsersDelete - @Id</h3>
Deleted @ChannelDeleteProgress.Sum(x=>x.Value.Deleted) messages so far!
@foreach (var (channel, progress) in ChannelDeleteProgress.Where(x=>x.Value.Deleted != x.Value.Total).OrderByDescending(x=>x.Value.Progress)) {
<div>@channel: @progress.Total total, @progress.Deleted deleted</div>
<progress max="@progress.Total" value="@progress.Deleted"></progress>
}
@if (Done) {
<h1>Done!</h1>
}
@code {
[Parameter]
public required string Id { get; set; }
private Dictionary<string, DeleteProgress> ChannelDeleteProgress { get; set; } = new();
private bool Done { get; set; }
protected override async Task OnInitializedAsync() {
var hc = new StreamingHttpClient();
hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config.AccessToken);
var response = await hc.GetAsync(Config.AdminUrl + $"/_spacebar/admin/Users/{Id}/delete?messageDeleteChunkSize=100");
if (!response.IsSuccessStatusCode) throw new Exception(await response.Content.ReadAsStringAsync());
var content = response.Content.ReadFromJsonAsAsyncEnumerable<AsyncActionResult>();
await foreach (var actionResult in content) {
Console.WriteLine(actionResult.ToJson(indent: false));
switch (actionResult.MessageType) {
case "STATS": {
var data = JsonSerializer.Deserialize<JsonObject>(actionResult.Data.ToJson());
ChannelDeleteProgress = data!["messages_per_channel"]!
.Deserialize<Dictionary<string, int>>()!
.ToDictionary(x=>x.Key, x=>new DeleteProgress { Total = x.Value });
break;
}
case "BULK_DELETED": {
var data = JsonSerializer.Deserialize<JsonObject>(actionResult.Data.ToJson());
ChannelDeleteProgress[data!["channel_id"]!.ToString()].Deleted += data!["deleted"]!.GetValue<int>();
break;
}
default: {
Console.WriteLine($"Unknown message type: {actionResult.MessageType}");
break;
}
}
StateHasChanged();
await Task.Delay(1);
}
Done = true;
StateHasChanged();
}
private class DeleteProgress {
public int Total { get; set; }
public int Deleted { get; set; } = 0;
public float Progress => (float)Deleted / Total;
}
}

View File

@ -0,0 +1,59 @@
using System.Net;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Spacebar.AdminAPI.TestClient;
using Spacebar.AdminAPI.TestClient.Services;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
try {
builder.Configuration.AddJsonStream(await new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }.GetStreamAsync("/appsettings.json"));
#if DEBUG
builder.Configuration.AddJsonStream(await new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }.GetStreamAsync("/appsettings.Development.json"));
#endif
}
catch (HttpRequestException e) {
if (e.StatusCode == HttpStatusCode.NotFound)
Console.WriteLine("Could not load appsettings, server returned 404.");
else
Console.WriteLine("Could not load appsettings: " + e);
}
catch (Exception e) {
Console.WriteLine("Could not load appsettings: " + e);
}
builder.Logging.AddConfiguration(
builder.Configuration.GetSection("Logging"));
builder.Services.AddBlazoredLocalStorageAsSingleton(config => {
config.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
config.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
config.JsonSerializerOptions.IgnoreReadOnlyProperties = true;
config.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip;
config.JsonSerializerOptions.WriteIndented = false;
});
// temporarily build the service provider to read config
{
await using var sp = builder.Services.BuildServiceProvider();
var localStorage = sp.GetRequiredService<ILocalStorageService>();
var config = await localStorage.GetItemAsync<Config>("sb_admin_tc_config");
if (config == null) {
config = new Config();
await localStorage.SetItemAsync("sb_admin_tc_config", config);
}
builder.Services.AddSingleton(config);
}
await builder.Build().RunAsync();

View File

@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5179",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,20 @@
using System.Text.Json.Serialization;
namespace Spacebar.AdminAPI.TestClient.Services;
public class Config {
[JsonPropertyName("api_url")]
public string ApiUrl { get; set; } = "http://localhost:3001";
[JsonPropertyName("gateway_url")]
public string GatewayUrl { get; set; } = "http://localhost:3002";
[JsonPropertyName("cdn_url")]
public string CdnUrl { get; set; } = "http://localhost:3003";
[JsonPropertyName("admin_url")]
public string AdminUrl { get; set; } = "http://localhost:5112";
[JsonPropertyName("access_token")]
public string? AccessToken { get; set; } = string.Empty;
}

View File

@ -0,0 +1,296 @@
#define SINGLE_HTTPCLIENT // Use a single HttpClient instance for all MatrixHttpClient instances
// #define SYNC_HTTPCLIENT // Only allow one request as a time, for debugging
using System.Data;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http.Headers;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using ArcaneLibs;
using ArcaneLibs.Extensions;
namespace Spacebar.AdminAPI.TestClient.Services;
#if SINGLE_HTTPCLIENT
// TODO: Add URI wrapper for
public class StreamingHttpClient {
private static readonly HttpClient Client;
static StreamingHttpClient() {
try {
var handler = new SocketsHttpHandler {
PooledConnectionLifetime = TimeSpan.FromMinutes(15),
MaxConnectionsPerServer = 4096,
EnableMultipleHttp2Connections = true
};
Client = new HttpClient(handler) {
DefaultRequestVersion = new Version(3, 0),
Timeout = TimeSpan.FromDays(1)
};
}
catch (PlatformNotSupportedException e) {
Console.WriteLine("Failed to create HttpClient with connection pooling, continuing without connection pool!");
Console.WriteLine("Original exception (safe to ignore!):");
Console.WriteLine(e);
Client = new HttpClient {
DefaultRequestVersion = new Version(3, 0)
};
}
catch (Exception e) {
Console.WriteLine("Failed to create HttpClient:");
Console.WriteLine(e);
throw;
}
}
#if SYNC_HTTPCLIENT
internal SemaphoreSlim _rateLimitSemaphore { get; } = new(1, 1);
#endif
public static bool LogRequests = true;
public Dictionary<string, string> AdditionalQueryParameters { get; set; } = new();
public Uri? BaseAddress { get; set; }
// default headers, not bound to client
public HttpRequestHeaders DefaultRequestHeaders { get; set; } =
typeof(HttpRequestHeaders).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, [], null)?.Invoke([]) as HttpRequestHeaders ??
throw new InvalidOperationException("Failed to create HttpRequestHeaders");
private static JsonSerializerOptions GetJsonSerializerOptions(JsonSerializerOptions? options = null) {
options ??= new JsonSerializerOptions();
// options.Converters.Add(new JsonFloatStringConverter());
// options.Converters.Add(new JsonDoubleStringConverter());
// options.Converters.Add(new JsonDecimalStringConverter());
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
return options;
}
public async Task<HttpResponseMessage> SendUnhandledAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
if (request.RequestUri is null) throw new NullReferenceException("RequestUri is null");
// if (!request.RequestUri.IsAbsoluteUri)
request.RequestUri = request.RequestUri.EnsureAbsolute(BaseAddress!);
var swWait = Stopwatch.StartNew();
#if SYNC_HTTPCLIENT
await _rateLimitSemaphore.WaitAsync(cancellationToken);
#endif
if (request.RequestUri is null) throw new NullReferenceException("RequestUri is null");
if (!request.RequestUri.IsAbsoluteUri)
request.RequestUri = new Uri(BaseAddress ?? throw new InvalidOperationException("Relative URI passed, but no BaseAddress is specified!"), request.RequestUri);
swWait.Stop();
var swExec = Stopwatch.StartNew();
foreach (var (key, value) in AdditionalQueryParameters) request.RequestUri = request.RequestUri.AddQuery(key, value);
foreach (var (key, value) in DefaultRequestHeaders) {
if (request.Headers.Contains(key)) continue;
request.Headers.Add(key, value);
}
request.Options.Set(new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse"), true);
if (LogRequests)
Console.WriteLine("Sending " + request.Summarise(includeHeaders: true, includeQuery: true, includeContentIfText: false, hideHeaders: ["Accept"]));
HttpResponseMessage? responseMessage;
try {
responseMessage = await Client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
}
catch (Exception e) {
if (e is TaskCanceledException or TimeoutException) {
if (request.Method == HttpMethod.Get && !cancellationToken.IsCancellationRequested) {
await Task.Delay(Random.Shared.Next(500, 2500), cancellationToken);
request.ResetSendStatus();
return await SendAsync(request, cancellationToken);
}
}
else if (!e.ToString().StartsWith("TypeError: NetworkError"))
Console.WriteLine(
$"Failed to send request {request.Method} {BaseAddress}{request.RequestUri} ({Util.BytesToString(request.Content?.Headers.ContentLength ?? 0)}):\n{e}");
throw;
}
#if SYNC_HTTPCLIENT
finally {
_rateLimitSemaphore.Release();
}
#endif
// Console.WriteLine($"Sending {request.Method} {request.RequestUri} ({Util.BytesToString(request.Content?.Headers.ContentLength ?? 0)}) -> {(int)responseMessage.StatusCode} {responseMessage.StatusCode} ({Util.BytesToString(responseMessage.GetContentLength())}, WAIT={swWait.ElapsedMilliseconds}ms, EXEC={swExec.ElapsedMilliseconds}ms)");
if (LogRequests)
Console.WriteLine("Received " + responseMessage.Summarise(includeHeaders: true, includeContentIfText: false, hideHeaders: [
"Server",
"Date",
"Transfer-Encoding",
"Connection",
"Vary",
"Content-Length",
"Access-Control-Allow-Origin",
"Access-Control-Allow-Methods",
"Access-Control-Allow-Headers",
"Access-Control-Expose-Headers",
"Cache-Control",
"Cross-Origin-Resource-Policy",
"X-Content-Security-Policy",
"Referrer-Policy",
"X-Robots-Tag",
"Content-Security-Policy"
]));
return responseMessage;
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default) {
var responseMessage = await SendUnhandledAsync(request, cancellationToken);
if (responseMessage.IsSuccessStatusCode) return responseMessage;
//retry on gateway timeout
// if (responseMessage.StatusCode == HttpStatusCode.GatewayTimeout) {
// request.ResetSendStatus();
// return await SendAsync(request, cancellationToken);
// }
//error handling
var content = await responseMessage.Content.ReadAsStringAsync(cancellationToken);
if (content.Length == 0)
throw new DataException("Content was empty");
// throw new MatrixException() {
// ErrorCode = "M_UNKNOWN",
// Error = "Unknown error, server returned no content"
// };
// if (!content.StartsWith('{')) throw new InvalidDataException("Encountered invalid data:\n" + content);
if (!content.TrimStart().StartsWith('{')) {
responseMessage.EnsureSuccessStatusCode();
throw new InvalidDataException("Encountered invalid data:\n" + content);
}
//we have a matrix error
throw new Exception("Unknown http exception");
// MatrixException? ex;
// try {
// ex = JsonSerializer.Deserialize<MatrixException>(content);
// }
// catch (JsonException e) {
// throw new LibMatrixException() {
// ErrorCode = "M_INVALID_JSON",
// Error = e.Message + "\nBody:\n" + await responseMessage.Content.ReadAsStringAsync(cancellationToken)
// };
// }
//
// Debug.Assert(ex != null, nameof(ex) + " != null");
// ex.RawContent = content;
// // Console.WriteLine($"Failed to send request: {ex}");
// if (ex.RetryAfterMs is null) throw ex!;
// //we have a ratelimit error
// await Task.Delay(ex.RetryAfterMs.Value, cancellationToken);
request.ResetSendStatus();
return await SendAsync(request, cancellationToken);
}
// GetAsync
public Task<HttpResponseMessage> GetAsync([StringSyntax("Uri")] string? requestUri, CancellationToken? cancellationToken = null) =>
SendAsync(new HttpRequestMessage(HttpMethod.Get, requestUri), cancellationToken ?? CancellationToken.None);
// GetFromJsonAsync
public async Task<T?> TryGetFromJsonAsync<T>(string requestUri, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default) {
try {
return await GetFromJsonAsync<T>(requestUri, options, cancellationToken);
}
catch (JsonException e) {
Console.WriteLine($"Failed to deserialize response from {requestUri}: {e.Message}");
return default;
}
catch (HttpRequestException e) {
Console.WriteLine($"Failed to get {requestUri}: {e.Message}");
return default;
}
}
public async Task<T> GetFromJsonAsync<T>(string requestUri, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default) {
options = GetJsonSerializerOptions(options);
var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await SendAsync(request, cancellationToken);
response.EnsureSuccessStatusCode();
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken);
return await JsonSerializer.DeserializeAsync<T>(responseStream, options, cancellationToken) ??
throw new InvalidOperationException("Failed to deserialize response");
}
// GetStreamAsync
public async Task<Stream> GetStreamAsync(string requestUri, CancellationToken cancellationToken = default) {
var request = new HttpRequestMessage(HttpMethod.Get, requestUri);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await SendAsync(request, cancellationToken);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStreamAsync(cancellationToken);
}
public async Task<HttpResponseMessage> PutAsJsonAsync<T>([StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri, T value, JsonSerializerOptions? options = null,
CancellationToken cancellationToken = default) where T : notnull {
options = GetJsonSerializerOptions(options);
var request = new HttpRequestMessage(HttpMethod.Put, requestUri);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Content = new StringContent(JsonSerializer.Serialize(value, value.GetType(), options),
Encoding.UTF8, "application/json");
return await SendAsync(request, cancellationToken);
}
public async Task<HttpResponseMessage> PostAsJsonAsync<T>([StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri, T value, JsonSerializerOptions? options = null,
CancellationToken cancellationToken = default) where T : notnull {
options ??= new JsonSerializerOptions();
// options.Converters.Add(new JsonFloatStringConverter());
// options.Converters.Add(new JsonDoubleStringConverter());
// options.Converters.Add(new JsonDecimalStringConverter());
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
var request = new HttpRequestMessage(HttpMethod.Post, requestUri);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Content = new StringContent(JsonSerializer.Serialize(value, value.GetType(), options),
Encoding.UTF8, "application/json");
return await SendAsync(request, cancellationToken);
}
public async IAsyncEnumerable<T?> GetAsyncEnumerableFromJsonAsync<T>([StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri, JsonSerializerOptions? options = null) {
options = GetJsonSerializerOptions(options);
var res = await GetAsync(requestUri);
options.PropertyNameCaseInsensitive = true;
var result = JsonSerializer.DeserializeAsyncEnumerable<T>(await res.Content.ReadAsStreamAsync(), options);
await foreach (var resp in result) yield return resp;
}
public static async Task<bool> CheckSuccessStatus(string url) {
//cors causes failure, try to catch
try {
var resp = await Client.GetAsync(url);
return resp.IsSuccessStatusCode;
}
catch (Exception e) {
Console.WriteLine($"Failed to check success status: {e.Message}");
return false;
}
}
public async Task<HttpResponseMessage> PostAsync(string uri, HttpContent? content, CancellationToken cancellationToken = default) {
var request = new HttpRequestMessage(HttpMethod.Post, uri) {
Content = content
};
return await SendAsync(request, cancellationToken);
}
public async Task DeleteAsync(string url) {
var request = new HttpRequestMessage(HttpMethod.Delete, url);
await SendAsync(request);
}
public async Task<HttpResponseMessage> DeleteAsJsonAsync<T>(string url, T payload) {
var request = new HttpRequestMessage(HttpMethod.Delete, url) {
Content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json")
};
return await SendAsync(request);
}
}
#endif

View File

@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LinkIncremental>true</LinkIncremental>
<LangVersion>preview</LangVersion>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
<BlazorEnableCompression>false</BlazorEnableCompression>
<BlazorCacheBootResources>false</BlazorCacheBootResources>
<!-- <RunAOTCompilation>true</RunAOTCompilation>-->
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ArcaneLibs" Version="1.0.0-preview.20241210-161342" />
<PackageReference Include="ArcaneLibs.Blazor.Components" Version="1.0.0-preview.20241210-161342" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0" PrivateAssets="all"/>
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Spacebar.AdminApi.Models\Spacebar.AdminApi.Models.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Blazored.LocalStorage
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using Spacebar.AdminAPI.TestClient
@using Spacebar.AdminAPI.TestClient.Layout

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -0,0 +1,114 @@
html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
h1:focus {
outline: none;
}
a, .btn-link {
color: #0071c1;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
.content {
padding-top: 1.1rem;
}
.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}
.invalid {
outline: 1px solid red;
}
.validation-message {
color: red;
}
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
.blazor-error-boundary {
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem;
color: white;
}
.blazor-error-boundary::after {
content: "An error has occurred."
}
.loading-progress {
position: relative;
display: block;
width: 8rem;
height: 8rem;
margin: 20vh auto 1rem auto;
}
.loading-progress circle {
fill: none;
stroke: #e0e0e0;
stroke-width: 0.6rem;
transform-origin: 50% 50%;
transform: rotate(-90deg);
}
.loading-progress circle:last-child {
stroke: #1b6ec2;
stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
position: absolute;
text-align: center;
font-weight: bold;
inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after {
content: var(--blazor-load-percentage-text, "Loading");
}
code {
color: #c02d76;
}
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
color: var(--bs-secondary-color);
text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
text-align: start;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Spacebar Admin API Test client</title>
<base href="/"/>
<link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css"/>
<link rel="stylesheet" href="lib/jetbrains-mono/jetbrains-mono.css"/>
<link rel="stylesheet" href="css/app.css"/>
<link rel="icon" type="image/png" href="favicon.png"/>
<link href="Spacebar.AdminAPI.TestClient.styles.css" rel="stylesheet"/>
</head>
<body>
<div id="app">
<svg class="loading-progress">
<circle r="40%" cx="50%" cy="50%"/>
<circle r="40%" cx="50%" cy="50%"/>
</svg>
<div class="loading-progress-text"></div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>

View File

@ -0,0 +1,118 @@
/* source: https://gist.github.com/aasmpro/95776294ecf48bd7d0562504bad848ea */
/* normal fonts */
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 100;
src: url("./ttf/JetBrainsMono-Thin.ttf") format("truetype");
src: url("./webfonts/JetBrainsMono-Thin.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 200;
src: url("./webfonts/JetBrainsMono-ExtraLight.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 300;
src: url("./webfonts/JetBrainsMono-Light.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 400;
src: url("./webfonts/JetBrainsMono-Regular.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 500;
src: url("./webfonts/JetBrainsMono-Medium.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 600;
src: url("./webfonts/JetBrainsMono-SemiBold.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 700;
src: url("./webfonts/JetBrainsMono-Bold.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: normal;
font-weight: 800;
src: url("./webfonts/JetBrainsMono-ExtraBold.woff2") format("woff2");
}
/* italic fonts */
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 100;
src: url("./webfonts/JetBrainsMono-ThinItalic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 200;
src: url("./webfonts/JetBrainsMono-ExtraLightItalic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 300;
src: url("./webfonts/JetBrainsMono-LightItalic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 400;
src: url("./webfonts/JetBrainsMono-Italic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 500;
src: url("./webfonts/JetBrainsMono-MediumItalic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 600;
src: url("./webfonts/JetBrainsMono-SemiBoldItalic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 700;
src: url("./webfonts/JetBrainsMono-BoldItalic.woff2") format("woff2");
}
@font-face {
font-family: JetBrainsMono;
font-style: italic;
font-weight: 800;
src: url("./webfonts/JetBrainsMono-ExtraBoldItalic.woff2") format("woff2");
}

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