diff --git a/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs b/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs new file mode 100644 index 0000000..b952ab0 --- /dev/null +++ b/Migrations/20240510202057_channelpermissions_partofchannel.Designer.cs @@ -0,0 +1,266 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using vassago.Models; + +#nullable disable + +namespace vassago.Migrations +{ + [DbContext(typeof(ChattingContext))] + [Migration("20240510202057_channelpermissions_partofchannel")] + partial class channelpermissions_partofchannel + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("vassago.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("ExternalId") + .HasColumnType("text"); + + b.Property("IsBot") + .HasColumnType("boolean"); + + b.Property("IsUserId") + .HasColumnType("uuid"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("SeenInChannelId") + .HasColumnType("uuid"); + + b.Property("Username") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("IsUserId"); + + b.HasIndex("SeenInChannelId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("vassago.Models.Attachment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Content") + .HasColumnType("bytea"); + + b.Property("ContentType") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("ExternalId") + .HasColumnType("numeric(20,0)"); + + b.Property("Filename") + .HasColumnType("text"); + + b.Property("MessageId") + .HasColumnType("uuid"); + + b.Property("Size") + .HasColumnType("integer"); + + b.Property("Source") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MessageId"); + + b.ToTable("Attachments"); + }); + + modelBuilder.Entity("vassago.Models.Channel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ChannelType") + .HasColumnType("integer"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("ExternalId") + .HasColumnType("text"); + + b.Property("LewdnessFilterLevel") + .HasColumnType("integer"); + + b.Property("LinksAllowed") + .HasColumnType("boolean"); + + b.Property("MaxAttachmentBytes") + .HasColumnType("numeric(20,0)"); + + b.Property("MaxTextChars") + .HasColumnType("bigint"); + + b.Property("MeannessFilterLevel") + .HasColumnType("integer"); + + b.Property("ParentChannelId") + .HasColumnType("uuid"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ReactionsPossible") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("ParentChannelId"); + + b.ToTable("Channels"); + }); + + modelBuilder.Entity("vassago.Models.Message", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActedOn") + .HasColumnType("boolean"); + + b.Property("AuthorId") + .HasColumnType("uuid"); + + b.Property("ChannelId") + .HasColumnType("uuid"); + + b.Property("Content") + .HasColumnType("text"); + + b.Property("ExternalId") + .HasColumnType("text"); + + b.Property("MentionsMe") + .HasColumnType("boolean"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("ChannelId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("vassago.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("vassago.Models.Account", b => + { + b.HasOne("vassago.Models.User", "IsUser") + .WithMany("Accounts") + .HasForeignKey("IsUserId"); + + b.HasOne("vassago.Models.Channel", "SeenInChannel") + .WithMany("Users") + .HasForeignKey("SeenInChannelId"); + + b.Navigation("IsUser"); + + b.Navigation("SeenInChannel"); + }); + + modelBuilder.Entity("vassago.Models.Attachment", b => + { + b.HasOne("vassago.Models.Message", "Message") + .WithMany("Attachments") + .HasForeignKey("MessageId"); + + b.Navigation("Message"); + }); + + modelBuilder.Entity("vassago.Models.Channel", b => + { + b.HasOne("vassago.Models.Channel", "ParentChannel") + .WithMany("SubChannels") + .HasForeignKey("ParentChannelId"); + + b.Navigation("ParentChannel"); + }); + + modelBuilder.Entity("vassago.Models.Message", b => + { + b.HasOne("vassago.Models.Account", "Author") + .WithMany() + .HasForeignKey("AuthorId"); + + b.HasOne("vassago.Models.Channel", "Channel") + .WithMany("Messages") + .HasForeignKey("ChannelId"); + + b.Navigation("Author"); + + b.Navigation("Channel"); + }); + + modelBuilder.Entity("vassago.Models.Channel", b => + { + b.Navigation("Messages"); + + b.Navigation("SubChannels"); + + b.Navigation("Users"); + }); + + modelBuilder.Entity("vassago.Models.Message", b => + { + b.Navigation("Attachments"); + }); + + modelBuilder.Entity("vassago.Models.User", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20240510202057_channelpermissions_partofchannel.cs b/Migrations/20240510202057_channelpermissions_partofchannel.cs new file mode 100644 index 0000000..7a8ef41 --- /dev/null +++ b/Migrations/20240510202057_channelpermissions_partofchannel.cs @@ -0,0 +1,228 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace vassago.Migrations +{ + /// + public partial class channelpermissions_partofchannel : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Accounts_FeaturePermissions_FeaturePermissionId", + table: "Accounts"); + + migrationBuilder.DropForeignKey( + name: "FK_Channels_ChannelPermissions_PermissionsId", + table: "Channels"); + + migrationBuilder.DropForeignKey( + name: "FK_Channels_FeaturePermissions_FeaturePermissionId", + table: "Channels"); + + migrationBuilder.DropForeignKey( + name: "FK_Users_FeaturePermissions_FeaturePermissionId", + table: "Users"); + + migrationBuilder.DropTable( + name: "ChannelPermissions"); + + migrationBuilder.DropTable( + name: "FeaturePermissions"); + + migrationBuilder.DropIndex( + name: "IX_Users_FeaturePermissionId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_Channels_FeaturePermissionId", + table: "Channels"); + + migrationBuilder.DropIndex( + name: "IX_Channels_PermissionsId", + table: "Channels"); + + migrationBuilder.DropIndex( + name: "IX_Accounts_FeaturePermissionId", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "FeaturePermissionId", + table: "Users"); + + migrationBuilder.DropColumn( + name: "FeaturePermissionId", + table: "Channels"); + + migrationBuilder.DropColumn( + name: "FeaturePermissionId", + table: "Accounts"); + + migrationBuilder.RenameColumn( + name: "PermissionsId", + table: "Channels", + newName: "MeannessFilterLevel"); + + migrationBuilder.AddColumn( + name: "LewdnessFilterLevel", + table: "Channels", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "LinksAllowed", + table: "Channels", + type: "boolean", + nullable: true); + + migrationBuilder.AddColumn( + name: "MaxAttachmentBytes", + table: "Channels", + type: "numeric(20,0)", + nullable: true); + + migrationBuilder.AddColumn( + name: "MaxTextChars", + table: "Channels", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "ReactionsPossible", + table: "Channels", + type: "boolean", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LewdnessFilterLevel", + table: "Channels"); + + migrationBuilder.DropColumn( + name: "LinksAllowed", + table: "Channels"); + + migrationBuilder.DropColumn( + name: "MaxAttachmentBytes", + table: "Channels"); + + migrationBuilder.DropColumn( + name: "MaxTextChars", + table: "Channels"); + + migrationBuilder.DropColumn( + name: "ReactionsPossible", + table: "Channels"); + + migrationBuilder.RenameColumn( + name: "MeannessFilterLevel", + table: "Channels", + newName: "PermissionsId"); + + migrationBuilder.AddColumn( + name: "FeaturePermissionId", + table: "Users", + type: "uuid", + nullable: true); + + migrationBuilder.AddColumn( + name: "FeaturePermissionId", + table: "Channels", + type: "uuid", + nullable: true); + + migrationBuilder.AddColumn( + name: "FeaturePermissionId", + table: "Accounts", + type: "uuid", + nullable: true); + + migrationBuilder.CreateTable( + name: "ChannelPermissions", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + LewdnessFilterLevel = table.Column(type: "integer", nullable: true), + LinksAllowed = table.Column(type: "boolean", nullable: true), + MaxAttachmentBytes = table.Column(type: "numeric(20,0)", nullable: true), + MaxTextChars = table.Column(type: "bigint", nullable: true), + MeannessFilterLevel = table.Column(type: "integer", nullable: true), + ReactionsPossible = table.Column(type: "boolean", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ChannelPermissions", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "FeaturePermissions", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Inheritable = table.Column(type: "boolean", nullable: false), + InternalName = table.Column(type: "text", nullable: true), + InternalTag = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FeaturePermissions", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Users_FeaturePermissionId", + table: "Users", + column: "FeaturePermissionId"); + + migrationBuilder.CreateIndex( + name: "IX_Channels_FeaturePermissionId", + table: "Channels", + column: "FeaturePermissionId"); + + migrationBuilder.CreateIndex( + name: "IX_Channels_PermissionsId", + table: "Channels", + column: "PermissionsId"); + + migrationBuilder.CreateIndex( + name: "IX_Accounts_FeaturePermissionId", + table: "Accounts", + column: "FeaturePermissionId"); + + migrationBuilder.AddForeignKey( + name: "FK_Accounts_FeaturePermissions_FeaturePermissionId", + table: "Accounts", + column: "FeaturePermissionId", + principalTable: "FeaturePermissions", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Channels_ChannelPermissions_PermissionsId", + table: "Channels", + column: "PermissionsId", + principalTable: "ChannelPermissions", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Channels_FeaturePermissions_FeaturePermissionId", + table: "Channels", + column: "FeaturePermissionId", + principalTable: "FeaturePermissions", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Users_FeaturePermissions_FeaturePermissionId", + table: "Users", + column: "FeaturePermissionId", + principalTable: "FeaturePermissions", + principalColumn: "Id"); + } + } +} diff --git a/Migrations/ChattingContextModelSnapshot.cs b/Migrations/ChattingContextModelSnapshot.cs index b4f89a1..cf8fd25 100644 --- a/Migrations/ChattingContextModelSnapshot.cs +++ b/Migrations/ChattingContextModelSnapshot.cs @@ -34,9 +34,6 @@ namespace vassago.Migrations b.Property("ExternalId") .HasColumnType("text"); - b.Property("FeaturePermissionId") - .HasColumnType("uuid"); - b.Property("IsBot") .HasColumnType("boolean"); @@ -54,8 +51,6 @@ namespace vassago.Migrations b.HasKey("Id"); - b.HasIndex("FeaturePermissionId"); - b.HasIndex("IsUserId"); b.HasIndex("SeenInChannelId"); @@ -115,37 +110,6 @@ namespace vassago.Migrations b.Property("ExternalId") .HasColumnType("text"); - b.Property("FeaturePermissionId") - .HasColumnType("uuid"); - - b.Property("ParentChannelId") - .HasColumnType("uuid"); - - b.Property("PermissionsId") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("FeaturePermissionId"); - - b.HasIndex("ParentChannelId"); - - b.HasIndex("PermissionsId"); - - b.ToTable("Channels"); - }); - - modelBuilder.Entity("vassago.Models.ChannelPermissions", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("LewdnessFilterLevel") .HasColumnType("integer"); @@ -161,32 +125,20 @@ namespace vassago.Migrations b.Property("MeannessFilterLevel") .HasColumnType("integer"); + b.Property("ParentChannelId") + .HasColumnType("uuid"); + + b.Property("Protocol") + .HasColumnType("text"); + b.Property("ReactionsPossible") .HasColumnType("boolean"); b.HasKey("Id"); - b.ToTable("ChannelPermissions"); - }); + b.HasIndex("ParentChannelId"); - modelBuilder.Entity("vassago.Models.FeaturePermission", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("Inheritable") - .HasColumnType("boolean"); - - b.Property("InternalName") - .HasColumnType("text"); - - b.Property("InternalTag") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("FeaturePermissions"); + b.ToTable("Channels"); }); modelBuilder.Entity("vassago.Models.Message", b => @@ -234,22 +186,13 @@ namespace vassago.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("FeaturePermissionId") - .HasColumnType("uuid"); - b.HasKey("Id"); - b.HasIndex("FeaturePermissionId"); - b.ToTable("Users"); }); modelBuilder.Entity("vassago.Models.Account", b => { - b.HasOne("vassago.Models.FeaturePermission", null) - .WithMany("RestrictedToAccounts") - .HasForeignKey("FeaturePermissionId"); - b.HasOne("vassago.Models.User", "IsUser") .WithMany("Accounts") .HasForeignKey("IsUserId"); @@ -274,21 +217,11 @@ namespace vassago.Migrations modelBuilder.Entity("vassago.Models.Channel", b => { - b.HasOne("vassago.Models.FeaturePermission", null) - .WithMany("RestrictedToChannels") - .HasForeignKey("FeaturePermissionId"); - b.HasOne("vassago.Models.Channel", "ParentChannel") .WithMany("SubChannels") .HasForeignKey("ParentChannelId"); - b.HasOne("vassago.Models.ChannelPermissions", "Permissions") - .WithMany() - .HasForeignKey("PermissionsId"); - b.Navigation("ParentChannel"); - - b.Navigation("Permissions"); }); modelBuilder.Entity("vassago.Models.Message", b => @@ -306,13 +239,6 @@ namespace vassago.Migrations b.Navigation("Channel"); }); - modelBuilder.Entity("vassago.Models.User", b => - { - b.HasOne("vassago.Models.FeaturePermission", null) - .WithMany("RestrictedToUsers") - .HasForeignKey("FeaturePermissionId"); - }); - modelBuilder.Entity("vassago.Models.Channel", b => { b.Navigation("Messages"); @@ -322,15 +248,6 @@ namespace vassago.Migrations b.Navigation("Users"); }); - modelBuilder.Entity("vassago.Models.FeaturePermission", b => - { - b.Navigation("RestrictedToAccounts"); - - b.Navigation("RestrictedToChannels"); - - b.Navigation("RestrictedToUsers"); - }); - modelBuilder.Entity("vassago.Models.Message", b => { b.Navigation("Attachments"); diff --git a/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs b/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs index 173ddfe..2f3ceda 100644 --- a/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs +++ b/ProtocolInterfaces/DiscordInterface/SlashCommandsHelper.cs @@ -9,7 +9,6 @@ using Discord.Net; namespace vassago.DiscordInterface { - public static class SlashCommandsHelper { private static List slashCommands = new List()