Compare commits
5 Commits
unbanbydis
...
db-changes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b669e2cb24 | ||
|
|
0df7ee424d | ||
|
|
81261fae49 | ||
| d7e8be97ff | |||
| 8217d99478 |
@@ -92,13 +92,22 @@ public partial class LightlessWizardModule
|
|||||||
var desiredVanityUid = modal.DesiredVanityUID;
|
var desiredVanityUid = modal.DesiredVanityUID;
|
||||||
using var db = await GetDbContext().ConfigureAwait(false);
|
using var db = await GetDbContext().ConfigureAwait(false);
|
||||||
bool canAddVanityId = !db.Users.Any(u => u.UID == modal.DesiredVanityUID || u.Alias == modal.DesiredVanityUID);
|
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)
|
if (!rgx.Match(desiredVanityUid).Success)
|
||||||
{
|
{
|
||||||
eb.WithColor(Color.Red);
|
eb.WithColor(Color.Red);
|
||||||
eb.WithTitle("Invalid Vanity UID");
|
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("Cancel", "wizard-vanity", ButtonStyle.Secondary, emote: new Emoji("❌"));
|
||||||
cb.WithButton("Pick Different UID", "wizard-vanity-uid-set:" + uid, ButtonStyle.Primary, 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";
|
public string Title => "Set Vanity UID";
|
||||||
|
|
||||||
[InputLabel("Set your 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; }
|
public string DesiredVanityUID { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class LightlessDbContext : DbContext
|
|||||||
public DbSet<CharaDataOriginalFile> CharaDataOriginalFiles { get; set; }
|
public DbSet<CharaDataOriginalFile> CharaDataOriginalFiles { get; set; }
|
||||||
public DbSet<CharaDataPose> CharaDataPoses { get; set; }
|
public DbSet<CharaDataPose> CharaDataPoses { get; set; }
|
||||||
public DbSet<CharaDataAllowance> CharaDataAllowances { get; set; }
|
public DbSet<CharaDataAllowance> CharaDataAllowances { get; set; }
|
||||||
|
public DbSet<GroupProfile> GroupProfiles { get; set; }
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder mb)
|
protected override void OnModelCreating(ModelBuilder mb)
|
||||||
{
|
{
|
||||||
@@ -70,6 +71,14 @@ public class LightlessDbContext : DbContext
|
|||||||
mb.Entity<BannedRegistrations>().ToTable("banned_registrations");
|
mb.Entity<BannedRegistrations>().ToTable("banned_registrations");
|
||||||
mb.Entity<Group>().ToTable("groups");
|
mb.Entity<Group>().ToTable("groups");
|
||||||
mb.Entity<Group>().HasIndex(c => c.OwnerUID);
|
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>().ToTable("group_pairs");
|
||||||
mb.Entity<GroupPair>().HasKey(u => new { u.GroupGID, u.GroupUserUID });
|
mb.Entity<GroupPair>().HasKey(u => new { u.GroupGID, u.GroupUserUID });
|
||||||
mb.Entity<GroupPair>().HasIndex(c => c.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>().HasKey(u => new { u.GroupGID, u.BannedUserUID });
|
||||||
mb.Entity<GroupBan>().HasIndex(c => c.BannedUserUID);
|
mb.Entity<GroupBan>().HasIndex(c => c.BannedUserUID);
|
||||||
mb.Entity<GroupBan>().HasIndex(c => c.GroupGID);
|
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>().ToTable("group_temp_invites");
|
||||||
mb.Entity<GroupTempInvite>().HasKey(u => new { u.GroupGID, u.Invite });
|
mb.Entity<GroupTempInvite>().HasKey(u => new { u.GroupGID, u.Invite });
|
||||||
mb.Entity<GroupTempInvite>().HasIndex(c => c.GroupGID);
|
mb.Entity<GroupTempInvite>().HasIndex(c => c.GroupGID);
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -430,6 +430,12 @@ namespace LightlessSyncServer.Migrations
|
|||||||
.HasColumnType("character varying(50)")
|
.HasColumnType("character varying(50)")
|
||||||
.HasColumnName("alias");
|
.HasColumnName("alias");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created_date")
|
||||||
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||||
|
|
||||||
b.Property<string>("HashedPassword")
|
b.Property<string>("HashedPassword")
|
||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasColumnName("hashed_password");
|
.HasColumnName("hashed_password");
|
||||||
@@ -510,6 +516,10 @@ namespace LightlessSyncServer.Migrations
|
|||||||
.HasColumnType("character varying(10)")
|
.HasColumnType("character varying(10)")
|
||||||
.HasColumnName("group_user_uid");
|
.HasColumnName("group_user_uid");
|
||||||
|
|
||||||
|
b.Property<bool>("FromFinder")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("from_finder");
|
||||||
|
|
||||||
b.Property<bool>("IsModerator")
|
b.Property<bool>("IsModerator")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
.HasColumnName("is_moderator");
|
.HasColumnName("is_moderator");
|
||||||
@@ -518,6 +528,10 @@ namespace LightlessSyncServer.Migrations
|
|||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
.HasColumnName("is_pinned");
|
.HasColumnName("is_pinned");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("JoinedGroupOn")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("joined_group_on");
|
||||||
|
|
||||||
b.HasKey("GroupGID", "GroupUserUID")
|
b.HasKey("GroupGID", "GroupUserUID")
|
||||||
.HasName("pk_group_pairs");
|
.HasName("pk_group_pairs");
|
||||||
|
|
||||||
@@ -568,6 +582,34 @@ namespace LightlessSyncServer.Migrations
|
|||||||
b.ToTable("group_pair_preferred_permissions", (string)null);
|
b.ToTable("group_pair_preferred_permissions", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LightlessSyncShared.Models.GroupProfile", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("GroupGID")
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("character varying(20)")
|
||||||
|
.HasColumnName("group_gid");
|
||||||
|
|
||||||
|
b.Property<string>("Base64GroupProfileImage")
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("base64group_profile_image");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("description");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("tags");
|
||||||
|
|
||||||
|
b.HasKey("GroupGID")
|
||||||
|
.HasName("pk_group_profiles");
|
||||||
|
|
||||||
|
b.HasIndex("GroupGID")
|
||||||
|
.HasDatabaseName("ix_group_profiles_group_gid");
|
||||||
|
|
||||||
|
b.ToTable("group_profiles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LightlessSyncShared.Models.GroupTempInvite", b =>
|
modelBuilder.Entity("LightlessSyncShared.Models.GroupTempInvite", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("GroupGID")
|
b.Property<string>("GroupGID")
|
||||||
@@ -1010,6 +1052,16 @@ namespace LightlessSyncServer.Migrations
|
|||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LightlessSyncShared.Models.GroupProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LightlessSyncShared.Models.Group", "Group")
|
||||||
|
.WithOne("Profile")
|
||||||
|
.HasForeignKey("LightlessSyncShared.Models.GroupProfile", "GroupGID")
|
||||||
|
.HasConstraintName("fk_group_profiles_groups_group_gid");
|
||||||
|
|
||||||
|
b.Navigation("Group");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LightlessSyncShared.Models.GroupTempInvite", b =>
|
modelBuilder.Entity("LightlessSyncShared.Models.GroupTempInvite", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("LightlessSyncShared.Models.Group", "Group")
|
b.HasOne("LightlessSyncShared.Models.Group", "Group")
|
||||||
@@ -1089,6 +1141,11 @@ namespace LightlessSyncServer.Migrations
|
|||||||
|
|
||||||
b.Navigation("Poses");
|
b.Navigation("Poses");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LightlessSyncShared.Models.Group", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Profile");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ public class Group
|
|||||||
public User Owner { get; set; }
|
public User Owner { get; set; }
|
||||||
[MaxLength(50)]
|
[MaxLength(50)]
|
||||||
public string Alias { get; set; }
|
public string Alias { get; set; }
|
||||||
|
public GroupProfile? Profile { get; set; }
|
||||||
public bool InvitesEnabled { get; set; }
|
public bool InvitesEnabled { get; set; }
|
||||||
public string HashedPassword { get; set; }
|
public string HashedPassword { get; set; }
|
||||||
public bool PreferDisableSounds { get; set; }
|
public bool PreferDisableSounds { get; set; }
|
||||||
public bool PreferDisableAnimations { get; set; }
|
public bool PreferDisableAnimations { get; set; }
|
||||||
public bool PreferDisableVFX { 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 User GroupUser { get; set; }
|
||||||
public bool IsPinned { get; set; }
|
public bool IsPinned { get; set; }
|
||||||
public bool IsModerator { 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; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user