Préparation feature 2.0

This commit is contained in:
2025-11-01 22:46:55 +01:00
parent e484616ecd
commit b2b9ecad7b
10 changed files with 762 additions and 9 deletions

View File

@@ -51,6 +51,9 @@ public class MareDbContext : DbContext
public DbSet<CharaDataOriginalFile> CharaDataOriginalFiles { get; set; }
public DbSet<CharaDataPose> CharaDataPoses { get; set; }
public DbSet<CharaDataAllowance> CharaDataAllowances { get; set; }
public DbSet<McdfShare> McdfShares { get; set; }
public DbSet<McdfShareAllowedUser> McdfShareAllowedUsers { get; set; }
public DbSet<McdfShareAllowedGroup> McdfShareAllowedGroups { get; set; }
protected override void OnModelCreating(ModelBuilder mb)
{
@@ -127,5 +130,28 @@ public class MareDbContext : DbContext
mb.Entity<CharaDataAllowance>().HasIndex(c => c.ParentId);
mb.Entity<CharaDataAllowance>().HasOne(u => u.AllowedGroup).WithMany().HasForeignKey(u => u.AllowedGroupGID).OnDelete(DeleteBehavior.Cascade);
mb.Entity<CharaDataAllowance>().HasOne(u => u.AllowedUser).WithMany().HasForeignKey(u => u.AllowedUserUID).OnDelete(DeleteBehavior.Cascade);
mb.Entity<McdfShare>().ToTable("mcdf_shares");
mb.Entity<McdfShare>().HasIndex(s => s.OwnerUID);
mb.Entity<McdfShare>().HasOne(s => s.Owner).WithMany().HasForeignKey(s => s.OwnerUID).OnDelete(DeleteBehavior.Cascade);
mb.Entity<McdfShare>().Property(s => s.Description).HasColumnType("text");
mb.Entity<McdfShare>().Property(s => s.CipherData).HasColumnType("bytea");
mb.Entity<McdfShare>().Property(s => s.Nonce).HasColumnType("bytea");
mb.Entity<McdfShare>().Property(s => s.Salt).HasColumnType("bytea");
mb.Entity<McdfShare>().Property(s => s.Tag).HasColumnType("bytea");
mb.Entity<McdfShare>().Property(s => s.CreatedUtc).HasColumnType("timestamp with time zone");
mb.Entity<McdfShare>().Property(s => s.UpdatedUtc).HasColumnType("timestamp with time zone");
mb.Entity<McdfShare>().Property(s => s.ExpiresAtUtc).HasColumnType("timestamp with time zone");
mb.Entity<McdfShare>().Property(s => s.DownloadCount).HasColumnType("integer");
mb.Entity<McdfShare>().HasMany(s => s.AllowedIndividuals).WithOne(a => a.Share).HasForeignKey(a => a.ShareId).OnDelete(DeleteBehavior.Cascade);
mb.Entity<McdfShare>().HasMany(s => s.AllowedSyncshells).WithOne(a => a.Share).HasForeignKey(a => a.ShareId).OnDelete(DeleteBehavior.Cascade);
mb.Entity<McdfShareAllowedUser>().ToTable("mcdf_share_allowed_users");
mb.Entity<McdfShareAllowedUser>().HasKey(u => new { u.ShareId, u.AllowedIndividualUid });
mb.Entity<McdfShareAllowedUser>().HasIndex(u => u.AllowedIndividualUid);
mb.Entity<McdfShareAllowedGroup>().ToTable("mcdf_share_allowed_groups");
mb.Entity<McdfShareAllowedGroup>().HasKey(g => new { g.ShareId, g.AllowedGroupGid });
mb.Entity<McdfShareAllowedGroup>().HasIndex(g => g.AllowedGroupGid);
}
}

View File

@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MareSynchronosServer.Migrations
{
/// <inheritdoc />
public partial class SyncshellDiscovery : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "auto_detect_visible",
table: "groups",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "password_temporarily_disabled",
table: "groups",
type: "boolean",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "auto_detect_visible",
table: "groups");
migrationBuilder.DropColumn(
name: "password_temporarily_disabled",
table: "groups");
}
}
}

View File

@@ -0,0 +1,106 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MareSynchronosServer.Migrations
{
/// <inheritdoc />
public partial class McdfShare : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "mcdf_shares",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
owner_uid = table.Column<string>(type: "character varying(10)", nullable: false),
description = table.Column<string>(type: "text", nullable: false),
cipher_data = table.Column<byte[]>(type: "bytea", nullable: false),
nonce = table.Column<byte[]>(type: "bytea", nullable: false),
salt = table.Column<byte[]>(type: "bytea", nullable: false),
tag = table.Column<byte[]>(type: "bytea", nullable: false),
created_utc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
updated_utc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
expires_at_utc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
download_count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_mcdf_shares", x => x.id);
table.ForeignKey(
name: "fk_mcdf_shares_users_owner_uid",
column: x => x.owner_uid,
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "mcdf_share_allowed_groups",
columns: table => new
{
share_id = table.Column<Guid>(type: "uuid", nullable: false),
allowed_group_gid = table.Column<string>(type: "character varying(20)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_mcdf_share_allowed_groups", x => new { x.share_id, x.allowed_group_gid });
table.ForeignKey(
name: "fk_mcdf_share_allowed_groups_mcdf_shares_share_id",
column: x => x.share_id,
principalTable: "mcdf_shares",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "mcdf_share_allowed_users",
columns: table => new
{
share_id = table.Column<Guid>(type: "uuid", nullable: false),
allowed_individual_uid = table.Column<string>(type: "character varying(10)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_mcdf_share_allowed_users", x => new { x.share_id, x.allowed_individual_uid });
table.ForeignKey(
name: "fk_mcdf_share_allowed_users_mcdf_shares_share_id",
column: x => x.share_id,
principalTable: "mcdf_shares",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_mcdf_share_allowed_groups_allowed_group_gid",
table: "mcdf_share_allowed_groups",
column: "allowed_group_gid");
migrationBuilder.CreateIndex(
name: "ix_mcdf_share_allowed_users_allowed_individual_uid",
table: "mcdf_share_allowed_users",
column: "allowed_individual_uid");
migrationBuilder.CreateIndex(
name: "ix_mcdf_shares_owner_uid",
table: "mcdf_shares",
column: "owner_uid");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "mcdf_share_allowed_groups");
migrationBuilder.DropTable(
name: "mcdf_share_allowed_users");
migrationBuilder.DropTable(
name: "mcdf_shares");
}
}
}

View File

@@ -454,6 +454,10 @@ namespace MareSynchronosServer.Migrations
.HasColumnType("boolean")
.HasColumnName("disable_vfx");
b.Property<bool>("AutoDetectVisible")
.HasColumnType("boolean")
.HasColumnName("auto_detect_visible");
b.Property<string>("HashedPassword")
.HasColumnType("text")
.HasColumnName("hashed_password");
@@ -462,10 +466,22 @@ namespace MareSynchronosServer.Migrations
.HasColumnType("boolean")
.HasColumnName("is_temporary");
b.Property<bool>("PasswordTemporarilyDisabled")
.HasColumnType("boolean")
.HasColumnName("password_temporarily_disabled");
b.Property<bool>("InvitesEnabled")
.HasColumnType("boolean")
.HasColumnName("invites_enabled");
b.Property<bool>("AutoDetectVisible")
.HasColumnType("boolean")
.HasColumnName("auto_detect_visible");
b.Property<bool>("PasswordTemporarilyDisabled")
.HasColumnType("boolean")
.HasColumnName("password_temporarily_disabled");
b.Property<string>("OwnerUID")
.HasColumnType("character varying(10)")
.HasColumnName("owner_uid");
@@ -479,6 +495,99 @@ namespace MareSynchronosServer.Migrations
b.ToTable("groups", (string)null);
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShare", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<byte[]>("CipherData")
.HasColumnType("bytea")
.HasColumnName("cipher_data");
b.Property<DateTime>("CreatedUtc")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_utc");
b.Property<int>("DownloadCount")
.HasColumnType("integer")
.HasColumnName("download_count");
b.Property<string>("Description")
.HasColumnType("text")
.HasColumnName("description");
b.Property<DateTime?>("ExpiresAtUtc")
.HasColumnType("timestamp with time zone")
.HasColumnName("expires_at_utc");
b.Property<byte[]>("Nonce")
.HasColumnType("bytea")
.HasColumnName("nonce");
b.Property<string>("OwnerUID")
.HasColumnType("character varying(10)")
.HasColumnName("owner_uid");
b.Property<byte[]>("Salt")
.HasColumnType("bytea")
.HasColumnName("salt");
b.Property<byte[]>("Tag")
.HasColumnType("bytea")
.HasColumnName("tag");
b.Property<DateTime?>("UpdatedUtc")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_utc");
b.HasKey("Id")
.HasName("pk_mcdf_shares");
b.HasIndex("OwnerUID")
.HasDatabaseName("ix_mcdf_shares_owner_uid");
b.ToTable("mcdf_shares", (string)null);
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShareAllowedGroup", b =>
{
b.Property<Guid>("ShareId")
.HasColumnType("uuid")
.HasColumnName("share_id");
b.Property<string>("AllowedGroupGid")
.HasColumnType("character varying(20)")
.HasColumnName("allowed_group_gid");
b.HasKey("ShareId", "AllowedGroupGid")
.HasName("pk_mcdf_share_allowed_groups");
b.HasIndex("AllowedGroupGid")
.HasDatabaseName("ix_mcdf_share_allowed_groups_allowed_group_gid");
b.ToTable("mcdf_share_allowed_groups", (string)null);
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShareAllowedUser", b =>
{
b.Property<Guid>("ShareId")
.HasColumnType("uuid")
.HasColumnName("share_id");
b.Property<string>("AllowedIndividualUid")
.HasColumnType("character varying(10)")
.HasColumnName("allowed_individual_uid");
b.HasKey("ShareId", "AllowedIndividualUid")
.HasName("pk_mcdf_share_allowed_users");
b.HasIndex("AllowedIndividualUid")
.HasDatabaseName("ix_mcdf_share_allowed_users_allowed_individual_uid");
b.ToTable("mcdf_share_allowed_users", (string)null);
});
modelBuilder.Entity("MareSynchronosShared.Models.GroupBan", b =>
{
b.Property<string>("GroupGID")
@@ -745,6 +854,13 @@ namespace MareSynchronosServer.Migrations
b.Navigation("User");
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShare", b =>
{
b.Navigation("AllowedIndividuals");
b.Navigation("AllowedSyncshells");
});
modelBuilder.Entity("MareSynchronosShared.Models.CharaData", b =>
{
b.HasOne("MareSynchronosShared.Models.User", "Uploader")
@@ -943,6 +1059,42 @@ namespace MareSynchronosServer.Migrations
b.Navigation("Group");
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShare", b =>
{
b.HasOne("MareSynchronosShared.Models.User", "Owner")
.WithMany()
.HasForeignKey("OwnerUID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_mcdf_shares_users_owner_uid");
b.Navigation("Owner");
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShareAllowedGroup", b =>
{
b.HasOne("MareSynchronosShared.Models.McdfShare", "Share")
.WithMany("AllowedSyncshells")
.HasForeignKey("ShareId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_mcdf_share_allowed_groups_mcdf_shares_share_id");
b.Navigation("Share");
});
modelBuilder.Entity("MareSynchronosShared.Models.McdfShareAllowedUser", b =>
{
b.HasOne("MareSynchronosShared.Models.McdfShare", "Share")
.WithMany("AllowedIndividuals")
.HasForeignKey("ShareId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_mcdf_share_allowed_users_mcdf_shares_share_id");
b.Navigation("Share");
});
modelBuilder.Entity("MareSynchronosShared.Models.LodeStoneAuth", b =>
{
b.HasOne("MareSynchronosShared.Models.User", "User")

View File

@@ -19,4 +19,6 @@ public class Group
public bool DisableVFX { get; set; }
public bool IsTemporary { get; set; }
public DateTime? ExpiresAt { get; set; }
public bool AutoDetectVisible { get; set; }
public bool PasswordTemporarilyDisabled { get; set; }
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace MareSynchronosShared.Models;
public class McdfShare
{
[Key]
public Guid Id { get; set; }
[MaxLength(10)]
public string OwnerUID { get; set; } = string.Empty;
public User Owner { get; set; } = null!;
public string Description { get; set; } = string.Empty;
public byte[] CipherData { get; set; } = Array.Empty<byte>();
public byte[] Nonce { get; set; } = Array.Empty<byte>();
public byte[] Salt { get; set; } = Array.Empty<byte>();
public byte[] Tag { get; set; } = Array.Empty<byte>();
public DateTime CreatedUtc { get; set; }
public DateTime? UpdatedUtc { get; set; }
public DateTime? ExpiresAtUtc { get; set; }
public int DownloadCount { get; set; }
public ICollection<McdfShareAllowedUser> AllowedIndividuals { get; set; } = new HashSet<McdfShareAllowedUser>();
public ICollection<McdfShareAllowedGroup> AllowedSyncshells { get; set; } = new HashSet<McdfShareAllowedGroup>();
}
public class McdfShareAllowedUser
{
public Guid ShareId { get; set; }
public McdfShare Share { get; set; } = null!;
[MaxLength(10)]
public string AllowedIndividualUid { get; set; } = string.Empty;
}
public class McdfShareAllowedGroup
{
public Guid ShareId { get; set; }
public McdfShare Share { get; set; } = null!;
[MaxLength(20)]
public string AllowedGroupGid { get; set; } = string.Empty;
}