Compare commits
8 Commits
debug-logg
...
db-changes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b669e2cb24 | ||
|
|
0df7ee424d | ||
|
|
81261fae49 | ||
| d7e8be97ff | |||
| 8217d99478 | |||
| 5e37ff86e7 | |||
|
|
d27f5f3df0 | ||
|
|
d98062a4fe |
Submodule LightlessAPI updated: 3a69c94f7f...4ce70bee83
@@ -121,6 +121,7 @@ public abstract class AuthControllerBase : Controller
|
||||
{
|
||||
CharacterIdentification = charaIdent,
|
||||
Reason = "Autobanned CharacterIdent (" + uid + ")",
|
||||
BannedUid = uid,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ using LightlessSyncShared.Metrics;
|
||||
using LightlessSyncShared.Services;
|
||||
using LightlessSyncShared.Utils;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using StackExchange.Redis.Extensions.Core.Configuration;
|
||||
using StackExchange.Redis.Extensions.System.Text.Json;
|
||||
using StackExchange.Redis;
|
||||
using System.Net;
|
||||
using LightlessSyncAuthService.Services;
|
||||
@@ -17,7 +15,6 @@ using LightlessSyncShared.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prometheus;
|
||||
using LightlessSyncShared.Utils.Configuration;
|
||||
using StackExchange.Redis.Extensions.Core.Abstractions;
|
||||
|
||||
namespace LightlessSyncAuthService;
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using LightlessSync.API.Dto.User;
|
||||
using LightlessSync.API.Routes;
|
||||
using LightlessSyncShared.Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LightlessSyncAuthService.Controllers;
|
||||
|
||||
[Route(LightlessAuth.User)]
|
||||
[Authorize(Policy = "Internal")]
|
||||
public class UserController : Controller
|
||||
{
|
||||
protected readonly ILogger Logger;
|
||||
protected readonly IDbContextFactory<LightlessDbContext> LightlessDbContextFactory;
|
||||
public UserController(ILogger<UserController> logger, IDbContextFactory<LightlessDbContext> lightlessDbContext)
|
||||
{
|
||||
Logger = logger;
|
||||
LightlessDbContextFactory = lightlessDbContext;
|
||||
}
|
||||
|
||||
[Route(LightlessAuth.Ban_Uid)]
|
||||
[HttpPost]
|
||||
public async Task MarkForBanUid([FromBody] BanRequest request)
|
||||
{
|
||||
using var dbContext = await LightlessDbContextFactory.CreateDbContextAsync();
|
||||
|
||||
Logger.LogInformation("Banning user with UID {UID}", request.Uid);
|
||||
|
||||
//Mark User as banned, and not marked for ban
|
||||
var auth = await dbContext.Auth.FirstOrDefaultAsync(f => f.UserUID == request.Uid);
|
||||
if (auth != null)
|
||||
{
|
||||
auth.MarkForBan = true;
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
[Route(LightlessAuth.User_Unban_Uid)]
|
||||
[HttpPost]
|
||||
public async Task UnBanUserByUid([FromBody] UnbanRequest request)
|
||||
{
|
||||
using var dbContext = await LightlessDbContextFactory.CreateDbContextAsync();
|
||||
|
||||
Logger.LogInformation("Unbanning user with UID {UID}", request.Uid);
|
||||
|
||||
//Mark User as not banned, and not marked for ban (if marked)
|
||||
var auth = await dbContext.Auth.FirstOrDefaultAsync(f => f.UserUID == request.Uid);
|
||||
if (auth != null)
|
||||
{
|
||||
auth.IsBanned = false;
|
||||
auth.MarkForBan = false;
|
||||
}
|
||||
|
||||
// Remove all bans associated with this user
|
||||
var bannedFromLightlessIds = dbContext.BannedUsers.Where(b => b.BannedUid == request.Uid);
|
||||
dbContext.BannedUsers.RemoveRange(bannedFromLightlessIds);
|
||||
|
||||
// Remove all character/discord bans associated with this user
|
||||
var lodestoneAuths = dbContext.LodeStoneAuth.Where(l => l.User != null && l.User.UID == request.Uid).ToList();
|
||||
foreach (var lodestoneAuth in lodestoneAuths)
|
||||
{
|
||||
var bannedRegs = dbContext.BannedRegistrations.Where(b => b.DiscordIdOrLodestoneAuth == lodestoneAuth.HashedLodestoneId || b.DiscordIdOrLodestoneAuth == lodestoneAuth.DiscordId.ToString());
|
||||
dbContext.BannedRegistrations.RemoveRange(bannedRegs);
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
[Route(LightlessAuth.User_Unban_Discord)]
|
||||
[HttpPost]
|
||||
public async Task UnBanUserByDiscordId([FromBody] UnbanRequest request)
|
||||
{
|
||||
Logger.LogInformation("Unbanning user with discordId: {discordId}", request.DiscordId);
|
||||
using var dbContext = await LightlessDbContextFactory.CreateDbContextAsync();
|
||||
|
||||
var userByDiscord = await dbContext.LodeStoneAuth.Include(l => l.User).FirstOrDefaultAsync(l => l.DiscordId.ToString() == request.DiscordId);
|
||||
|
||||
if (userByDiscord?.User == null)
|
||||
{
|
||||
Logger.LogInformation("Unbanning user with discordId: {discordId} but no user found", request.DiscordId);
|
||||
return;
|
||||
}
|
||||
var bannedRegs = dbContext.BannedRegistrations.Where(b => b.DiscordIdOrLodestoneAuth == request.DiscordId || b.DiscordIdOrLodestoneAuth == userByDiscord.HashedLodestoneId);
|
||||
//Mark User as not banned, and not marked for ban (if marked)
|
||||
var auth = await dbContext.Auth.FirstOrDefaultAsync(f => f.UserUID == userByDiscord.User.UID);
|
||||
if (auth != null)
|
||||
{
|
||||
auth.IsBanned = false;
|
||||
auth.MarkForBan = false;
|
||||
}
|
||||
// Remove all bans associated with this user
|
||||
var bannedFromLightlessIds = dbContext.BannedUsers.Where(b => b.BannedUid == auth.UserUID || b.BannedUid == auth.PrimaryUserUID);
|
||||
dbContext.BannedUsers.RemoveRange(bannedFromLightlessIds);
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using LightlessSyncServer.Hubs;
|
||||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using AspNetCoreRateLimit;
|
||||
using LightlessSync.API.SignalR;
|
||||
using LightlessSyncAuthService.Controllers;
|
||||
using LightlessSyncServer.Controllers;
|
||||
using LightlessSyncServer.Hubs;
|
||||
using LightlessSyncServer.Services;
|
||||
using LightlessSyncShared.Data;
|
||||
using LightlessSyncShared.Metrics;
|
||||
using LightlessSyncServer.Services;
|
||||
using LightlessSyncShared.Utils;
|
||||
using LightlessSyncShared.RequirementHandlers;
|
||||
using LightlessSyncShared.Services;
|
||||
using Prometheus;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Text;
|
||||
using StackExchange.Redis;
|
||||
using StackExchange.Redis.Extensions.Core.Configuration;
|
||||
using System.Net;
|
||||
using StackExchange.Redis.Extensions.System.Text.Json;
|
||||
using LightlessSync.API.SignalR;
|
||||
using LightlessSyncShared.Utils;
|
||||
using LightlessSyncShared.Utils.Configuration;
|
||||
using MessagePack;
|
||||
using MessagePack.Resolvers;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using LightlessSyncServer.Controllers;
|
||||
using LightlessSyncShared.RequirementHandlers;
|
||||
using LightlessSyncShared.Utils.Configuration;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Prometheus;
|
||||
using StackExchange.Redis;
|
||||
using StackExchange.Redis.Extensions.Core.Configuration;
|
||||
using StackExchange.Redis.Extensions.System.Text.Json;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace LightlessSyncServer;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class Startup
|
||||
a.FeatureProviders.Remove(a.FeatureProviders.OfType<ControllerFeatureProvider>().First());
|
||||
if (lightlessConfig.GetValue<Uri>(nameof(ServerConfiguration.MainServerAddress), defaultValue: null) == null)
|
||||
{
|
||||
a.FeatureProviders.Add(new AllowedControllersFeatureProvider(typeof(LightlessServerConfigurationController), typeof(LightlessBaseConfigurationController), typeof(ClientMessageController)));
|
||||
a.FeatureProviders.Add(new AllowedControllersFeatureProvider(typeof(LightlessServerConfigurationController), typeof(LightlessBaseConfigurationController), typeof(ClientMessageController), typeof(UserController)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using FluentAssertions;
|
||||
using LightlessSyncServer.Discord;
|
||||
using LightlessSyncServices.Discord;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ using LightlessSyncShared.Models;
|
||||
using LightlessSyncShared.Services;
|
||||
using LightlessSyncShared.Utils.Configuration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace LightlessSyncServices.Discord;
|
||||
|
||||
@@ -9,6 +9,7 @@ using LightlessSyncShared.Services;
|
||||
using StackExchange.Redis;
|
||||
using LightlessSync.API.Data.Enum;
|
||||
using LightlessSyncShared.Utils.Configuration;
|
||||
using LightlessSync.API.Dto.User;
|
||||
|
||||
namespace LightlessSyncServices.Discord;
|
||||
|
||||
@@ -18,15 +19,16 @@ public class LightlessModule : InteractionModuleBase
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly IConfigurationService<ServicesConfiguration> _lightlessServicesConfiguration;
|
||||
private readonly IConnectionMultiplexer _connectionMultiplexer;
|
||||
|
||||
private readonly ServerTokenGenerator _serverTokenGenerator;
|
||||
public LightlessModule(ILogger<LightlessModule> logger, IServiceProvider services,
|
||||
IConfigurationService<ServicesConfiguration> lightlessServicesConfiguration,
|
||||
IConnectionMultiplexer connectionMultiplexer)
|
||||
IConnectionMultiplexer connectionMultiplexer, ServerTokenGenerator serverTokenGenerator)
|
||||
{
|
||||
_logger = logger;
|
||||
_services = services;
|
||||
_lightlessServicesConfiguration = lightlessServicesConfiguration;
|
||||
_connectionMultiplexer = connectionMultiplexer;
|
||||
_serverTokenGenerator = serverTokenGenerator;
|
||||
}
|
||||
|
||||
[SlashCommand("userinfo", "Shows you your user information")]
|
||||
@@ -103,9 +105,15 @@ public class LightlessModule : InteractionModuleBase
|
||||
try
|
||||
{
|
||||
using HttpClient c = new HttpClient();
|
||||
await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue<Uri>
|
||||
(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"), new ClientMessage(messageType, message, uid ?? string.Empty))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
||||
var testUri = new Uri(_lightlessServicesConfiguration.GetValue<Uri>
|
||||
(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage");
|
||||
|
||||
await c.PostAsJsonAsync(
|
||||
new Uri(_lightlessServicesConfiguration.GetValue<Uri>(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"),
|
||||
new ClientMessage(messageType, message, uid ?? string.Empty)
|
||||
).ConfigureAwait(false);
|
||||
|
||||
var discordChannelForMessages = _lightlessServicesConfiguration.GetValueOrDefault<ulong?>(nameof(ServicesConfiguration.DiscordChannelForMessages), null);
|
||||
if (uid == null && discordChannelForMessages != null)
|
||||
@@ -138,6 +146,134 @@ public class LightlessModule : InteractionModuleBase
|
||||
}
|
||||
}
|
||||
|
||||
[SlashCommand("unbanbydiscord", "ADMIN ONLY: Unban a user by their discord ID")]
|
||||
public async Task UnbanByDiscord([Summary("discord_id", "Discord ID to unban")] string discordId)
|
||||
{
|
||||
_logger.LogInformation("SlashCommand:{userId}:{Method}:{params}",
|
||||
Context.Interaction.User.Id, nameof(UnbanByDiscord),
|
||||
string.Join(",", new[] { $"{nameof(discordId)}:{discordId}" }));
|
||||
try
|
||||
{
|
||||
using HttpClient c = new HttpClient();
|
||||
|
||||
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
||||
await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue<Uri>
|
||||
(nameof(ServicesConfiguration.MainServerAddress)), "/user/unbanDiscord"), new UnbanRequest(string.Empty, discordId))
|
||||
.ConfigureAwait(false);
|
||||
var discordChannelForMessages = _lightlessServicesConfiguration.GetValueOrDefault<ulong?>(nameof(ServicesConfiguration.DiscordChannelForMessages), null);
|
||||
if (discordChannelForMessages != null)
|
||||
{
|
||||
var discordChannel = await Context.Guild.GetChannelAsync(discordChannelForMessages.Value).ConfigureAwait(false) as IMessageChannel;
|
||||
if (discordChannel != null)
|
||||
{
|
||||
var embedColor = Color.Blue;
|
||||
|
||||
EmbedBuilder eb = new();
|
||||
eb.WithTitle("Unban Alert!");
|
||||
eb.WithColor(embedColor);
|
||||
eb.WithDescription(discordId + " has been unbanned");
|
||||
|
||||
await discordChannel.SendMessageAsync(embed: eb.Build()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
await RespondAsync("Message sent", ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EmbedBuilder eb = new();
|
||||
eb.WithTitle("An error occured");
|
||||
eb.WithDescription("Please report this: " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
|
||||
await RespondAsync(embeds: new Embed[] { eb.Build() }, ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[SlashCommand("unbanbyuid", "ADMIN ONLY: Unban a user by their uid")]
|
||||
public async Task UnbanByUID([Summary("uid", "uid to unban")] string uid)
|
||||
{
|
||||
_logger.LogInformation("SlashCommand:{userId}:{Method}:{params}",
|
||||
Context.Interaction.User.Id, nameof(UnbanByUID),
|
||||
string.Join(",", new[] { $"{nameof(uid)}:{uid}" }));
|
||||
try
|
||||
{
|
||||
using HttpClient c = new HttpClient();
|
||||
var testUri = new Uri(_lightlessServicesConfiguration.GetValue<Uri>
|
||||
(nameof(ServicesConfiguration.MainServerAddress)), "/user/unbanDiscord");
|
||||
|
||||
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
||||
await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue<Uri>
|
||||
(nameof(ServicesConfiguration.MainServerAddress)), "/user/unbanUID"), new UnbanRequest(uid, string.Empty))
|
||||
.ConfigureAwait(false);
|
||||
var discordChannelForMessages = _lightlessServicesConfiguration.GetValueOrDefault<ulong?>(nameof(ServicesConfiguration.DiscordChannelForMessages), null);
|
||||
if (discordChannelForMessages != null)
|
||||
{
|
||||
var discordChannel = await Context.Guild.GetChannelAsync(discordChannelForMessages.Value).ConfigureAwait(false) as IMessageChannel;
|
||||
if (discordChannel != null)
|
||||
{
|
||||
var embedColor = Color.Blue;
|
||||
|
||||
EmbedBuilder eb = new();
|
||||
eb.WithTitle("Unban Alert!");
|
||||
eb.WithColor(embedColor);
|
||||
eb.WithDescription(uid + " has been unbanned");
|
||||
|
||||
await discordChannel.SendMessageAsync(embed: eb.Build()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
await RespondAsync("Message sent", ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EmbedBuilder eb = new();
|
||||
eb.WithTitle("An error occured");
|
||||
eb.WithDescription("Please report this: " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
|
||||
await RespondAsync(embeds: new Embed[] { eb.Build() }, ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
[SlashCommand("markforban", "ADMIN ONLY: ban a user by their uid")]
|
||||
public async Task MarkUidForBan([Summary("uid", "uid to ban")] string uid)
|
||||
{
|
||||
_logger.LogInformation("SlashCommand:{userId}:{Method}:{params}",
|
||||
Context.Interaction.User.Id, nameof(MarkUidForBan),
|
||||
string.Join(",", new[] { $"{nameof(uid)}:{uid}" }));
|
||||
try
|
||||
{
|
||||
using HttpClient c = new HttpClient();
|
||||
|
||||
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
||||
await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue<Uri>
|
||||
(nameof(ServicesConfiguration.MainServerAddress)), "/user/ban"), new BanRequest(uid))
|
||||
.ConfigureAwait(false);
|
||||
var discordChannelForMessages = _lightlessServicesConfiguration.GetValueOrDefault<ulong?>(nameof(ServicesConfiguration.DiscordChannelForMessages), null);
|
||||
if (discordChannelForMessages != null)
|
||||
{
|
||||
var discordChannel = await Context.Guild.GetChannelAsync(discordChannelForMessages.Value).ConfigureAwait(false) as IMessageChannel;
|
||||
if (discordChannel != null)
|
||||
{
|
||||
var embedColor = Color.Blue;
|
||||
|
||||
EmbedBuilder eb = new();
|
||||
eb.WithTitle("Ban Alert!");
|
||||
eb.WithColor(embedColor);
|
||||
eb.WithDescription(uid + " has been marked for ban");
|
||||
|
||||
await discordChannel.SendMessageAsync(embed: eb.Build()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
await RespondAsync("Message sent", ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EmbedBuilder eb = new();
|
||||
eb.WithTitle("An error occured");
|
||||
eb.WithDescription("Please report this: " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
|
||||
await RespondAsync(embeds: new Embed[] { eb.Build() }, ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Embed> HandleUserAdd(string desiredUid, ulong discordUserId)
|
||||
{
|
||||
var embed = new EmbedBuilder();
|
||||
|
||||
@@ -92,13 +92,22 @@ public partial class LightlessWizardModule
|
||||
var desiredVanityUid = modal.DesiredVanityUID;
|
||||
using var db = await GetDbContext().ConfigureAwait(false);
|
||||
bool canAddVanityId = !db.Users.Any(u => u.UID == modal.DesiredVanityUID || u.Alias == modal.DesiredVanityUID);
|
||||
var forbiddenWords = new[] { "null", "nil" };
|
||||
|
||||
Regex rgx = new(@"^[_\-a-zA-Z0-9]{5,15}$", RegexOptions.ECMAScript);
|
||||
Regex rgx = new(@"^[_\-a-zA-Z0-9]{3,15}$", RegexOptions.ECMAScript);
|
||||
if (!rgx.Match(desiredVanityUid).Success)
|
||||
{
|
||||
eb.WithColor(Color.Red);
|
||||
eb.WithTitle("Invalid Vanity UID");
|
||||
eb.WithDescription("A Vanity UID must be between 5 and 15 characters long and only contain the letters A-Z, numbers 0-9, dashes (-) and underscores (_).");
|
||||
eb.WithDescription("A Vanity UID must be between 3 and 15 characters long and only contain the letters A-Z, numbers 0-9, dashes (-) and underscores (_).");
|
||||
cb.WithButton("Cancel", "wizard-vanity", ButtonStyle.Secondary, emote: new Emoji("❌"));
|
||||
cb.WithButton("Pick Different UID", "wizard-vanity-uid-set:" + uid, ButtonStyle.Primary, new Emoji("💅"));
|
||||
}
|
||||
else if (forbiddenWords.Contains(desiredVanityUid.Trim().ToLowerInvariant()))
|
||||
{
|
||||
eb.WithColor(Color.Red);
|
||||
eb.WithTitle("Invalid Vanity UID");
|
||||
eb.WithDescription("You cannot use 'Null' or 'Nil' (any case) as a Vanity UID. Please pick a different one.");
|
||||
cb.WithButton("Cancel", "wizard-vanity", ButtonStyle.Secondary, emote: new Emoji("❌"));
|
||||
cb.WithButton("Pick Different UID", "wizard-vanity-uid-set:" + uid, ButtonStyle.Primary, new Emoji("💅"));
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public partial class LightlessWizardModule : InteractionModuleBase
|
||||
public string Title => "Set Vanity UID";
|
||||
|
||||
[InputLabel("Set your Vanity UID")]
|
||||
[ModalTextInput("vanity_uid", TextInputStyle.Short, "5-15 characters, underscore, dash", 5, 15)]
|
||||
[ModalTextInput("vanity_uid", TextInputStyle.Short, "3-15 characters, underscore, dash", 3, 15)]
|
||||
public string DesiredVanityUID { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ public class LightlessDbContext : DbContext
|
||||
public DbSet<CharaDataOriginalFile> CharaDataOriginalFiles { get; set; }
|
||||
public DbSet<CharaDataPose> CharaDataPoses { get; set; }
|
||||
public DbSet<CharaDataAllowance> CharaDataAllowances { get; set; }
|
||||
public DbSet<GroupProfile> GroupProfiles { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder mb)
|
||||
{
|
||||
@@ -70,6 +71,14 @@ public class LightlessDbContext : DbContext
|
||||
mb.Entity<BannedRegistrations>().ToTable("banned_registrations");
|
||||
mb.Entity<Group>().ToTable("groups");
|
||||
mb.Entity<Group>().HasIndex(c => c.OwnerUID);
|
||||
mb.Entity<Group>()
|
||||
.Property(g => g.CreatedDate)
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
mb.Entity<Group>()
|
||||
.HasOne(g => g.Profile)
|
||||
.WithOne(p => p.Group)
|
||||
.HasForeignKey<GroupProfile>(p => p.GroupGID)
|
||||
.IsRequired(false);
|
||||
mb.Entity<GroupPair>().ToTable("group_pairs");
|
||||
mb.Entity<GroupPair>().HasKey(u => new { u.GroupGID, u.GroupUserUID });
|
||||
mb.Entity<GroupPair>().HasIndex(c => c.GroupUserUID);
|
||||
@@ -78,6 +87,9 @@ public class LightlessDbContext : DbContext
|
||||
mb.Entity<GroupBan>().HasKey(u => new { u.GroupGID, u.BannedUserUID });
|
||||
mb.Entity<GroupBan>().HasIndex(c => c.BannedUserUID);
|
||||
mb.Entity<GroupBan>().HasIndex(c => c.GroupGID);
|
||||
mb.Entity<GroupProfile>().ToTable("group_profiles");
|
||||
mb.Entity<GroupProfile>().HasKey(u => u.GroupGID);
|
||||
mb.Entity<GroupProfile>().HasIndex(c => c.GroupGID);
|
||||
mb.Entity<GroupTempInvite>().ToTable("group_temp_invites");
|
||||
mb.Entity<GroupTempInvite>().HasKey(u => new { u.GroupGID, u.Invite });
|
||||
mb.Entity<GroupTempInvite>().HasIndex(c => c.GroupGID);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using LightlessSyncShared.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
@@ -11,9 +12,11 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace LightlessSyncServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(LightlessDbContext))]
|
||||
partial class LightlessDbContextModelSnapshot : ModelSnapshot
|
||||
[Migration("20250905192853_AddBannedUid")]
|
||||
partial class AddBannedUid
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
@@ -64,6 +67,10 @@ namespace LightlessSyncServer.Migrations
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("character_identification");
|
||||
|
||||
b.Property<string>("BannedUid")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("banned_uid");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("reason");
|
||||
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LightlessSyncServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddBannedUid : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "banned_uid",
|
||||
table: "banned_users",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "banned_uid",
|
||||
table: "banned_users");
|
||||
}
|
||||
}
|
||||
}
|
||||
1151
LightlessSyncServer/LightlessSyncShared/Migrations/20250916200240_AddGroupProfilesAndDates.Designer.cs
generated
Normal file
1151
LightlessSyncServer/LightlessSyncShared/Migrations/20250916200240_AddGroupProfilesAndDates.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LightlessSyncServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddGroupProfilesAndDates : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "created_date",
|
||||
table: "groups",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValueSql: "CURRENT_TIMESTAMP");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "from_finder",
|
||||
table: "group_pairs",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "joined_group_on",
|
||||
table: "group_pairs",
|
||||
type: "timestamp with time zone",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "group_profiles",
|
||||
columns: table => new
|
||||
{
|
||||
group_gid = table.Column<string>(type: "character varying(20)", nullable: false),
|
||||
description = table.Column<string>(type: "text", nullable: true),
|
||||
tags = table.Column<string>(type: "text", nullable: true),
|
||||
base64group_profile_image = table.Column<string>(type: "text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_group_profiles", x => x.group_gid);
|
||||
table.ForeignKey(
|
||||
name: "fk_group_profiles_groups_group_gid",
|
||||
column: x => x.group_gid,
|
||||
principalTable: "groups",
|
||||
principalColumn: "gid",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_group_profiles_group_gid",
|
||||
table: "group_profiles",
|
||||
column: "group_gid");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "group_profiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "created_date",
|
||||
table: "groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "from_finder",
|
||||
table: "group_pairs");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "joined_group_on",
|
||||
table: "group_pairs");
|
||||
}
|
||||
}
|
||||
}
|
||||
1155
LightlessSyncServer/LightlessSyncShared/Migrations/20250917004805_AddProfilesToGroup.Designer.cs
generated
Normal file
1155
LightlessSyncServer/LightlessSyncShared/Migrations/20250917004805_AddProfilesToGroup.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LightlessSyncServer.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddProfilesToGroup : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_group_profiles_groups_group_gid",
|
||||
table: "group_profiles");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_group_profiles_groups_group_gid",
|
||||
table: "group_profiles",
|
||||
column: "group_gid",
|
||||
principalTable: "groups",
|
||||
principalColumn: "gid");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_group_profiles_groups_group_gid",
|
||||
table: "group_profiles");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_group_profiles_groups_group_gid",
|
||||
table: "group_profiles",
|
||||
column: "group_gid",
|
||||
principalTable: "groups",
|
||||
principalColumn: "gid",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@ public class Banned
|
||||
[Key]
|
||||
[MaxLength(100)]
|
||||
public string CharacterIdentification { get; set; }
|
||||
public string BannedUid { get; set; }
|
||||
public string Reason { get; set; }
|
||||
[Timestamp]
|
||||
public byte[] Timestamp { get; set; }
|
||||
|
||||
@@ -11,9 +11,11 @@ public class Group
|
||||
public User Owner { get; set; }
|
||||
[MaxLength(50)]
|
||||
public string Alias { get; set; }
|
||||
public GroupProfile? Profile { get; set; }
|
||||
public bool InvitesEnabled { get; set; }
|
||||
public string HashedPassword { get; set; }
|
||||
public bool PreferDisableSounds { get; set; }
|
||||
public bool PreferDisableAnimations { get; set; }
|
||||
public bool PreferDisableVFX { get; set; }
|
||||
public DateTime CreatedDate { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
@@ -8,4 +8,6 @@ public class GroupPair
|
||||
public User GroupUser { get; set; }
|
||||
public bool IsPinned { get; set; }
|
||||
public bool IsModerator { get; set; }
|
||||
public bool FromFinder { get; set; } = false;
|
||||
public DateTime? JoinedGroupOn { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LightlessSyncShared.Models;
|
||||
public class GroupProfile
|
||||
{
|
||||
[Key]
|
||||
[MaxLength(20)]
|
||||
public string GroupGID { get; set; }
|
||||
public Group Group { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public string Base64GroupProfileImage { get; set; }
|
||||
}
|
||||
@@ -109,11 +109,9 @@ public class LightlessConfigurationServiceClient<T> : IHostedService, IConfigura
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Getting {key} from Http with {} ", key, GetRoute(key, Convert.ToString(defaultValue, CultureInfo.InvariantCulture)));
|
||||
|
||||
_logger.LogInformation("Getting {key} from Http", key);
|
||||
using HttpRequestMessage msg = new(HttpMethod.Get, GetRoute(key, Convert.ToString(defaultValue, CultureInfo.InvariantCulture)));
|
||||
msg.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
||||
_logger.LogInformation("Using Token {token}", _serverTokenGenerator.Token);
|
||||
using var response = await _httpClient.SendAsync(msg).ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user