From 3611b745ff1ef0115c08ab007b5b080678d3cf0c Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Fri, 24 Mar 2023 20:11:18 +0100 Subject: [PATCH] Revert "Merge branch 'PleskIntegration' into main" This reverts commit 18c205d8a021e9aabea3aeaf613f8d907b0e6a93, reversing changes made to c5be86b695b986166aaedbc4389de3c4ce529ba8. --- Moonlight/App/Database/DataContext.cs | 1 - .../App/Database/Entities/PleskServer.cs | 9 - Moonlight/App/Database/Entities/Website.cs | 9 +- ...0230322091250_AddedPleskServer.Designer.cs | 1085 ---------------- .../20230322091250_AddedPleskServer.cs | 39 - ...2093852_AddedNameToPleskServer.Designer.cs | 1089 ----------------- .../20230322093852_AddedNameToPleskServer.cs | 29 - ...322094525_SwitchedToPleskModel.Designer.cs | 1073 ---------------- .../20230322094525_SwitchedToPleskModel.cs | 124 -- ...84631_AddedBaseDomainToWebsite.Designer.cs | 1077 ---------------- ...20230323084631_AddedBaseDomainToWebsite.cs | 29 - .../Migrations/DataContextModelSnapshot.cs | 65 +- Moonlight/App/Exceptions/PleskException.cs | 32 - Moonlight/App/Helpers/PleskApiHelper.cs | 120 -- .../App/Models/Plesk/Requests/CreateDomain.cs | 42 - .../App/Models/Plesk/Resources/Client.cs | 39 - .../App/Models/Plesk/Resources/Identifier.cs | 12 - .../App/Repositories/PleskServerRepository.cs | 44 - Moonlight/App/Services/WebsiteService.cs | 107 +- Moonlight/Program.cs | 2 - .../Shared/Components/Forms/WSelect.razor | 43 - .../Navigations/AdminWebsiteNavigation.razor | 22 - .../Components/Partials/SidebarMenu.razor | 29 +- .../Shared/Views/Admin/Websites/Index.razor | 93 -- .../Shared/Views/Admin/Websites/New.razor | 122 -- .../Views/Admin/Websites/Servers/Index.razor | 58 - .../Views/Admin/Websites/Servers/New.razor | 64 - Moonlight/resources/lang/de_de.lang | 11 - 28 files changed, 75 insertions(+), 5394 deletions(-) delete mode 100644 Moonlight/App/Database/Entities/PleskServer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.Designer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.Designer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.Designer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.cs delete mode 100644 Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.Designer.cs delete mode 100644 Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.cs delete mode 100644 Moonlight/App/Exceptions/PleskException.cs delete mode 100644 Moonlight/App/Helpers/PleskApiHelper.cs delete mode 100644 Moonlight/App/Models/Plesk/Requests/CreateDomain.cs delete mode 100644 Moonlight/App/Models/Plesk/Resources/Client.cs delete mode 100644 Moonlight/App/Models/Plesk/Resources/Identifier.cs delete mode 100644 Moonlight/App/Repositories/PleskServerRepository.cs delete mode 100644 Moonlight/Shared/Components/Forms/WSelect.razor delete mode 100644 Moonlight/Shared/Components/Navigations/AdminWebsiteNavigation.razor delete mode 100644 Moonlight/Shared/Views/Admin/Websites/Index.razor delete mode 100644 Moonlight/Shared/Views/Admin/Websites/New.razor delete mode 100644 Moonlight/Shared/Views/Admin/Websites/Servers/Index.razor delete mode 100644 Moonlight/Shared/Views/Admin/Websites/Servers/New.razor diff --git a/Moonlight/App/Database/DataContext.cs b/Moonlight/App/Database/DataContext.cs index 1311d16e..c8575c49 100644 --- a/Moonlight/App/Database/DataContext.cs +++ b/Moonlight/App/Database/DataContext.cs @@ -42,7 +42,6 @@ public class DataContext : DbContext public DbSet AaPanels { get; set; } public DbSet Websites { get; set; } public DbSet DdosAttacks { get; set; } - public DbSet PleskServers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/Moonlight/App/Database/Entities/PleskServer.cs b/Moonlight/App/Database/Entities/PleskServer.cs deleted file mode 100644 index 1c88ff5f..00000000 --- a/Moonlight/App/Database/Entities/PleskServer.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class PleskServer -{ - public int Id { get; set; } - public string BaseUrl { get; set; } = ""; - public string ApiKey { get; set; } = ""; - public string Name { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Website.cs b/Moonlight/App/Database/Entities/Website.cs index 7672dd09..d5c86d97 100644 --- a/Moonlight/App/Database/Entities/Website.cs +++ b/Moonlight/App/Database/Entities/Website.cs @@ -3,8 +3,11 @@ public class Website { public int Id { get; set; } - public int PleskId { get; set; } + public int InternalAaPanelId { get; set; } + public AaPanel AaPanel { get; set; } public User Owner { get; set; } - public PleskServer PleskServer { get; set; } - public string BaseDomain { get; set; } + public string DomainName { get; set; } + public string PhpVersion { get; set; } + public string FtpUsername { get; set; } + public string FtpPassword { get; set; } } \ No newline at end of file diff --git a/Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.Designer.cs b/Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.Designer.cs deleted file mode 100644 index 5276f339..00000000 --- a/Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.Designer.cs +++ /dev/null @@ -1,1085 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.App.Database; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20230322091250_AddedPleskServer")] - partial class AddedPleskServer - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Moonlight.App.Database.Entities.AaPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Url") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AaPanels"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("InternalAaPanelId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AaPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Data") - .HasColumnType("bigint"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Ongoing") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.ToTable("DdosAttacks"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Default") - .HasColumnType("tinyint(1)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("DockerImages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("SharedDomainId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("SharedDomainId"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Allocations") - .HasColumnType("int"); - - b.Property("ConfigFiles") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallEntrypoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Startup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StartupDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TagsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("ImageTags"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("ImageVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LoadingMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("LoadingMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("AuditLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.ErrorLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Class") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Stacktrace") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ErrorLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.SecurityLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("SecurityLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("MoonlightDaemonPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SftpPort") - .HasColumnType("int"); - - b.Property("Ssl") - .HasColumnType("tinyint(1)"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("NodeAllocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Action") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NotificationClientId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NotificationClientId"); - - b.ToTable("NotificationActions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationClients"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.PleskServer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("BaseUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PleskServers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Revokes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("bigint"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Installing") - .HasColumnType("tinyint(1)"); - - b.Property("MainAllocationId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("bigint"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OverrideStartup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Suspended") - .HasColumnType("tinyint(1)"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("MainAllocationId"); - - b.HasIndex("NodeId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Bytes") - .HasColumnType("bigint"); - - b.Property("Created") - .HasColumnType("tinyint(1)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerBackups"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SharedDomain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudflareId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SharedDomains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SellPassId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("SubscriptionLimits"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("IsSupport") - .HasColumnType("tinyint(1)"); - - b.Property("IsSystem") - .HasColumnType("tinyint(1)"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Country") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordDiscriminator") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("DiscordUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.Property("SubscriptionSince") - .HasColumnType("datetime(6)"); - - b.Property("SupportPending") - .HasColumnType("tinyint(1)"); - - b.Property("TokenValidTime") - .HasColumnType("datetime(6)"); - - b.Property("TotpEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("TotpSecret") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("DomainName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InternalAaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("PhpVersion") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("AaPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Websites"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") - .WithMany() - .HasForeignKey("AaPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AaPanel"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Node"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("DockerImages") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.SharedDomain", "SharedDomain") - .WithMany() - .HasForeignKey("SharedDomainId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("SharedDomain"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Variables") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", null) - .WithMany("Allocations") - .HasForeignKey("NodeId"); - - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Allocations") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.HasOne("Moonlight.App.Database.Entities.Notification.NotificationClient", "NotificationClient") - .WithMany() - .HasForeignKey("NotificationClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NotificationClient"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.NodeAllocation", "MainAllocation") - .WithMany() - .HasForeignKey("MainAllocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - - b.Navigation("MainAllocation"); - - b.Navigation("Node"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Backups") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Variables") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Subscription", null) - .WithMany("Limits") - .HasForeignKey("SubscriptionId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId"); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.HasOne("Moonlight.App.Database.Entities.Subscription", "Subscription") - .WithMany() - .HasForeignKey("SubscriptionId"); - - b.Navigation("Subscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") - .WithMany() - .HasForeignKey("AaPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AaPanel"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Navigation("Allocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Navigation("Allocations"); - - b.Navigation("Backups"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Navigation("Limits"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.cs b/Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.cs deleted file mode 100644 index a6d4baf7..00000000 --- a/Moonlight/App/Database/Migrations/20230322091250_AddedPleskServer.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedPleskServer : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "PleskServers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - BaseUrl = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApiKey = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_PleskServers", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PleskServers"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.Designer.cs b/Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.Designer.cs deleted file mode 100644 index d4a778e6..00000000 --- a/Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.Designer.cs +++ /dev/null @@ -1,1089 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.App.Database; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20230322093852_AddedNameToPleskServer")] - partial class AddedNameToPleskServer - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Moonlight.App.Database.Entities.AaPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Url") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AaPanels"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("InternalAaPanelId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AaPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Data") - .HasColumnType("bigint"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Ongoing") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.ToTable("DdosAttacks"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Default") - .HasColumnType("tinyint(1)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("DockerImages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("SharedDomainId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("SharedDomainId"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Allocations") - .HasColumnType("int"); - - b.Property("ConfigFiles") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallEntrypoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Startup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StartupDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TagsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("ImageTags"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("ImageVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LoadingMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("LoadingMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("AuditLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.ErrorLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Class") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Stacktrace") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ErrorLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.SecurityLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("SecurityLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("MoonlightDaemonPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SftpPort") - .HasColumnType("int"); - - b.Property("Ssl") - .HasColumnType("tinyint(1)"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("NodeAllocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Action") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NotificationClientId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NotificationClientId"); - - b.ToTable("NotificationActions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationClients"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.PleskServer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("BaseUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PleskServers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Revokes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("bigint"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Installing") - .HasColumnType("tinyint(1)"); - - b.Property("MainAllocationId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("bigint"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OverrideStartup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Suspended") - .HasColumnType("tinyint(1)"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("MainAllocationId"); - - b.HasIndex("NodeId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Bytes") - .HasColumnType("bigint"); - - b.Property("Created") - .HasColumnType("tinyint(1)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerBackups"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SharedDomain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudflareId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SharedDomains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SellPassId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("SubscriptionLimits"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("IsSupport") - .HasColumnType("tinyint(1)"); - - b.Property("IsSystem") - .HasColumnType("tinyint(1)"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Country") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordDiscriminator") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("DiscordUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.Property("SubscriptionSince") - .HasColumnType("datetime(6)"); - - b.Property("SupportPending") - .HasColumnType("tinyint(1)"); - - b.Property("TokenValidTime") - .HasColumnType("datetime(6)"); - - b.Property("TotpEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("TotpSecret") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("DomainName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InternalAaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("PhpVersion") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("AaPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Websites"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") - .WithMany() - .HasForeignKey("AaPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AaPanel"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Node"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("DockerImages") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.SharedDomain", "SharedDomain") - .WithMany() - .HasForeignKey("SharedDomainId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("SharedDomain"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Variables") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", null) - .WithMany("Allocations") - .HasForeignKey("NodeId"); - - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Allocations") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.HasOne("Moonlight.App.Database.Entities.Notification.NotificationClient", "NotificationClient") - .WithMany() - .HasForeignKey("NotificationClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NotificationClient"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.NodeAllocation", "MainAllocation") - .WithMany() - .HasForeignKey("MainAllocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - - b.Navigation("MainAllocation"); - - b.Navigation("Node"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Backups") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Variables") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Subscription", null) - .WithMany("Limits") - .HasForeignKey("SubscriptionId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId"); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.HasOne("Moonlight.App.Database.Entities.Subscription", "Subscription") - .WithMany() - .HasForeignKey("SubscriptionId"); - - b.Navigation("Subscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") - .WithMany() - .HasForeignKey("AaPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AaPanel"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Navigation("Allocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Navigation("Allocations"); - - b.Navigation("Backups"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Navigation("Limits"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.cs b/Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.cs deleted file mode 100644 index d19f2dc0..00000000 --- a/Moonlight/App/Database/Migrations/20230322093852_AddedNameToPleskServer.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedNameToPleskServer : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Name", - table: "PleskServers", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Name", - table: "PleskServers"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.Designer.cs b/Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.Designer.cs deleted file mode 100644 index ca85bf2f..00000000 --- a/Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.Designer.cs +++ /dev/null @@ -1,1073 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.App.Database; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20230322094525_SwitchedToPleskModel")] - partial class SwitchedToPleskModel - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Moonlight.App.Database.Entities.AaPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Url") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AaPanels"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("InternalAaPanelId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AaPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Data") - .HasColumnType("bigint"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Ongoing") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.ToTable("DdosAttacks"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Default") - .HasColumnType("tinyint(1)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("DockerImages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("SharedDomainId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("SharedDomainId"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Allocations") - .HasColumnType("int"); - - b.Property("ConfigFiles") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallEntrypoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Startup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StartupDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TagsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("ImageTags"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("ImageVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LoadingMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("LoadingMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("AuditLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.ErrorLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Class") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Stacktrace") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ErrorLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.SecurityLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("SecurityLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("MoonlightDaemonPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SftpPort") - .HasColumnType("int"); - - b.Property("Ssl") - .HasColumnType("tinyint(1)"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("NodeAllocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Action") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NotificationClientId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NotificationClientId"); - - b.ToTable("NotificationActions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationClients"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.PleskServer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("BaseUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PleskServers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Revokes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("bigint"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Installing") - .HasColumnType("tinyint(1)"); - - b.Property("MainAllocationId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("bigint"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OverrideStartup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Suspended") - .HasColumnType("tinyint(1)"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("MainAllocationId"); - - b.HasIndex("NodeId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Bytes") - .HasColumnType("bigint"); - - b.Property("Created") - .HasColumnType("tinyint(1)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerBackups"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SharedDomain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudflareId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SharedDomains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SellPassId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("SubscriptionLimits"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("IsSupport") - .HasColumnType("tinyint(1)"); - - b.Property("IsSystem") - .HasColumnType("tinyint(1)"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Country") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordDiscriminator") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("DiscordUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.Property("SubscriptionSince") - .HasColumnType("datetime(6)"); - - b.Property("SupportPending") - .HasColumnType("tinyint(1)"); - - b.Property("TokenValidTime") - .HasColumnType("datetime(6)"); - - b.Property("TotpEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("TotpSecret") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("PleskId") - .HasColumnType("int"); - - b.Property("PleskServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("PleskServerId"); - - b.ToTable("Websites"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") - .WithMany() - .HasForeignKey("AaPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AaPanel"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Node"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("DockerImages") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.SharedDomain", "SharedDomain") - .WithMany() - .HasForeignKey("SharedDomainId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("SharedDomain"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Variables") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", null) - .WithMany("Allocations") - .HasForeignKey("NodeId"); - - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Allocations") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.HasOne("Moonlight.App.Database.Entities.Notification.NotificationClient", "NotificationClient") - .WithMany() - .HasForeignKey("NotificationClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NotificationClient"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.NodeAllocation", "MainAllocation") - .WithMany() - .HasForeignKey("MainAllocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - - b.Navigation("MainAllocation"); - - b.Navigation("Node"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Backups") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Variables") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Subscription", null) - .WithMany("Limits") - .HasForeignKey("SubscriptionId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId"); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.HasOne("Moonlight.App.Database.Entities.Subscription", "Subscription") - .WithMany() - .HasForeignKey("SubscriptionId"); - - b.Navigation("Subscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.PleskServer", "PleskServer") - .WithMany() - .HasForeignKey("PleskServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("PleskServer"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Navigation("Allocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Navigation("Allocations"); - - b.Navigation("Backups"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Navigation("Limits"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.cs b/Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.cs deleted file mode 100644 index 4f02ef51..00000000 --- a/Moonlight/App/Database/Migrations/20230322094525_SwitchedToPleskModel.cs +++ /dev/null @@ -1,124 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class SwitchedToPleskModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Websites_AaPanels_AaPanelId", - table: "Websites"); - - migrationBuilder.DropIndex( - name: "IX_Websites_AaPanelId", - table: "Websites"); - - migrationBuilder.DropColumn( - name: "DomainName", - table: "Websites"); - - migrationBuilder.DropColumn( - name: "FtpPassword", - table: "Websites"); - - migrationBuilder.DropColumn( - name: "FtpUsername", - table: "Websites"); - - migrationBuilder.DropColumn( - name: "PhpVersion", - table: "Websites"); - - migrationBuilder.RenameColumn( - name: "InternalAaPanelId", - table: "Websites", - newName: "PleskServerId"); - - migrationBuilder.RenameColumn( - name: "AaPanelId", - table: "Websites", - newName: "PleskId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_PleskServerId", - table: "Websites", - column: "PleskServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Websites_PleskServers_PleskServerId", - table: "Websites", - column: "PleskServerId", - principalTable: "PleskServers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Websites_PleskServers_PleskServerId", - table: "Websites"); - - migrationBuilder.DropIndex( - name: "IX_Websites_PleskServerId", - table: "Websites"); - - migrationBuilder.RenameColumn( - name: "PleskServerId", - table: "Websites", - newName: "InternalAaPanelId"); - - migrationBuilder.RenameColumn( - name: "PleskId", - table: "Websites", - newName: "AaPanelId"); - - migrationBuilder.AddColumn( - name: "DomainName", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "FtpPassword", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "FtpUsername", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "PhpVersion", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_AaPanelId", - table: "Websites", - column: "AaPanelId"); - - migrationBuilder.AddForeignKey( - name: "FK_Websites_AaPanels_AaPanelId", - table: "Websites", - column: "AaPanelId", - principalTable: "AaPanels", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.Designer.cs b/Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.Designer.cs deleted file mode 100644 index 21da56db..00000000 --- a/Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.Designer.cs +++ /dev/null @@ -1,1077 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.App.Database; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20230323084631_AddedBaseDomainToWebsite")] - partial class AddedBaseDomainToWebsite - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Moonlight.App.Database.Entities.AaPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Url") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("AaPanels"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("InternalAaPanelId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AaPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Data") - .HasColumnType("bigint"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Ongoing") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.ToTable("DdosAttacks"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Default") - .HasColumnType("tinyint(1)"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("DockerImages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("SharedDomainId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("SharedDomainId"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Allocations") - .HasColumnType("int"); - - b.Property("ConfigFiles") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallDockerImage") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallEntrypoint") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("InstallScript") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Startup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StartupDetection") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StopCommand") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TagsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.ToTable("Images"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("ImageTags"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("DefaultValue") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.ToTable("ImageVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LoadingMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("LoadingMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("AuditLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.ErrorLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Class") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Stacktrace") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.HasKey("Id"); - - b.ToTable("ErrorLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.LogsEntries.SecurityLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("JsonData") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("System") - .HasColumnType("tinyint(1)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("SecurityLog"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Fqdn") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HttpPort") - .HasColumnType("int"); - - b.Property("MoonlightDaemonPort") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SftpPort") - .HasColumnType("int"); - - b.Property("Ssl") - .HasColumnType("tinyint(1)"); - - b.Property("Token") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Nodes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NodeId"); - - b.HasIndex("ServerId"); - - b.ToTable("NodeAllocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Action") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NotificationClientId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NotificationClientId"); - - b.ToTable("NotificationActions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationClients"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.PleskServer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("BaseUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PleskServers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Identifier") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Revokes"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("bigint"); - - b.Property("DockerImageIndex") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Installing") - .HasColumnType("tinyint(1)"); - - b.Property("MainAllocationId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("bigint"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("NodeId") - .HasColumnType("int"); - - b.Property("OverrideStartup") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Suspended") - .HasColumnType("tinyint(1)"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("MainAllocationId"); - - b.HasIndex("NodeId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Servers"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Bytes") - .HasColumnType("bigint"); - - b.Property("Created") - .HasColumnType("tinyint(1)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Uuid") - .HasColumnType("char(36)"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerBackups"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Key") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.Property("Value") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("ServerVariables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SharedDomain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudflareId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SharedDomains"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SellPassId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Amount") - .HasColumnType("int"); - - b.Property("Cpu") - .HasColumnType("int"); - - b.Property("Disk") - .HasColumnType("int"); - - b.Property("ImageId") - .HasColumnType("int"); - - b.Property("Memory") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("SubscriptionLimits"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("IsSupport") - .HasColumnType("tinyint(1)"); - - b.Property("IsSystem") - .HasColumnType("tinyint(1)"); - - b.Property("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Country") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordDiscriminator") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("DiscordUsername") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .HasColumnType("int"); - - b.Property("SubscriptionId") - .HasColumnType("int"); - - b.Property("SubscriptionSince") - .HasColumnType("datetime(6)"); - - b.Property("SupportPending") - .HasColumnType("tinyint(1)"); - - b.Property("TokenValidTime") - .HasColumnType("datetime(6)"); - - b.Property("TotpEnabled") - .HasColumnType("tinyint(1)"); - - b.Property("TotpSecret") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("SubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("PleskId") - .HasColumnType("int"); - - b.Property("PleskServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.HasIndex("PleskServerId"); - - b.ToTable("Websites"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") - .WithMany() - .HasForeignKey("AaPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AaPanel"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DdosAttack", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Node"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.DockerImage", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("DockerImages") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Domain", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.SharedDomain", "SharedDomain") - .WithMany() - .HasForeignKey("SharedDomainId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("SharedDomain"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ImageVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Variables") - .HasForeignKey("ImageId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NodeAllocation", b => - { - b.HasOne("Moonlight.App.Database.Entities.Node", null) - .WithMany("Allocations") - .HasForeignKey("NodeId"); - - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Allocations") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationAction", b => - { - b.HasOne("Moonlight.App.Database.Entities.Notification.NotificationClient", "NotificationClient") - .WithMany() - .HasForeignKey("NotificationClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("NotificationClient"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Notification.NotificationClient", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.NodeAllocation", "MainAllocation") - .WithMany() - .HasForeignKey("MainAllocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Node", "Node") - .WithMany() - .HasForeignKey("NodeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Image"); - - b.Navigation("MainAllocation"); - - b.Navigation("Node"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerBackup", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Backups") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.ServerVariable", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", null) - .WithMany("Variables") - .HasForeignKey("ServerId"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SubscriptionLimit", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", "Image") - .WithMany() - .HasForeignKey("ImageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.Subscription", null) - .WithMany("Limits") - .HasForeignKey("SubscriptionId"); - - b.Navigation("Image"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId"); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.HasOne("Moonlight.App.Database.Entities.Subscription", "Subscription") - .WithMany() - .HasForeignKey("SubscriptionId"); - - b.Navigation("Subscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.PleskServer", "PleskServer") - .WithMany() - .HasForeignKey("PleskServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - - b.Navigation("PleskServer"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Node", b => - { - b.Navigation("Allocations"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Navigation("Allocations"); - - b.Navigation("Backups"); - - b.Navigation("Variables"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Navigation("Limits"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.cs b/Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.cs deleted file mode 100644 index 2cde8fcf..00000000 --- a/Moonlight/App/Database/Migrations/20230323084631_AddedBaseDomainToWebsite.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedBaseDomainToWebsite : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "BaseDomain", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "BaseDomain", - table: "Websites"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs b/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs index 2b03d4bd..566e4e67 100644 --- a/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs +++ b/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs @@ -446,29 +446,6 @@ namespace Moonlight.App.Database.Migrations b.ToTable("NotificationClients"); }); - modelBuilder.Entity("Moonlight.App.Database.Entities.PleskServer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("BaseUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("PleskServers"); - }); - modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b => { b.Property("Id") @@ -810,24 +787,36 @@ namespace Moonlight.App.Database.Migrations .ValueGeneratedOnAdd() .HasColumnType("int"); - b.Property("BaseDomain") + b.Property("AaPanelId") + .HasColumnType("int"); + + b.Property("DomainName") .IsRequired() .HasColumnType("longtext"); + b.Property("FtpPassword") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("FtpUsername") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("InternalAaPanelId") + .HasColumnType("int"); + b.Property("OwnerId") .HasColumnType("int"); - b.Property("PleskId") - .HasColumnType("int"); - - b.Property("PleskServerId") - .HasColumnType("int"); + b.Property("PhpVersion") + .IsRequired() + .HasColumnType("longtext"); b.HasKey("Id"); - b.HasIndex("OwnerId"); + b.HasIndex("AaPanelId"); - b.HasIndex("PleskServerId"); + b.HasIndex("OwnerId"); b.ToTable("Websites"); }); @@ -1018,21 +1007,21 @@ namespace Moonlight.App.Database.Migrations modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => { + b.HasOne("Moonlight.App.Database.Entities.AaPanel", "AaPanel") + .WithMany() + .HasForeignKey("AaPanelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("Moonlight.App.Database.Entities.User", "Owner") .WithMany() .HasForeignKey("OwnerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Moonlight.App.Database.Entities.PleskServer", "PleskServer") - .WithMany() - .HasForeignKey("PleskServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.Navigation("AaPanel"); b.Navigation("Owner"); - - b.Navigation("PleskServer"); }); modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => diff --git a/Moonlight/App/Exceptions/PleskException.cs b/Moonlight/App/Exceptions/PleskException.cs deleted file mode 100644 index 2623091d..00000000 --- a/Moonlight/App/Exceptions/PleskException.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.Exceptions; - -[Serializable] -public class PleskException : Exception -{ - public int StatusCode { private get; set; } - - public PleskException() - { - } - - public PleskException(string message, int statusCode) : base(message) - { - StatusCode = statusCode; - } - - public PleskException(string message) : base(message) - { - } - - public PleskException(string message, Exception inner) : base(message, inner) - { - } - - protected PleskException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/PleskApiHelper.cs b/Moonlight/App/Helpers/PleskApiHelper.cs deleted file mode 100644 index 6b3b07cd..00000000 --- a/Moonlight/App/Helpers/PleskApiHelper.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System.Text; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.Helpers; - -public class PleskApiHelper -{ - private readonly RestClient Client; - - public PleskApiHelper() - { - Client = new(); - } - - public async Task Get(PleskServer server, string resource) - { - var request = CreateRequest(server, resource); - - var response = await Client.GetAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new PleskException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - - return JsonConvert.DeserializeObject(response.Content!)!; - } - - public async Task Post(PleskServer server, string resource, object? body) - { - var request = CreateRequest(server, resource); - - request.AddParameter("text/plain", - JsonConvert.SerializeObject(body), - ParameterType.RequestBody - ); - - var response = await Client.PostAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new PleskException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - - return JsonConvert.DeserializeObject(response.Content!)!; - } - - public async Task Delete(PleskServer server, string resource, object? body) - { - var request = CreateRequest(server, resource); - - if(body != null) - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.DeleteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new PleskException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - private RestRequest CreateRequest(PleskServer server, string resource) - { - RestRequest request = new(server.BaseUrl + "/" + resource); - - request.AddHeader("Content-Type", "application/json"); - request.AddHeader("Accept", "application/json"); - - // Implementation of auth method using auth header and api key - // https://docs.plesk.com/en-US/obsidian/api-rpc/about-rest-api.79359/#authentication-methods - - if (server.ApiKey.Contains(":")) - { - var base64 = Convert.ToBase64String( - Encoding.ASCII.GetBytes(server.ApiKey) - ); - - request.AddHeader("Authorization", "Basic " + base64); - } - else - request.AddHeader("X-API-Key", server.ApiKey); - - - return request; - } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Plesk/Requests/CreateDomain.cs b/Moonlight/App/Models/Plesk/Requests/CreateDomain.cs deleted file mode 100644 index 255bb091..00000000 --- a/Moonlight/App/Models/Plesk/Requests/CreateDomain.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Plesk.Requests; - -public class CreateDomain -{ - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("hosting_type")] - public string HostingType { get; set; } - - [JsonProperty("hosting_settings")] public HostingSettings HostingSettings { get; set; } = new(); - - [JsonProperty("owner_client")] public OwnerClient OwnerClient { get; set; } = new(); - - [JsonProperty("plan")] public Plan Plan { get; set; } = new(); -} - -public partial class HostingSettings -{ - [JsonProperty("ftp_login")] - public string FtpLogin { get; set; } - - [JsonProperty("ftp_password")] - public string FtpPassword { get; set; } -} - -public partial class OwnerClient -{ - [JsonProperty("id")] - public long Id { get; set; } -} - -public partial class Plan -{ - [JsonProperty("name")] - public string Name { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Plesk/Resources/Client.cs b/Moonlight/App/Models/Plesk/Resources/Client.cs deleted file mode 100644 index 409bad5c..00000000 --- a/Moonlight/App/Models/Plesk/Resources/Client.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Plesk.Resources; - -public class Client -{ - [JsonProperty("id")] - public int Id { get; set; } - - [JsonProperty("created")] - public DateTimeOffset Created { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("company")] - public string Company { get; set; } - - [JsonProperty("login")] - public string Login { get; set; } - - [JsonProperty("status")] - public long Status { get; set; } - - [JsonProperty("email")] - public string Email { get; set; } - - [JsonProperty("locale")] - public string Locale { get; set; } - - [JsonProperty("guid")] - public Guid Guid { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("type")] - public string Type { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Plesk/Resources/Identifier.cs b/Moonlight/App/Models/Plesk/Resources/Identifier.cs deleted file mode 100644 index c99eec65..00000000 --- a/Moonlight/App/Models/Plesk/Resources/Identifier.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Plesk.Resources; - -public class Identifier -{ - [JsonProperty("id")] - public int Id { get; set; } - - [JsonProperty("guid")] - public Guid Guid { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/PleskServerRepository.cs b/Moonlight/App/Repositories/PleskServerRepository.cs deleted file mode 100644 index 53742635..00000000 --- a/Moonlight/App/Repositories/PleskServerRepository.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories; - -public class PleskServerRepository : IDisposable -{ - private readonly DataContext DataContext; - - public PleskServerRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.PleskServers; - } - - public PleskServer Add(PleskServer pleskServer) - { - var x = DataContext.PleskServers.Add(pleskServer); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(PleskServer pleskServer) - { - DataContext.PleskServers.Update(pleskServer); - DataContext.SaveChanges(); - } - - public void Delete(PleskServer pleskServer) - { - DataContext.PleskServers.Remove(pleskServer); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/WebsiteService.cs b/Moonlight/App/Services/WebsiteService.cs index 595e8d5c..4cdda657 100644 --- a/Moonlight/App/Services/WebsiteService.cs +++ b/Moonlight/App/Services/WebsiteService.cs @@ -1,9 +1,7 @@ -using Microsoft.EntityFrameworkCore; +using aaPanelSharp; +using Microsoft.EntityFrameworkCore; using Moonlight.App.Database.Entities; using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Plesk.Requests; -using Moonlight.App.Models.Plesk.Resources; using Moonlight.App.Repositories; namespace Moonlight.App.Services; @@ -11,100 +9,31 @@ namespace Moonlight.App.Services; public class WebsiteService { private readonly WebsiteRepository WebsiteRepository; - private readonly PleskServerRepository PleskServerRepository; - private readonly PleskApiHelper PleskApiHelper; - public WebsiteService(WebsiteRepository websiteRepository, PleskServerRepository pleskServerRepository, - PleskApiHelper pleskApiHelper) + public WebsiteService(WebsiteRepository websiteRepository) { WebsiteRepository = websiteRepository; - PleskServerRepository = pleskServerRepository; - PleskApiHelper = pleskApiHelper; } - public async Task Create(User owner, string baseDomain, string ftpPassword, PleskServer? ps = null) + public Website Create(AaPanel aaPanel, User user, string name) { - var pleskServer = ps ?? PleskServerRepository.Get().FirstOrDefault(); + if (WebsiteRepository.Get().Any(x => x.DomainName == name)) + throw new DisplayException("A website with this domain has already been created"); - if (pleskServer == null) - throw new DisplayException("No plesk server found to deploy the website"); - - var website = WebsiteRepository.Add(new Website() + var access = new aaPanel(aaPanel.Url, aaPanel.Key); + return null; + } + + private aaPanel CreateApiAccess(Website website) + { + if (website.AaPanel == null) { - PleskServer = pleskServer, - Owner = owner, - BaseDomain = baseDomain - }); - - try - { - var userId = await GetAdminAccountForDeploy(pleskServer); - - string ftpUsername = baseDomain.Replace(".", "_"); - - var createDomain = new CreateDomain() - { - Description = "Moonlight website " + website.Id, - Name = baseDomain, - OwnerClient = new() - { - Id = userId - }, - Plan = new() - { - Name = "Unlimited" - }, - HostingType = "virtual", - HostingSettings = new() - { - FtpLogin = ftpUsername, - FtpPassword = ftpPassword - } - }; - - var identifier = await PleskApiHelper.Post( - pleskServer, - "domains", - createDomain - ); - - website.PleskId = identifier.Id; - - WebsiteRepository.Update(website); - - return website; + website = WebsiteRepository + .Get() + .Include(x => x.AaPanel) + .First(x => x.Id == website.Id); } - catch (Exception e) - { - WebsiteRepository.Delete(website); - - throw; - } - } - - public async Task Delete(Website w) - { - var website = WebsiteRepository - .Get() - .Include(x => x.PleskServer) - .FirstOrDefault(x => x.Id == w.Id); - - if (website == null) - throw new DisplayException("Website not found"); - - await PleskApiHelper.Delete(website.PleskServer, $"domains/{website.PleskId}", null); - WebsiteRepository.Delete(website); - } - - private async Task GetAdminAccountForDeploy(PleskServer pleskServer) - { - var clients = await PleskApiHelper.Get(pleskServer, "clients"); - var adminClient = clients.FirstOrDefault(x => x.Type == "admin"); - - if (adminClient == null) - throw new DisplayException("Unable to deploy website. Plesk admin account is missing"); - - return adminClient.Id; + return new aaPanel(website.AaPanel.Url, website.AaPanel.Key); } } \ No newline at end of file diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs index d1cf4b69..45436097 100644 --- a/Moonlight/Program.cs +++ b/Moonlight/Program.cs @@ -65,7 +65,6 @@ namespace Moonlight builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); - builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -121,7 +120,6 @@ namespace Moonlight builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddScoped(); - builder.Services.AddScoped(); // Background services builder.Services.AddSingleton(); diff --git a/Moonlight/Shared/Components/Forms/WSelect.razor b/Moonlight/Shared/Components/Forms/WSelect.razor deleted file mode 100644 index 040a9ffb..00000000 --- a/Moonlight/Shared/Components/Forms/WSelect.razor +++ /dev/null @@ -1,43 +0,0 @@ -@typeparam TItem - - - -@code -{ - [Parameter] - public TItem[] Items { get; set; } - - [Parameter] - public Func DisplayField { get; set; } - - [Parameter] - public Action OnChange { get; set; } - - private int Binding - { - get - { - if (Value == null) - return -1; - - return Value.GetHashCode(); - } - set - { - var i = Items.FirstOrDefault(x => x!.GetHashCode() == value); - - if (i != null) - { - Value = i; - OnChange?.Invoke(Value); - } - } - } - - private TItem Value; -} diff --git a/Moonlight/Shared/Components/Navigations/AdminWebsiteNavigation.razor b/Moonlight/Shared/Components/Navigations/AdminWebsiteNavigation.razor deleted file mode 100644 index 40b98026..00000000 --- a/Moonlight/Shared/Components/Navigations/AdminWebsiteNavigation.razor +++ /dev/null @@ -1,22 +0,0 @@ - - -@code -{ - [Parameter] - public int Index { get; set; } = 0; -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Partials/SidebarMenu.razor b/Moonlight/Shared/Components/Partials/SidebarMenu.razor index 88778c21..5ce76e18 100644 --- a/Moonlight/Shared/Components/Partials/SidebarMenu.razor +++ b/Moonlight/Shared/Components/Partials/SidebarMenu.razor @@ -155,13 +155,32 @@ else -