Compare commits

...

2 commits

19 changed files with 68 additions and 54 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "myhm-commission", "name": "Looking Glass",
"dockerComposeFile": "../docker-compose.dev.yml", "dockerComposeFile": "../docker-compose.dev.yml",
"service": "myhm-commission-dev", "service": "looking-glass-dev",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": { "customizations": {
"vscode": { "vscode": {
@ -23,7 +23,8 @@
"redhat.vscode-xml", "redhat.vscode-xml",
"aaron-bond.better-comments", "aaron-bond.better-comments",
"donjayamanne.githistory", "donjayamanne.githistory",
"eamodio.gitlens" "eamodio.gitlens",
"ms-azuretools.vscode-docker"
] ]
} }
}, },

4
.vscode/launch.json vendored
View file

@ -5,10 +5,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "C#: myhm-commission", "name": "C#: Looking Glass",
"type": "dotnet", "type": "dotnet",
"request": "launch", "request": "launch",
"projectPath": "${workspaceFolder}/myhm-commission.csproj" "projectPath": "${workspaceFolder}/LookingGlass.csproj"
} }
] ]

View file

@ -1,5 +1,5 @@
{ {
"dotnet.defaultSolution": "myhm-commission.sln", "dotnet.defaultSolution": "LookingGlass.sln",
"editor.formatOnSave": true, "editor.formatOnSave": true,
"[csharp]": { "[csharp]": {
"editor.defaultFormatter": "csharpier.csharpier-vscode", "editor.defaultFormatter": "csharpier.csharpier-vscode",

View file

@ -1,6 +1,6 @@
# Contributing to $WIP # Contributing to Looking Glass
Thanks for taking the time to contribute to $WIP! Please read through this document to ensure that your contribution is in compliance with our guidelines. We are excited to have you contribute to our project! Thanks for taking the time to contribute to Looking Glass! Please read through this document to ensure that your contribution is in compliance with our guidelines. We are excited to have you contribute to our project!
## Conventional Commits ## Conventional Commits

View file

@ -1,6 +1,6 @@
namespace Myhm.Data namespace LookingGlass.Data
{ {
public class MyhmConfiguration public class ApplicationSettings
{ {
public required string AuthToken { get; init; } public required string AuthToken { get; init; }
public required string DatabaseConnectionString { get; init; } public required string DatabaseConnectionString { get; init; }

View file

@ -1,12 +1,13 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using static EnumStringValues.EnumExtensions; using static EnumStringValues.EnumExtensions;
namespace Myhm.Data namespace LookingGlass.Data
{ {
public class MyhmContext(DbContextOptions<MyhmContext> options) : DbContext(options) public class ApplicationContext(DbContextOptions<ApplicationContext> options)
: DbContext(options)
{ {
public DbSet<Moderation> Moderation { get; set; } = default!; public DbSet<Moderation> Moderation { get; set; } = default!;
public DbSet<Token> Token { get; set; } = default!; public DbSet<User> User { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {

View file

@ -1,6 +1,6 @@
using EnumStringValues; using EnumStringValues;
namespace Myhm.Data; namespace LookingGlass.Data;
public class Moderation public class Moderation
{ {

View file

@ -1,9 +0,0 @@
namespace Myhm.Data;
public class Token
{
public int Id { get; set; }
public string String { get; set; } = default!;
public int DiscordUserId { get; set; }
public DateTime CreatedAt { get; set; }
}

22
Data/User.cs Normal file
View file

@ -0,0 +1,22 @@
namespace LookingGlass.Data;
public class User
{
public int Id { get; set; }
public string Token { get; set; } = default!;
public int DiscordUserId { get; set; }
public DateTime CreatedAt { get; set; }
public bool WriteAccess { get; set; } = false;
public bool Disabled { get; set; } = false;
public static User FromToken(string token, ApplicationContext context)
{
User user =
context.User.First(u => u.Token == token) ?? throw new Exception("User not found");
if (user.Disabled)
{
throw new Exception("User not found");
}
return user;
}
}

View file

@ -7,17 +7,17 @@ EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:9.0@sha256:84fd557bebc64015e731aca1085b92c7619e49bdbe247e57392a43d92276f617 AS build FROM mcr.microsoft.com/dotnet/sdk:9.0@sha256:84fd557bebc64015e731aca1085b92c7619e49bdbe247e57392a43d92276f617 AS build
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
WORKDIR /src WORKDIR /src
COPY ["myhm-commission.csproj", "./"] COPY ["LookingGlass.csproj", "./"]
RUN dotnet restore "myhm-commission.csproj" RUN dotnet restore "LookingGlass.csproj"
COPY . . COPY . .
WORKDIR "/src/" WORKDIR "/src/"
RUN dotnet build "myhm-commission.csproj" -c $BUILD_CONFIGURATION -o /app/build RUN dotnet build "LookingGlass.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish FROM build AS publish
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "myhm-commission.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false RUN dotnet publish "LookingGlass.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final FROM base AS final
WORKDIR /app WORKDIR /app
COPY --from=publish /app/publish . COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "myhm-commission.dll"] ENTRYPOINT ["dotnet", "LookingGlass.dll"]

View file

@ -209,7 +209,7 @@ If you develop a new program, and you want it to be of the greatest possible use
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
myhm-commission looking-glass
Copyright (C) 2025 MYHM Copyright (C) 2025 MYHM
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
@ -222,7 +222,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
myhm-commission Copyright (C) 2025 MYHM looking-glass Copyright (C) 2025 MYHM
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.

View file

@ -4,7 +4,7 @@
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Myhm</RootNamespace> <RootNamespace>LookingGlass</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn> <NoWarn>$(NoWarn);1591</NoWarn>

View file

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59 VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "myhm-commission", "myhm-commission.csproj", "{D39B0551-B762-4BD9-81DC-FF49FB7F8439}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LookingGlass", "LookingGlass.csproj", "{D39B0551-B762-4BD9-81DC-FF49FB7F8439}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View file

@ -1,14 +1,14 @@
using System.Reflection; using System.Reflection;
using LookingGlass.Data;
using LookingGlass.Util.SwaggerTheme;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Myhm.Data;
using Myhm.Util.SwaggerTheme;
using Newtonsoft.Json; using Newtonsoft.Json;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration.GetSection("Configuration").Get<MyhmConfiguration>(); var config = builder.Configuration.GetSection("Configuration").Get<ApplicationSettings>();
builder.Services.Configure<MyhmConfiguration>(builder.Configuration.GetSection("Configuration")); builder.Services.Configure<ApplicationSettings>(builder.Configuration.GetSection("Configuration"));
if ((config?.AuthToken?.Length ?? 0) < 64 && !builder.Environment.IsDevelopment()) if ((config?.AuthToken?.Length ?? 0) < 64 && !builder.Environment.IsDevelopment())
{ {
@ -17,8 +17,8 @@ if ((config?.AuthToken?.Length ?? 0) < 64 && !builder.Environment.IsDevelopment(
); );
} }
builder.Services.AddDbContextFactory<MyhmContext>(options => builder.Services.AddDbContextFactory<ApplicationContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("MyhmContext")) options.UseNpgsql(builder.Configuration.GetConnectionString("ApplicationContext"))
); );
if (config?.UseSentry == true) if (config?.UseSentry == true)
@ -34,7 +34,7 @@ builder.Services.AddSwaggerGen(opts =>
"v1", "v1",
new OpenApiInfo new OpenApiInfo
{ {
Title = "Myhm API", Title = "Looking Glass API",
Version = "v1", Version = "v1",
Description = "", Description = "",
} }

View file

@ -1 +1 @@
# myhm-commission # looking-glass

View file

@ -1,7 +1,7 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
namespace Myhm.Util; namespace LookingGlass.Util;
public class RandomStringGenerator public class RandomStringGenerator
{ {

View file

@ -1,7 +1,6 @@
using System;
using AspNetCore.Swagger.Themes; using AspNetCore.Swagger.Themes;
namespace Myhm.Util.SwaggerTheme; namespace LookingGlass.Util.SwaggerTheme;
public class CustomStyle : ModernStyle public class CustomStyle : ModernStyle
{ {

View file

@ -1,10 +1,10 @@
services: services:
myhm-commission-dev: looking-glass-dev:
container_name: myhm-commission-dev container_name: looking-glass-dev
image: mcr.microsoft.com/devcontainers/dotnet:1-9.0-bookworm@sha256:f84f5dc61134aacd099c03f58663994da48047a6f43b9d5ba446a5b5ad2074aa image: mcr.microsoft.com/devcontainers/dotnet:1-9.0-bookworm@sha256:f84f5dc61134aacd099c03f58663994da48047a6f43b9d5ba446a5b5ad2074aa
environment: environment:
CONFIGURATION__AUTHTOKEN: "hi" CONFIGURATION__AUTHTOKEN: "hi"
CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://myhm-commission:myhm-commission@postgres:5432/myhm-commission" CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://looking-glass:looking-glass@postgres:5432/looking-glass"
ASPNETCORE_URLS: "http://0.0.0.0:8000" ASPNETCORE_URLS: "http://0.0.0.0:8000"
LOGGING__LOGLEVEL_DEFAULT: "Trace" LOGGING__LOGLEVEL_DEFAULT: "Trace"
CONFIGURATION__USESENTRY: false CONFIGURATION__USESENTRY: false
@ -15,7 +15,7 @@ services:
command: sleep infinity command: sleep infinity
database: database:
container_name: myhm-commission-db container_name: looking-glass-db
extends: extends:
service: database service: database
file: ./docker-compose.yml file: ./docker-compose.yml

View file

@ -1,6 +1,6 @@
services: services:
myhm-commission: looking-glass:
image: www.coastalcommits.com/cswimr/myhm-commission:latest image: www.coastalcommits.com/cswimr/lookingglass:latest
ports: ports:
- 8000:8000 - 8000:8000
environment: environment:
@ -20,7 +20,7 @@ services:
# The only current valid value is `PostgresSQL`. This is used to determine which database type to use. # The only current valid value is `PostgresSQL`. This is used to determine which database type to use.
CONFIGURATION__DATABASETYPE: "PostgresSQL" CONFIGURATION__DATABASETYPE: "PostgresSQL"
CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://myhm-commission:myhm-commission@postgres:5432/myhm-commission" CONFIGURATION__DATABASECONNECTIONSTRING: "postgres://LookingGlass:LookingGlass@postgres:5432/LookingGlass"
# Determines the log level for the application's default logger. # Determines the log level for the application's default logger.
# Valid values are `Trace`, `Debug`, `Information`, `Warning`, `Error`, and `Critical`. # Valid values are `Trace`, `Debug`, `Information`, `Warning`, `Error`, and `Critical`.
@ -41,13 +41,13 @@ services:
CONFIGURATION__USESWAGGER: true CONFIGURATION__USESWAGGER: true
database: database:
container_name: myhm-commission-db container_name: looking-glass-db
image: postgres:17.2@sha256:87ec5e0a167dc7d4831729f9e1d2ee7b8597dcc49ccd9e43cc5f89e808d2adae image: postgres:17.2@sha256:87ec5e0a167dc7d4831729f9e1d2ee7b8597dcc49ccd9e43cc5f89e808d2adae
restart: always restart: always
environment: environment:
POSTGRES_USER: myhm-commission POSTGRES_USER: LookingGlass
POSTGRES_PASSWORD: myhm-commission POSTGRES_PASSWORD: LookingGlass
POSTGRES_DB: myhm-commission POSTGRES_DB: LookingGlass
volumes: volumes:
- postgres-data:/var/lib/postgresql/data - postgres-data:/var/lib/postgresql/data