Compare commits
15 Commits
fix-images
...
unbanbydis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d758f58f8 | ||
|
|
9631f521bc | ||
|
|
f6b33425b5 | ||
|
|
42ed164c54 | ||
|
|
9cd77d2b55 | ||
|
|
332f7f7bb2 | ||
|
|
56bc277436 | ||
|
|
176f0e7e56 | ||
|
|
b700f58d88 | ||
|
|
232b3d535c | ||
|
|
b5aa817d0b | ||
|
|
7c81f880e1 | ||
|
|
4f249a2db9 | ||
|
|
3f76121e26 | ||
|
|
4feb64f015 |
Submodule LightlessAPI updated: 3a69c94f7f...4ce70bee83
@@ -121,6 +121,7 @@ public abstract class AuthControllerBase : Controller
|
|||||||
{
|
{
|
||||||
CharacterIdentification = charaIdent,
|
CharacterIdentification = charaIdent,
|
||||||
Reason = "Autobanned CharacterIdent (" + uid + ")",
|
Reason = "Autobanned CharacterIdent (" + uid + ")",
|
||||||
|
BannedUid = uid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ using LightlessSyncShared.Metrics;
|
|||||||
using LightlessSyncShared.Services;
|
using LightlessSyncShared.Services;
|
||||||
using LightlessSyncShared.Utils;
|
using LightlessSyncShared.Utils;
|
||||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using StackExchange.Redis.Extensions.Core.Configuration;
|
|
||||||
using StackExchange.Redis.Extensions.System.Text.Json;
|
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using LightlessSyncAuthService.Services;
|
using LightlessSyncAuthService.Services;
|
||||||
@@ -17,7 +15,6 @@ using LightlessSyncShared.Data;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Prometheus;
|
using Prometheus;
|
||||||
using LightlessSyncShared.Utils.Configuration;
|
using LightlessSyncShared.Utils.Configuration;
|
||||||
using StackExchange.Redis.Extensions.Core.Abstractions;
|
|
||||||
|
|
||||||
namespace LightlessSyncAuthService;
|
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 AspNetCoreRateLimit;
|
||||||
|
using LightlessSync.API.SignalR;
|
||||||
|
using LightlessSyncAuthService.Controllers;
|
||||||
|
using LightlessSyncServer.Controllers;
|
||||||
|
using LightlessSyncServer.Hubs;
|
||||||
|
using LightlessSyncServer.Services;
|
||||||
using LightlessSyncShared.Data;
|
using LightlessSyncShared.Data;
|
||||||
using LightlessSyncShared.Metrics;
|
using LightlessSyncShared.Metrics;
|
||||||
using LightlessSyncServer.Services;
|
using LightlessSyncShared.RequirementHandlers;
|
||||||
using LightlessSyncShared.Utils;
|
|
||||||
using LightlessSyncShared.Services;
|
using LightlessSyncShared.Services;
|
||||||
using Prometheus;
|
using LightlessSyncShared.Utils;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using LightlessSyncShared.Utils.Configuration;
|
||||||
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 MessagePack;
|
using MessagePack;
|
||||||
using MessagePack.Resolvers;
|
using MessagePack.Resolvers;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http.Connections;
|
||||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using LightlessSyncServer.Controllers;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using LightlessSyncShared.RequirementHandlers;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using LightlessSyncShared.Utils.Configuration;
|
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;
|
namespace LightlessSyncServer;
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ public class Startup
|
|||||||
a.FeatureProviders.Remove(a.FeatureProviders.OfType<ControllerFeatureProvider>().First());
|
a.FeatureProviders.Remove(a.FeatureProviders.OfType<ControllerFeatureProvider>().First());
|
||||||
if (lightlessConfig.GetValue<Uri>(nameof(ServerConfiguration.MainServerAddress), defaultValue: null) == null)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using LightlessSyncServer.Discord;
|
using LightlessSyncServices.Discord;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using LightlessSyncShared.Models;
|
|||||||
using LightlessSyncShared.Services;
|
using LightlessSyncShared.Services;
|
||||||
using LightlessSyncShared.Utils.Configuration;
|
using LightlessSyncShared.Utils.Configuration;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
|
|
||||||
namespace LightlessSyncServices.Discord;
|
namespace LightlessSyncServices.Discord;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using LightlessSyncShared.Services;
|
|||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using LightlessSync.API.Data.Enum;
|
using LightlessSync.API.Data.Enum;
|
||||||
using LightlessSyncShared.Utils.Configuration;
|
using LightlessSyncShared.Utils.Configuration;
|
||||||
|
using LightlessSync.API.Dto.User;
|
||||||
|
|
||||||
namespace LightlessSyncServices.Discord;
|
namespace LightlessSyncServices.Discord;
|
||||||
|
|
||||||
@@ -106,6 +107,8 @@ public class LightlessModule : InteractionModuleBase
|
|||||||
using HttpClient c = new HttpClient();
|
using HttpClient c = new HttpClient();
|
||||||
|
|
||||||
c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
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(
|
await c.PostAsJsonAsync(
|
||||||
new Uri(_lightlessServicesConfiguration.GetValue<Uri>(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"),
|
new Uri(_lightlessServicesConfiguration.GetValue<Uri>(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"),
|
||||||
@@ -143,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)
|
public async Task<Embed> HandleUserAdd(string desiredUid, ulong discordUserId)
|
||||||
{
|
{
|
||||||
var embed = new EmbedBuilder();
|
var embed = new EmbedBuilder();
|
||||||
|
|||||||
1098
LightlessSyncServer/LightlessSyncShared/Migrations/20250905192853_AddBannedUid.Designer.cs
generated
Normal file
1098
LightlessSyncServer/LightlessSyncShared/Migrations/20250905192853_AddBannedUid.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,10 @@ namespace LightlessSyncServer.Migrations
|
|||||||
.HasColumnType("character varying(100)")
|
.HasColumnType("character varying(100)")
|
||||||
.HasColumnName("character_identification");
|
.HasColumnName("character_identification");
|
||||||
|
|
||||||
|
b.Property<string>("BannedUid")
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("banned_uid");
|
||||||
|
|
||||||
b.Property<string>("Reason")
|
b.Property<string>("Reason")
|
||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("reason");
|
.HasColumnName("reason");
|
||||||
@@ -7,6 +7,7 @@ public class Banned
|
|||||||
[Key]
|
[Key]
|
||||||
[MaxLength(100)]
|
[MaxLength(100)]
|
||||||
public string CharacterIdentification { get; set; }
|
public string CharacterIdentification { get; set; }
|
||||||
|
public string BannedUid { get; set; }
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
[Timestamp]
|
[Timestamp]
|
||||||
public byte[] Timestamp { get; set; }
|
public byte[] Timestamp { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user