diff --git a/.devcontainers/devcontainer.json b/.devcontainers/devcontainer.json deleted file mode 100644 index 2ce16662..00000000 --- a/.devcontainers/devcontainer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "C# (.NET)", - "image": "mcr.microsoft.com/devcontainers/dotnet:0-6.0", - - "customizations": { - "vscode": { - "settings": {}, - "extensions": [ - "streetsidesoftware.code-spell-checker" - ] - } - }, - - "portsAttributes": { - "5118": { - "label": "Moonlight", - "onAutoForward": "notify" - } - } -} \ No newline at end of file diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 3729ff0c..00000000 --- a/.dockerignore +++ /dev/null @@ -1,25 +0,0 @@ -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -LICENSE -README.md \ No newline at end of file diff --git a/.github/workflows/canary-docker-build.yml b/.github/workflows/canary-docker-build.yml deleted file mode 100644 index af18796e..00000000 --- a/.github/workflows/canary-docker-build.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Canary Docker Build - -on: - workflow_dispatch: - pull_request: - types: - - closed - branches: [ "main" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Login into docker hub - run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }} - - name: Build and Push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./Moonlight/Dockerfile - push: true - tags: moonlightpanel/moonlight:canary - platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/release-docker-build.yml b/.github/workflows/release-docker-build.yml deleted file mode 100644 index e57f8eb9..00000000 --- a/.github/workflows/release-docker-build.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Release Docker Build - -on: - workflow_dispatch: - release: - types: [ published ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Login into docker hub - run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }} - - name: Build and Push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./Moonlight/Dockerfile - push: true - tags: moonlightpanel/moonlight:beta - platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/.github/workflows/test-docker-build.yml b/.github/workflows/test-docker-build.yml deleted file mode 100644 index 656d46c2..00000000 --- a/.github/workflows/test-docker-build.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Test Build - -on: - push: - branches: [ "main" ] - pull_request: - types: - - closed - branches: [ "main" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Build Docker image - run: docker build -t moonlightpanel/moonlight:${{ github.sha }} -f Moonlight/Dockerfile . \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7afc561b..845d31f7 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,3 @@ Desktop.ini .idea/.idea.Moonlight/.idea/discord.xml storage/ -Moonlight/publish.ps1 -Moonlight/version diff --git a/.idea/.idea.Moonlight/.idea/.gitignore b/.idea/.idea.Moonlight/.idea/.gitignore deleted file mode 100644 index 4a2ea511..00000000 --- a/.idea/.idea.Moonlight/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/contentModel.xml -/projectSettingsUpdater.xml -/modules.xml -/.idea.Moonlight.iml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.idea.Moonlight/.idea/efCoreCommonOptions.xml b/.idea/.idea.Moonlight/.idea/efCoreCommonOptions.xml deleted file mode 100644 index fb98c234..00000000 --- a/.idea/.idea.Moonlight/.idea/efCoreCommonOptions.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/efCoreDialogsState.xml b/.idea/.idea.Moonlight/.idea/efCoreDialogsState.xml deleted file mode 100644 index acb9617f..00000000 --- a/.idea/.idea.Moonlight/.idea/efCoreDialogsState.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/encodings.xml b/.idea/.idea.Moonlight/.idea/encodings.xml deleted file mode 100644 index df87cf95..00000000 --- a/.idea/.idea.Moonlight/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/icon.svg b/.idea/.idea.Moonlight/.idea/icon.svg deleted file mode 100644 index 193ebfae..00000000 --- a/.idea/.idea.Moonlight/.idea/icon.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/.idea/.idea.Moonlight/.idea/indexLayout.xml b/.idea/.idea.Moonlight/.idea/indexLayout.xml deleted file mode 100644 index 7b08163c..00000000 --- a/.idea/.idea.Moonlight/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Moonlight/.idea/vcs.xml b/.idea/.idea.Moonlight/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/.idea.Moonlight/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 8b2de09e..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md. - "name": ".NET Core Launch (web)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/Moonlight/bin/Debug/net6.0/Moonlight.dll", - "args": [], - "cwd": "${workspaceFolder}/Moonlight", - "stopAtEntry": false, - // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser - "serverReadyAction": { - "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)" - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "sourceFileMap": { - "/Views": "${workspaceFolder}/Views" - } - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach" - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index eb9666ad..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/Moonlight.sln", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/Moonlight.sln", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "--project", - "${workspaceFolder}/Moonlight.sln" - ], - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index e261afcf..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,128 +0,0 @@ -

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (modified)

-

By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.

-

Section 1 – Definitions.

-
    -
  1. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
  2. -
  3. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
  4. -
  5. BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
  6. -
  7. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
  8. -
  9. Effective Technological Measures means those measures that, in the absence of proper authority, may not -be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar -international agreements.
  10. -
  11. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
  12. -
  13. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
  14. -
  15. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
  16. -
  17. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
  18. -
  19. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
  20. -
  21. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. This also includes free hosting services or simmular which have no direct permission from the moonlight panel team to use this software. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
  22. -
  23. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
  24. -
  25. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
  26. -
  27. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
  28. -
-

Section 2 – Scope.

-
    -
  1. License grant. -
      -
    1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: -
        -
      1. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
      2. -
      3. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
      4. -
      -
    2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
    3. -
    4. Term. The term of this Public License is specified in Section 6(a).
    5. -
    6. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
    7. -
    8. Downstream recipients. -
      -
        -
      1. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
      2. -
      3. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
      4. -
      5. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
      6. -
      -
      -
    9. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
    10. -
    -
  2. Other rights.

    -
      -
    1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
    2. -
    3. Patent and trademark rights are not licensed under this Public License.
    4. -
    5. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
    6. -
    -
  3. -
-

Section 3 – License Conditions.

-

Your exercise of the Licensed Rights is expressly made subject to the following conditions.

-
    -
  1. Attribution.

    -
      -
    1. If You Share the Licensed Material (including in modified form), You must:

      -
        -
      1. retain the following if it is supplied by the Licensor with the Licensed Material: -
          -
        1. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
        2. -
        3. a copyright notice;
        4. -
        5. a notice that refers to this Public License;
        6. -
        7. a notice that refers to the disclaimer of warranties;
        8. -
        9. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
        10. -
        -
      2. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
      3. -
      4. indicate the Licensed Material is licensed under this Public License, -and include the text of, or the URI or hyperlink to, this Public -License.
      5. -
      -
    2. -
    3. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
    4. -
    5. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
    6. -
    -
  2. -
  3. ShareAlike. -

    In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.

    -
      -
    1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
    2. -
    3. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
    4. -
    5. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
    6. -
    -
  4. -
-

Section 4 – Sui Generis Database Rights.

-

Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:

-
    -
  1. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
  2. -
  3. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
  4. -
  5. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
  6. -
- For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. -

Section 5 – Disclaimer of Warranties and Limitation of Liability.

-
    -
  1. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
  2. -
  3. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
  4. -
-
    -
  1. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
  2. -
-

Section 6 – Term and Termination.

-
    -
  1. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
  2. -
  3. -

    Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:

    -
      -
    1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
    2. -
    3. upon express reinstatement by the Licensor.
    4. -
    -For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
  4. -
  5. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
  6. -
  7. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
  8. -
-

Section 7 – Other Terms and Conditions.

-
    -
  1. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
  2. -
  3. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
  4. -
-

Section 8 – Interpretation.

-
    -
  1. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
  2. -
  3. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
  4. -
  5. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
  6. -
  7. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
  8. -
- -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Moonlight.sln b/Moonlight.sln deleted file mode 100644 index 4d5f3224..00000000 --- a/Moonlight.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32516.85 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moonlight", "Moonlight\Moonlight.csproj", "{16141D00-A997-4BA6-B0DC-AF6F4712613A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {16141D00-A997-4BA6-B0DC-AF6F4712613A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {16141D00-A997-4BA6-B0DC-AF6F4712613A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {16141D00-A997-4BA6-B0DC-AF6F4712613A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {16141D00-A997-4BA6-B0DC-AF6F4712613A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9C904DEA-9663-4892-B3CA-5CD6E710648C} - EndGlobalSection -EndGlobal diff --git a/Moonlight/App/ApiClients/CloudPanel/CloudPanelApiHelper.cs b/Moonlight/App/ApiClients/CloudPanel/CloudPanelApiHelper.cs deleted file mode 100644 index cfa2b51d..00000000 --- a/Moonlight/App/ApiClients/CloudPanel/CloudPanelApiHelper.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.ApiClients.CloudPanel; - -public class CloudPanelApiHelper -{ - private readonly RestClient Client; - - public CloudPanelApiHelper() - { - Client = new(); - } - - public async Task Post(Database.Entities.CloudPanel cloudPanel, string resource, object? body) - { - var request = CreateRequest(cloudPanel, resource); - - request.Method = Method.Post; - - if(body != null) - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new CloudPanelException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - public async Task Delete(Database.Entities.CloudPanel cloudPanel, string resource, object? body) - { - var request = CreateRequest(cloudPanel, resource); - - request.Method = Method.Delete; - - if(body != null) - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new CloudPanelException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - private RestRequest CreateRequest(Database.Entities.CloudPanel cloudPanel, string resource) - { - var url = $"{cloudPanel.ApiUrl}/" + resource; - - var request = new RestRequest(url); - - request.AddHeader("Content-Type", "application/json"); - request.AddHeader("Accept", "application/json"); - request.AddHeader("Authorization", "Bearer " + cloudPanel.ApiKey); - - return request; - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/CloudPanel/CloudPanelException.cs b/Moonlight/App/ApiClients/CloudPanel/CloudPanelException.cs deleted file mode 100644 index a7610348..00000000 --- a/Moonlight/App/ApiClients/CloudPanel/CloudPanelException.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.ApiClients.CloudPanel; - -[Serializable] -public class CloudPanelException : Exception -{ - public int StatusCode { get; set; } - - public CloudPanelException() - { - } - - public CloudPanelException(string message, int statusCode) : base(message) - { - StatusCode = statusCode; - } - - public CloudPanelException(string message) : base(message) - { - } - - public CloudPanelException(string message, Exception inner) : base(message, inner) - { - } - - protected CloudPanelException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/CloudPanel/Requests/AddDatabase.cs b/Moonlight/App/ApiClients/CloudPanel/Requests/AddDatabase.cs deleted file mode 100644 index 26d8d4bb..00000000 --- a/Moonlight/App/ApiClients/CloudPanel/Requests/AddDatabase.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.CloudPanel.Requests; - -public class AddDatabase -{ - [JsonProperty("domainName")] - public string DomainName { get; set; } - - [JsonProperty("databaseName")] - public string DatabaseName { get; set; } - - [JsonProperty("databaseUserName")] - public string DatabaseUserName { get; set; } - - [JsonProperty("databaseUserPassword")] - public string DatabaseUserPassword { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/CloudPanel/Requests/AddPhpSite.cs b/Moonlight/App/ApiClients/CloudPanel/Requests/AddPhpSite.cs deleted file mode 100644 index 9e04eeff..00000000 --- a/Moonlight/App/ApiClients/CloudPanel/Requests/AddPhpSite.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.CloudPanel.Requests; - -public class AddPhpSite -{ - [JsonProperty("domainName")] public string DomainName { get; set; } = ""; - - [JsonProperty("siteUser")] public string SiteUser { get; set; } = ""; - - [JsonProperty("siteUserPassword")] public string SiteUserPassword { get; set; } = ""; - - [JsonProperty("vHostTemplate")] public string VHostTemplate { get; set; } = ""; - - [JsonProperty("phpVersion")] public string PhpVersion { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/CloudPanel/Requests/InstallLetsEncrypt.cs b/Moonlight/App/ApiClients/CloudPanel/Requests/InstallLetsEncrypt.cs deleted file mode 100644 index e10068fd..00000000 --- a/Moonlight/App/ApiClients/CloudPanel/Requests/InstallLetsEncrypt.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.CloudPanel.Requests; - -public class InstallLetsEncrypt -{ - [JsonProperty("domainName")] - public string DomainName { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/DaemonApiHelper.cs b/Moonlight/App/ApiClients/Daemon/DaemonApiHelper.cs deleted file mode 100644 index c9d14065..00000000 --- a/Moonlight/App/ApiClients/Daemon/DaemonApiHelper.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Moonlight.App.Database.Entities; -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.ApiClients.Daemon; - -public class DaemonApiHelper -{ - private readonly RestClient Client; - - public DaemonApiHelper() - { - Client = new(); - } - - public async Task Get(Node node, string resource) - { - var request = await CreateRequest(node, resource); - - request.Method = Method.Get; - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new DaemonException( - $"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(Node node, string resource, object body) - { - var request = await CreateRequest(node, resource); - - request.Method = Method.Post; - - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new DaemonException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - public async Task Delete(Node node, string resource, object body) - { - var request = await CreateRequest(node, resource); - - request.Method = Method.Delete; - - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new DaemonException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - private Task CreateRequest(Node node, string resource) - { - var url = $"http://{node.Fqdn}:{node.MoonlightDaemonPort}/"; - - RestRequest request = new(url + resource); - - request.AddHeader("Content-Type", "application/json"); - request.AddHeader("Accept", "application/json"); - request.AddHeader("Authorization", node.Token); - - return Task.FromResult(request); - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/DaemonException.cs b/Moonlight/App/ApiClients/Daemon/DaemonException.cs deleted file mode 100644 index 58ca2e9e..00000000 --- a/Moonlight/App/ApiClients/Daemon/DaemonException.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.ApiClients.Daemon; - -[Serializable] -public class DaemonException : Exception -{ - public int StatusCode { get; set; } - - public DaemonException() - { - } - - public DaemonException(string message, int statusCode) : base(message) - { - StatusCode = statusCode; - } - - public DaemonException(string message) : base(message) - { - } - - public DaemonException(string message, Exception inner) : base(message, inner) - { - } - - protected DaemonException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Requests/Mount.cs b/Moonlight/App/ApiClients/Daemon/Requests/Mount.cs deleted file mode 100644 index fb69f557..00000000 --- a/Moonlight/App/ApiClients/Daemon/Requests/Mount.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Requests; - -public class Mount -{ - public string Server { get; set; } = ""; - public string ServerPath { get; set; } = ""; - public string Path { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Requests/Unmount.cs b/Moonlight/App/ApiClients/Daemon/Requests/Unmount.cs deleted file mode 100644 index c18fe8e1..00000000 --- a/Moonlight/App/ApiClients/Daemon/Requests/Unmount.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Requests; - -public class Unmount -{ - public string Path { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Resources/Container.cs b/Moonlight/App/ApiClients/Daemon/Resources/Container.cs deleted file mode 100644 index 25741299..00000000 --- a/Moonlight/App/ApiClients/Daemon/Resources/Container.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Resources; - -public class Container -{ - public string Name { get; set; } = ""; - public long Memory { get; set; } - public double Cpu { get; set; } - public long NetworkIn { get; set; } - public long NetworkOut { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Resources/CpuMetrics.cs b/Moonlight/App/ApiClients/Daemon/Resources/CpuMetrics.cs deleted file mode 100644 index d954b945..00000000 --- a/Moonlight/App/ApiClients/Daemon/Resources/CpuMetrics.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Resources; - -public class CpuMetrics -{ - public string CpuModel { get; set; } = ""; - public double CpuUsage { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Resources/DiskMetrics.cs b/Moonlight/App/ApiClients/Daemon/Resources/DiskMetrics.cs deleted file mode 100644 index b301f20f..00000000 --- a/Moonlight/App/ApiClients/Daemon/Resources/DiskMetrics.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Resources; - -public class DiskMetrics -{ - public long Used { get; set; } - public long Total { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Resources/DockerMetrics.cs b/Moonlight/App/ApiClients/Daemon/Resources/DockerMetrics.cs deleted file mode 100644 index 80d44ed2..00000000 --- a/Moonlight/App/ApiClients/Daemon/Resources/DockerMetrics.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Resources; - -public class DockerMetrics -{ - public Container[] Containers { get; set; } = Array.Empty(); -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Resources/MemoryMetrics.cs b/Moonlight/App/ApiClients/Daemon/Resources/MemoryMetrics.cs deleted file mode 100644 index cb3fd8d4..00000000 --- a/Moonlight/App/ApiClients/Daemon/Resources/MemoryMetrics.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Resources; - -public class MemoryMetrics -{ - public long Used { get; set; } - public long Total { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Daemon/Resources/SystemMetrics.cs b/Moonlight/App/ApiClients/Daemon/Resources/SystemMetrics.cs deleted file mode 100644 index 28c6bb72..00000000 --- a/Moonlight/App/ApiClients/Daemon/Resources/SystemMetrics.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.ApiClients.Daemon.Resources; - -public class SystemMetrics -{ - public string OsName { get; set; } = ""; - public long Uptime { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Google/Requests/GoogleOAuth2CodePayload.cs b/Moonlight/App/ApiClients/Google/Requests/GoogleOAuth2CodePayload.cs deleted file mode 100644 index a4ef4bb1..00000000 --- a/Moonlight/App/ApiClients/Google/Requests/GoogleOAuth2CodePayload.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Google.Requests; - -public class GoogleOAuth2CodePayload -{ - [JsonProperty("grant_type")] - public string GrantType { get; set; } = "authorization_code"; - - [JsonProperty("code")] - public string Code { get; set; } - - [JsonProperty("client_id")] - public string ClientId { get; set; } - - [JsonProperty("client_secret")] - public string ClientSecret { get; set; } - - [JsonProperty("redirect_uri")] - public string RedirectUri { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/IpLocate/Resources/IpLocate.cs b/Moonlight/App/ApiClients/IpLocate/Resources/IpLocate.cs deleted file mode 100644 index d75717cf..00000000 --- a/Moonlight/App/ApiClients/IpLocate/Resources/IpLocate.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.IpLocate.Resources; - -public class IpLocate -{ - [JsonProperty("query")] - public string Query { get; set; } - - [JsonProperty("status")] - public string Status { get; set; } - - [JsonProperty("country")] - public string Country { get; set; } - - [JsonProperty("countryCode")] - public string CountryCode { get; set; } - - [JsonProperty("region")] - public string Region { get; set; } - - [JsonProperty("regionName")] - public string RegionName { get; set; } - - [JsonProperty("city")] - public string City { get; set; } - - [JsonProperty("zip")] - public string Zip { get; set; } - - [JsonProperty("lat")] - public double Lat { get; set; } - - [JsonProperty("lon")] - public double Lon { get; set; } - - [JsonProperty("timezone")] - public string Timezone { get; set; } - - [JsonProperty("isp")] - public string Isp { get; set; } - - [JsonProperty("org")] - public string Org { get; set; } - - [JsonProperty("as")] - public string As { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Modrinth/ModrinthApiHelper.cs b/Moonlight/App/ApiClients/Modrinth/ModrinthApiHelper.cs deleted file mode 100644 index 489ae5d6..00000000 --- a/Moonlight/App/ApiClients/Modrinth/ModrinthApiHelper.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.ApiClients.Modrinth; - -public class ModrinthApiHelper -{ - private readonly RestClient Client; - - public ModrinthApiHelper() - { - Client = new(); - Client.AddDefaultParameter( - new HeaderParameter("User-Agent", "Moonlight-Panel/Moonlight (admin@endelon-hosting.de)") - ); - } - - public async Task Get(string resource) - { - var request = CreateRequest(resource); - - request.Method = Method.Get; - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new ModrinthException( - $"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!)!; - } - - private RestRequest CreateRequest(string resource) - { - var url = "https://api.modrinth.com/v2/" + resource; - - var request = new RestRequest(url) - { - Timeout = 300000 - }; - - request.AddHeader("Content-Type", "application/json"); - request.AddHeader("Accept", "application/json"); - - return request; - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Modrinth/ModrinthException.cs b/Moonlight/App/ApiClients/Modrinth/ModrinthException.cs deleted file mode 100644 index c6959359..00000000 --- a/Moonlight/App/ApiClients/Modrinth/ModrinthException.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Moonlight.App.ApiClients.Modrinth; - -public class ModrinthException : Exception -{ - public int StatusCode { get; set; } - - public ModrinthException() - { - } - - public ModrinthException(string message, int statusCode) : base(message) - { - StatusCode = statusCode; - } - - public ModrinthException(string message, Exception inner) : base(message, inner) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Modrinth/Resources/Pagination.cs b/Moonlight/App/ApiClients/Modrinth/Resources/Pagination.cs deleted file mode 100644 index b462e5a3..00000000 --- a/Moonlight/App/ApiClients/Modrinth/Resources/Pagination.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Modrinth.Resources; - -public class Pagination -{ - [JsonProperty("hits")] public Project[] Hits { get; set; } - - [JsonProperty("offset")] public long Offset { get; set; } - - [JsonProperty("limit")] public long Limit { get; set; } - - [JsonProperty("total_hits")] public long TotalHits { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Modrinth/Resources/Project.cs b/Moonlight/App/ApiClients/Modrinth/Resources/Project.cs deleted file mode 100644 index 6ae7a670..00000000 --- a/Moonlight/App/ApiClients/Modrinth/Resources/Project.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Modrinth.Resources; - -public class Project -{ - [JsonProperty("project_id")] public string ProjectId { get; set; } - - [JsonProperty("project_type")] public string ProjectType { get; set; } - - [JsonProperty("slug")] public string Slug { get; set; } - - [JsonProperty("author")] public string Author { get; set; } - - [JsonProperty("title")] public string Title { get; set; } - - [JsonProperty("description")] public string Description { get; set; } - - [JsonProperty("categories")] public string[] Categories { get; set; } - - [JsonProperty("display_categories")] public string[] DisplayCategories { get; set; } - - [JsonProperty("versions")] public string[] Versions { get; set; } - - [JsonProperty("downloads")] public long Downloads { get; set; } - - [JsonProperty("follows")] public long Follows { get; set; } - - [JsonProperty("icon_url")] public string IconUrl { get; set; } - - [JsonProperty("date_created")] public DateTimeOffset DateCreated { get; set; } - - [JsonProperty("date_modified")] public DateTimeOffset DateModified { get; set; } - - [JsonProperty("latest_version")] public string LatestVersion { get; set; } - - [JsonProperty("license")] public string License { get; set; } - - [JsonProperty("client_side")] public string ClientSide { get; set; } - - [JsonProperty("server_side")] public string ServerSide { get; set; } - - [JsonProperty("gallery")] public Uri[] Gallery { get; set; } - - [JsonProperty("featured_gallery")] public Uri FeaturedGallery { get; set; } - - [JsonProperty("color")] public long? Color { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Modrinth/Resources/Version.cs b/Moonlight/App/ApiClients/Modrinth/Resources/Version.cs deleted file mode 100644 index 69c13326..00000000 --- a/Moonlight/App/ApiClients/Modrinth/Resources/Version.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Modrinth.Resources; - -public class Version -{ - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("version_number")] - public string VersionNumber { get; set; } - - [JsonProperty("changelog")] - public string Changelog { get; set; } - - [JsonProperty("dependencies")] - public object[] Dependencies { get; set; } - - [JsonProperty("game_versions")] - public object[] GameVersions { get; set; } - - [JsonProperty("version_type")] - public string VersionType { get; set; } - - [JsonProperty("loaders")] - public object[] Loaders { get; set; } - - [JsonProperty("featured")] - public bool Featured { get; set; } - - [JsonProperty("status")] - public string Status { get; set; } - - [JsonProperty("requested_status")] - public string RequestedStatus { get; set; } - - [JsonProperty("id")] - public string Id { get; set; } - - [JsonProperty("project_id")] - public string ProjectId { get; set; } - - [JsonProperty("author_id")] - public string AuthorId { get; set; } - - [JsonProperty("date_published")] - public DateTime DatePublished { get; set; } - - [JsonProperty("downloads")] - public long Downloads { get; set; } - - [JsonProperty("changelog_url")] - public object ChangelogUrl { get; set; } - - [JsonProperty("files")] - public VersionFile[] Files { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Modrinth/Resources/VersionFile.cs b/Moonlight/App/ApiClients/Modrinth/Resources/VersionFile.cs deleted file mode 100644 index 07ccfa63..00000000 --- a/Moonlight/App/ApiClients/Modrinth/Resources/VersionFile.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Modrinth.Resources; - -public class VersionFile -{ - [JsonProperty("url")] - public Uri Url { get; set; } - - [JsonProperty("filename")] - public string Filename { get; set; } - - [JsonProperty("primary")] - public bool Primary { get; set; } - - [JsonProperty("size")] - public long Size { get; set; } - - [JsonProperty("file_type")] - public string FileType { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Paper/PaperApiHelper.cs b/Moonlight/App/ApiClients/Paper/PaperApiHelper.cs deleted file mode 100644 index 601e1ac2..00000000 --- a/Moonlight/App/ApiClients/Paper/PaperApiHelper.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Moonlight.App.Exceptions; -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.ApiClients.Paper; - -public class PaperApiHelper -{ - private string ApiUrl { get; set; } - - public PaperApiHelper() - { - ApiUrl = "https://api.papermc.io/v2/projects/"; - } - - public async Task Get(string url) - { - RestClient client = new(); - - string requrl = "NONSET"; - - if (ApiUrl.EndsWith("/")) - requrl = ApiUrl + url; - else - requrl = ApiUrl + "/" + url; - - RestRequest request = new(requrl, Method.Get); - - request.AddHeader("Content-Type", "application/json"); - - var response = await client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new PaperException( - $"An error occured: ({response.StatusCode}) {response.Content}" - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - - return JsonConvert.DeserializeObject(response.Content!)!; - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Paper/PaperException.cs b/Moonlight/App/ApiClients/Paper/PaperException.cs deleted file mode 100644 index da62fcd2..00000000 --- a/Moonlight/App/ApiClients/Paper/PaperException.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Moonlight.App.ApiClients.Paper; - -public class PaperException : Exception -{ - public PaperException() - { - } - - public PaperException(string message) : base(message) - { - } - - public PaperException(string message, Exception inner) : base(message, inner) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Paper/Resources/PaperBuilds.cs b/Moonlight/App/ApiClients/Paper/Resources/PaperBuilds.cs deleted file mode 100644 index 393b506d..00000000 --- a/Moonlight/App/ApiClients/Paper/Resources/PaperBuilds.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Paper.Resources; - -public class PaperBuilds -{ - [JsonProperty("project_id")] - public string ProjectId { get; set; } - - [JsonProperty("project_name")] - public string ProjectName { get; set; } - - [JsonProperty("version")] - public string Version { get; set; } - - [JsonProperty("builds")] - public List Builds { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Paper/Resources/PaperVersions.cs b/Moonlight/App/ApiClients/Paper/Resources/PaperVersions.cs deleted file mode 100644 index 573b5786..00000000 --- a/Moonlight/App/ApiClients/Paper/Resources/PaperVersions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Paper.Resources; - -public class PaperVersions -{ - [JsonProperty("project_id")] - public string ProjectId { get; set; } - - [JsonProperty("project_name")] - public string ProjectName { get; set; } - - [JsonProperty("version_groups")] - public List VersionGroups { get; set; } - - [JsonProperty("versions")] - public List Versions { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Telemetry/Requests/TelemetryData.cs b/Moonlight/App/ApiClients/Telemetry/Requests/TelemetryData.cs deleted file mode 100644 index c8fafe75..00000000 --- a/Moonlight/App/ApiClients/Telemetry/Requests/TelemetryData.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Moonlight.App.ApiClients.Telemetry.Requests; - -public class TelemetryData -{ - public string AppUrl { get; set; } = ""; - public int Servers { get; set; } - public int Nodes { get; set; } - public int Users { get; set; } - public int Databases { get; set; } - public int Webspaces { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Telemetry/TelemetryApiHelper.cs b/Moonlight/App/ApiClients/Telemetry/TelemetryApiHelper.cs deleted file mode 100644 index d9b07450..00000000 --- a/Moonlight/App/ApiClients/Telemetry/TelemetryApiHelper.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.ApiClients.Telemetry; - -public class TelemetryApiHelper -{ - private readonly RestClient Client; - - public TelemetryApiHelper() - { - Client = new(); - } - - public async Task Post(string resource, object? body) - { - var request = CreateRequest(resource); - - request.Method = Method.Post; - - request.AddParameter("application/json", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new TelemetryException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - private RestRequest CreateRequest(string resource) - { - var url = "https://telemetry.moonlightpanel.xyz/" + resource; - - var request = new RestRequest(url) - { - Timeout = 3000000 - }; - - return request; - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Telemetry/TelemetryException.cs b/Moonlight/App/ApiClients/Telemetry/TelemetryException.cs deleted file mode 100644 index 7b66b710..00000000 --- a/Moonlight/App/ApiClients/Telemetry/TelemetryException.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.ApiClients.Telemetry; - -[Serializable] -public class TelemetryException : Exception -{ - public int StatusCode { get; set; } - - public TelemetryException() - { - } - - public TelemetryException(string message, int statusCode) : base(message) - { - StatusCode = statusCode; - } - - public TelemetryException(string message) : base(message) - { - } - - public TelemetryException(string message, Exception inner) : base(message, inner) - { - } - - protected TelemetryException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/PowerSignal.cs b/Moonlight/App/ApiClients/Wings/PowerSignal.cs deleted file mode 100644 index b036b9d5..00000000 --- a/Moonlight/App/ApiClients/Wings/PowerSignal.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.ApiClients.Wings; - -public enum PowerSignal -{ - Start, - Stop, - Kill, - Restart -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/CompressFiles.cs b/Moonlight/App/ApiClients/Wings/Requests/CompressFiles.cs deleted file mode 100644 index 4a90c9dd..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/CompressFiles.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class CompressFiles -{ - [JsonProperty("root")] - public string Root { get; set; } - - [JsonProperty("files")] - public string[] Files { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/CreateBackup.cs b/Moonlight/App/ApiClients/Wings/Requests/CreateBackup.cs deleted file mode 100644 index 0d9aaae9..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/CreateBackup.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class CreateBackup -{ - [JsonProperty("adapter")] - public string Adapter { get; set; } - - [JsonProperty("uuid")] - public Guid Uuid { get; set; } - - [JsonProperty("ignore")] - public string Ignore { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/CreateDirectory.cs b/Moonlight/App/ApiClients/Wings/Requests/CreateDirectory.cs deleted file mode 100644 index 424fc962..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/CreateDirectory.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class CreateDirectory -{ - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("path")] - public string Path { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/CreateServer.cs b/Moonlight/App/ApiClients/Wings/Requests/CreateServer.cs deleted file mode 100644 index 2cf980aa..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/CreateServer.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class CreateServer -{ - [JsonProperty("uuid")] - public Guid Uuid { get; set; } - - [JsonProperty("start_on_completion")] - public bool StartOnCompletion { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/DecompressFile.cs b/Moonlight/App/ApiClients/Wings/Requests/DecompressFile.cs deleted file mode 100644 index 298ec83a..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/DecompressFile.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class DecompressFile -{ - [JsonProperty("root")] - public string Root { get; set; } - - [JsonProperty("file")] - public string File { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/DeleteFiles.cs b/Moonlight/App/ApiClients/Wings/Requests/DeleteFiles.cs deleted file mode 100644 index 82d0d389..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/DeleteFiles.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class DeleteFiles -{ - [JsonProperty("root")] - public string Root { get; set; } - - [JsonProperty("files")] public List Files { get; set; } = new(); -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/RenameFiles.cs b/Moonlight/App/ApiClients/Wings/Requests/RenameFiles.cs deleted file mode 100644 index 57c37bb7..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/RenameFiles.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class RenameFiles -{ - [JsonProperty("root")] - public string Root { get; set; } - - [JsonProperty("files")] public RenameFilesData[] Files { get; set; } -} - -public class RenameFilesData -{ - [JsonProperty("from")] - public string From { get; set; } - - [JsonProperty("to")] - public string To { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/RestoreBackup.cs b/Moonlight/App/ApiClients/Wings/Requests/RestoreBackup.cs deleted file mode 100644 index 18f0f51c..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/RestoreBackup.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class RestoreBackup -{ - [JsonProperty("adapter")] - public string Adapter { get; set; } - - [JsonProperty("truncate_directory")] public bool TruncateDirectory { get; set; } = false; - [JsonProperty("download_url")] public string DownloadUrl { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Requests/ServerPower.cs b/Moonlight/App/ApiClients/Wings/Requests/ServerPower.cs deleted file mode 100644 index 75ee64ce..00000000 --- a/Moonlight/App/ApiClients/Wings/Requests/ServerPower.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Requests; - -public class ServerPower -{ - [JsonProperty("action")] - public string Action { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Resources/ListDirectory.cs b/Moonlight/App/ApiClients/Wings/Resources/ListDirectory.cs deleted file mode 100644 index 304c7656..00000000 --- a/Moonlight/App/ApiClients/Wings/Resources/ListDirectory.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Resources; - -public class ListDirectory -{ - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("created")] - public DateTimeOffset Created { get; set; } - - [JsonProperty("modified")] - public DateTimeOffset Modified { get; set; } - - [JsonProperty("size")] - public long Size { get; set; } - - [JsonProperty("directory")] - public bool Directory { get; set; } - - [JsonProperty("file")] - public bool File { get; set; } - - [JsonProperty("symlink")] - public bool Symlink { get; set; } - - [JsonProperty("mime")] - public string Mime { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Resources/ServerDetails.cs b/Moonlight/App/ApiClients/Wings/Resources/ServerDetails.cs deleted file mode 100644 index 6756128a..00000000 --- a/Moonlight/App/ApiClients/Wings/Resources/ServerDetails.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Resources; - -public class ServerDetails -{ - [JsonProperty("state")] - public string State { get; set; } - - [JsonProperty("is_suspended")] - public bool IsSuspended { get; set; } - - [JsonProperty("utilization")] - public ServerDetailsUtilization Utilization { get; set; } - - public class ServerDetailsUtilization - { - [JsonProperty("memory_bytes")] - public long MemoryBytes { get; set; } - - [JsonProperty("memory_limit_bytes")] - public long MemoryLimitBytes { get; set; } - - [JsonProperty("cpu_absolute")] - public double CpuAbsolute { get; set; } - - [JsonProperty("network")] - public ServerDetailsNetwork Network { get; set; } - - [JsonProperty("uptime")] - public long Uptime { get; set; } - - [JsonProperty("state")] - public string State { get; set; } - - [JsonProperty("disk_bytes")] - public long DiskBytes { get; set; } - } - - public class ServerDetailsNetwork - { - [JsonProperty("rx_bytes")] - public long RxBytes { get; set; } - - [JsonProperty("tx_bytes")] - public long TxBytes { get; set; } - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/Resources/SystemStatus.cs b/Moonlight/App/ApiClients/Wings/Resources/SystemStatus.cs deleted file mode 100644 index 66b4d4cc..00000000 --- a/Moonlight/App/ApiClients/Wings/Resources/SystemStatus.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.ApiClients.Wings.Resources; - -public class SystemStatus -{ - [JsonProperty("architecture")] - public string Architecture { get; set; } - - [JsonProperty("cpu_count")] - public long CpuCount { get; set; } - - [JsonProperty("kernel_version")] - public string KernelVersion { get; set; } - - [JsonProperty("os")] - public string Os { get; set; } - - [JsonProperty("version")] - public string Version { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/WingsApiHelper.cs b/Moonlight/App/ApiClients/Wings/WingsApiHelper.cs deleted file mode 100644 index cd63e93a..00000000 --- a/Moonlight/App/ApiClients/Wings/WingsApiHelper.cs +++ /dev/null @@ -1,221 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Newtonsoft.Json; -using RestSharp; - -namespace Moonlight.App.ApiClients.Wings; - -public class WingsApiHelper -{ - private readonly RestClient Client; - - public WingsApiHelper() - { - Client = new(); - } - - public async Task Get(Node node, string resource) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Get; - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"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 GetRaw(Node node, string resource) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Get; - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - - return response.Content!; - } - - public async Task Post(Node node, string resource, object? body) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Post; - - request.AddParameter("text/plain", - JsonConvert.SerializeObject(body), - ParameterType.RequestBody - ); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"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(Node node, string resource, object? body) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Post; - - if(body != null) - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - public async Task PostRaw(Node node, string resource, object body) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Post; - - request.AddParameter("text/plain", body, ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - public async Task Delete(Node node, string resource, object? body) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Delete; - - if(body != null) - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - public async Task Put(Node node, string resource, object? body) - { - var request = CreateRequest(node, resource); - - request.Method = Method.Put; - - request.AddParameter("text/plain", JsonConvert.SerializeObject(body), ParameterType.RequestBody); - - var response = await Client.ExecuteAsync(request); - - if (!response.IsSuccessful) - { - if (response.StatusCode != 0) - { - throw new WingsException( - $"An error occured: ({response.StatusCode}) {response.Content}", - (int)response.StatusCode - ); - } - else - { - throw new Exception($"An internal error occured: {response.ErrorMessage}"); - } - } - } - - private RestRequest CreateRequest(Node node, string resource) - { - var url = (node.Ssl ? "https" : "http") + $"://{node.Fqdn}:{node.HttpPort}/" + resource; - - var request = new RestRequest(url) - { - Timeout = 300000 - }; - - request.AddHeader("Content-Type", "application/json"); - request.AddHeader("Accept", "application/json"); - request.AddHeader("Authorization", "Bearer " + node.Token); - - return request; - } -} \ No newline at end of file diff --git a/Moonlight/App/ApiClients/Wings/WingsException.cs b/Moonlight/App/ApiClients/Wings/WingsException.cs deleted file mode 100644 index 5cb1d789..00000000 --- a/Moonlight/App/ApiClients/Wings/WingsException.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.ApiClients.Wings; - -[Serializable] -public class WingsException : Exception -{ - public int StatusCode { get; set; } - - public WingsException() - { - } - - public WingsException(string message, int statusCode) : base(message) - { - StatusCode = statusCode; - } - - public WingsException(string message) : base(message) - { - } - - public WingsException(string message, Exception inner) : base(message, inner) - { - } - - protected WingsException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/Configuration/ConfigV1.cs b/Moonlight/App/Configuration/ConfigV1.cs deleted file mode 100644 index bae80c85..00000000 --- a/Moonlight/App/Configuration/ConfigV1.cs +++ /dev/null @@ -1,410 +0,0 @@ -using System.ComponentModel; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Configuration; - -using System; -using Newtonsoft.Json; - -public class ConfigV1 -{ - [JsonProperty("Moonlight")] public MoonlightData Moonlight { get; set; } = new(); - - public class MoonlightData - { - [JsonProperty("AppUrl")] - [Description("The url moonlight is accesible with from the internet")] - public string AppUrl { get; set; } = "http://your-moonlight-url-without-slash"; - - [JsonProperty("EnableLatencyCheck")] - [Description( - "This will enable a latency check for connections to moonlight. Users with an too high latency will be warned that moonlight might be buggy for them")] - public bool EnableLatencyCheck { get; set; } = true; - - [JsonProperty("LatencyCheckThreshold")] - [Description("Specify the latency threshold which has to be reached in order to trigger the warning message")] - public int LatencyCheckThreshold { get; set; } = 1000; - - [JsonProperty("LetsEncrypt")] public LetsEncrypt LetsEncrypt { get; set; } = new(); - - [JsonProperty("Auth")] public AuthData Auth { get; set; } = new(); - - [JsonProperty("Database")] public DatabaseData Database { get; set; } = new(); - - [JsonProperty("DiscordBotApi")] public DiscordBotApiData DiscordBotApi { get; set; } = new(); - - [JsonProperty("DiscordBot")] public DiscordBotData DiscordBot { get; set; } = new(); - - [JsonProperty("Domains")] public DomainsData Domains { get; set; } = new(); - - [JsonProperty("Html")] public HtmlData Html { get; set; } = new(); - - [JsonProperty("Marketing")] public MarketingData Marketing { get; set; } = new(); - - [JsonProperty("OAuth2")] public OAuth2Data OAuth2 { get; set; } = new(); - - [JsonProperty("Security")] public SecurityData Security { get; set; } = new(); - - [JsonProperty("Mail")] public MailData Mail { get; set; } = new(); - - [JsonProperty("Cleanup")] public CleanupData Cleanup { get; set; } = new(); - - [JsonProperty("DiscordNotifications")] - public DiscordNotificationsData DiscordNotifications { get; set; } = new(); - - [JsonProperty("Statistics")] public StatisticsData Statistics { get; set; } = new(); - - [JsonProperty("Rating")] public RatingData Rating { get; set; } = new(); - - [JsonProperty("SmartDeploy")] public SmartDeployData SmartDeploy { get; set; } = new(); - - [JsonProperty("Sentry")] public SentryData Sentry { get; set; } = new(); - - [JsonProperty("Stripe")] public StripeData Stripe { get; set; } = new(); - - [JsonProperty("Tickets")] public TicketsData Tickets { get; set; } = new(); - } - - public class LetsEncrypt - { - [JsonProperty("Enable")] - [Description("Enable automatic lets encrypt certificate issuing. This is a beta feature")] - public bool Enable { get; set; } = false; - - [JsonProperty("ExpireEmail")] - [Description("Lets encrypt will send you an email upon certificate expiration to this address")] - public string ExpireEmail { get; set; } = "your@email.test"; - - [JsonProperty("CountryCode")] - [Description("Country code to use for generating the certificate")] - public string CountryCode { get; set; } = "DE"; - - [JsonProperty("State")] - [Description("State to use for generating the certificate")] - public string State { get; set; } = "Germany"; - - [JsonProperty("Locality")] - [Description("Locality to use for generating the certificate")] - public string Locality { get; set; } = "Bavaria"; - - [JsonProperty("Organization")] - [Description("Organization to use for generating the certificate")] - public string Organization { get; set; } = "Moonlight Panel"; - } - - public class TicketsData - { - [JsonProperty("WelcomeMessage")] - [Description("The message that will be sent when a user created a ticket")] - public string WelcomeMessage { get; set; } = "Welcome to the support"; - } - - public class StripeData - { - [JsonProperty("ApiKey")] - [Description( - "Put here your stripe api key if you add subscriptions. Currently the only billing option is stripe which is enabled by default and cannot be turned off. This feature is still experimental")] - public string ApiKey { get; set; } = ""; - } - - public class AuthData - { - [JsonProperty("DenyLogin")] - [Description("Prevent every new login")] - public bool DenyLogin { get; set; } = false; - - [JsonProperty("DenyRegister")] - [Description("Prevent every new user to register")] - public bool DenyRegister { get; set; } = false; - - [JsonProperty("CheckForBots")] - [Description("Check for bots when a user has been registered")] - public bool CheckForBots { get; set; } = true; - - [JsonProperty("BlockLinuxUsers")] - [Description("Blocks linux users from registering")] - public bool BlockLinuxUsers { get; set; } = false; - } - - public class CleanupData - { - [JsonProperty("Cpu")] - [Description("The maximum amount of cpu usage in percent a node is allowed to use before the cleanup starts")] - public long Cpu { get; set; } = 90; - - [JsonProperty("Memory")] - [Description("The minumum amount of memory in megabytes avaliable before the cleanup starts")] - public long Memory { get; set; } = 8192; - - [JsonProperty("Wait")] - [Description("The delay between every cleanup check in minutes")] - public long Wait { get; set; } = 15; - - [JsonProperty("Uptime")] - [Description("The maximum uptime of any server in hours before it the server restarted by the cleanup system")] - public long Uptime { get; set; } = 6; - - [JsonProperty("Enable")] - [Description( - "The cleanup system provides a fair way for stopping unused servers and staying stable even with overallocation. A detailed explanation: docs.endelon-hosting.de/erklaerungen/cleanup")] - public bool Enable { get; set; } = false; - - [JsonProperty("MinUptime")] - [Description("The minumum uptime of a server in minutes to prevent stopping servers which just started")] - public long MinUptime { get; set; } = 10; - } - - public class DatabaseData - { - [JsonProperty("Database")] public string Database { get; set; } = "moonlight_db"; - - [JsonProperty("Host")] public string Host { get; set; } = "your.database.host"; - - [JsonProperty("Password")] [Blur] public string Password { get; set; } = "secret"; - - [JsonProperty("Port")] public long Port { get; set; } = 3306; - - [JsonProperty("Username")] public string Username { get; set; } = "moonlight_user"; - } - - public class DiscordBotApiData - { - [JsonProperty("Enable")] - [Description("Enable the discord bot api. Currently only DatBot is using this api")] - public bool Enable { get; set; } = false; - - [JsonProperty("Token")] - [Description("Specify the token the api client needs to provide")] - [Blur] - public string Token { get; set; } = Guid.NewGuid().ToString(); - } - - public class DiscordBotData - { - [JsonProperty("Enable")] - [Description("The discord bot can be used to allow customers to manage their servers via discord")] - public bool Enable { get; set; } = false; - - [JsonProperty("Token")] - [Description("Your discord bot token goes here")] - [Blur] - public string Token { get; set; } = "discord token here"; - - [JsonProperty("PowerActions")] - [Description("Enable actions like starting and stopping servers")] - public bool PowerActions { get; set; } = false; - - [JsonProperty("SendCommands")] - [Description("Allow users to send commands to their servers")] - public bool SendCommands { get; set; } = false; - } - - public class DiscordNotificationsData - { - [JsonProperty("Enable")] - [Description( - "The discord notification system sends you a message everytime a event like a new support chat message is triggered with usefull data describing the event")] - public bool Enable { get; set; } = false; - - [JsonProperty("WebHook")] - [Description("The discord webhook the notifications are being sent to")] - [Blur] - public string WebHook { get; set; } = "http://your-discord-webhook-url"; - } - - public class DomainsData - { - [JsonProperty("Enable")] - [Description("This enables the domain system")] - public bool Enable { get; set; } = false; - - [JsonProperty("AccountId")] - [Description("This option specifies the cloudflare account id")] - public string AccountId { get; set; } = "cloudflare acc id"; - - [JsonProperty("Email")] - [Description("This specifies the cloudflare email to use for communicating with the cloudflare api")] - public string Email { get; set; } = "cloudflare@acc.email"; - - [JsonProperty("Key")] - [Description("Your cloudflare api key goes here")] - [Blur] - public string Key { get; set; } = "secret"; - } - - public class HtmlData - { - [JsonProperty("Headers")] public HeadersData Headers { get; set; } = new(); - } - - public class HeadersData - { - [JsonProperty("Color")] - [Description( - "This specifies the color of the embed generated by platforms like discord when someone posts a link to your moonlight instance")] - public string Color { get; set; } = "#4b27e8"; - - [JsonProperty("Description")] - [Description( - "This specifies the description text of the embed generated by platforms like discord when someone posts a link to your moonlight instance and can also help google to index your moonlight instance correctly")] - public string Description { get; set; } = "the next generation hosting panel"; - - [JsonProperty("Keywords")] - [Description( - "To help search engines like google to index your moonlight instance correctly you can specify keywords seperated by a comma here")] - public string Keywords { get; set; } = "moonlight"; - - [JsonProperty("Title")] - [Description( - "This specifies the title of the embed generated by platforms like discord when someone posts a link to your moonlight instance")] - public string Title { get; set; } = "Moonlight - endelon.link"; - } - - public class MailData - { - [JsonProperty("Email")] public string Email { get; set; } = "username@your.mail.host"; - - [JsonProperty("Server")] public string Server { get; set; } = "your.mail.host"; - - [JsonProperty("Password")] [Blur] public string Password { get; set; } = "secret"; - - [JsonProperty("Port")] public int Port { get; set; } = 465; - - [JsonProperty("Ssl")] public bool Ssl { get; set; } = true; - } - - public class MarketingData - { - [JsonProperty("BrandName")] public string BrandName { get; set; } = "Endelon Hosting"; - - [JsonProperty("Imprint")] public string Imprint { get; set; } = "https://your-site.xyz/imprint"; - - [JsonProperty("Privacy")] public string Privacy { get; set; } = "https://your-site.xyz/privacy"; - [JsonProperty("About")] public string About { get; set; } = "https://your-site.xyz/about"; - [JsonProperty("Website")] public string Website { get; set; } = "https://your-site.xyz"; - } - - public class OAuth2Data - { - [JsonProperty("OverrideUrl")] - [Description("This overrides the redirect url which would be typicaly the app url")] - public string OverrideUrl { get; set; } = "https://only-for-development.cases"; - - [JsonProperty("EnableOverrideUrl")] - [Description("This enables the url override")] - public bool EnableOverrideUrl { get; set; } = false; - - [JsonProperty("Providers")] - public OAuth2ProviderData[] Providers { get; set; } = Array.Empty(); - } - - public class OAuth2ProviderData - { - [JsonProperty("Id")] public string Id { get; set; } - - [JsonProperty("ClientId")] public string ClientId { get; set; } - - [JsonProperty("ClientSecret")] [Blur] public string ClientSecret { get; set; } - } - - public class RatingData - { - [JsonProperty("Enabled")] - [Description( - "The rating systems shows a user who is registered longer than the set amout of days a popup to rate this platform if he hasnt rated it before")] - public bool Enabled { get; set; } = false; - - [JsonProperty("Url")] - [Description( - "This is the url a user who rated above a set limit is shown to rate you again. Its recommended to put your google or trustpilot rate link here")] - public string Url { get; set; } = "https://link-to-google-or-smth"; - - [JsonProperty("MinRating")] - [Description("The minimum star count on the rating ranging from 1 to 5")] - public int MinRating { get; set; } = 4; - - [JsonProperty("DaysSince")] - [Description("The days a user has to be registered to even be able to get this popup")] - public int DaysSince { get; set; } = 5; - } - - public class SecurityData - { - [JsonProperty("Token")] - [Description( - "This is the moonlight app token. It is used to encrypt and decrypt data and validate tokens and sessions")] - [Blur] - public string Token { get; set; } = Guid.NewGuid().ToString(); - - [JsonProperty("MalwareCheckOnStart")] - [Description( - "This option will enable the scanning for malware on every server before it has been started and if something has been found, the power action will be canceled")] - public bool MalwareCheckOnStart { get; set; } = true; - - [JsonProperty("BlockIpDuration")] - [Description("The duration in minutes a ip will be blocked by the anti ddos system")] - public int BlockIpDuration { get; set; } = 15; - - [JsonProperty("ReCaptcha")] public ReCaptchaData ReCaptcha { get; set; } = new(); - - [JsonProperty("BlockDatacenterIps")] - [Description( - "If this option is enabled, users with an ip from datacenters will not be able to access the panel")] - public bool BlockDatacenterIps { get; set; } = true; - - [JsonProperty("AllowCloudflareIps")] - [Description("Allow cloudflare ips to bypass the datacenter ip check")] - public bool AllowCloudflareIps { get; set; } = false; - } - - public class ReCaptchaData - { - [JsonProperty("Enable")] - [Description( - "Enables repatcha at places like the register page. For information how to get your recaptcha credentails go to google.com/recaptcha/about/")] - public bool Enable { get; set; } = false; - - [JsonProperty("SiteKey")] [Blur] public string SiteKey { get; set; } = "recaptcha site key here"; - - [JsonProperty("SecretKey")] [Blur] public string SecretKey { get; set; } = "recaptcha secret here"; - } - - public class SentryData - { - [JsonProperty("Enable")] - [Description( - "Sentry is a way to monitor application crashes and performance issues in real time. Enable this option only if you set a sentry dsn")] - public bool Enable { get; set; } = false; - - [JsonProperty("Dsn")] - [Description("The dsn is the key moonlight needs to communicate with your sentry instance")] - [Blur] - public string Dsn { get; set; } = "http://your-sentry-url-here"; - } - - public class SmartDeployData - { - [JsonProperty("Server")] public SmartDeployServerData Server { get; set; } = new(); - } - - public class SmartDeployServerData - { - [JsonProperty("EnableOverride")] public bool EnableOverride { get; set; } = false; - - [JsonProperty("OverrideNode")] public long OverrideNode { get; set; } = 1; - } - - public class StatisticsData - { - [JsonProperty("Enabled")] public bool Enabled { get; set; } = false; - - [JsonProperty("Wait")] public long Wait { get; set; } = 15; - } - - public class SellPassData - { - [JsonProperty("Enable")] public bool Enable { get; set; } = false; - - [JsonProperty("Url")] public string Url { get; set; } = "https://not-implemented-yet"; - } -} \ No newline at end of file diff --git a/Moonlight/App/Database/DataContext.cs b/Moonlight/App/Database/DataContext.cs deleted file mode 100644 index d872f3e5..00000000 --- a/Moonlight/App/Database/DataContext.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Database.Entities.Notification; -using Moonlight.App.Database.Interceptors; -using Moonlight.App.Services; - -namespace Moonlight.App.Database; - -public class DataContext : DbContext -{ - private readonly ConfigService ConfigService; - - public DataContext(ConfigService configService) - { - ConfigService = configService; - } - - public DbSet DockerImages { get; set; } - public DbSet Images { get; set; } - public DbSet ImageVariables { get; set; } - public DbSet Nodes { get; set; } - public DbSet NodeAllocations { get; set; } - public DbSet Servers { get; set; } - public DbSet ServerBackups { get; set; } - public DbSet ServerVariables { get; set; } - public DbSet Users { get; set; } - public DbSet LoadingMessages { get; set; } - public DbSet SharedDomains { get; set; } - public DbSet Domains { get; set; } - public DbSet Revokes { get; set; } - public DbSet NotificationClients { get; set; } - public DbSet NotificationActions { get; set; } - public DbSet DdosAttacks { get; set; } - public DbSet Subscriptions { get; set; } - public DbSet Statistics { get; set; } - public DbSet NewsEntries { get; set; } - - public DbSet CloudPanels { get; set; } - public DbSet Databases { get; set; } - public DbSet WebSpaces { get; set; } - public DbSet SupportChatMessages { get; set; } - public DbSet IpBans { get; set; } - public DbSet PermissionGroups { get; set; } - public DbSet SecurityLogs { get; set; } - public DbSet BlocklistIps { get; set; } - public DbSet WhitelistIps { get; set; } - - public DbSet Tickets { get; set; } - public DbSet TicketMessages { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if (!optionsBuilder.IsConfigured) - { - var config = ConfigService - .Get() - .Moonlight.Database; - - var connectionString = $"host={config.Host};" + - $"port={config.Port};" + - $"database={config.Database};" + - $"uid={config.Username};" + - $"pwd={config.Password}"; - - optionsBuilder.UseMySql( - connectionString, - ServerVersion.Parse("5.7.37-mysql"), - builder => - { - builder.EnableRetryOnFailure(5); - } - ); - - if(ConfigService.SqlDebugMode) - optionsBuilder.AddInterceptors(new SqlLoggingInterceptor()); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/BlocklistIp.cs b/Moonlight/App/Database/Entities/BlocklistIp.cs deleted file mode 100644 index 5e80daf2..00000000 --- a/Moonlight/App/Database/Entities/BlocklistIp.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class BlocklistIp -{ - public int Id { get; set; } - public string Ip { get; set; } = ""; - public DateTime ExpiresAt { get; set; } - public long Packets { get; set; } - public DateTime CreatedAt { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/CloudPanel.cs b/Moonlight/App/Database/Entities/CloudPanel.cs deleted file mode 100644 index de872b0f..00000000 --- a/Moonlight/App/Database/Entities/CloudPanel.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class CloudPanel -{ - public int Id { get; set; } - public string Name { get; set; } = ""; - public string ApiUrl { get; set; } = ""; - public string ApiKey { get; set; } = ""; - public string Host { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/DdosAttack.cs b/Moonlight/App/Database/Entities/DdosAttack.cs deleted file mode 100644 index 1b792e29..00000000 --- a/Moonlight/App/Database/Entities/DdosAttack.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class DdosAttack -{ - public int Id { get; set; } - public bool Ongoing { get; set; } - public long Data { get; set; } - public string Ip { get; set; } = ""; - public Node Node { get; set; } = null!; - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/DockerImage.cs b/Moonlight/App/Database/Entities/DockerImage.cs deleted file mode 100644 index 047d1faa..00000000 --- a/Moonlight/App/Database/Entities/DockerImage.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Database.Entities; - -public class DockerImage -{ - [JsonIgnore] - public int Id { get; set; } - public bool Default { get; set; } = false; - public string Name { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Domain.cs b/Moonlight/App/Database/Entities/Domain.cs deleted file mode 100644 index 2f7645a6..00000000 --- a/Moonlight/App/Database/Entities/Domain.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Database.Entities; - -public class Domain -{ - public int Id { get; set; } - - [Required] - public string Name { get; set; } - public SharedDomain SharedDomain { get; set; } - public User Owner { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Image.cs b/Moonlight/App/Database/Entities/Image.cs deleted file mode 100644 index 70660f0d..00000000 --- a/Moonlight/App/Database/Entities/Image.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Database.Entities; - -public class Image -{ - [JsonIgnore] - public int Id { get; set; } - public Guid Uuid { get; set; } - public string Name { get; set; } = ""; - public string Description { get; set; } = ""; - public string ConfigFiles { get; set; } = "{}"; - public string StopCommand { get; set; } = ""; - public string StartupDetection { get; set; } = ""; - public string InstallScript { get; set; } = ""; - public string InstallDockerImage { get; set; } = ""; - public string InstallEntrypoint { get; set; } = ""; - public string Startup { get; set; } = ""; - public int Allocations { get; set; } = 1; - public List DockerImages { get; set; } = new(); - public List Variables { get; set; } = new(); - public string TagsJson { get; set; } = ""; - public string BackgroundImageUrl { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/ImageVariable.cs b/Moonlight/App/Database/Entities/ImageVariable.cs deleted file mode 100644 index 8a394a70..00000000 --- a/Moonlight/App/Database/Entities/ImageVariable.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Database.Entities; - -public class ImageVariable -{ - [JsonIgnore] - public int Id { get; set; } - public string Key { get; set; } = ""; - public string DefaultValue { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/IpBan.cs b/Moonlight/App/Database/Entities/IpBan.cs deleted file mode 100644 index 7ace5eef..00000000 --- a/Moonlight/App/Database/Entities/IpBan.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class IpBan -{ - public int Id { get; set; } - public string Ip { get; set; } = ""; - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/LoadingMessage.cs b/Moonlight/App/Database/Entities/LoadingMessage.cs deleted file mode 100644 index 668590d0..00000000 --- a/Moonlight/App/Database/Entities/LoadingMessage.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class LoadingMessage -{ - public int Id { get; set; } - public string Message { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/MySqlDatabase.cs b/Moonlight/App/Database/Entities/MySqlDatabase.cs deleted file mode 100644 index c9cdc6ef..00000000 --- a/Moonlight/App/Database/Entities/MySqlDatabase.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class MySqlDatabase -{ - public int Id { get; set; } - public WebSpace WebSpace { get; set; } - public string UserName { get; set; } = ""; - public string Password { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/NewsEntry.cs b/Moonlight/App/Database/Entities/NewsEntry.cs deleted file mode 100644 index d40fb26c..00000000 --- a/Moonlight/App/Database/Entities/NewsEntry.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class NewsEntry -{ - public int Id { get; set; } - - public DateTime Date { get; set; } - public string Title { get; set; } - public string Markdown { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Node.cs b/Moonlight/App/Database/Entities/Node.cs deleted file mode 100644 index 1eb293c5..00000000 --- a/Moonlight/App/Database/Entities/Node.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class Node -{ - public int Id { get; set; } - public string Name { get; set; } = ""; - public string Fqdn { get; set; } = ""; - public string TokenId { get; set; } = ""; - public string Token { get; set; } = ""; - public int SftpPort { get; set; } - public int HttpPort { get; set; } - public int MoonlightDaemonPort { get; set; } - public List Allocations { get; set; } = new(); - public bool Ssl { get; set; } = false; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/NodeAllocation.cs b/Moonlight/App/Database/Entities/NodeAllocation.cs deleted file mode 100644 index d726f7f6..00000000 --- a/Moonlight/App/Database/Entities/NodeAllocation.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class NodeAllocation -{ - public int Id { get; set; } - public int Port { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Notification/NotificationAction.cs b/Moonlight/App/Database/Entities/Notification/NotificationAction.cs deleted file mode 100644 index 3d7d052c..00000000 --- a/Moonlight/App/Database/Entities/Notification/NotificationAction.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities.Notification; - -public class NotificationAction -{ - public int Id { get; set; } - public NotificationClient NotificationClient { get; set; } - public string Action { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Notification/NotificationClient.cs b/Moonlight/App/Database/Entities/Notification/NotificationClient.cs deleted file mode 100644 index 133a1dcb..00000000 --- a/Moonlight/App/Database/Entities/Notification/NotificationClient.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Database.Entities.Notification; - -public class NotificationClient -{ - public int Id { get; set; } - public User User { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/PermissionGroup.cs b/Moonlight/App/Database/Entities/PermissionGroup.cs deleted file mode 100644 index f6b44bab..00000000 --- a/Moonlight/App/Database/Entities/PermissionGroup.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class PermissionGroup -{ - public int Id { get; set; } - public string Name { get; set; } = ""; - public byte[] Permissions { get; set; } = Array.Empty(); -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Revoke.cs b/Moonlight/App/Database/Entities/Revoke.cs deleted file mode 100644 index 142d86a6..00000000 --- a/Moonlight/App/Database/Entities/Revoke.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class Revoke -{ - public int Id { get; set; } - public string Identifier { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/SecurityLog.cs b/Moonlight/App/Database/Entities/SecurityLog.cs deleted file mode 100644 index 4d83890b..00000000 --- a/Moonlight/App/Database/Entities/SecurityLog.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class SecurityLog -{ - public int Id { get; set; } - public string Text { get; set; } = ""; - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Server.cs b/Moonlight/App/Database/Entities/Server.cs deleted file mode 100644 index bea519d1..00000000 --- a/Moonlight/App/Database/Entities/Server.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class Server -{ - public int Id { get; set; } - public Guid Uuid { get; set; } - public string Name { get; set; } = ""; - public int Cpu { get; set; } - public long Memory { get; set; } - public long Disk { get; set; } - public Image Image { get; set; } = null!; - public int DockerImageIndex { get; set; } = 0; - public string OverrideStartup { get; set; } = ""; - public bool Installing { get; set; } = false; - public bool Suspended { get; set; } = false; - public bool IsArchived { get; set; } = false; - public ServerBackup? Archive { get; set; } = null; - - public List Variables { get; set; } = new(); - public List Backups { get; set; } = new(); - public List Allocations { get; set; } = new(); - public NodeAllocation? MainAllocation { get; set; } = null; - public Node Node { get; set; } = null!; - public User Owner { get; set; } = null!; - public bool IsCleanupException { get; set; } = false; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/ServerBackup.cs b/Moonlight/App/Database/Entities/ServerBackup.cs deleted file mode 100644 index 185e59ae..00000000 --- a/Moonlight/App/Database/Entities/ServerBackup.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class ServerBackup -{ - public int Id { get; set; } - public string Name { get; set; } = ""; - public Guid Uuid { get; set; } - public DateTime CreatedAt { get; set; } - public bool Created { get; set; } = false; - public long Bytes { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/ServerVariable.cs b/Moonlight/App/Database/Entities/ServerVariable.cs deleted file mode 100644 index 0feecbb4..00000000 --- a/Moonlight/App/Database/Entities/ServerVariable.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class ServerVariable -{ - public int Id { get; set; } - public string Key { get; set; } = ""; - public string Value { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/SharedDomain.cs b/Moonlight/App/Database/Entities/SharedDomain.cs deleted file mode 100644 index cf9f27ae..00000000 --- a/Moonlight/App/Database/Entities/SharedDomain.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class SharedDomain -{ - public int Id { get; set; } - public string Name { get; set; } - public string CloudflareId { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/StatisticsData.cs b/Moonlight/App/Database/Entities/StatisticsData.cs deleted file mode 100644 index 64f8ea7d..00000000 --- a/Moonlight/App/Database/Entities/StatisticsData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class StatisticsData -{ - public int Id { get; set; } - - public string Chart { get; set; } - - public double Value { get; set; } - - public DateTime Date { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Subscription.cs b/Moonlight/App/Database/Entities/Subscription.cs deleted file mode 100644 index 5e1fd059..00000000 --- a/Moonlight/App/Database/Entities/Subscription.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Database.Entities; - -public class Subscription -{ - public int Id { get; set; } - public string Name { get; set; } = ""; - public string Description { get; set; } = ""; - public Currency Currency { get; set; } = Currency.USD; - public double Price { get; set; } - public string StripeProductId { get; set; } = ""; - public string StripePriceId { get; set; } = ""; - public string LimitsJson { get; set; } = ""; - public int Duration { get; set; } = 30; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/SupportChatMessage.cs b/Moonlight/App/Database/Entities/SupportChatMessage.cs deleted file mode 100644 index 47ad3e6b..00000000 --- a/Moonlight/App/Database/Entities/SupportChatMessage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Database.Entities; - -public class SupportChatMessage -{ - public int Id { get; set; } - - public string Content { get; set; } = ""; - public string Attachment { get; set; } = ""; - - public User? Sender { get; set; } - public User Recipient { get; set; } - - public bool IsQuestion { get; set; } = false; - public QuestionType QuestionType { get; set; } - public string Answer { get; set; } = ""; - - public DateTime CreatedAt { get; set; } - public DateTime UpdatedAt { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/SupportChatSnippets.cs b/Moonlight/App/Database/Entities/SupportChatSnippets.cs deleted file mode 100644 index b4021ae2..00000000 --- a/Moonlight/App/Database/Entities/SupportChatSnippets.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class SupportChatSnippets -{ - public int Id { get; set; } - public string Name { get; set; } = ""; - public string Description { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/Ticket.cs b/Moonlight/App/Database/Entities/Ticket.cs deleted file mode 100644 index 2a90d917..00000000 --- a/Moonlight/App/Database/Entities/Ticket.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Database.Entities; - -public class Ticket -{ - public int Id { get; set; } - public string IssueTopic { get; set; } = ""; - public string IssueDescription { get; set; } = ""; - public string IssueTries { get; set; } = ""; - public User CreatedBy { get; set; } - public User? AssignedTo { get; set; } - public TicketPriority Priority { get; set; } - public TicketStatus Status { get; set; } - public TicketSubject Subject { get; set; } - public int SubjectId { get; set; } - public List Messages { get; set; } = new(); - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/TicketMessage.cs b/Moonlight/App/Database/Entities/TicketMessage.cs deleted file mode 100644 index 940631bc..00000000 --- a/Moonlight/App/Database/Entities/TicketMessage.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class TicketMessage -{ - public int Id { get; set; } - public string Content { get; set; } = ""; - public string? AttachmentUrl { get; set; } - public User? Sender { get; set; } - public bool IsSystemMessage { get; set; } - public bool IsEdited { get; set; } - public bool IsSupportMessage { get; set; } - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; - public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/User.cs b/Moonlight/App/Database/Entities/User.cs deleted file mode 100644 index be6036f4..00000000 --- a/Moonlight/App/Database/Entities/User.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Database.Entities; - -public class User -{ - public int Id { get; set; } - - // Personal data - - public string FirstName { get; set; } = ""; - - public string LastName { get; set; } = ""; - - public string Email { get; set; } = ""; - - public string Password { get; set; } = ""; - - public string Address { get; set; } = ""; - - public string City { get; set; } = ""; - - public string State { get; set; } = ""; - - public string Country { get; set; } = ""; - - public string ServerListLayoutJson { get; set; } = ""; - - // States - - public UserStatus Status { get; set; } = UserStatus.Unverified; - public bool Admin { get; set; } = false; - public bool SupportPending { get; set; } = false; - public bool HasRated { get; set; } = false; - public int Rating { get; set; } = 0; - public bool StreamerMode { get; set; } = false; - - // Security - public bool TotpEnabled { get; set; } = false; - public string TotpSecret { get; set; } = ""; - public DateTime TokenValidTime { get; set; } = DateTime.UtcNow; - public byte[] Permissions { get; set; } = Array.Empty(); - public PermissionGroup? PermissionGroup { get; set; } - - // Discord - public ulong DiscordId { get; set; } - - // Date stuff - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; - public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; - public DateTime LastVisitedAt { get; set; } = DateTime.UtcNow; - - // Subscriptions - - public Subscription? CurrentSubscription { get; set; } = null; - public DateTime SubscriptionSince { get; set; } = DateTime.UtcNow; - public DateTime SubscriptionExpires { get; set; } = DateTime.UtcNow; - - // Ip logs - public string RegisterIp { get; set; } = ""; - public string LastIp { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/WebSpace.cs b/Moonlight/App/Database/Entities/WebSpace.cs deleted file mode 100644 index 1112fdf6..00000000 --- a/Moonlight/App/Database/Entities/WebSpace.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class WebSpace -{ - public int Id { get; set; } - public string Domain { get; set; } = ""; - public string UserName { get; set; } = ""; - public string Password { get; set; } = ""; - public string VHostTemplate { get; set; } = ""; - public User Owner { get; set; } - public List Databases { get; set; } = new(); - public CloudPanel CloudPanel { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Entities/WhitelistIp.cs b/Moonlight/App/Database/Entities/WhitelistIp.cs deleted file mode 100644 index 571263a1..00000000 --- a/Moonlight/App/Database/Entities/WhitelistIp.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Database.Entities; - -public class WhitelistIp -{ - public int Id { get; set; } - public string Ip { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Database/Interceptors/SqlLoggingInterceptor.cs b/Moonlight/App/Database/Interceptors/SqlLoggingInterceptor.cs deleted file mode 100644 index 7b19fb1a..00000000 --- a/Moonlight/App/Database/Interceptors/SqlLoggingInterceptor.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Data.Common; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Database.Interceptors; - -public class SqlLoggingInterceptor : DbCommandInterceptor -{ - public override InterceptionResult ReaderExecuting( - DbCommand command, - CommandEventData eventData, - InterceptionResult result) - { - LogSql(command.CommandText); - return base.ReaderExecuting(command, eventData, result); - } - - public override InterceptionResult ScalarExecuting( - DbCommand command, - CommandEventData eventData, - InterceptionResult result) - { - LogSql(command.CommandText); - return base.ScalarExecuting(command, eventData, result); - } - - public override InterceptionResult NonQueryExecuting( - DbCommand command, - CommandEventData eventData, - InterceptionResult result) - { - LogSql(command.CommandText); - return base.NonQueryExecuting(command, eventData, result); - } - - private void LogSql(string sql) - { - Logger.Info($"[SQL DEBUG] {sql.Replace("\n", "")}"); - } -} \ No newline at end of file diff --git a/Moonlight/App/Database/Migrations/20230215200722_InitialCreate.Designer.cs b/Moonlight/App/Database/Migrations/20230215200722_InitialCreate.Designer.cs deleted file mode 100644 index a4bdbce2..00000000 --- a/Moonlight/App/Database/Migrations/20230215200722_InitialCreate.Designer.cs +++ /dev/null @@ -1,515 +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("20230215200722_InitialCreate")] - partial class InitialCreate - { - /// - 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.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.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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("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.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.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("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.ToTable("Users"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230215200722_InitialCreate.cs b/Moonlight/App/Database/Migrations/20230215200722_InitialCreate.cs deleted file mode 100644 index 7bc64d22..00000000 --- a/Moonlight/App/Database/Migrations/20230215200722_InitialCreate.cs +++ /dev/null @@ -1,434 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Images", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Uuid = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ConfigFiles = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - StopCommand = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - StartupDetection = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InstallScript = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InstallDockerImage = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InstallEntrypoint = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Startup = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Images", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "LoadingMessages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Message = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_LoadingMessages", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Nodes", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Fqdn = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - TokenId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Token = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SftpPort = table.Column(type: "int", nullable: false), - HttpPort = table.Column(type: "int", nullable: false), - MoonlightDaemonPort = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Nodes", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FirstName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - LastName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Email = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Password = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Address = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - City = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - State = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Country = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Status = table.Column(type: "int", nullable: false), - TotpEnabled = table.Column(type: "tinyint(1)", nullable: false), - TotpSecret = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - TokenValidTime = table.Column(type: "datetime(6)", nullable: false), - DiscordId = table.Column(type: "bigint", nullable: false), - DiscordUsername = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DiscordDiscriminator = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - UpdatedAt = table.Column(type: "datetime(6)", nullable: false), - Admin = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "DockerImages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Default = table.Column(type: "tinyint(1)", nullable: false), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ImageId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_DockerImages", x => x.Id); - table.ForeignKey( - name: "FK_DockerImages_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ImageTags", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ImageId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ImageTags", x => x.Id); - table.ForeignKey( - name: "FK_ImageTags_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ImageVariables", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Key = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - DefaultValue = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ImageId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ImageVariables", x => x.Id); - table.ForeignKey( - name: "FK_ImageVariables_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "NodeAllocations", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Port = table.Column(type: "int", nullable: false), - NodeId = table.Column(type: "int", nullable: true), - ServerId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_NodeAllocations", x => x.Id); - table.ForeignKey( - name: "FK_NodeAllocations_Nodes_NodeId", - column: x => x.NodeId, - principalTable: "Nodes", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Servers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Uuid = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Cpu = table.Column(type: "int", nullable: false), - Memory = table.Column(type: "bigint", nullable: false), - Disk = table.Column(type: "bigint", nullable: false), - ImageId = table.Column(type: "int", nullable: false), - DockerImageIndex = table.Column(type: "int", nullable: false), - OverrideStartup = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Installing = table.Column(type: "tinyint(1)", nullable: false), - Suspended = table.Column(type: "tinyint(1)", nullable: false), - MainAllocationId = table.Column(type: "int", nullable: false), - NodeId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Servers", x => x.Id); - table.ForeignKey( - name: "FK_Servers_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Servers_NodeAllocations_MainAllocationId", - column: x => x.MainAllocationId, - principalTable: "NodeAllocations", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Servers_Nodes_NodeId", - column: x => x.NodeId, - principalTable: "Nodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Servers_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ServerBackups", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Uuid = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Created = table.Column(type: "tinyint(1)", nullable: false), - Bytes = table.Column(type: "bigint", nullable: false), - ServerId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ServerBackups", x => x.Id); - table.ForeignKey( - name: "FK_ServerBackups_Servers_ServerId", - column: x => x.ServerId, - principalTable: "Servers", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ServerVariables", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Key = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ServerId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ServerVariables", x => x.Id); - table.ForeignKey( - name: "FK_ServerVariables_Servers_ServerId", - column: x => x.ServerId, - principalTable: "Servers", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_DockerImages_ImageId", - table: "DockerImages", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_ImageTags_ImageId", - table: "ImageTags", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_ImageVariables_ImageId", - table: "ImageVariables", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_NodeAllocations_NodeId", - table: "NodeAllocations", - column: "NodeId"); - - migrationBuilder.CreateIndex( - name: "IX_NodeAllocations_ServerId", - table: "NodeAllocations", - column: "ServerId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerBackups_ServerId", - table: "ServerBackups", - column: "ServerId"); - - migrationBuilder.CreateIndex( - name: "IX_Servers_ImageId", - table: "Servers", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_Servers_MainAllocationId", - table: "Servers", - column: "MainAllocationId"); - - migrationBuilder.CreateIndex( - name: "IX_Servers_NodeId", - table: "Servers", - column: "NodeId"); - - migrationBuilder.CreateIndex( - name: "IX_Servers_OwnerId", - table: "Servers", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_ServerVariables_ServerId", - table: "ServerVariables", - column: "ServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_NodeAllocations_Servers_ServerId", - table: "NodeAllocations", - column: "ServerId", - principalTable: "Servers", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Servers_Images_ImageId", - table: "Servers"); - - migrationBuilder.DropForeignKey( - name: "FK_NodeAllocations_Nodes_NodeId", - table: "NodeAllocations"); - - migrationBuilder.DropForeignKey( - name: "FK_Servers_Nodes_NodeId", - table: "Servers"); - - migrationBuilder.DropForeignKey( - name: "FK_NodeAllocations_Servers_ServerId", - table: "NodeAllocations"); - - migrationBuilder.DropTable( - name: "DockerImages"); - - migrationBuilder.DropTable( - name: "ImageTags"); - - migrationBuilder.DropTable( - name: "ImageVariables"); - - migrationBuilder.DropTable( - name: "LoadingMessages"); - - migrationBuilder.DropTable( - name: "ServerBackups"); - - migrationBuilder.DropTable( - name: "ServerVariables"); - - migrationBuilder.DropTable( - name: "Images"); - - migrationBuilder.DropTable( - name: "Nodes"); - - migrationBuilder.DropTable( - name: "Servers"); - - migrationBuilder.DropTable( - name: "NodeAllocations"); - - migrationBuilder.DropTable( - name: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230217152643_MigratedSomeModels.Designer.cs b/Moonlight/App/Database/Migrations/20230217152643_MigratedSomeModels.Designer.cs deleted file mode 100644 index bb8b080a..00000000 --- a/Moonlight/App/Database/Migrations/20230217152643_MigratedSomeModels.Designer.cs +++ /dev/null @@ -1,570 +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("20230217152643_MigratedSomeModels")] - partial class MigratedSomeModels - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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("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.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.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("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.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230217152643_MigratedSomeModels.cs b/Moonlight/App/Database/Migrations/20230217152643_MigratedSomeModels.cs deleted file mode 100644 index ba2588c8..00000000 --- a/Moonlight/App/Database/Migrations/20230217152643_MigratedSomeModels.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class MigratedSomeModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AuditLog", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Type = table.Column(type: "int", nullable: false), - JsonData = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - System = table.Column(type: "tinyint(1)", nullable: false), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AuditLog", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Databases", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - AaPanelId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Databases", x => x.Id); - table.ForeignKey( - name: "FK_Databases_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Databases_OwnerId", - table: "Databases", - column: "OwnerId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AuditLog"); - - migrationBuilder.DropTable( - name: "Databases"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230217163230_AddNodeSslOption.Designer.cs b/Moonlight/App/Database/Migrations/20230217163230_AddNodeSslOption.Designer.cs deleted file mode 100644 index b6f8463a..00000000 --- a/Moonlight/App/Database/Migrations/20230217163230_AddNodeSslOption.Designer.cs +++ /dev/null @@ -1,573 +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("20230217163230_AddNodeSslOption")] - partial class AddNodeSslOption - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.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("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.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230217163230_AddNodeSslOption.cs b/Moonlight/App/Database/Migrations/20230217163230_AddNodeSslOption.cs deleted file mode 100644 index f21b4f78..00000000 --- a/Moonlight/App/Database/Migrations/20230217163230_AddNodeSslOption.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddNodeSslOption : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Ssl", - table: "Nodes", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Ssl", - table: "Nodes"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230221173242_AddSupportMessage.Designer.cs b/Moonlight/App/Database/Migrations/20230221173242_AddSupportMessage.Designer.cs deleted file mode 100644 index 8c8f5eac..00000000 --- a/Moonlight/App/Database/Migrations/20230221173242_AddSupportMessage.Designer.cs +++ /dev/null @@ -1,617 +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("20230221173242_AddSupportMessage")] - partial class AddSupportMessage - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.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("Message") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - 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("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.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.SupportMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230221173242_AddSupportMessage.cs b/Moonlight/App/Database/Migrations/20230221173242_AddSupportMessage.cs deleted file mode 100644 index 4153bfe1..00000000 --- a/Moonlight/App/Database/Migrations/20230221173242_AddSupportMessage.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddSupportMessage : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "SupportMessages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Message = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SenderId = table.Column(type: "int", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - IsQuestion = table.Column(type: "tinyint(1)", nullable: false), - Type = table.Column(type: "int", nullable: false), - Answer = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_SupportMessages", x => x.Id); - table.ForeignKey( - name: "FK_SupportMessages_Users_SenderId", - column: x => x.SenderId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_SupportMessages_SenderId", - table: "SupportMessages", - column: "SenderId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "SupportMessages"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230221183730_UpdatedSupportAndUserModel.Designer.cs b/Moonlight/App/Database/Migrations/20230221183730_UpdatedSupportAndUserModel.Designer.cs deleted file mode 100644 index 01ee545b..00000000 --- a/Moonlight/App/Database/Migrations/20230221183730_UpdatedSupportAndUserModel.Designer.cs +++ /dev/null @@ -1,635 +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.Databse.Migrations -{ - [DbContext(typeof(DataContext))] - [Migration("20230221183730_UpdatedSupportAndUserModel")] - partial class UpdatedSupportAndUserModel - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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.Image", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.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("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.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230221183730_UpdatedSupportAndUserModel.cs b/Moonlight/App/Database/Migrations/20230221183730_UpdatedSupportAndUserModel.cs deleted file mode 100644 index 278cbca4..00000000 --- a/Moonlight/App/Database/Migrations/20230221183730_UpdatedSupportAndUserModel.cs +++ /dev/null @@ -1,122 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Databse.Migrations -{ - /// - public partial class UpdatedSupportAndUserModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_SupportMessages_Users_SenderId", - table: "SupportMessages"); - - migrationBuilder.AddColumn( - name: "SupportPending", - table: "Users", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - - migrationBuilder.AlterColumn( - name: "SenderId", - table: "SupportMessages", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AddColumn( - name: "IsSupport", - table: "SupportMessages", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsSystem", - table: "SupportMessages", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "RecipientId", - table: "SupportMessages", - type: "int", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_SupportMessages_RecipientId", - table: "SupportMessages", - column: "RecipientId"); - - migrationBuilder.AddForeignKey( - name: "FK_SupportMessages_Users_RecipientId", - table: "SupportMessages", - column: "RecipientId", - principalTable: "Users", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_SupportMessages_Users_SenderId", - table: "SupportMessages", - column: "SenderId", - principalTable: "Users", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_SupportMessages_Users_RecipientId", - table: "SupportMessages"); - - migrationBuilder.DropForeignKey( - name: "FK_SupportMessages_Users_SenderId", - table: "SupportMessages"); - - migrationBuilder.DropIndex( - name: "IX_SupportMessages_RecipientId", - table: "SupportMessages"); - - migrationBuilder.DropColumn( - name: "SupportPending", - table: "Users"); - - migrationBuilder.DropColumn( - name: "IsSupport", - table: "SupportMessages"); - - migrationBuilder.DropColumn( - name: "IsSystem", - table: "SupportMessages"); - - migrationBuilder.DropColumn( - name: "RecipientId", - table: "SupportMessages"); - - migrationBuilder.AlterColumn( - name: "SenderId", - table: "SupportMessages", - type: "int", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_SupportMessages_Users_SenderId", - table: "SupportMessages", - column: "SenderId", - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230223121111_AddedDomainsAndSharedDomains.Designer.cs b/Moonlight/App/Database/Migrations/20230223121111_AddedDomainsAndSharedDomains.Designer.cs deleted file mode 100644 index 22e1f0c1..00000000 --- a/Moonlight/App/Database/Migrations/20230223121111_AddedDomainsAndSharedDomains.Designer.cs +++ /dev/null @@ -1,702 +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("20230223121111_AddedDomainsAndSharedDomains")] - partial class AddedDomainsAndSharedDomains - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("CloudflareId") - .IsRequired() - .HasColumnType("longtext"); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.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("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.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230223121111_AddedDomainsAndSharedDomains.cs b/Moonlight/App/Database/Migrations/20230223121111_AddedDomainsAndSharedDomains.cs deleted file mode 100644 index 1b1cc2c7..00000000 --- a/Moonlight/App/Database/Migrations/20230223121111_AddedDomainsAndSharedDomains.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedDomainsAndSharedDomains : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "SharedDomains", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CloudflareId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_SharedDomains", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Domains", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SharedDomainId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false), - CloudflareId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Domains", x => x.Id); - table.ForeignKey( - name: "FK_Domains_SharedDomains_SharedDomainId", - column: x => x.SharedDomainId, - principalTable: "SharedDomains", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Domains_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_OwnerId", - table: "Domains", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_Domains_SharedDomainId", - table: "Domains", - column: "SharedDomainId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Domains"); - - migrationBuilder.DropTable( - name: "SharedDomains"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230227150444_RemovedCloudflareId.Designer.cs b/Moonlight/App/Database/Migrations/20230227150444_RemovedCloudflareId.Designer.cs deleted file mode 100644 index 64559b51..00000000 --- a/Moonlight/App/Database/Migrations/20230227150444_RemovedCloudflareId.Designer.cs +++ /dev/null @@ -1,698 +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("20230227150444_RemovedCloudflareId")] - partial class RemovedCloudflareId - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.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("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.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230227150444_RemovedCloudflareId.cs b/Moonlight/App/Database/Migrations/20230227150444_RemovedCloudflareId.cs deleted file mode 100644 index 7e4e8450..00000000 --- a/Moonlight/App/Database/Migrations/20230227150444_RemovedCloudflareId.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedCloudflareId : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CloudflareId", - table: "Domains"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CloudflareId", - table: "Domains", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230302124359_AddedSubscriptions.Designer.cs b/Moonlight/App/Database/Migrations/20230302124359_AddedSubscriptions.Designer.cs deleted file mode 100644 index 073baa19..00000000 --- a/Moonlight/App/Database/Migrations/20230302124359_AddedSubscriptions.Designer.cs +++ /dev/null @@ -1,788 +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("20230302124359_AddedSubscriptions")] - partial class AddedSubscriptions - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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("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("SubscriptionId") - .HasColumnType("int"); - - 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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230302124359_AddedSubscriptions.cs b/Moonlight/App/Database/Migrations/20230302124359_AddedSubscriptions.cs deleted file mode 100644 index c80bb2a4..00000000 --- a/Moonlight/App/Database/Migrations/20230302124359_AddedSubscriptions.cs +++ /dev/null @@ -1,114 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedSubscriptions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "SubscriptionId", - table: "Users", - type: "int", - nullable: true); - - migrationBuilder.CreateTable( - name: "Subscriptions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SellPassId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Subscriptions", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "SubscriptionLimits", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ImageId = table.Column(type: "int", nullable: false), - Amount = table.Column(type: "int", nullable: false), - Cpu = table.Column(type: "int", nullable: false), - Memory = table.Column(type: "int", nullable: false), - Disk = table.Column(type: "int", nullable: false), - SubscriptionId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SubscriptionLimits", x => x.Id); - table.ForeignKey( - name: "FK_SubscriptionLimits_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SubscriptionLimits_Subscriptions_SubscriptionId", - column: x => x.SubscriptionId, - principalTable: "Subscriptions", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Users_SubscriptionId", - table: "Users", - column: "SubscriptionId"); - - migrationBuilder.CreateIndex( - name: "IX_SubscriptionLimits_ImageId", - table: "SubscriptionLimits", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_SubscriptionLimits_SubscriptionId", - table: "SubscriptionLimits", - column: "SubscriptionId"); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Subscriptions_SubscriptionId", - table: "Users", - column: "SubscriptionId", - principalTable: "Subscriptions", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Users_Subscriptions_SubscriptionId", - table: "Users"); - - migrationBuilder.DropTable( - name: "SubscriptionLimits"); - - migrationBuilder.DropTable( - name: "Subscriptions"); - - migrationBuilder.DropIndex( - name: "IX_Users_SubscriptionId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionId", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230302140920_AddedRevokes.Designer.cs b/Moonlight/App/Database/Migrations/20230302140920_AddedRevokes.Designer.cs deleted file mode 100644 index 29788cc8..00000000 --- a/Moonlight/App/Database/Migrations/20230302140920_AddedRevokes.Designer.cs +++ /dev/null @@ -1,803 +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("20230302140920_AddedRevokes")] - partial class AddedRevokes - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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("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("SubscriptionId") - .HasColumnType("int"); - - 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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230302140920_AddedRevokes.cs b/Moonlight/App/Database/Migrations/20230302140920_AddedRevokes.cs deleted file mode 100644 index c47ba70c..00000000 --- a/Moonlight/App/Database/Migrations/20230302140920_AddedRevokes.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedRevokes : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Revokes", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Identifier = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Revokes", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Revokes"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230303155025_AddedMoreSubscriptionData.Designer.cs b/Moonlight/App/Database/Migrations/20230303155025_AddedMoreSubscriptionData.Designer.cs deleted file mode 100644 index e7200208..00000000 --- a/Moonlight/App/Database/Migrations/20230303155025_AddedMoreSubscriptionData.Designer.cs +++ /dev/null @@ -1,809 +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("20230303155025_AddedMoreSubscriptionData")] - partial class AddedMoreSubscriptionData - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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("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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230303155025_AddedMoreSubscriptionData.cs b/Moonlight/App/Database/Migrations/20230303155025_AddedMoreSubscriptionData.cs deleted file mode 100644 index 80463951..00000000 --- a/Moonlight/App/Database/Migrations/20230303155025_AddedMoreSubscriptionData.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedMoreSubscriptionData : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "SubscriptionDuration", - table: "Users", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SubscriptionSince", - table: "Users", - type: "datetime(6)", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "SubscriptionDuration", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionSince", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230303162313_AddedSubscriptionDuration.Designer.cs b/Moonlight/App/Database/Migrations/20230303162313_AddedSubscriptionDuration.Designer.cs deleted file mode 100644 index 641d7205..00000000 --- a/Moonlight/App/Database/Migrations/20230303162313_AddedSubscriptionDuration.Designer.cs +++ /dev/null @@ -1,812 +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("20230303162313_AddedSubscriptionDuration")] - partial class AddedSubscriptionDuration - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230303162313_AddedSubscriptionDuration.cs b/Moonlight/App/Database/Migrations/20230303162313_AddedSubscriptionDuration.cs deleted file mode 100644 index cea257db..00000000 --- a/Moonlight/App/Database/Migrations/20230303162313_AddedSubscriptionDuration.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedSubscriptionDuration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Duration", - table: "Subscriptions", - type: "int", - nullable: false, - defaultValue: 0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Duration", - table: "Subscriptions"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230303170026_NotificationClientMigration.Designer.cs b/Moonlight/App/Database/Migrations/20230303170026_NotificationClientMigration.Designer.cs deleted file mode 100644 index 1710cd95..00000000 --- a/Moonlight/App/Database/Migrations/20230303170026_NotificationClientMigration.Designer.cs +++ /dev/null @@ -1,839 +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("20230303170026_NotificationClientMigration")] - partial class NotificationClientMigration - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230303170026_NotificationClientMigration.cs b/Moonlight/App/Database/Migrations/20230303170026_NotificationClientMigration.cs deleted file mode 100644 index 2c006bbd..00000000 --- a/Moonlight/App/Database/Migrations/20230303170026_NotificationClientMigration.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class NotificationClientMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "NotificationClients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_NotificationClients", x => x.Id); - table.ForeignKey( - name: "FK_NotificationClients_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_NotificationClients_UserId", - table: "NotificationClients", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "NotificationClients"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230303174010_AddedNotificationActions.Designer.cs b/Moonlight/App/Database/Migrations/20230303174010_AddedNotificationActions.Designer.cs deleted file mode 100644 index 0d9ffef5..00000000 --- a/Moonlight/App/Database/Migrations/20230303174010_AddedNotificationActions.Designer.cs +++ /dev/null @@ -1,870 +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("20230303174010_AddedNotificationActions")] - partial class AddedNotificationActions - { - /// - 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.AuditLogEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230303174010_AddedNotificationActions.cs b/Moonlight/App/Database/Migrations/20230303174010_AddedNotificationActions.cs deleted file mode 100644 index a93a967f..00000000 --- a/Moonlight/App/Database/Migrations/20230303174010_AddedNotificationActions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedNotificationActions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "NotificationActions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - NotificationClientId = table.Column(type: "int", nullable: false), - Action = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_NotificationActions", x => x.Id); - table.ForeignKey( - name: "FK_NotificationActions_NotificationClients_NotificationClientId", - column: x => x.NotificationClientId, - principalTable: "NotificationClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_NotificationActions_NotificationClientId", - table: "NotificationActions", - column: "NotificationClientId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "NotificationActions"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230305014834_AddedLoggingAndDbStuff.Designer.cs b/Moonlight/App/Database/Migrations/20230305014834_AddedLoggingAndDbStuff.Designer.cs deleted file mode 100644 index c30818ec..00000000 --- a/Moonlight/App/Database/Migrations/20230305014834_AddedLoggingAndDbStuff.Designer.cs +++ /dev/null @@ -1,925 +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("20230305014834_AddedLoggingAndDbStuff")] - partial class AddedLoggingAndDbStuff - { - /// - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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("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("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("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.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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230305014834_AddedLoggingAndDbStuff.cs b/Moonlight/App/Database/Migrations/20230305014834_AddedLoggingAndDbStuff.cs deleted file mode 100644 index c02562ce..00000000 --- a/Moonlight/App/Database/Migrations/20230305014834_AddedLoggingAndDbStuff.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedLoggingAndDbStuff : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ErrorLog", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Stacktrace = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - System = table.Column(type: "tinyint(1)", nullable: false), - JsonData = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Class = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_ErrorLog", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "SecurityLog", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - System = table.Column(type: "tinyint(1)", nullable: false), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Type = table.Column(type: "int", nullable: false), - JsonData = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_SecurityLog", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ErrorLog"); - - migrationBuilder.DropTable( - name: "SecurityLog"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230305021844_AddedDatesToLogs.Designer.cs b/Moonlight/App/Database/Migrations/20230305021844_AddedDatesToLogs.Designer.cs deleted file mode 100644 index c9b6f20c..00000000 --- a/Moonlight/App/Database/Migrations/20230305021844_AddedDatesToLogs.Designer.cs +++ /dev/null @@ -1,934 +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("20230305021844_AddedDatesToLogs")] - partial class AddedDatesToLogs - { - /// - 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.Database", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AaPanelId") - .HasColumnType("int"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Databases"); - }); - - 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("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("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("ImageId") - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("ImageId"); - - 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.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.Database", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - 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.ImageTag", b => - { - b.HasOne("Moonlight.App.Database.Entities.Image", null) - .WithMany("Tags") - .HasForeignKey("ImageId"); - }); - - 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.Image", b => - { - b.Navigation("DockerImages"); - - b.Navigation("Tags"); - - 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/20230305021844_AddedDatesToLogs.cs b/Moonlight/App/Database/Migrations/20230305021844_AddedDatesToLogs.cs deleted file mode 100644 index 7276d7cb..00000000 --- a/Moonlight/App/Database/Migrations/20230305021844_AddedDatesToLogs.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedDatesToLogs : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "SecurityLog", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "ErrorLog", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "AuditLog", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "SecurityLog"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "ErrorLog"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "AuditLog"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230314164750_SwitchedToJsonTags.Designer.cs b/Moonlight/App/Database/Migrations/20230314164750_SwitchedToJsonTags.Designer.cs deleted file mode 100644 index 5ddb3854..00000000 --- a/Moonlight/App/Database/Migrations/20230314164750_SwitchedToJsonTags.Designer.cs +++ /dev/null @@ -1,1023 +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("20230314164750_SwitchedToJsonTags")] - partial class SwitchedToJsonTags - { - /// - 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.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("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.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.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/20230314164750_SwitchedToJsonTags.cs b/Moonlight/App/Database/Migrations/20230314164750_SwitchedToJsonTags.cs deleted file mode 100644 index 916cdae4..00000000 --- a/Moonlight/App/Database/Migrations/20230314164750_SwitchedToJsonTags.cs +++ /dev/null @@ -1,174 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class SwitchedToJsonTags : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_ImageTags_Images_ImageId", - table: "ImageTags"); - - migrationBuilder.DropIndex( - name: "IX_ImageTags_ImageId", - table: "ImageTags"); - - migrationBuilder.DropColumn( - name: "ImageId", - table: "ImageTags"); - - migrationBuilder.AddColumn( - name: "TagsJson", - table: "Images", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "InternalAaPanelId", - table: "Databases", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "Name", - table: "Databases", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "AaPanels", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Url = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Key = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - BaseDomain = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AaPanels", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Websites", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - InternalAaPanelId = table.Column(type: "int", nullable: false), - AaPanelId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false), - DomainName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - PhpVersion = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - FtpUsername = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - FtpPassword = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Websites", x => x.Id); - table.ForeignKey( - name: "FK_Websites_AaPanels_AaPanelId", - column: x => x.AaPanelId, - principalTable: "AaPanels", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Websites_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Databases_AaPanelId", - table: "Databases", - column: "AaPanelId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_AaPanelId", - table: "Websites", - column: "AaPanelId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_OwnerId", - table: "Websites", - column: "OwnerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Databases_AaPanels_AaPanelId", - table: "Databases", - column: "AaPanelId", - principalTable: "AaPanels", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Databases_AaPanels_AaPanelId", - table: "Databases"); - - migrationBuilder.DropTable( - name: "Websites"); - - migrationBuilder.DropTable( - name: "AaPanels"); - - migrationBuilder.DropIndex( - name: "IX_Databases_AaPanelId", - table: "Databases"); - - migrationBuilder.DropColumn( - name: "TagsJson", - table: "Images"); - - migrationBuilder.DropColumn( - name: "InternalAaPanelId", - table: "Databases"); - - migrationBuilder.DropColumn( - name: "Name", - table: "Databases"); - - migrationBuilder.AddColumn( - name: "ImageId", - table: "ImageTags", - type: "int", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_ImageTags_ImageId", - table: "ImageTags", - column: "ImageId"); - - migrationBuilder.AddForeignKey( - name: "FK_ImageTags_Images_ImageId", - table: "ImageTags", - column: "ImageId", - principalTable: "Images", - principalColumn: "Id"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230314190100_AddedAllocationsToImage.Designer.cs b/Moonlight/App/Database/Migrations/20230314190100_AddedAllocationsToImage.Designer.cs deleted file mode 100644 index 38247d55..00000000 --- a/Moonlight/App/Database/Migrations/20230314190100_AddedAllocationsToImage.Designer.cs +++ /dev/null @@ -1,1026 +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("20230314190100_AddedAllocationsToImage")] - partial class AddedAllocationsToImage - { - /// - 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.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.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.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/20230314190100_AddedAllocationsToImage.cs b/Moonlight/App/Database/Migrations/20230314190100_AddedAllocationsToImage.cs deleted file mode 100644 index 15284fd1..00000000 --- a/Moonlight/App/Database/Migrations/20230314190100_AddedAllocationsToImage.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedAllocationsToImage : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Allocations", - table: "Images", - type: "int", - nullable: false, - defaultValue: 0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Allocations", - table: "Images"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230320153817_AddedDdosAttacks.Designer.cs b/Moonlight/App/Database/Migrations/20230320153817_AddedDdosAttacks.Designer.cs deleted file mode 100644 index 45a55a67..00000000 --- a/Moonlight/App/Database/Migrations/20230320153817_AddedDdosAttacks.Designer.cs +++ /dev/null @@ -1,1066 +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("20230320153817_AddedDdosAttacks")] - partial class AddedDdosAttacks - { - /// - 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.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/20230320153817_AddedDdosAttacks.cs b/Moonlight/App/Database/Migrations/20230320153817_AddedDdosAttacks.cs deleted file mode 100644 index 77bb38a4..00000000 --- a/Moonlight/App/Database/Migrations/20230320153817_AddedDdosAttacks.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedDdosAttacks : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DdosAttacks", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Ongoing = table.Column(type: "tinyint(1)", nullable: false), - Data = table.Column(type: "bigint", nullable: false), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - NodeId = table.Column(type: "int", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DdosAttacks", x => x.Id); - table.ForeignKey( - name: "FK_DdosAttacks_Nodes_NodeId", - column: x => x.NodeId, - principalTable: "Nodes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_DdosAttacks_NodeId", - table: "DdosAttacks", - column: "NodeId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DdosAttacks"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.Designer.cs b/Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.Designer.cs deleted file mode 100644 index 4ebe388b..00000000 --- a/Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.Designer.cs +++ /dev/null @@ -1,1058 +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("20230324164853_RemovedDiscordUsernameAndDiscriminator")] - partial class RemovedDiscordUsernameAndDiscriminator - { - /// - 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.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("DiscordId") - .HasColumnType("bigint"); - - 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/20230324164853_RemovedDiscordUsernameAndDiscriminator.cs b/Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.cs deleted file mode 100644 index 5da02fcf..00000000 --- a/Moonlight/App/Database/Migrations/20230324164853_RemovedDiscordUsernameAndDiscriminator.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedDiscordUsernameAndDiscriminator : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "DiscordDiscriminator", - table: "Users"); - - migrationBuilder.DropColumn( - name: "DiscordUsername", - table: "Users"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "DiscordDiscriminator", - table: "Users", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "DiscordUsername", - table: "Users", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230402204329_AddCleanupExceptionsTable.Designer.cs b/Moonlight/App/Database/Migrations/20230402204329_AddCleanupExceptionsTable.Designer.cs deleted file mode 100644 index 7ae61058..00000000 --- a/Moonlight/App/Database/Migrations/20230402204329_AddCleanupExceptionsTable.Designer.cs +++ /dev/null @@ -1,1082 +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("20230402204329_AddCleanupExceptionsTable")] - partial class AddCleanupExceptionsTable - { - /// - 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.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() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("Country") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - 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.Models.Misc.CleanupException", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Note") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("CleanupExceptions"); - }); - - 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/20230402204329_AddCleanupExceptionsTable.cs b/Moonlight/App/Database/Migrations/20230402204329_AddCleanupExceptionsTable.cs deleted file mode 100644 index 3c0f8e18..00000000 --- a/Moonlight/App/Database/Migrations/20230402204329_AddCleanupExceptionsTable.cs +++ /dev/null @@ -1,170 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddCleanupExceptionsTable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "State", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "LastName", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "FirstName", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Country", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "City", - table: "Users", - type: "varchar(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Address", - table: "Users", - type: "varchar(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "CleanupExceptions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ServerId = table.Column(type: "int", nullable: false), - Note = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_CleanupExceptions", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CleanupExceptions"); - - migrationBuilder.AlterColumn( - name: "State", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "LastName", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "FirstName", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Country", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "City", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(128)", - oldMaxLength: 128) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Address", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(128)", - oldMaxLength: 128) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230402215155_ChengedCleanupExceptionModel.Designer.cs b/Moonlight/App/Database/Migrations/20230402215155_ChengedCleanupExceptionModel.Designer.cs deleted file mode 100644 index 6dd7b206..00000000 --- a/Moonlight/App/Database/Migrations/20230402215155_ChengedCleanupExceptionModel.Designer.cs +++ /dev/null @@ -1,1098 +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("20230402215155_ChengedCleanupExceptionModel")] - partial class ChengedCleanupExceptionModel - { - /// - 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.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() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("Country") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - 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.Models.Misc.CleanupException", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Note") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ServerId"); - - b.ToTable("CleanupExceptions"); - }); - - 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.Models.Misc.CleanupException", b => - { - b.HasOne("Moonlight.App.Database.Entities.Server", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Server"); - }); - - 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/20230402215155_ChengedCleanupExceptionModel.cs b/Moonlight/App/Database/Migrations/20230402215155_ChengedCleanupExceptionModel.cs deleted file mode 100644 index 15e5bcbc..00000000 --- a/Moonlight/App/Database/Migrations/20230402215155_ChengedCleanupExceptionModel.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class ChengedCleanupExceptionModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "CleanupExceptions", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.CreateIndex( - name: "IX_CleanupExceptions_ServerId", - table: "CleanupExceptions", - column: "ServerId"); - - migrationBuilder.AddForeignKey( - name: "FK_CleanupExceptions_Servers_ServerId", - table: "CleanupExceptions", - column: "ServerId", - principalTable: "Servers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_CleanupExceptions_Servers_ServerId", - table: "CleanupExceptions"); - - migrationBuilder.DropIndex( - name: "IX_CleanupExceptions_ServerId", - table: "CleanupExceptions"); - - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "CleanupExceptions"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230402220651_RemovedCleanupExceptionChangedServerModel.Designer.cs b/Moonlight/App/Database/Migrations/20230402220651_RemovedCleanupExceptionChangedServerModel.Designer.cs deleted file mode 100644 index 59b5c123..00000000 --- a/Moonlight/App/Database/Migrations/20230402220651_RemovedCleanupExceptionChangedServerModel.Designer.cs +++ /dev/null @@ -1,1067 +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("20230402220651_RemovedCleanupExceptionChangedServerModel")] - partial class RemovedCleanupExceptionChangedServerModel - { - /// - 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.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("IsCleanupException") - .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() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("Admin") - .HasColumnType("tinyint(1)"); - - b.Property("City") - .IsRequired() - .HasMaxLength(128) - .HasColumnType("varchar(128)"); - - b.Property("Country") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("varchar(64)"); - - 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/20230402220651_RemovedCleanupExceptionChangedServerModel.cs b/Moonlight/App/Database/Migrations/20230402220651_RemovedCleanupExceptionChangedServerModel.cs deleted file mode 100644 index 4f1a3c19..00000000 --- a/Moonlight/App/Database/Migrations/20230402220651_RemovedCleanupExceptionChangedServerModel.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedCleanupExceptionChangedServerModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "CleanupExceptions"); - - migrationBuilder.AddColumn( - name: "IsCleanupException", - table: "Servers", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsCleanupException", - table: "Servers"); - - migrationBuilder.CreateTable( - name: "CleanupExceptions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ServerId = table.Column(type: "int", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Note = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_CleanupExceptions", x => x.Id); - table.ForeignKey( - name: "FK_CleanupExceptions_Servers_ServerId", - column: x => x.ServerId, - principalTable: "Servers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_CleanupExceptions_ServerId", - table: "CleanupExceptions", - column: "ServerId"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230403130734_RemovedOldSubscriptionData.Designer.cs b/Moonlight/App/Database/Migrations/20230403130734_RemovedOldSubscriptionData.Designer.cs deleted file mode 100644 index d5429e9a..00000000 --- a/Moonlight/App/Database/Migrations/20230403130734_RemovedOldSubscriptionData.Designer.cs +++ /dev/null @@ -1,962 +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("20230403130734_RemovedOldSubscriptionData")] - partial class RemovedOldSubscriptionData - { - /// - 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.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("IsCleanupException") - .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.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("DiscordId") - .HasColumnType("bigint"); - - 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("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.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.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.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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230403130734_RemovedOldSubscriptionData.cs b/Moonlight/App/Database/Migrations/20230403130734_RemovedOldSubscriptionData.cs deleted file mode 100644 index 23c0f92b..00000000 --- a/Moonlight/App/Database/Migrations/20230403130734_RemovedOldSubscriptionData.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedOldSubscriptionData : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Users_Subscriptions_SubscriptionId", - table: "Users"); - - migrationBuilder.DropTable( - name: "SubscriptionLimits"); - - migrationBuilder.DropTable( - name: "Subscriptions"); - - migrationBuilder.DropIndex( - name: "IX_Users_SubscriptionId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionDuration", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionSince", - table: "Users"); - - migrationBuilder.AlterColumn( - name: "State", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "LastName", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "FirstName", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Country", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(64)", - oldMaxLength: 64) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "City", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(128)", - oldMaxLength: 128) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Address", - table: "Users", - type: "longtext", - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(128)", - oldMaxLength: 128) - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "State", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "LastName", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "FirstName", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Country", - table: "Users", - type: "varchar(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "City", - table: "Users", - type: "varchar(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AlterColumn( - name: "Address", - table: "Users", - type: "varchar(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "longtext") - .Annotation("MySql:CharSet", "utf8mb4") - .OldAnnotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "SubscriptionDuration", - table: "Users", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SubscriptionId", - table: "Users", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "SubscriptionSince", - table: "Users", - type: "datetime(6)", - nullable: true); - - migrationBuilder.CreateTable( - name: "Subscriptions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Description = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Duration = table.Column(type: "int", nullable: false), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SellPassId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Subscriptions", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "SubscriptionLimits", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ImageId = table.Column(type: "int", nullable: false), - Amount = table.Column(type: "int", nullable: false), - Cpu = table.Column(type: "int", nullable: false), - Disk = table.Column(type: "int", nullable: false), - Memory = table.Column(type: "int", nullable: false), - SubscriptionId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SubscriptionLimits", x => x.Id); - table.ForeignKey( - name: "FK_SubscriptionLimits_Images_ImageId", - column: x => x.ImageId, - principalTable: "Images", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SubscriptionLimits_Subscriptions_SubscriptionId", - column: x => x.SubscriptionId, - principalTable: "Subscriptions", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Users_SubscriptionId", - table: "Users", - column: "SubscriptionId"); - - migrationBuilder.CreateIndex( - name: "IX_SubscriptionLimits_ImageId", - table: "SubscriptionLimits", - column: "ImageId"); - - migrationBuilder.CreateIndex( - name: "IX_SubscriptionLimits_SubscriptionId", - table: "SubscriptionLimits", - column: "SubscriptionId"); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Subscriptions_SubscriptionId", - table: "Users", - column: "SubscriptionId", - principalTable: "Subscriptions", - principalColumn: "Id"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230403131343_AddedNewSubscriptionData.Designer.cs b/Moonlight/App/Database/Migrations/20230403131343_AddedNewSubscriptionData.Designer.cs deleted file mode 100644 index e0d6429f..00000000 --- a/Moonlight/App/Database/Migrations/20230403131343_AddedNewSubscriptionData.Designer.cs +++ /dev/null @@ -1,1005 +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("20230403131343_AddedNewSubscriptionData")] - partial class AddedNewSubscriptionData - { - /// - 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.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("IsCleanupException") - .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("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - 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("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("CurrentSubscriptionId"); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230403131343_AddedNewSubscriptionData.cs b/Moonlight/App/Database/Migrations/20230403131343_AddedNewSubscriptionData.cs deleted file mode 100644 index 5299884f..00000000 --- a/Moonlight/App/Database/Migrations/20230403131343_AddedNewSubscriptionData.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedNewSubscriptionData : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CurrentSubscriptionId", - table: "Users", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "SubscriptionDuration", - table: "Users", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "SubscriptionSince", - table: "Users", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.CreateTable( - name: "Subscriptions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Description = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - LimitsJson = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Subscriptions", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Users_CurrentSubscriptionId", - table: "Users", - column: "CurrentSubscriptionId"); - - migrationBuilder.AddForeignKey( - name: "FK_Users_Subscriptions_CurrentSubscriptionId", - table: "Users", - column: "CurrentSubscriptionId", - principalTable: "Subscriptions", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Users_Subscriptions_CurrentSubscriptionId", - table: "Users"); - - migrationBuilder.DropTable( - name: "Subscriptions"); - - migrationBuilder.DropIndex( - name: "IX_Users_CurrentSubscriptionId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "CurrentSubscriptionId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionDuration", - table: "Users"); - - migrationBuilder.DropColumn( - name: "SubscriptionSince", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230404163809_RemovedLegacyAaPanelStuff.Designer.cs b/Moonlight/App/Database/Migrations/20230404163809_RemovedLegacyAaPanelStuff.Designer.cs deleted file mode 100644 index 5220ef2c..00000000 --- a/Moonlight/App/Database/Migrations/20230404163809_RemovedLegacyAaPanelStuff.Designer.cs +++ /dev/null @@ -1,876 +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("20230404163809_RemovedLegacyAaPanelStuff")] - partial class RemovedLegacyAaPanelStuff - { - /// - 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.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.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("IsCleanupException") - .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("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - 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("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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230404163809_RemovedLegacyAaPanelStuff.cs b/Moonlight/App/Database/Migrations/20230404163809_RemovedLegacyAaPanelStuff.cs deleted file mode 100644 index aee8be1d..00000000 --- a/Moonlight/App/Database/Migrations/20230404163809_RemovedLegacyAaPanelStuff.cs +++ /dev/null @@ -1,133 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedLegacyAaPanelStuff : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Databases"); - - migrationBuilder.DropTable( - name: "Websites"); - - migrationBuilder.DropTable( - name: "AaPanels"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AaPanels", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - BaseDomain = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Key = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Url = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_AaPanels", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Databases", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - AaPanelId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false), - InternalAaPanelId = table.Column(type: "int", nullable: false), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Databases", x => x.Id); - table.ForeignKey( - name: "FK_Databases_AaPanels_AaPanelId", - column: x => x.AaPanelId, - principalTable: "AaPanels", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Databases_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Websites", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - AaPanelId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false), - DomainName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - FtpPassword = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - FtpUsername = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - InternalAaPanelId = table.Column(type: "int", nullable: false), - PhpVersion = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Websites", x => x.Id); - table.ForeignKey( - name: "FK_Websites_AaPanels_AaPanelId", - column: x => x.AaPanelId, - principalTable: "AaPanels", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Websites_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Databases_AaPanelId", - table: "Databases", - column: "AaPanelId"); - - migrationBuilder.CreateIndex( - name: "IX_Databases_OwnerId", - table: "Databases", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_AaPanelId", - table: "Websites", - column: "AaPanelId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_OwnerId", - table: "Websites", - column: "OwnerId"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230404181522_AddedPleskAndWebsiteModels.Designer.cs b/Moonlight/App/Database/Migrations/20230404181522_AddedPleskAndWebsiteModels.Designer.cs deleted file mode 100644 index c8355767..00000000 --- a/Moonlight/App/Database/Migrations/20230404181522_AddedPleskAndWebsiteModels.Designer.cs +++ /dev/null @@ -1,946 +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("20230404181522_AddedPleskAndWebsiteModels")] - partial class AddedPleskAndWebsiteModels - { - /// - 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.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("ApiUrl") - .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("IsCleanupException") - .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("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - 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("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("CurrentSubscriptionId"); - - 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.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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230404181522_AddedPleskAndWebsiteModels.cs b/Moonlight/App/Database/Migrations/20230404181522_AddedPleskAndWebsiteModels.cs deleted file mode 100644 index 4c8834fa..00000000 --- a/Moonlight/App/Database/Migrations/20230404181522_AddedPleskAndWebsiteModels.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedPleskAndWebsiteModels : 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), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApiUrl = 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"); - - migrationBuilder.CreateTable( - name: "Websites", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - BaseDomain = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - PleskId = table.Column(type: "int", nullable: false), - PleskServerId = table.Column(type: "int", nullable: false), - OwnerId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Websites", x => x.Id); - table.ForeignKey( - name: "FK_Websites_PleskServers_PleskServerId", - column: x => x.PleskServerId, - principalTable: "PleskServers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Websites_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_OwnerId", - table: "Websites", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_PleskServerId", - table: "Websites", - column: "PleskServerId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Websites"); - - migrationBuilder.DropTable( - name: "PleskServers"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230405162507_UpdatedWebsiteModel.Designer.cs b/Moonlight/App/Database/Migrations/20230405162507_UpdatedWebsiteModel.Designer.cs deleted file mode 100644 index 5d2125bd..00000000 --- a/Moonlight/App/Database/Migrations/20230405162507_UpdatedWebsiteModel.Designer.cs +++ /dev/null @@ -1,954 +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("20230405162507_UpdatedWebsiteModel")] - partial class UpdatedWebsiteModel - { - /// - 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.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("ApiUrl") - .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("IsCleanupException") - .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("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - 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("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("CurrentSubscriptionId"); - - 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("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230405162507_UpdatedWebsiteModel.cs b/Moonlight/App/Database/Migrations/20230405162507_UpdatedWebsiteModel.cs deleted file mode 100644 index 6085df04..00000000 --- a/Moonlight/App/Database/Migrations/20230405162507_UpdatedWebsiteModel.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class UpdatedWebsiteModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "FtpLogin", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "FtpPassword", - table: "Websites", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "FtpLogin", - table: "Websites"); - - migrationBuilder.DropColumn( - name: "FtpPassword", - table: "Websites"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230406161820_AddedStatistics.Designer.cs b/Moonlight/App/Database/Migrations/20230406161820_AddedStatistics.Designer.cs deleted file mode 100644 index 6345ccb1..00000000 --- a/Moonlight/App/Database/Migrations/20230406161820_AddedStatistics.Designer.cs +++ /dev/null @@ -1,894 +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("20230406161820_AddedStatistics")] - partial class AddedStatistics - { - /// - 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.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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - 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("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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230406161820_AddedStatistics.cs b/Moonlight/App/Database/Migrations/20230406161820_AddedStatistics.cs deleted file mode 100644 index b00cb9cc..00000000 --- a/Moonlight/App/Database/Migrations/20230406161820_AddedStatistics.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedStatistics : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Statistics", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Chart = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Value = table.Column(type: "double", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Statistics", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Statistics"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230406182554_ChangedStatisticsModel.Designer.cs b/Moonlight/App/Database/Migrations/20230406182554_ChangedStatisticsModel.Designer.cs deleted file mode 100644 index 73544a6e..00000000 --- a/Moonlight/App/Database/Migrations/20230406182554_ChangedStatisticsModel.Designer.cs +++ /dev/null @@ -1,975 +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("20230406182554_ChangedStatisticsModel")] - partial class ChangedStatisticsModel - { - /// - 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.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("ApiUrl") - .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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint"); - - 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("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("CurrentSubscriptionId"); - - 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("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230406182554_ChangedStatisticsModel.cs b/Moonlight/App/Database/Migrations/20230406182554_ChangedStatisticsModel.cs deleted file mode 100644 index 24d619e9..00000000 --- a/Moonlight/App/Database/Migrations/20230406182554_ChangedStatisticsModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class ChangedStatisticsModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Date", - table: "Statistics", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Date", - table: "Statistics"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230412162710_NewsEntriesTableAdded.Designer.cs b/Moonlight/App/Database/Migrations/20230412162710_NewsEntriesTableAdded.Designer.cs deleted file mode 100644 index bf04412e..00000000 --- a/Moonlight/App/Database/Migrations/20230412162710_NewsEntriesTableAdded.Designer.cs +++ /dev/null @@ -1,997 +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("20230412162710_NewsEntriesTableAdded")] - partial class NewsEntriesTableAdded - { - /// - 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.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.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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("ApiUrl") - .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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - 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("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230412162710_NewsEntriesTableAdded.cs b/Moonlight/App/Database/Migrations/20230412162710_NewsEntriesTableAdded.cs deleted file mode 100644 index b35646ae..00000000 --- a/Moonlight/App/Database/Migrations/20230412162710_NewsEntriesTableAdded.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class NewsEntriesTableAdded : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "DiscordId", - table: "Users", - type: "bigint unsigned", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint"); - - migrationBuilder.CreateTable( - name: "NewsEntries", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Date = table.Column(type: "datetime(6)", nullable: false), - Title = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Markdown = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_NewsEntries", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "NewsEntries"); - - migrationBuilder.AlterColumn( - name: "DiscordId", - table: "Users", - type: "bigint", - nullable: false, - oldClrType: typeof(ulong), - oldType: "bigint unsigned"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230413150426_MadeMainAllocationNullable.Designer.cs b/Moonlight/App/Database/Migrations/20230413150426_MadeMainAllocationNullable.Designer.cs deleted file mode 100644 index 0eb52201..00000000 --- a/Moonlight/App/Database/Migrations/20230413150426_MadeMainAllocationNullable.Designer.cs +++ /dev/null @@ -1,995 +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("20230413150426_MadeMainAllocationNullable")] - partial class MadeMainAllocationNullable - { - /// - 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.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.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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("ApiUrl") - .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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - 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("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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"); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230413150426_MadeMainAllocationNullable.cs b/Moonlight/App/Database/Migrations/20230413150426_MadeMainAllocationNullable.cs deleted file mode 100644 index e6d79d8a..00000000 --- a/Moonlight/App/Database/Migrations/20230413150426_MadeMainAllocationNullable.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class MadeMainAllocationNullable : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Servers_NodeAllocations_MainAllocationId", - table: "Servers"); - - migrationBuilder.AlterColumn( - name: "MainAllocationId", - table: "Servers", - type: "int", - nullable: true, - oldClrType: typeof(int), - oldType: "int"); - - migrationBuilder.AddForeignKey( - name: "FK_Servers_NodeAllocations_MainAllocationId", - table: "Servers", - column: "MainAllocationId", - principalTable: "NodeAllocations", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Servers_NodeAllocations_MainAllocationId", - table: "Servers"); - - migrationBuilder.AlterColumn( - name: "MainAllocationId", - table: "Servers", - type: "int", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "int", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_Servers_NodeAllocations_MainAllocationId", - table: "Servers", - column: "MainAllocationId", - principalTable: "NodeAllocations", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230414110513_RemovedImageTags.Designer.cs b/Moonlight/App/Database/Migrations/20230414110513_RemovedImageTags.Designer.cs deleted file mode 100644 index fafeeafe..00000000 --- a/Moonlight/App/Database/Migrations/20230414110513_RemovedImageTags.Designer.cs +++ /dev/null @@ -1,980 +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("20230414110513_RemovedImageTags")] - partial class RemovedImageTags - { - /// - 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.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.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.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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("ApiUrl") - .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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - 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("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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"); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - 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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230414110513_RemovedImageTags.cs b/Moonlight/App/Database/Migrations/20230414110513_RemovedImageTags.cs deleted file mode 100644 index 2001c98f..00000000 --- a/Moonlight/App/Database/Migrations/20230414110513_RemovedImageTags.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedImageTags : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ImageTags"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ImageTags", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_ImageTags", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230419120719_AddedCloudPanelModels.Designer.cs b/Moonlight/App/Database/Migrations/20230419120719_AddedCloudPanelModels.Designer.cs deleted file mode 100644 index 26edf52f..00000000 --- a/Moonlight/App/Database/Migrations/20230419120719_AddedCloudPanelModels.Designer.cs +++ /dev/null @@ -1,1099 +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("20230419120719_AddedCloudPanelModels")] - partial class AddedCloudPanelModels - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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.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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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("ApiUrl") - .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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - b.Navigation("Owner"); - }); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230419120719_AddedCloudPanelModels.cs b/Moonlight/App/Database/Migrations/20230419120719_AddedCloudPanelModels.cs deleted file mode 100644 index 845437af..00000000 --- a/Moonlight/App/Database/Migrations/20230419120719_AddedCloudPanelModels.cs +++ /dev/null @@ -1,121 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedCloudPanelModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "CloudPanels", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApiUrl = 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_CloudPanels", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WebSpaces", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Domain = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - UserName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Password = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - VHostTemplate = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - OwnerId = table.Column(type: "int", nullable: false), - CloudPanelId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WebSpaces", x => x.Id); - table.ForeignKey( - name: "FK_WebSpaces_CloudPanels_CloudPanelId", - column: x => x.CloudPanelId, - principalTable: "CloudPanels", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_WebSpaces_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Databases", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - WebSpaceId = table.Column(type: "int", nullable: false), - UserName = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Password = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_Databases", x => x.Id); - table.ForeignKey( - name: "FK_Databases_WebSpaces_WebSpaceId", - column: x => x.WebSpaceId, - principalTable: "WebSpaces", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Databases_WebSpaceId", - table: "Databases", - column: "WebSpaceId"); - - migrationBuilder.CreateIndex( - name: "IX_WebSpaces_CloudPanelId", - table: "WebSpaces", - column: "CloudPanelId"); - - migrationBuilder.CreateIndex( - name: "IX_WebSpaces_OwnerId", - table: "WebSpaces", - column: "OwnerId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Databases"); - - migrationBuilder.DropTable( - name: "WebSpaces"); - - migrationBuilder.DropTable( - name: "CloudPanels"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230419125155_AddedHostFieldToCloudPanelModel.Designer.cs b/Moonlight/App/Database/Migrations/20230419125155_AddedHostFieldToCloudPanelModel.Designer.cs deleted file mode 100644 index dda0a9f9..00000000 --- a/Moonlight/App/Database/Migrations/20230419125155_AddedHostFieldToCloudPanelModel.Designer.cs +++ /dev/null @@ -1,1103 +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("20230419125155_AddedHostFieldToCloudPanelModel")] - partial class AddedHostFieldToCloudPanelModel - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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.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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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("ApiUrl") - .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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Website", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("BaseDomain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpLogin") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FtpPassword") - .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.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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - b.Navigation("Owner"); - }); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230419125155_AddedHostFieldToCloudPanelModel.cs b/Moonlight/App/Database/Migrations/20230419125155_AddedHostFieldToCloudPanelModel.cs deleted file mode 100644 index a0273c4d..00000000 --- a/Moonlight/App/Database/Migrations/20230419125155_AddedHostFieldToCloudPanelModel.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedHostFieldToCloudPanelModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Host", - table: "CloudPanels", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Host", - table: "CloudPanels"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230420213846_AddedNewSupportChatModels.Designer.cs b/Moonlight/App/Database/Migrations/20230420213846_AddedNewSupportChatModels.Designer.cs deleted file mode 100644 index 7cea0436..00000000 --- a/Moonlight/App/Database/Migrations/20230420213846_AddedNewSupportChatModels.Designer.cs +++ /dev/null @@ -1,1087 +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("20230420213846_AddedNewSupportChatModels")] - partial class AddedNewSupportChatModels - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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.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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230420213846_AddedNewSupportChatModels.cs b/Moonlight/App/Database/Migrations/20230420213846_AddedNewSupportChatModels.cs deleted file mode 100644 index e8160af4..00000000 --- a/Moonlight/App/Database/Migrations/20230420213846_AddedNewSupportChatModels.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedNewSupportChatModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Websites"); - - migrationBuilder.DropTable( - name: "PleskServers"); - - migrationBuilder.CreateTable( - name: "SupportChatMessages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Content = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Attachment = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SenderId = table.Column(type: "int", nullable: true), - RecipientId = table.Column(type: "int", nullable: false), - IsQuestion = table.Column(type: "tinyint(1)", nullable: false), - QuestionType = table.Column(type: "int", nullable: false), - Answer = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - UpdatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SupportChatMessages", x => x.Id); - table.ForeignKey( - name: "FK_SupportChatMessages_Users_RecipientId", - column: x => x.RecipientId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SupportChatMessages_Users_SenderId", - column: x => x.SenderId, - principalTable: "Users", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_SupportChatMessages_RecipientId", - table: "SupportChatMessages", - column: "RecipientId"); - - migrationBuilder.CreateIndex( - name: "IX_SupportChatMessages_SenderId", - table: "SupportChatMessages", - column: "SenderId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "SupportChatMessages"); - - migrationBuilder.CreateTable( - name: "PleskServers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ApiKey = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ApiUrl = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_PleskServers", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "Websites", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - OwnerId = table.Column(type: "int", nullable: false), - PleskServerId = table.Column(type: "int", nullable: false), - BaseDomain = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - FtpLogin = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - FtpPassword = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - PleskId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Websites", x => x.Id); - table.ForeignKey( - name: "FK_Websites_PleskServers_PleskServerId", - column: x => x.PleskServerId, - principalTable: "PleskServers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Websites_Users_OwnerId", - column: x => x.OwnerId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_OwnerId", - table: "Websites", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_Websites_PleskServerId", - table: "Websites", - column: "PleskServerId"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230421143556_RemovedOldSupportChatModel.Designer.cs b/Moonlight/App/Database/Migrations/20230421143556_RemovedOldSupportChatModel.Designer.cs deleted file mode 100644 index d34006e9..00000000 --- a/Moonlight/App/Database/Migrations/20230421143556_RemovedOldSupportChatModel.Designer.cs +++ /dev/null @@ -1,1028 +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("20230421143556_RemovedOldSupportChatModel")] - partial class RemovedOldSupportChatModel - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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.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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - 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("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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230421143556_RemovedOldSupportChatModel.cs b/Moonlight/App/Database/Migrations/20230421143556_RemovedOldSupportChatModel.cs deleted file mode 100644 index c89742ee..00000000 --- a/Moonlight/App/Database/Migrations/20230421143556_RemovedOldSupportChatModel.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedOldSupportChatModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "SupportMessages"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "SupportMessages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RecipientId = table.Column(type: "int", nullable: true), - SenderId = table.Column(type: "int", nullable: true), - Answer = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - IsQuestion = table.Column(type: "tinyint(1)", nullable: false), - IsSupport = table.Column(type: "tinyint(1)", nullable: false), - IsSystem = table.Column(type: "tinyint(1)", nullable: false), - Message = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Type = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SupportMessages", x => x.Id); - table.ForeignKey( - name: "FK_SupportMessages_Users_RecipientId", - column: x => x.RecipientId, - principalTable: "Users", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_SupportMessages_Users_SenderId", - column: x => x.SenderId, - principalTable: "Users", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_SupportMessages_RecipientId", - table: "SupportMessages", - column: "RecipientId"); - - migrationBuilder.CreateIndex( - name: "IX_SupportMessages_SenderId", - table: "SupportMessages", - column: "SenderId"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230504094654_AddedRatingDataToUser.Designer.cs b/Moonlight/App/Database/Migrations/20230504094654_AddedRatingDataToUser.Designer.cs deleted file mode 100644 index fba910d4..00000000 --- a/Moonlight/App/Database/Migrations/20230504094654_AddedRatingDataToUser.Designer.cs +++ /dev/null @@ -1,1034 +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("20230504094654_AddedRatingDataToUser")] - partial class AddedRatingDataToUser - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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.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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230504094654_AddedRatingDataToUser.cs b/Moonlight/App/Database/Migrations/20230504094654_AddedRatingDataToUser.cs deleted file mode 100644 index 8dd3b501..00000000 --- a/Moonlight/App/Database/Migrations/20230504094654_AddedRatingDataToUser.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedRatingDataToUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "HasRated", - table: "Users", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "Rating", - table: "Users", - type: "int", - nullable: false, - defaultValue: 0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "HasRated", - table: "Users"); - - migrationBuilder.DropColumn( - name: "Rating", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230519125351_AddIpBanModel.Designer.cs b/Moonlight/App/Database/Migrations/20230519125351_AddIpBanModel.Designer.cs deleted file mode 100644 index 138f7a67..00000000 --- a/Moonlight/App/Database/Migrations/20230519125351_AddIpBanModel.Designer.cs +++ /dev/null @@ -1,1052 +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("20230519125351_AddIpBanModel")] - partial class AddIpBanModel - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230519125351_AddIpBanModel.cs b/Moonlight/App/Database/Migrations/20230519125351_AddIpBanModel.cs deleted file mode 100644 index b03c3044..00000000 --- a/Moonlight/App/Database/Migrations/20230519125351_AddIpBanModel.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddIpBanModel : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "IpBans", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IpBans", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "IpBans"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230609202138_AddBackgroundImageUrlImage.Designer.cs b/Moonlight/App/Database/Migrations/20230609202138_AddBackgroundImageUrlImage.Designer.cs deleted file mode 100644 index c5579182..00000000 --- a/Moonlight/App/Database/Migrations/20230609202138_AddBackgroundImageUrlImage.Designer.cs +++ /dev/null @@ -1,1056 +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("20230609202138_AddBackgroundImageUrlImage")] - partial class AddBackgroundImageUrlImage - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230609202138_AddBackgroundImageUrlImage.cs b/Moonlight/App/Database/Migrations/20230609202138_AddBackgroundImageUrlImage.cs deleted file mode 100644 index 062ed711..00000000 --- a/Moonlight/App/Database/Migrations/20230609202138_AddBackgroundImageUrlImage.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddBackgroundImageUrlImage : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "BackgroundImageUrl", - table: "Images", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "BackgroundImageUrl", - table: "Images"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230611152138_AddLastVisitedTimestamp.Designer.cs b/Moonlight/App/Database/Migrations/20230611152138_AddLastVisitedTimestamp.Designer.cs deleted file mode 100644 index d8440197..00000000 --- a/Moonlight/App/Database/Migrations/20230611152138_AddLastVisitedTimestamp.Designer.cs +++ /dev/null @@ -1,1059 +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("20230611152138_AddLastVisitedTimestamp")] - partial class AddLastVisitedTimestamp - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("IsCleanupException") - .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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230611152138_AddLastVisitedTimestamp.cs b/Moonlight/App/Database/Migrations/20230611152138_AddLastVisitedTimestamp.cs deleted file mode 100644 index 763ef815..00000000 --- a/Moonlight/App/Database/Migrations/20230611152138_AddLastVisitedTimestamp.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddLastVisitedTimestamp : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "LastVisitedAt", - table: "Users", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "LastVisitedAt", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230614010621_AddedServerAchive.Designer.cs b/Moonlight/App/Database/Migrations/20230614010621_AddedServerAchive.Designer.cs deleted file mode 100644 index 42978d0a..00000000 --- a/Moonlight/App/Database/Migrations/20230614010621_AddedServerAchive.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("20230614010621_AddedServerAchive")] - partial class AddedServerAchive - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230614010621_AddedServerAchive.cs b/Moonlight/App/Database/Migrations/20230614010621_AddedServerAchive.cs deleted file mode 100644 index 033be1a9..00000000 --- a/Moonlight/App/Database/Migrations/20230614010621_AddedServerAchive.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedServerAchive : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ArchiveId", - table: "Servers", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "IsArchived", - table: "Servers", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - - migrationBuilder.CreateIndex( - name: "IX_Servers_ArchiveId", - table: "Servers", - column: "ArchiveId"); - - migrationBuilder.AddForeignKey( - name: "FK_Servers_ServerBackups_ArchiveId", - table: "Servers", - column: "ArchiveId", - principalTable: "ServerBackups", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Servers_ServerBackups_ArchiveId", - table: "Servers"); - - migrationBuilder.DropIndex( - name: "IX_Servers_ArchiveId", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "ArchiveId", - table: "Servers"); - - migrationBuilder.DropColumn( - name: "IsArchived", - table: "Servers"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230623235512_AddedServerListLayoutToUser.Designer.cs b/Moonlight/App/Database/Migrations/20230623235512_AddedServerListLayoutToUser.Designer.cs deleted file mode 100644 index cc09283e..00000000 --- a/Moonlight/App/Database/Migrations/20230623235512_AddedServerListLayoutToUser.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("20230623235512_AddedServerListLayoutToUser")] - partial class AddedServerListLayoutToUser - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230623235512_AddedServerListLayoutToUser.cs b/Moonlight/App/Database/Migrations/20230623235512_AddedServerListLayoutToUser.cs deleted file mode 100644 index 10a12c7b..00000000 --- a/Moonlight/App/Database/Migrations/20230623235512_AddedServerListLayoutToUser.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedServerListLayoutToUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ServerListLayoutJson", - table: "Users", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ServerListLayoutJson", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230625190428_AddedStreamerMode.Designer.cs b/Moonlight/App/Database/Migrations/20230625190428_AddedStreamerMode.Designer.cs deleted file mode 100644 index 444c0f8d..00000000 --- a/Moonlight/App/Database/Migrations/20230625190428_AddedStreamerMode.Designer.cs +++ /dev/null @@ -1,1080 +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("20230625190428_AddedStreamerMode")] - partial class AddedStreamerMode - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230625190428_AddedStreamerMode.cs b/Moonlight/App/Database/Migrations/20230625190428_AddedStreamerMode.cs deleted file mode 100644 index e4f633fa..00000000 --- a/Moonlight/App/Database/Migrations/20230625190428_AddedStreamerMode.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedStreamerMode : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "StreamerMode", - table: "Users", - type: "tinyint(1)", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "StreamerMode", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.Designer.cs b/Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.Designer.cs deleted file mode 100644 index 4c540ce0..00000000 --- a/Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.Designer.cs +++ /dev/null @@ -1,1088 +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("20230703175432_AddedIpLogsForUser")] - partial class AddedIpLogsForUser - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionDuration") - .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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.cs b/Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.cs deleted file mode 100644 index abbac6d4..00000000 --- a/Moonlight/App/Database/Migrations/20230703175432_AddedIpLogsForUser.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedIpLogsForUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "LastIp", - table: "Users", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "RegisterIp", - table: "Users", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "LastIp", - table: "Users"); - - migrationBuilder.DropColumn( - name: "RegisterIp", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230705171914_AddedStripeIntegration.Designer.cs b/Moonlight/App/Database/Migrations/20230705171914_AddedStripeIntegration.Designer.cs deleted file mode 100644 index 18ebe32a..00000000 --- a/Moonlight/App/Database/Migrations/20230705171914_AddedStripeIntegration.Designer.cs +++ /dev/null @@ -1,1105 +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("20230705171914_AddedStripeIntegration")] - partial class AddedStripeIntegration - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230705171914_AddedStripeIntegration.cs b/Moonlight/App/Database/Migrations/20230705171914_AddedStripeIntegration.cs deleted file mode 100644 index ec21c0ce..00000000 --- a/Moonlight/App/Database/Migrations/20230705171914_AddedStripeIntegration.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddedStripeIntegration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "SubscriptionDuration", - table: "Users"); - - migrationBuilder.AddColumn( - name: "SubscriptionExpires", - table: "Users", - type: "datetime(6)", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - migrationBuilder.AddColumn( - name: "Currency", - table: "Subscriptions", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "Duration", - table: "Subscriptions", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "Price", - table: "Subscriptions", - type: "double", - nullable: false, - defaultValue: 0.0); - - migrationBuilder.AddColumn( - name: "StripePriceId", - table: "Subscriptions", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.AddColumn( - name: "StripeProductId", - table: "Subscriptions", - type: "longtext", - nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "SubscriptionExpires", - table: "Users"); - - migrationBuilder.DropColumn( - name: "Currency", - table: "Subscriptions"); - - migrationBuilder.DropColumn( - name: "Duration", - table: "Subscriptions"); - - migrationBuilder.DropColumn( - name: "Price", - table: "Subscriptions"); - - migrationBuilder.DropColumn( - name: "StripePriceId", - table: "Subscriptions"); - - migrationBuilder.DropColumn( - name: "StripeProductId", - table: "Subscriptions"); - - migrationBuilder.AddColumn( - name: "SubscriptionDuration", - table: "Users", - type: "int", - nullable: false, - defaultValue: 0); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230715095531_AddPermissions.Designer.cs b/Moonlight/App/Database/Migrations/20230715095531_AddPermissions.Designer.cs deleted file mode 100644 index d1edbaa4..00000000 --- a/Moonlight/App/Database/Migrations/20230715095531_AddPermissions.Designer.cs +++ /dev/null @@ -1,1109 +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("20230715095531_AddPermissions")] - partial class AddPermissions - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.Navigation("CurrentSubscription"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230715095531_AddPermissions.cs b/Moonlight/App/Database/Migrations/20230715095531_AddPermissions.cs deleted file mode 100644 index 05c6c80e..00000000 --- a/Moonlight/App/Database/Migrations/20230715095531_AddPermissions.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddPermissions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Permissions", - table: "Users", - type: "longblob", - nullable: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Permissions", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.Designer.cs b/Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.Designer.cs deleted file mode 100644 index 0e593f36..00000000 --- a/Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.Designer.cs +++ /dev/null @@ -1,1139 +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("20230715214550_AddPermissionGroup")] - partial class AddPermissionGroup - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.PermissionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("PermissionGroups"); - }); - - 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("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PermissionGroupId") - .HasColumnType("int"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.HasIndex("PermissionGroupId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.HasOne("Moonlight.App.Database.Entities.PermissionGroup", "PermissionGroup") - .WithMany() - .HasForeignKey("PermissionGroupId"); - - b.Navigation("CurrentSubscription"); - - b.Navigation("PermissionGroup"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.cs b/Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.cs deleted file mode 100644 index c7201a48..00000000 --- a/Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddPermissionGroup : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PermissionGroupId", - table: "Users", - type: "int", - nullable: true); - - migrationBuilder.CreateTable( - name: "PermissionGroups", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Permissions = table.Column(type: "longblob", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PermissionGroups", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_Users_PermissionGroupId", - table: "Users", - column: "PermissionGroupId"); - - migrationBuilder.AddForeignKey( - name: "FK_Users_PermissionGroups_PermissionGroupId", - table: "Users", - column: "PermissionGroupId", - principalTable: "PermissionGroups", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Users_PermissionGroups_PermissionGroupId", - table: "Users"); - - migrationBuilder.DropTable( - name: "PermissionGroups"); - - migrationBuilder.DropIndex( - name: "IX_Users_PermissionGroupId", - table: "Users"); - - migrationBuilder.DropColumn( - name: "PermissionGroupId", - table: "Users"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230718123232_RemovedOldLogsAndAddedErrorLog.Designer.cs b/Moonlight/App/Database/Migrations/20230718123232_RemovedOldLogsAndAddedErrorLog.Designer.cs deleted file mode 100644 index 63c7352f..00000000 --- a/Moonlight/App/Database/Migrations/20230718123232_RemovedOldLogsAndAddedErrorLog.Designer.cs +++ /dev/null @@ -1,1068 +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("20230718123232_RemovedOldLogsAndAddedErrorLog")] - partial class RemovedOldLogsAndAddedErrorLog - { - /// - 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.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.PermissionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("PermissionGroups"); - }); - - 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.SecurityLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Text") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SecurityLogs"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PermissionGroupId") - .HasColumnType("int"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.HasIndex("PermissionGroupId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.HasOne("Moonlight.App.Database.Entities.PermissionGroup", "PermissionGroup") - .WithMany() - .HasForeignKey("PermissionGroupId"); - - b.Navigation("CurrentSubscription"); - - b.Navigation("PermissionGroup"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230718123232_RemovedOldLogsAndAddedErrorLog.cs b/Moonlight/App/Database/Migrations/20230718123232_RemovedOldLogsAndAddedErrorLog.cs deleted file mode 100644 index 4dbf8103..00000000 --- a/Moonlight/App/Database/Migrations/20230718123232_RemovedOldLogsAndAddedErrorLog.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class RemovedOldLogsAndAddedErrorLog : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AuditLog"); - - migrationBuilder.DropTable( - name: "ErrorLog"); - - migrationBuilder.DropTable( - name: "SecurityLog"); - - migrationBuilder.CreateTable( - name: "SecurityLogs", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Text = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SecurityLogs", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "SecurityLogs"); - - migrationBuilder.CreateTable( - name: "AuditLog", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - JsonData = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - System = table.Column(type: "tinyint(1)", nullable: false), - Type = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AuditLog", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "ErrorLog", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Class = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - JsonData = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Stacktrace = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - System = table.Column(type: "tinyint(1)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ErrorLog", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "SecurityLog", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - JsonData = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - System = table.Column(type: "tinyint(1)", nullable: false), - Type = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SecurityLog", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230721201950_AddIpRules.Designer.cs b/Moonlight/App/Database/Migrations/20230721201950_AddIpRules.Designer.cs deleted file mode 100644 index 2633a17a..00000000 --- a/Moonlight/App/Database/Migrations/20230721201950_AddIpRules.Designer.cs +++ /dev/null @@ -1,1107 +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("20230721201950_AddIpRules")] - partial class AddIpRules - { - /// - 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.BlocklistIp", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("ExpiresAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Packets") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("BlocklistIps"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.PermissionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("PermissionGroups"); - }); - - 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.SecurityLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Text") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SecurityLogs"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PermissionGroupId") - .HasColumnType("int"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.HasIndex("PermissionGroupId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WhitelistIp", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("WhitelistIps"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - 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", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.HasOne("Moonlight.App.Database.Entities.PermissionGroup", "PermissionGroup") - .WithMany() - .HasForeignKey("PermissionGroupId"); - - b.Navigation("CurrentSubscription"); - - b.Navigation("PermissionGroup"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230721201950_AddIpRules.cs b/Moonlight/App/Database/Migrations/20230721201950_AddIpRules.cs deleted file mode 100644 index fd59d4db..00000000 --- a/Moonlight/App/Database/Migrations/20230721201950_AddIpRules.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddIpRules : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "BlocklistIps", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - ExpiresAt = table.Column(type: "datetime(6)", nullable: false), - Packets = table.Column(type: "bigint", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BlocklistIps", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "WhitelistIps", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Ip = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4") - }, - constraints: table => - { - table.PrimaryKey("PK_WhitelistIps", x => x.Id); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "BlocklistIps"); - - migrationBuilder.DropTable( - name: "WhitelistIps"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230803012947_AddNewTicketModels.Designer.cs b/Moonlight/App/Database/Migrations/20230803012947_AddNewTicketModels.Designer.cs deleted file mode 100644 index 90562359..00000000 --- a/Moonlight/App/Database/Migrations/20230803012947_AddNewTicketModels.Designer.cs +++ /dev/null @@ -1,1233 +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("20230803012947_AddNewTicketModels")] - partial class AddNewTicketModels - { - /// - 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.BlocklistIp", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("ExpiresAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Packets") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("BlocklistIps"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.PermissionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("PermissionGroups"); - }); - - 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.SecurityLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Text") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SecurityLogs"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedToId") - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("CreatedById") - .HasColumnType("int"); - - b.Property("IssueDescription") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IssueTopic") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IssueTries") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Subject") - .HasColumnType("int"); - - b.Property("SubjectId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssignedToId"); - - b.HasIndex("CreatedById"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.TicketMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AttachmentUrl") - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsEdited") - .HasColumnType("tinyint(1)"); - - b.Property("IsSupportMessage") - .HasColumnType("tinyint(1)"); - - b.Property("IsSystemMessage") - .HasColumnType("tinyint(1)"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("TicketId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("SenderId"); - - b.HasIndex("TicketId"); - - b.ToTable("TicketMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PermissionGroupId") - .HasColumnType("int"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.HasIndex("PermissionGroupId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WhitelistIp", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("WhitelistIps"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Ticket", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "AssignedTo") - .WithMany() - .HasForeignKey("AssignedToId"); - - b.HasOne("Moonlight.App.Database.Entities.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AssignedTo"); - - b.Navigation("CreatedBy"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.TicketMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.HasOne("Moonlight.App.Database.Entities.Ticket", null) - .WithMany("Messages") - .HasForeignKey("TicketId"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.HasOne("Moonlight.App.Database.Entities.Subscription", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.HasOne("Moonlight.App.Database.Entities.PermissionGroup", "PermissionGroup") - .WithMany() - .HasForeignKey("PermissionGroupId"); - - b.Navigation("CurrentSubscription"); - - b.Navigation("PermissionGroup"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.Ticket", b => - { - b.Navigation("Messages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Database/Migrations/20230803012947_AddNewTicketModels.cs b/Moonlight/App/Database/Migrations/20230803012947_AddNewTicketModels.cs deleted file mode 100644 index abbd006c..00000000 --- a/Moonlight/App/Database/Migrations/20230803012947_AddNewTicketModels.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - /// - public partial class AddNewTicketModels : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Tickets", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - IssueTopic = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - IssueDescription = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - IssueTries = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - CreatedById = table.Column(type: "int", nullable: false), - AssignedToId = table.Column(type: "int", nullable: true), - Priority = table.Column(type: "int", nullable: false), - Status = table.Column(type: "int", nullable: false), - Subject = table.Column(type: "int", nullable: false), - SubjectId = table.Column(type: "int", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Tickets", x => x.Id); - table.ForeignKey( - name: "FK_Tickets_Users_AssignedToId", - column: x => x.AssignedToId, - principalTable: "Users", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_Tickets_Users_CreatedById", - column: x => x.CreatedById, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateTable( - name: "TicketMessages", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Content = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - AttachmentUrl = table.Column(type: "longtext", nullable: true) - .Annotation("MySql:CharSet", "utf8mb4"), - SenderId = table.Column(type: "int", nullable: true), - IsSystemMessage = table.Column(type: "tinyint(1)", nullable: false), - IsEdited = table.Column(type: "tinyint(1)", nullable: false), - IsSupportMessage = table.Column(type: "tinyint(1)", nullable: false), - CreatedAt = table.Column(type: "datetime(6)", nullable: false), - UpdatedAt = table.Column(type: "datetime(6)", nullable: false), - TicketId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketMessages", x => x.Id); - table.ForeignKey( - name: "FK_TicketMessages_Tickets_TicketId", - column: x => x.TicketId, - principalTable: "Tickets", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_TicketMessages_Users_SenderId", - column: x => x.SenderId, - principalTable: "Users", - principalColumn: "Id"); - }) - .Annotation("MySql:CharSet", "utf8mb4"); - - migrationBuilder.CreateIndex( - name: "IX_TicketMessages_SenderId", - table: "TicketMessages", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketMessages_TicketId", - table: "TicketMessages", - column: "TicketId"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_AssignedToId", - table: "Tickets", - column: "AssignedToId"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_CreatedById", - table: "Tickets", - column: "CreatedById"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TicketMessages"); - - migrationBuilder.DropTable( - name: "Tickets"); - } - } -} diff --git a/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs b/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs deleted file mode 100644 index 4a21928a..00000000 --- a/Moonlight/App/Database/Migrations/DataContextModelSnapshot.cs +++ /dev/null @@ -1,1230 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Moonlight.App.Database; - -#nullable disable - -namespace Moonlight.App.Database.Migrations -{ - [DbContext(typeof(DataContext))] - partial class DataContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 64); - - modelBuilder.Entity("Moonlight.App.Database.Entities.BlocklistIp", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("ExpiresAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Packets") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("BlocklistIps"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.CloudPanel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ApiKey") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ApiUrl") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Host") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("CloudPanels"); - }); - - 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("BackgroundImageUrl") - .IsRequired() - .HasColumnType("longtext"); - - 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.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.IpBan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("IpBans"); - }); - - 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.MySqlDatabase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("WebSpaceId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WebSpaceId"); - - b.ToTable("Databases"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.NewsEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Markdown") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Title") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("NewsEntries"); - }); - - 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.PermissionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.HasKey("Id"); - - b.ToTable("PermissionGroups"); - }); - - 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.SecurityLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("Text") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("SecurityLogs"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Server", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("ArchiveId") - .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("IsArchived") - .HasColumnType("tinyint(1)"); - - b.Property("IsCleanupException") - .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("ArchiveId"); - - 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.StatisticsData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Chart") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Date") - .HasColumnType("datetime(6)"); - - b.Property("Value") - .HasColumnType("double"); - - b.HasKey("Id"); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Subscription", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Currency") - .HasColumnType("int"); - - b.Property("Description") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Duration") - .HasColumnType("int"); - - b.Property("LimitsJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Name") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Price") - .HasColumnType("double"); - - b.Property("StripePriceId") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("StripeProductId") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("Subscriptions"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.SupportChatMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Answer") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Attachment") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsQuestion") - .HasColumnType("tinyint(1)"); - - b.Property("QuestionType") - .HasColumnType("int"); - - b.Property("RecipientId") - .HasColumnType("int"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("RecipientId"); - - b.HasIndex("SenderId"); - - b.ToTable("SupportChatMessages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AssignedToId") - .HasColumnType("int"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("CreatedById") - .HasColumnType("int"); - - b.Property("IssueDescription") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IssueTopic") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("IssueTries") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Priority") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Subject") - .HasColumnType("int"); - - b.Property("SubjectId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssignedToId"); - - b.HasIndex("CreatedById"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.TicketMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("AttachmentUrl") - .HasColumnType("longtext"); - - b.Property("Content") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("CreatedAt") - .HasColumnType("datetime(6)"); - - b.Property("IsEdited") - .HasColumnType("tinyint(1)"); - - b.Property("IsSupportMessage") - .HasColumnType("tinyint(1)"); - - b.Property("IsSystemMessage") - .HasColumnType("tinyint(1)"); - - b.Property("SenderId") - .HasColumnType("int"); - - b.Property("TicketId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime(6)"); - - b.HasKey("Id"); - - b.HasIndex("SenderId"); - - b.HasIndex("TicketId"); - - b.ToTable("TicketMessages"); - }); - - 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("CurrentSubscriptionId") - .HasColumnType("int"); - - b.Property("DiscordId") - .HasColumnType("bigint unsigned"); - - b.Property("Email") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("HasRated") - .HasColumnType("tinyint(1)"); - - b.Property("LastIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("LastVisitedAt") - .HasColumnType("datetime(6)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("PermissionGroupId") - .HasColumnType("int"); - - b.Property("Permissions") - .IsRequired() - .HasColumnType("longblob"); - - b.Property("Rating") - .HasColumnType("int"); - - b.Property("RegisterIp") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("ServerListLayoutJson") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("State") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StreamerMode") - .HasColumnType("tinyint(1)"); - - b.Property("SubscriptionExpires") - .HasColumnType("datetime(6)"); - - 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("CurrentSubscriptionId"); - - b.HasIndex("PermissionGroupId"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("CloudPanelId") - .HasColumnType("int"); - - b.Property("Domain") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("OwnerId") - .HasColumnType("int"); - - b.Property("Password") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("UserName") - .IsRequired() - .HasColumnType("longtext"); - - b.Property("VHostTemplate") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.HasIndex("CloudPanelId"); - - b.HasIndex("OwnerId"); - - b.ToTable("WebSpaces"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WhitelistIp", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - b.Property("Ip") - .IsRequired() - .HasColumnType("longtext"); - - b.HasKey("Id"); - - b.ToTable("WhitelistIps"); - }); - - 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.MySqlDatabase", b => - { - b.HasOne("Moonlight.App.Database.Entities.WebSpace", "WebSpace") - .WithMany("Databases") - .HasForeignKey("WebSpaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("WebSpace"); - }); - - 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.ServerBackup", "Archive") - .WithMany() - .HasForeignKey("ArchiveId"); - - 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"); - - 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("Archive"); - - 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.SupportChatMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Recipient") - .WithMany() - .HasForeignKey("RecipientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.Navigation("Recipient"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.Ticket", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "AssignedTo") - .WithMany() - .HasForeignKey("AssignedToId"); - - b.HasOne("Moonlight.App.Database.Entities.User", "CreatedBy") - .WithMany() - .HasForeignKey("CreatedById") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AssignedTo"); - - b.Navigation("CreatedBy"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.TicketMessage", b => - { - b.HasOne("Moonlight.App.Database.Entities.User", "Sender") - .WithMany() - .HasForeignKey("SenderId"); - - b.HasOne("Moonlight.App.Database.Entities.Ticket", null) - .WithMany("Messages") - .HasForeignKey("TicketId"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.User", b => - { - b.HasOne("Moonlight.App.Database.Entities.Subscription", "CurrentSubscription") - .WithMany() - .HasForeignKey("CurrentSubscriptionId"); - - b.HasOne("Moonlight.App.Database.Entities.PermissionGroup", "PermissionGroup") - .WithMany() - .HasForeignKey("PermissionGroupId"); - - b.Navigation("CurrentSubscription"); - - b.Navigation("PermissionGroup"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.HasOne("Moonlight.App.Database.Entities.CloudPanel", "CloudPanel") - .WithMany() - .HasForeignKey("CloudPanelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Moonlight.App.Database.Entities.User", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CloudPanel"); - - 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.Ticket", b => - { - b.Navigation("Messages"); - }); - - modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b => - { - b.Navigation("Databases"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Moonlight/App/Diagnostics/HealthChecks/DaemonHealthCheck.cs b/Moonlight/App/Diagnostics/HealthChecks/DaemonHealthCheck.cs deleted file mode 100644 index ce024112..00000000 --- a/Moonlight/App/Diagnostics/HealthChecks/DaemonHealthCheck.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Diagnostics; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Moonlight.App.Database.Entities; -using Moonlight.App.Repositories; -using Moonlight.App.Services; - -namespace Moonlight.App.Diagnostics.HealthChecks; - -public class DaemonHealthCheck : IHealthCheck -{ - private readonly Repository NodeRepository; - private readonly NodeService NodeService; - - public DaemonHealthCheck(Repository nodeRepository, NodeService nodeService) - { - NodeRepository = nodeRepository; - NodeService = nodeService; - } - - public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken()) - { - var nodes = NodeRepository.Get().ToArray(); - - var results = new Dictionary(); - var healthCheckData = new Dictionary(); - - foreach (var node in nodes) - { - try - { - await NodeService.GetCpuMetrics(node); - - results.Add(node, true); - } - catch (Exception e) - { - results.Add(node, false); - healthCheckData.Add(node.Name, e.ToStringDemystified()); - } - } - - var offlineNodes = results - .Where(x => !x.Value) - .ToArray(); - - if (offlineNodes.Length == nodes.Length) - { - return HealthCheckResult.Unhealthy("All node daemons are offline", null, healthCheckData); - } - - if (offlineNodes.Length == 0) - { - return HealthCheckResult.Healthy("All node daemons are online"); - } - - return HealthCheckResult.Degraded($"{offlineNodes.Length} node daemons are offline", null, healthCheckData); - } -} \ No newline at end of file diff --git a/Moonlight/App/Diagnostics/HealthChecks/DatabaseHealthCheck.cs b/Moonlight/App/Diagnostics/HealthChecks/DatabaseHealthCheck.cs deleted file mode 100644 index 34c23b5b..00000000 --- a/Moonlight/App/Diagnostics/HealthChecks/DatabaseHealthCheck.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Moonlight.App.Database; - -namespace Moonlight.App.Diagnostics.HealthChecks; - -public class DatabaseHealthCheck : IHealthCheck -{ - private readonly DataContext DataContext; - - public DatabaseHealthCheck(DataContext dataContext) - { - DataContext = dataContext; - } - - public async Task CheckHealthAsync( - HealthCheckContext context, - CancellationToken cancellationToken = new CancellationToken()) - { - try - { - await DataContext.Database.OpenConnectionAsync(cancellationToken); - await DataContext.Database.CloseConnectionAsync(); - - return HealthCheckResult.Healthy("Database is online"); - } - catch (Exception e) - { - return HealthCheckResult.Unhealthy("Database is offline", e); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Diagnostics/HealthChecks/NodeHealthCheck.cs b/Moonlight/App/Diagnostics/HealthChecks/NodeHealthCheck.cs deleted file mode 100644 index b330ffcc..00000000 --- a/Moonlight/App/Diagnostics/HealthChecks/NodeHealthCheck.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Diagnostics; -using Microsoft.Extensions.Diagnostics.HealthChecks; -using Moonlight.App.Database.Entities; -using Moonlight.App.Repositories; -using Moonlight.App.Services; - -namespace Moonlight.App.Diagnostics.HealthChecks; - -public class NodeHealthCheck : IHealthCheck -{ - private readonly Repository NodeRepository; - private readonly NodeService NodeService; - - public NodeHealthCheck(Repository nodeRepository, NodeService nodeService) - { - NodeRepository = nodeRepository; - NodeService = nodeService; - } - - public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken()) - { - var nodes = NodeRepository.Get().ToArray(); - - var results = new Dictionary(); - var healthCheckData = new Dictionary(); - - foreach (var node in nodes) - { - try - { - await NodeService.GetStatus(node); - - results.Add(node, true); - } - catch (Exception e) - { - results.Add(node, false); - healthCheckData.Add(node.Name, e.ToStringDemystified()); - } - } - - var offlineNodes = results - .Where(x => !x.Value) - .ToArray(); - - if (offlineNodes.Length == nodes.Length) - { - return HealthCheckResult.Unhealthy("All nodes are offline", null, healthCheckData); - } - - if (offlineNodes.Length == 0) - { - return HealthCheckResult.Healthy("All nodes are online"); - } - - return HealthCheckResult.Degraded($"{offlineNodes.Length} nodes are offline", null, healthCheckData); - } -} \ No newline at end of file diff --git a/Moonlight/App/Events/EventSystem.cs b/Moonlight/App/Events/EventSystem.cs deleted file mode 100644 index 2994ed9c..00000000 --- a/Moonlight/App/Events/EventSystem.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.Diagnostics; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Events; - -public class EventSystem -{ - private List Subscribers = new(); - - private readonly bool Debug = false; - private readonly bool DisableWarning = false; - private readonly TimeSpan TookToLongTime = TimeSpan.FromSeconds(1); - - public Task On(string id, object handle, Func action) - { - if(Debug) - Logger.Debug($"{handle} subscribed to '{id}'"); - - lock (Subscribers) - { - if (!Subscribers.Any(x => x.Id == id && x.Handle == handle)) - { - Subscribers.Add(new () - { - Action = action, - Handle = handle, - Id = id - }); - } - } - - return Task.CompletedTask; - } - - public Task Emit(string id, object? data = null) - { - Subscriber[] subscribers; - - lock (Subscribers) - { - subscribers = Subscribers - .Where(x => x.Id == id) - .ToArray(); - } - - var tasks = new List(); - - foreach (var subscriber in subscribers) - { - tasks.Add(new Task(() => - { - var stopWatch = new Stopwatch(); - stopWatch.Start(); - - var del = (Delegate)subscriber.Action; - - try - { - ((Task)del.DynamicInvoke(data)!).Wait(); - } - catch (Exception e) - { - Logger.Warn($"Error emitting '{subscriber.Id} on {subscriber.Handle}'"); - Logger.Warn(e); - } - - stopWatch.Stop(); - - if (!DisableWarning) - { - if (stopWatch.Elapsed.TotalMilliseconds > TookToLongTime.TotalMilliseconds) - { - Logger.Warn($"Subscriber {subscriber.Handle} for event '{subscriber.Id}' took long to process. {stopWatch.Elapsed.TotalMilliseconds}ms"); - } - } - - if (Debug) - { - Logger.Debug($"Subscriber {subscriber.Handle} for event '{subscriber.Id}' took {stopWatch.Elapsed.TotalMilliseconds}ms"); - } - })); - } - - foreach (var task in tasks) - { - task.Start(); - } - - Task.Run(() => - { - Task.WaitAll(tasks.ToArray()); - - if(Debug) - Logger.Debug($"Completed all event tasks for '{id}' and removed object from storage"); - }); - - if(Debug) - Logger.Debug($"Completed event emit '{id}'"); - - return Task.CompletedTask; - } - - public Task Off(string id, object handle) - { - if(Debug) - Logger.Debug($"{handle} unsubscribed to '{id}'"); - - lock (Subscribers) - { - Subscribers.RemoveAll(x => x.Id == id && x.Handle == handle); - } - - return Task.CompletedTask; - } - - public Task WaitForEvent(string id, object handle, Func? filter = null) - { - var taskCompletionSource = new TaskCompletionSource(); - - Func action = async data => - { - if (filter == null) - { - taskCompletionSource.SetResult(data); - await Off(id, handle); - } - else if(filter.Invoke(data)) - { - taskCompletionSource.SetResult(data); - await Off(id, handle); - } - }; - - On(id, handle, action); - - return taskCompletionSource.Task; - } -} \ No newline at end of file diff --git a/Moonlight/App/Events/Subscriber.cs b/Moonlight/App/Events/Subscriber.cs deleted file mode 100644 index 0d64012c..00000000 --- a/Moonlight/App/Events/Subscriber.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Events; - -public class Subscriber -{ - public string Id { get; set; } - public object Action { get; set; } - public object Handle { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Exceptions/CloudflareException.cs b/Moonlight/App/Exceptions/CloudflareException.cs deleted file mode 100644 index 0a8d9709..00000000 --- a/Moonlight/App/Exceptions/CloudflareException.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.Exceptions; - -[Serializable] -public class CloudflareException : Exception -{ - // - // For guidelines regarding the creation of new exception types, see - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp - // and - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp - // - - public CloudflareException() - { - } - - public CloudflareException(string message) : base(message) - { - } - - public CloudflareException(string message, Exception inner) : base(message, inner) - { - } - - protected CloudflareException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/Exceptions/DisplayException.cs b/Moonlight/App/Exceptions/DisplayException.cs deleted file mode 100644 index 636ac672..00000000 --- a/Moonlight/App/Exceptions/DisplayException.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Runtime.Serialization; - -namespace Moonlight.App.Exceptions; - -[Serializable] -public class DisplayException : Exception -{ - public bool DoNotTranslate { get; set; } = false; - - // - // For guidelines regarding the creation of new exception types, see - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp - // and - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp - // - - public DisplayException() - { - } - - public DisplayException(string message) : base(message) - { - } - - public DisplayException(string message, bool doNotTranslate) : base(message) - { - DoNotTranslate = doNotTranslate; - } - - public DisplayException(string message, Exception inner) : base(message, inner) - { - } - - protected DisplayException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } -} \ No newline at end of file diff --git a/Moonlight/App/Extensions/DbSetExtensions.cs b/Moonlight/App/Extensions/DbSetExtensions.cs deleted file mode 100644 index 7f06c81c..00000000 --- a/Moonlight/App/Extensions/DbSetExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace Moonlight.App.Extensions; - -public static class DbSetExtensions -{ - public static T Random(this DbSet repo) where T : class - { - Random rand = new Random(); - int toSkip = rand.Next(0, repo.Count()); - - return repo.Skip(toSkip).Take(1).First(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Extensions/JSRuntimeExtensions.cs b/Moonlight/App/Extensions/JSRuntimeExtensions.cs deleted file mode 100644 index 7d6f4511..00000000 --- a/Moonlight/App/Extensions/JSRuntimeExtensions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Extensions; - -public static class JSRuntimeExtensions -{ - public static async Task InvokeVoidSafeAsync(this IJSRuntime jsRuntime, string method, params object[] args) - { - try - { - await jsRuntime.InvokeVoidAsync(method, args); - } - catch (Exception) - { - // ignored - } - } - - public static void InvokeVoidSafe(this IJSRuntime jsRuntime, string method, params object[] args) - { - try - { - jsRuntime.InvokeVoidAsync(method, args); - } - catch (Exception) - { - // ignored - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Extensions/StringExtensions.cs b/Moonlight/App/Extensions/StringExtensions.cs deleted file mode 100644 index 4c48f684..00000000 --- a/Moonlight/App/Extensions/StringExtensions.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Moonlight.App.Extensions; - -public static class StringExtensions -{ - public static string FirstCharToUpper(this string input) => - input switch - { - null => throw new ArgumentNullException(nameof(input)), - "" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)), - _ => string.Concat(input[0].ToString().ToUpper(), input.AsSpan(1)) - }; -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/AvgHelper.cs b/Moonlight/App/Helpers/AvgHelper.cs deleted file mode 100644 index 808aa81a..00000000 --- a/Moonlight/App/Helpers/AvgHelper.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Helpers; - -public static class AvgHelper -{ - public static StatisticsData[] Calculate(StatisticsData[] data, int splitSize = 40) - { - if (data.Length <= splitSize) - return data; - - var result = new List(); - - var i = data.Length / (float)splitSize; - var pc = (int)Math.Round(i); - - foreach (var part in data.Chunk(pc)) - { - double d = 0; - var res = new StatisticsData(); - - foreach (var entry in part) - { - d += entry.Value; - } - - res.Chart = part.First().Chart; - res.Date = part.First().Date; - - if (d == 0) - res.Value = 0; - - res.Value = d / part.Length; - result.Add(res); - } - - return result.ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/BackupHelper.cs b/Moonlight/App/Helpers/BackupHelper.cs deleted file mode 100644 index 635bcfde..00000000 --- a/Moonlight/App/Helpers/BackupHelper.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System.Diagnostics; -using System.IO.Compression; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Services; -using MySql.Data.MySqlClient; - -namespace Moonlight.App.Helpers; - -public class BackupHelper -{ - public async Task CreateBackup(string path) - { - Logger.Info("Started moonlight backup creation"); - Logger.Info($"This backup will be saved to '{path}'"); - - var stopWatch = new Stopwatch(); - stopWatch.Start(); - - var cachePath = PathBuilder.Dir("storage", "backups", "cache"); - - Directory.CreateDirectory(cachePath); - - // - // Exporting database - // - - Logger.Info("Exporting database"); - - var configService = new ConfigService(new()); - var dataContext = new DataContext(configService); - - await using MySqlConnection conn = new MySqlConnection(dataContext.Database.GetConnectionString()); - await using MySqlCommand cmd = new MySqlCommand(); - using MySqlBackup mb = new MySqlBackup(cmd); - - cmd.Connection = conn; - await conn.OpenAsync(); - mb.ExportToFile(PathBuilder.File(cachePath, "database.sql")); - await conn.CloseAsync(); - - // - // Saving config - // - - Logger.Info("Saving configuration"); - File.Copy( - PathBuilder.File("storage", "configs", "config.json"), - PathBuilder.File(cachePath, "config.json")); - - // - // Saving all storage items needed to restore the panel - // - - Logger.Info("Saving resources"); - CopyDirectory( - PathBuilder.Dir("storage", "resources"), - PathBuilder.Dir(cachePath, "resources")); - - Logger.Info("Saving logs"); - CopyDirectory( - PathBuilder.Dir("storage", "logs"), - PathBuilder.Dir(cachePath, "logs")); - - Logger.Info("Saving uploads"); - CopyDirectory( - PathBuilder.Dir("storage", "uploads"), - PathBuilder.Dir(cachePath, "uploads")); - - // - // Compressing the backup to a single file - // - - Logger.Info("Compressing"); - ZipFile.CreateFromDirectory(cachePath, - path, - CompressionLevel.Fastest, - false); - - Directory.Delete(cachePath, true); - - stopWatch.Stop(); - Logger.Info($"Backup successfully created. Took {stopWatch.Elapsed.TotalSeconds} seconds"); - } - - private void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs = true) - { - DirectoryInfo dir = new DirectoryInfo(sourceDirName); - - if (!dir.Exists) - { - throw new DirectoryNotFoundException($"Source directory does not exist or could not be found: {sourceDirName}"); - } - - if (!Directory.Exists(destDirName)) - { - Directory.CreateDirectory(destDirName); - } - - FileInfo[] files = dir.GetFiles(); - - foreach (FileInfo file in files) - { - string tempPath = Path.Combine(destDirName, file.Name); - file.CopyTo(tempPath, false); - } - - if (copySubDirs) - { - DirectoryInfo[] dirs = dir.GetDirectories(); - - foreach (DirectoryInfo subdir in dirs) - { - string tempPath = Path.Combine(destDirName, subdir.Name); - CopyDirectory(subdir.FullName, tempPath, copySubDirs); - } - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/BitHelper.cs b/Moonlight/App/Helpers/BitHelper.cs deleted file mode 100644 index 4f0dacd3..00000000 --- a/Moonlight/App/Helpers/BitHelper.cs +++ /dev/null @@ -1,88 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class BitHelper -{ - public static bool ReadBit(byte[] byteArray, int bitIndex) - { - if (bitIndex < 0) - throw new ArgumentOutOfRangeException("bitIndex"); - - int byteIndex = bitIndex / 8; - if (byteIndex >= byteArray.Length) - throw new ArgumentOutOfRangeException("bitIndex"); - - int bitNumber = bitIndex % 8; - byte mask = (byte)(1 << bitNumber); - - return (byteArray[byteIndex] & mask) != 0; - } - - public static byte[] WriteBit(byte[] byteArray, int bitIndex, bool value) - { - if (bitIndex < 0) - throw new ArgumentOutOfRangeException("bitIndex"); - - int byteIndex = bitIndex / 8; - byte[] resultArray; - - if (byteIndex >= byteArray.Length) - { - // Create a new array with increased size and copy elements from old array - resultArray = new byte[byteIndex + 1]; - Array.Copy(byteArray, resultArray, byteArray.Length); - } - else - { - // Create a new array and copy elements from old array - resultArray = new byte[byteArray.Length]; - Array.Copy(byteArray, resultArray, byteArray.Length); - } - - int bitNumber = bitIndex % 8; - byte mask = (byte)(1 << bitNumber); - - if (value) - resultArray[byteIndex] |= mask; // Set the bit to 1 - else - resultArray[byteIndex] &= (byte)~mask; // Set the bit to 0 - - return resultArray; - } - - public static byte[] OverwriteByteArrays(byte[] targetArray, byte[] overwriteArray) - { - int targetLength = targetArray.Length; - int overwriteLength = overwriteArray.Length; - - int maxLength = Math.Max(targetLength, overwriteLength); - - byte[] resultArray = new byte[maxLength]; - - for (int i = 0; i < maxLength; i++) - { - byte targetByte = i < targetLength ? targetArray[i] : (byte)0; - byte overwriteByte = i < overwriteLength ? overwriteArray[i] : (byte)0; - - for (int j = 0; j < 8; j++) - { - bool overwriteBit = (overwriteByte & (1 << j)) != 0; - if (i < targetLength) - { - bool targetBit = (targetByte & (1 << j)) != 0; - if (overwriteBit) - { - targetByte = targetBit ? (byte)(targetByte | (1 << j)) : (byte)(targetByte & ~(1 << j)); - } - } - else if (overwriteBit) - { - targetByte |= (byte)(1 << j); - } - } - - resultArray[i] = targetByte; - } - - return resultArray; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/BlurAttribute.cs b/Moonlight/App/Helpers/BlurAttribute.cs deleted file mode 100644 index 170c2b4f..00000000 --- a/Moonlight/App/Helpers/BlurAttribute.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class BlurAttribute : Attribute -{ - -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/ByteSizeValue.cs b/Moonlight/App/Helpers/ByteSizeValue.cs deleted file mode 100644 index d761b0d7..00000000 --- a/Moonlight/App/Helpers/ByteSizeValue.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class ByteSizeValue -{ - public long Bytes { get; set; } - - public long KiloBytes - { - get => Bytes / 1024; - set => Bytes = value * 1024; - } - - public long MegaBytes - { - get => KiloBytes / 1024; - set => KiloBytes = value * 1024; - } - - public long GigaBytes - { - get => MegaBytes / 1024; - set => MegaBytes = value * 1024; - } - - public static ByteSizeValue FromBytes(long bytes) - { - return new() - { - Bytes = bytes - }; - } - - public static ByteSizeValue FromKiloBytes(long kiloBytes) - { - return new() - { - KiloBytes = kiloBytes - }; - } - - public static ByteSizeValue FromMegaBytes(long megaBytes) - { - return new() - { - MegaBytes = megaBytes - }; - } - - public static ByteSizeValue FromGigaBytes(long gigaBytes) - { - return new() - { - GigaBytes = gigaBytes - }; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/ComponentHelper.cs b/Moonlight/App/Helpers/ComponentHelper.cs deleted file mode 100644 index 830c5958..00000000 --- a/Moonlight/App/Helpers/ComponentHelper.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Moonlight.App.Helpers; - -public class ComponentHelper -{ - public static RenderFragment FromType(Type type) => builder => - { - builder.OpenComponent(0, type); - builder.CloseComponent(); - }; -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/DatabaseCheckupService.cs b/Moonlight/App/Helpers/DatabaseCheckupService.cs deleted file mode 100644 index 829e5310..00000000 --- a/Moonlight/App/Helpers/DatabaseCheckupService.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Diagnostics; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Services; -using Moonlight.App.Services.Files; -using MySql.Data.MySqlClient; - -namespace Moonlight.App.Helpers; - -public class DatabaseCheckupService -{ - private readonly ConfigService ConfigService; - - public DatabaseCheckupService(ConfigService configService) - { - ConfigService = configService; - } - - public async Task Perform() - { - var context = new DataContext(ConfigService); - - Logger.Info("Checking database"); - - if (!await context.Database.CanConnectAsync()) - { - Logger.Fatal("-----------------------------------------------"); - Logger.Fatal("Unable to connect to mysql database"); - Logger.Fatal("Please make sure the configuration is correct"); - Logger.Fatal(""); - Logger.Fatal("Moonlight will wait 1 minute, then exit"); - Logger.Fatal("-----------------------------------------------"); - - Thread.Sleep(TimeSpan.FromMinutes(1)); - Environment.Exit(10324); - } - - Logger.Info("Checking for pending migrations"); - - var migrations = (await context.Database - .GetPendingMigrationsAsync()) - .ToArray(); - - if (migrations.Any()) - { - Logger.Info($"{migrations.Length} migrations pending. Updating now"); - - try - { - var backupHelper = new BackupHelper(); - await backupHelper.CreateBackup( - PathBuilder.File("storage", "backups", $"{new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds()}.zip")); - } - catch (Exception e) - { - Logger.Fatal("Unable to create backup"); - Logger.Fatal(e); - Logger.Fatal("Moonlight will continue to start and apply the migrations without a backup"); - } - - Logger.Info("Applying migrations"); - - await context.Database.MigrateAsync(); - - Logger.Info("Successfully applied migrations"); - } - else - { - Logger.Info("Database is up-to-date. No migrations have been performed"); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/DiscordMaintenanceToggle.cs b/Moonlight/App/Helpers/DiscordMaintenanceToggle.cs deleted file mode 100644 index fee30658..00000000 --- a/Moonlight/App/Helpers/DiscordMaintenanceToggle.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Discord.WebSocket; -using Moonlight.App.Services.DiscordBot; - -namespace Moonlight.App.Helpers; - -public class DiscordMaintenanceToggle -{ - private Task MaintenanceModeToggle(SocketSlashCommand command) - { - DiscordBotService.MaintenanceMode = !DiscordBotService.MaintenanceMode; - return Task.CompletedTask; - } -} diff --git a/Moonlight/App/Helpers/EggConverter.cs b/Moonlight/App/Helpers/EggConverter.cs deleted file mode 100644 index d97647c2..00000000 --- a/Moonlight/App/Helpers/EggConverter.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Text; -using Moonlight.App.Database.Entities; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Moonlight.App.Helpers; - -public static class EggConverter -{ - public static Image Convert(string json) - { - var result = new Image(); - - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(json)) - ).Build(); - - result.Allocations = 1; - result.Description = data.GetValue("description") ?? ""; - result.Uuid = Guid.NewGuid(); - result.Startup = data.GetValue("startup") ?? ""; - result.Name = data.GetValue("name") ?? "Ptero Egg"; - - foreach (var variable in data.GetSection("variables").GetChildren()) - { - result.Variables.Add(new() - { - Key = variable.GetValue("env_variable") ?? "", - DefaultValue = variable.GetValue("default_value") ?? "" - }); - } - - var configData = data.GetSection("config"); - - result.ConfigFiles = configData.GetValue("files") ?? "{}"; - - var dImagesData = JObject.Parse(json); - var dImages = (JObject)dImagesData["docker_images"]!; - - foreach (var dockerImage in dImages) - { - var di = new DockerImage() - { - Default = dockerImage.Key == dImages.Properties().Last().Name, - Name = dockerImage.Value!.ToString() - }; - - result.DockerImages.Add(di); - } - - var installSection = data.GetSection("scripts").GetSection("installation"); - - result.InstallEntrypoint = installSection.GetValue("entrypoint") ?? "bash"; - result.InstallScript = installSection.GetValue("script") ?? ""; - result.InstallDockerImage = installSection.GetValue("container") ?? ""; - - var rawJson = configData.GetValue("startup"); - - var startupData = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(rawJson!)) - ).Build(); - - result.StartupDetection = startupData.GetValue("done", "") ?? ""; - result.StopCommand = configData.GetValue("stop") ?? ""; - - result.TagsJson = "[]"; - result.BackgroundImageUrl = ""; - - return result; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/FieldCssHelper.cs b/Moonlight/App/Helpers/FieldCssHelper.cs deleted file mode 100644 index 557532a4..00000000 --- a/Moonlight/App/Helpers/FieldCssHelper.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Components.Forms; - -namespace Moonlight.App.Helpers; - -public class FieldCssHelper : FieldCssClassProvider -{ - public override string GetFieldCssClass(EditContext editContext, in FieldIdentifier fieldIdentifier) - { - return editContext.GetValidationMessages(fieldIdentifier).Any() ? "is-invalid" : "is-valid"; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/ContextAction.cs b/Moonlight/App/Helpers/Files/ContextAction.cs deleted file mode 100644 index 704c4250..00000000 --- a/Moonlight/App/Helpers/Files/ContextAction.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Helpers.Files; - -public class ContextAction -{ - public string Id { get; set; } = ""; - public string Name { get; set; } = ""; - public Action Action { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/FileAccess.cs b/Moonlight/App/Helpers/Files/FileAccess.cs deleted file mode 100644 index a900c462..00000000 --- a/Moonlight/App/Helpers/Files/FileAccess.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Moonlight.App.Helpers.Files; - -public abstract class FileAccess : ICloneable -{ - public string CurrentPath { get; set; } = "/"; - - public abstract Task Ls(); - public abstract Task Cd(string dir); - public abstract Task Up(); - public abstract Task SetDir(string dir); - public abstract Task Read(FileData fileData); - public abstract Task Write(FileData fileData, string content); - public abstract Task Upload(string name, Stream stream, Action? progressUpdated = null); - public abstract Task MkDir(string name); - public abstract Task Pwd(); - public abstract Task DownloadUrl(FileData fileData); - public abstract Task DownloadStream(FileData fileData); - public abstract Task Delete(FileData fileData); - public abstract Task Move(FileData fileData, string newPath); - public abstract Task Compress(params FileData[] files); - public abstract Task Decompress(FileData fileData); - public abstract Task GetLaunchUrl(); - public abstract object Clone(); -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/FileData.cs b/Moonlight/App/Helpers/Files/FileData.cs deleted file mode 100644 index f0bb75f0..00000000 --- a/Moonlight/App/Helpers/Files/FileData.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Helpers.Files; - -public class FileData -{ - public string Name { get; set; } = ""; - public long Size { get; set; } - public bool IsFile { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/FtpFileAccess.cs b/Moonlight/App/Helpers/Files/FtpFileAccess.cs deleted file mode 100644 index df17025d..00000000 --- a/Moonlight/App/Helpers/Files/FtpFileAccess.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System.Net; -using System.Text; -using FluentFTP; -using Moonlight.App.Exceptions; - -namespace Moonlight.App.Helpers.Files; - -public class FtpFileAccess : FileAccess -{ - private string FtpHost, FtpUser, FtpPassword; - private int FtpPort; - - private AsyncFtpClient Client; - - public FtpFileAccess(string ftpHost, int ftpPort, string ftpUser, string ftpPassword) - { - FtpHost = ftpHost; - FtpPort = ftpPort; - FtpUser = ftpUser; - FtpPassword = ftpPassword; - - Client = new AsyncFtpClient(FtpHost, FtpUser, FtpPassword, FtpPort); - } - - private async Task EnsureConnect() - { - if (!Client.IsConnected) - await Client.AutoConnect(); - } - - public override async Task Ls() - { - await EnsureConnect(); - - var x = new List(); - - foreach (FtpListItem item in (await Client.GetListing(CurrentPath)).OrderBy(x => x.Type + " " + x.Name)) - { - long size = 0; - - if (item.Type == FtpObjectType.File) - { - size = await Client.GetFileSize(item.FullName); - } - - x.Add(new() - { - Name = item.Name, - Size = size, - IsFile = item.Type == FtpObjectType.File, - }); - } - - return x.ToArray(); - } - - public override Task Cd(string dir) - { - var x = Path.Combine(CurrentPath, dir).Replace("\\", "/") + "/"; - x = x.Replace("//", "/"); - CurrentPath = x; - - return Task.CompletedTask; - } - - public override Task Up() - { - CurrentPath = Path.GetFullPath(Path.Combine(CurrentPath, "..")).Replace("\\", "/").Replace("C:", ""); - return Task.CompletedTask; - } - - public override Task SetDir(string dir) - { - CurrentPath = dir; - return Task.CompletedTask; - } - - public override async Task Read(FileData fileData) - { - await EnsureConnect(); - - var s = new MemoryStream(8 * 1024 * 1204); //TODO: Add config option - await Client.DownloadStream(s, CurrentPath.TrimEnd('/') + "/" + fileData.Name); - var data = s.ToArray(); - await s.DisposeAsync(); - var str = Encoding.UTF8.GetString(data); - return str; - } - - public override async Task Write(FileData fileData, string content) - { - await EnsureConnect(); - - var s = new MemoryStream(8 * 1024 * 1204); //TODO: Add config option - s.Write(Encoding.UTF8.GetBytes(content)); - s.Position = 0; - await Client.UploadStream(s, CurrentPath.TrimEnd('/') + "/" + fileData.Name, FtpRemoteExists.Overwrite); - await s.DisposeAsync(); - } - - public override async Task Upload(string name, Stream dataStream, Action? progressUpdated = null) - { - await EnsureConnect(); - - IProgress progress = new Progress(x => - { - progressUpdated?.Invoke((int)x.Progress); - }); - await Client.UploadStream(dataStream, CurrentPath.TrimEnd('/') + "/" + name, FtpRemoteExists.Overwrite, false, progress); - } - - public override async Task MkDir(string name) - { - await EnsureConnect(); - - await Client.CreateDirectory(CurrentPath.TrimEnd('/') + "/" + name + "/"); - } - - public override Task Pwd() - { - return Task.FromResult(CurrentPath); - } - - public override Task DownloadUrl(FileData fileData) - { - throw new NotImplementedException(); - } - - public override async Task DownloadStream(FileData fileData) - { - await EnsureConnect(); - - var s = new MemoryStream(8 * 1024 * 1204); //TODO: Add config option - var downloaded = await Client.DownloadStream(s, CurrentPath.TrimEnd('/') + "/" + fileData.Name); - - if (!downloaded) - throw new DisplayException("Unable to download file"); - - return s; - } - - public override async Task Delete(FileData fileData) - { - await EnsureConnect(); - - if (fileData.IsFile) - await Client.DeleteFile(CurrentPath.TrimEnd('/') + "/" + fileData.Name); - else - await Client.DeleteDirectory(CurrentPath.TrimEnd('/') + "/" + fileData.Name); - } - - public override async Task Move(FileData fileData, string newPath) - { - await EnsureConnect(); - - if (fileData.IsFile) - await Client.MoveFile(CurrentPath.TrimEnd('/') + "/" + fileData.Name, newPath); - else - await Client.MoveDirectory(CurrentPath.TrimEnd('/') + "/" + fileData.Name, newPath); - } - - public override Task Compress(params FileData[] files) - { - throw new NotImplementedException(); - } - - public override Task Decompress(FileData fileData) - { - throw new NotImplementedException(); - } - - public override Task GetLaunchUrl() - { - return Task.FromResult( - $"ftp://{FtpUser}:{FtpPassword}@{FtpHost}:{FtpPort}/"); - } - - public override object Clone() - { - return new FtpFileAccess(FtpHost, FtpPort, FtpUser, FtpPassword); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/HostFileAccess.cs b/Moonlight/App/Helpers/Files/HostFileAccess.cs deleted file mode 100644 index 35b5224f..00000000 --- a/Moonlight/App/Helpers/Files/HostFileAccess.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System.IO.Compression; - -namespace Moonlight.App.Helpers.Files; - -public class HostFileAccess : FileAccess -{ - private string BasePath; - - public HostFileAccess(string basePath) - { - BasePath = basePath; - } - private string currhp => BasePath.TrimEnd('/') + "/" + CurrentPath.TrimStart('/').TrimEnd('/') + "/"; - public override async Task Ls() - { - var x = new List(); - - foreach (var dir in Directory.GetDirectories(currhp)) - { - x.Add(new() - { - Name = dir.Remove(0, currhp.Length), - Size = 0, - IsFile = false, - }); - } - - foreach (var fn in Directory.GetFiles(currhp)) - { - x.Add(new() - { - Name = fn.Remove(0, currhp.Length), - Size = new FileInfo(fn).Length, - IsFile = true, - }); - } - - return x.ToArray(); - } - - public override Task Cd(string dir) - { - var x = Path.Combine(CurrentPath, dir).Replace("\\", "/") + "/"; - x = x.Replace("//", "/"); - CurrentPath = x; - - return Task.CompletedTask; - } - - public override Task Up() - { - CurrentPath = Path.GetFullPath(Path.Combine(CurrentPath, "..")).Replace("\\", "/").Replace("C:", ""); - return Task.CompletedTask; - } - - public override Task SetDir(string dir) - { - CurrentPath = dir; - return Task.CompletedTask; - } - - public override async Task Read(FileData fileData) - { - return await File.ReadAllTextAsync(currhp + fileData.Name); - } - - public override async Task Write(FileData fileData, string content) - { - await File.WriteAllTextAsync(currhp + fileData.Name, content); - } - - public override async Task Upload(string name, Stream dataStream, Action? progressUpdated = null) - { - var ms = new MemoryStream(); - await dataStream.CopyToAsync(ms); - var data = ms.ToArray(); - ms.Dispose(); - dataStream.Dispose(); - - await File.WriteAllBytesAsync(currhp + name, data); - } - - public override async Task MkDir(string name) - { - Directory.CreateDirectory(currhp + name + "/"); - } - - public override Task Pwd() - { - return Task.FromResult(CurrentPath); - } - - public override Task DownloadUrl(FileData fileData) - { - throw new NotImplementedException(); - } - - public override async Task DownloadStream(FileData fileData) - { - var s = new MemoryStream(8 * 1024 * 1204); //TODO: Add config option - - s.Write(File.ReadAllBytes(currhp + fileData.Name)); - s.Position = 0; - - return s; - } - - public override async Task Delete(FileData fileData) - { - if (fileData.IsFile) - File.Delete(currhp + fileData.Name); - else - Directory.Delete(currhp + fileData.Name, true); - } - - public override async Task Move(FileData fileData, string newPath) - { - if (fileData.IsFile) - File.Move(currhp + fileData.Name, BasePath + newPath); - else - Directory.Move(currhp + fileData.Name, BasePath + newPath); - } - - public override Task Compress(params FileData[] files) - { - throw new NotImplementedException(); - } - - public override Task Decompress(FileData fileData) - { - throw new NotImplementedException(); - } - - public override Task GetLaunchUrl() - { - throw new NotImplementedException(); - } - - public override object Clone() - { - return new HostFileAccess(BasePath); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/SftpFileAccess.cs b/Moonlight/App/Helpers/Files/SftpFileAccess.cs deleted file mode 100644 index 84b8dd60..00000000 --- a/Moonlight/App/Helpers/Files/SftpFileAccess.cs +++ /dev/null @@ -1,207 +0,0 @@ -using Renci.SshNet; -using ConnectionInfo = Renci.SshNet.ConnectionInfo; - -namespace Moonlight.App.Helpers.Files; - -public class SftpFileAccess : FileAccess -{ - private readonly string SftpHost; - private readonly string SftpUser; - private readonly string SftpPassword; - private readonly int SftpPort; - private readonly bool ForceUserDir; - private readonly string AdditionalPath; - - private readonly SftpClient Client; - - private string InternalPath - { - get - { - if (ForceUserDir) - return $"/home/{SftpUser}{AdditionalPath}{CurrentPath}"; - - return InternalPath; - } - } - - public SftpFileAccess(string sftpHost, string sftpUser, string sftpPassword, int sftpPort, - bool forceUserDir = false, string additionalPath = "") - { - SftpHost = sftpHost; - SftpUser = sftpUser; - SftpPassword = sftpPassword; - SftpPort = sftpPort; - ForceUserDir = forceUserDir; - AdditionalPath = additionalPath; - - Client = new( - new ConnectionInfo( - SftpHost, - SftpPort, - SftpUser, - new PasswordAuthenticationMethod( - SftpUser, - SftpPassword - ) - ) - ); - } - - private void EnsureConnect() - { - if (!Client.IsConnected) - Client.Connect(); - } - - - public override Task Ls() - { - EnsureConnect(); - - var x = new List(); - - foreach (var file in Client.ListDirectory(InternalPath)) - { - if (file.Name != "." && file.Name != "..") - { - x.Add(new() - { - Name = file.Name, - Size = file.Attributes.Size, - IsFile = !file.IsDirectory - }); - } - } - - return Task.FromResult(x.ToArray()); - } - - public override Task Cd(string dir) - { - var x = Path.Combine(CurrentPath, dir).Replace("\\", "/") + "/"; - x = x.Replace("//", "/"); - CurrentPath = x; - - return Task.CompletedTask; - } - - public override Task Up() - { - CurrentPath = Path.GetFullPath(Path.Combine(CurrentPath, "..")).Replace("\\", "/").Replace("C:", ""); - return Task.CompletedTask; - } - - public override Task SetDir(string dir) - { - CurrentPath = dir; - return Task.CompletedTask; - } - - public override Task Read(FileData fileData) - { - EnsureConnect(); - - var textStream = Client.Open(InternalPath.TrimEnd('/') + "/" + fileData.Name, FileMode.Open); - - if (textStream == null) - return Task.FromResult(""); - - var streamReader = new StreamReader(textStream); - - var text = streamReader.ReadToEnd(); - - streamReader.Close(); - textStream.Close(); - - return Task.FromResult(text); - } - - public override Task Write(FileData fileData, string content) - { - EnsureConnect(); - - var textStream = Client.Open(InternalPath.TrimEnd('/') + "/" + fileData.Name, FileMode.Create); - - var streamWriter = new StreamWriter(textStream); - streamWriter.Write(content); - - streamWriter.Flush(); - textStream.Flush(); - - streamWriter.Close(); - textStream.Close(); - - return Task.CompletedTask; - } - - public override async Task Upload(string name, Stream stream, Action? progressUpdated = null) - { - var dataStream = new SyncStreamAdapter(stream); - - await Task.Factory.FromAsync((x, _) => Client.BeginUploadFile(dataStream, InternalPath + name, x, null, u => - { - progressUpdated?.Invoke((int)((long)u / stream.Length)); - }), - Client.EndUploadFile, null); - } - - public override Task MkDir(string name) - { - Client.CreateDirectory(InternalPath + name); - - return Task.CompletedTask; - } - - public override Task Pwd() - { - return Task.FromResult(CurrentPath); - } - - public override Task DownloadUrl(FileData fileData) - { - throw new NotImplementedException(); - } - - public override Task DownloadStream(FileData fileData) - { - var stream = new MemoryStream(100 * 1024 * 1024); - Client.DownloadFile(InternalPath + fileData.Name, stream); - - return Task.FromResult(stream); - } - - public override Task Delete(FileData fileData) - { - Client.Delete(InternalPath + fileData.Name); - - return Task.CompletedTask; - } - - public override Task Move(FileData fileData, string newPath) - { - Client.RenameFile(InternalPath + fileData.Name, InternalPath + newPath); - - return Task.CompletedTask; - } - - public override Task Compress(params FileData[] files) - { - throw new NotImplementedException(); - } - - public override Task Decompress(FileData fileData) - { - throw new NotImplementedException(); - } - - public override Task GetLaunchUrl() - { - return Task.FromResult($"sftp://{SftpUser}@{SftpHost}:{SftpPort}"); - } - - public override object Clone() - { - return new SftpFileAccess(SftpHost, SftpUser, SftpPassword, SftpPort, ForceUserDir); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Files/WingsFileAccess.cs b/Moonlight/App/Helpers/Files/WingsFileAccess.cs deleted file mode 100644 index 8070a507..00000000 --- a/Moonlight/App/Helpers/Files/WingsFileAccess.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System.Web; -using Moonlight.App.ApiClients.Wings; -using Moonlight.App.ApiClients.Wings.Requests; -using Moonlight.App.ApiClients.Wings.Resources; -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers.Wings; -using Moonlight.App.Services; -using RestSharp; - -namespace Moonlight.App.Helpers.Files; - -public class WingsFileAccess : FileAccess -{ - private readonly WingsApiHelper WingsApiHelper; - private readonly WingsJwtHelper WingsJwtHelper; - private readonly ConfigService ConfigService; - private readonly Server Server; - private readonly User User; - - public WingsFileAccess( - WingsApiHelper wingsApiHelper, - WingsJwtHelper wingsJwtHelper, - Server server, - ConfigService configService, - User user) - { - WingsApiHelper = wingsApiHelper; - WingsJwtHelper = wingsJwtHelper; - Server = server; - ConfigService = configService; - User = user; - - if (server.Node == null) - { - throw new ArgumentException("The wings file access server model needs to include the node data"); - } - } - - public override async Task Ls() - { - var res = await WingsApiHelper.Get( - Server.Node, - $"api/servers/{Server.Uuid}/files/list-directory?directory={CurrentPath}" - ); - - var result = new List(); - - foreach (var resGrouped in res.GroupBy(x => x.Directory)) - { - foreach (var resItem in resGrouped.OrderBy(x => x.Name)) - { - result.Add(new() - { - Name = resItem.Name, - Size = resItem.File ? resItem.Size : 0, - IsFile = resItem.File, - }); - } - } - - return result.ToArray(); - } - - public override Task Cd(string dir) - { - var x = Path.Combine(CurrentPath, dir).Replace("\\", "/") + "/"; - x = x.Replace("//", "/"); - CurrentPath = x; - - return Task.CompletedTask; - } - - public override Task Up() - { - CurrentPath = Path.GetFullPath(Path.Combine(CurrentPath, "..")).Replace("\\", "/").Replace("C:", ""); - return Task.CompletedTask; - } - - public override Task SetDir(string dir) - { - CurrentPath = dir; - return Task.CompletedTask; - } - - public override async Task Read(FileData fileData) - { - return await WingsApiHelper.GetRaw(Server.Node, - $"api/servers/{Server.Uuid}/files/contents?file={CurrentPath}{fileData.Name}"); - } - - public override async Task Write(FileData fileData, string content) - { - await WingsApiHelper.PostRaw(Server.Node, - $"api/servers/{Server.Uuid}/files/write?file={CurrentPath}{fileData.Name}", content); - } - - public override async Task Upload(string name, Stream dataStream, Action? progressUpdated = null) - { - var token = WingsJwtHelper.Generate( - Server.Node.Token, - claims => { claims.Add("server_uuid", Server.Uuid.ToString()); } - ); - - var client = new RestClient(); - var request = new RestRequest(); - - if (Server.Node.Ssl) - request.Resource = - $"https://{Server.Node.Fqdn}:{Server.Node.HttpPort}/upload/file?token={token}&directory={CurrentPath}"; - else - request.Resource = - $"http://{Server.Node.Fqdn}:{Server.Node.HttpPort}/upload/file?token={token}&directory={CurrentPath}"; - - request.AddParameter("name", "files"); - request.AddParameter("filename", name); - request.AddHeader("Content-Type", "multipart/form-data"); - request.AddHeader("Origin", ConfigService.Get().Moonlight.AppUrl); - request.AddFile("files", () => - { - return new StreamProgressHelper(dataStream) - { - Progress = i => { progressUpdated?.Invoke(i); } - }; - }, name); - - await client.ExecutePostAsync(request); - - client.Dispose(); - dataStream.Close(); - } - - public override async Task MkDir(string name) - { - await WingsApiHelper.Post(Server.Node, $"api/servers/{Server.Uuid}/files/create-directory", - new CreateDirectory() - { - Name = name, - Path = CurrentPath - } - ); - } - - public override Task Pwd() - { - return Task.FromResult(CurrentPath); - } - - public override Task DownloadUrl(FileData fileData) - { - var token = WingsJwtHelper.Generate(Server.Node.Token, claims => - { - claims.Add("server_uuid", Server.Uuid.ToString()); - claims.Add("file_path", CurrentPath + "/" + fileData.Name); - }); - - if (Server.Node.Ssl) - { - return Task.FromResult( - $"https://{Server.Node.Fqdn}:{Server.Node.HttpPort}/download/file?token={token}" - ); - } - else - { - return Task.FromResult( - $"http://{Server.Node.Fqdn}:{Server.Node.HttpPort}/download/file?token={token}" - ); - } - } - - public override Task DownloadStream(FileData fileData) - { - throw new NotImplementedException(); - } - - public override async Task Delete(FileData fileData) - { - await WingsApiHelper.Post(Server.Node, $"api/servers/{Server.Uuid}/files/delete", new DeleteFiles() - { - Root = CurrentPath, - Files = new() - { - fileData.Name - } - }); - } - - public override async Task Move(FileData fileData, string newPath) - { - var req = new RenameFiles() - { - Root = "/", - Files = new[] - { - new RenameFilesData() - { - From = (CurrentPath + fileData.Name), - To = newPath - } - } - }; - - await WingsApiHelper.Put(Server.Node, $"api/servers/{Server.Uuid}/files/rename", req); - } - - public override async Task Compress(params FileData[] files) - { - var req = new CompressFiles() - { - Root = CurrentPath, - Files = files.Select(x => x.Name).ToArray() - }; - - await WingsApiHelper.Post(Server.Node, $"api/servers/{Server.Uuid}/files/compress", req); - } - - public override async Task Decompress(FileData fileData) - { - try - { - var req = new DecompressFile() - { - Root = CurrentPath, - File = fileData.Name - }; - - await WingsApiHelper.Post(Server.Node, $"api/servers/{Server.Uuid}/files/decompress", req); - } - catch (Exception e) - { - if (e.Message.ToLower().Contains("canceled")) - { - // ignore, maybe do smth better here, like showing a waiting thing or so - } - else - { - throw; - } - } - } - - public override Task GetLaunchUrl() - { - return Task.FromResult( - $"sftp://{User.Id}.{StringHelper.IntToStringWithLeadingZeros(Server.Id, 8)}@{Server.Node.Fqdn}:{Server.Node.SftpPort}"); - } - - public override object Clone() - { - return new WingsFileAccess(WingsApiHelper, WingsJwtHelper, Server, ConfigService, User); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Formatter.cs b/Moonlight/App/Helpers/Formatter.cs deleted file mode 100644 index 05faba8c..00000000 --- a/Moonlight/App/Helpers/Formatter.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System.Text; -using Microsoft.AspNetCore.Components; -using Moonlight.App.Services; - -namespace Moonlight.App.Helpers; - -public static class Formatter -{ - public static string ReplaceEnd(string input, string substringToReplace, string newSubstring) - { - int lastIndexOfSubstring = input.LastIndexOf(substringToReplace); - if (lastIndexOfSubstring >= 0) - { - input = input.Remove(lastIndexOfSubstring, substringToReplace.Length).Insert(lastIndexOfSubstring, newSubstring); - } - - return input; - } - public static string ConvertCamelCaseToSpaces(string input) - { - StringBuilder output = new StringBuilder(); - - foreach (char c in input) - { - if (char.IsUpper(c)) - { - output.Append(' '); - } - - output.Append(c); - } - - return output.ToString().Trim(); - } - public static string FormatUptime(double uptime) - { - TimeSpan t = TimeSpan.FromMilliseconds(uptime); - - if (t.Days > 0) - { - return $"{t.Days}d {t.Hours}h {t.Minutes}m {t.Seconds}s"; - } - else - { - return $"{t.Hours}h {t.Minutes}m {t.Seconds}s"; - } - } - - public static string FormatUptime(TimeSpan t) - { - if (t.Days > 0) - { - return $"{t.Days}d {t.Hours}h {t.Minutes}m {t.Seconds}s"; - } - else - { - return $"{t.Hours}h {t.Minutes}m {t.Seconds}s"; - } - } - - private static double Round(this double d, int decimals) - { - return Math.Round(d, decimals); - } - - public static string FormatSize(long bytes) - { - var i = Math.Abs(bytes) / 1024D; - if (i < 1) - { - return bytes + " B"; - } - else if (i / 1024D < 1) - { - return i.Round(2) + " KB"; - } - else if (i / (1024D * 1024D) < 1) - { - return (i / 1024D).Round(2) + " MB"; - } - else - { - return (i / (1024D * 1024D)).Round(2) + " GB"; - } - } - - public static string FormatAgoFromDateTime(DateTime dt, SmartTranslateService translateService = null) - { - TimeSpan timeSince = DateTime.UtcNow.Subtract(dt); - - if (timeSince.TotalMilliseconds < 1) - return translateService == null ? "just now" : translateService.Translate("just now"); - - if (timeSince.TotalMinutes < 1) - return translateService == null ? "less than a minute ago" : translateService.Translate("less than a minute ago"); - - if (timeSince.TotalMinutes < 2) - return translateService == null ? "1 minute ago" : translateService.Translate("1 minute ago"); - - if (timeSince.TotalMinutes < 60) - return Math.Round(timeSince.TotalMinutes) + (translateService == null ? " minutes ago" : translateService.Translate(" minutes ago")); - - if (timeSince.TotalHours < 2) - return translateService == null ? "1 hour ago" : translateService.Translate("1 hour ago"); - - if (timeSince.TotalHours < 24) - return Math.Round(timeSince.TotalHours) + (translateService == null ? " hours ago" : translateService.Translate(" hours ago")); - - if (timeSince.TotalDays < 2) - return translateService == null ? "1 day ago" : translateService.Translate("1 day ago"); - - return Math.Round(timeSince.TotalDays) + (translateService == null ? " days ago" : translateService.Translate(" days ago")); - } - - public static string FormatDate(DateTime e) - { - string i2s(int i) - { - if (i.ToString().Length < 2) - return "0" + i; - return i.ToString(); - } - - return $"{i2s(e.Day)}.{i2s(e.Month)}.{e.Year} {i2s(e.Hour)}:{i2s(e.Minute)}"; - } - - public static string FormatDateOnly(DateTime e) - { - string i2s(int i) - { - if (i.ToString().Length < 2) - return "0" + i; - return i.ToString(); - } - - return $"{i2s(e.Day)}.{i2s(e.Month)}.{e.Year}"; - } - - public static string FormatSize(double bytes) - { - var i = Math.Abs(bytes) / 1024D; - if (i < 1) - { - return bytes + " B"; - } - else if (i / 1024D < 1) - { - return i.Round(2) + " KB"; - } - else if (i / (1024D * 1024D) < 1) - { - return (i / 1024D).Round(2) + " MB"; - } - else - { - return (i / (1024D * 1024D)).Round(2) + " GB"; - } - } - - public static double CalculateAverage(List values) - { - if (values == null || values.Count == 0) - { - throw new ArgumentException("The list cannot be null or empty."); - } - - double sum = 0; - foreach (double value in values) - { - sum += value; - } - - return sum / values.Count; - } - - public static double CalculatePercentage(double part, double total) - { - if (total == 0) - { - return 0; - } - - return (part / total) * 100; - } - - public static RenderFragment FormatLineBreaks(string content) - { - return builder => - { - int i = 0; - var arr = content.Split("\n", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); - - foreach (var line in arr) - { - builder.AddContent(i, line); - if (i++ != arr.Length - 1) - { - builder.AddMarkupContent(i, "
"); - } - } - }; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/HostSystemHelper.cs b/Moonlight/App/Helpers/HostSystemHelper.cs deleted file mode 100644 index 1ad3da13..00000000 --- a/Moonlight/App/Helpers/HostSystemHelper.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Moonlight.App.Helpers; - -public class HostSystemHelper -{ - public string GetOsName() - { - try - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Windows platform detected - var osVersion = Environment.OSVersion.Version; - return $"Windows {osVersion.Major}.{osVersion.Minor}.{osVersion.Build}"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - // Linux platform detected - var release = System.IO.File.ReadAllText("/etc/os-release"); - var version = release.Split('\n') - .FirstOrDefault(x => x.StartsWith("VERSION_ID=")) - ?.Split('=')[1] - ?.Replace("\"", ""); - return $"Linux {version ?? release}"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - // macOS platform detected - var osVersion = Environment.OSVersion.Version; - return $"macOS {osVersion.Major}.{osVersion.Minor}.{osVersion.Build}"; - } - else - { - // Unknown platform - return "N/A"; - } - } - catch (Exception e) - { - Logger.Warn("Error retrieving os information"); - Logger.Warn(e); - - return "N/A"; - } - } - - public int GetMemoryUsage() - { - var process = Process.GetCurrentProcess(); - var bytes = process.WorkingSet64; - return (int)(bytes / (1024.0 * 1024.0)); - } - - public int GetCpuUsage() - { - var process = Process.GetCurrentProcess(); - var cpuTime = process.TotalProcessorTime; - var wallClockTime = DateTime.UtcNow - process.StartTime.ToUniversalTime(); - return (int)(100.0 * cpuTime.TotalMilliseconds / wallClockTime.TotalMilliseconds / Environment.ProcessorCount); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Logger.cs b/Moonlight/App/Helpers/Logger.cs deleted file mode 100644 index df88bfcb..00000000 --- a/Moonlight/App/Helpers/Logger.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Diagnostics; -using System.Reflection; -using Moonlight.App.Database; -using Moonlight.App.Services; -using Moonlight.App.Services.Files; -using Serilog; - -namespace Moonlight.App.Helpers; - -public static class Logger -{ - // The private static instance of the config service, because we have no di here - private static ConfigService ConfigService = new(new StorageService()); - - #region String method calls - public static void Verbose(string message, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Verbose("{Message}", message); - - if(channel == "security") - LogSecurityInDb(message); - } - - public static void Info(string message, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Information("{Message}", message); - - if(channel == "security") - LogSecurityInDb(message); - } - - public static void Debug(string message, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Debug("{Message}", message); - - if(channel == "security") - LogSecurityInDb(message); - } - - public static void Error(string message, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Error("{Message}", message); - - if(channel == "security") - LogSecurityInDb(message); - } - - public static void Warn(string message, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Warning("{Message}", message); - - if(channel == "security") - LogSecurityInDb(message); - } - - public static void Fatal(string message, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Fatal("{Message}", message); - - if(channel == "security") - LogSecurityInDb(message); - } - #endregion - - #region Exception method calls - public static void Verbose(Exception exception, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Verbose(exception, ""); - - if(channel == "security") - LogSecurityInDb(exception); - } - - public static void Info(Exception exception, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Information(exception, ""); - - if(channel == "security") - LogSecurityInDb(exception); - } - - public static void Debug(Exception exception, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Debug(exception, ""); - - if(channel == "security") - LogSecurityInDb(exception); - } - - public static void Error(Exception exception, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Error(exception, ""); - - if(channel == "security") - LogSecurityInDb(exception); - } - - public static void Warn(Exception exception, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Warning(exception, ""); - - if(channel == "security") - LogSecurityInDb(exception); - } - - public static void Fatal(Exception exception, string channel = "default") - { - Log.ForContext("SourceContext", GetNameOfCallingClass()) - .Fatal(exception, ""); - - if(channel == "security") - LogSecurityInDb(exception); - } - #endregion - - private static string GetNameOfCallingClass(int skipFrames = 4) - { - string fullName; - Type declaringType; - - do - { - MethodBase method = new StackFrame(skipFrames, false).GetMethod(); - declaringType = method.DeclaringType; - if (declaringType == null) - { - return method.Name; - } - skipFrames++; - if (declaringType.Name.Contains("<")) - fullName = declaringType.ReflectedType.Name; - else - fullName = declaringType.Name; - } - while (declaringType.Module.Name.Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase) | fullName.Contains("Logger")); - - return fullName; - } - - - private static void LogSecurityInDb(Exception exception) - { - LogSecurityInDb(exception.ToStringDemystified()); - } - private static void LogSecurityInDb(string text) - { - Task.Run(() => - { - var dataContext = new DataContext(ConfigService); - - dataContext.SecurityLogs.Add(new() - { - Text = text - }); - - dataContext.SaveChanges(); - dataContext.Dispose(); - }); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/MonacoTypeHelper.cs b/Moonlight/App/Helpers/MonacoTypeHelper.cs deleted file mode 100644 index 8e37c19b..00000000 --- a/Moonlight/App/Helpers/MonacoTypeHelper.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class MonacoTypeHelper -{ - public static string GetEditorType(string file) - { - var extension = Path.GetExtension(file); - extension = extension.TrimStart("."[0]); - - switch (extension) - { - case "bat": - return "bat"; - case "cs": - return "csharp"; - case "css": - return "css"; - case "html": - return "html"; - case "java": - return "java"; - case "js": - return "javascript"; - case "ini": - return "ini"; - case "json": - return "json"; - case "lua": - return "lua"; - case "php": - return "php"; - case "py": - return "python"; - case "sh": - return "shell"; - case "xml": - return "xml"; - case "yml": - return "yaml"; - default: - return "plaintext"; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/MustBeTrueAttribute.cs b/Moonlight/App/Helpers/MustBeTrueAttribute.cs deleted file mode 100644 index 59c6e629..00000000 --- a/Moonlight/App/Helpers/MustBeTrueAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Helpers; - -[AttributeUsage(AttributeTargets.Property)] -public class MustBeTrueAttribute : ValidationAttribute -{ - public override bool IsValid(object value) - { - if (value is bool boolValue) - { - return boolValue; - } - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/ParseHelper.cs b/Moonlight/App/Helpers/ParseHelper.cs deleted file mode 100644 index f19236e6..00000000 --- a/Moonlight/App/Helpers/ParseHelper.cs +++ /dev/null @@ -1,106 +0,0 @@ -namespace Moonlight.App.Helpers; - -public static class ParseHelper -{ - public static int MinecraftToInt(string raw) - { - var versionWithoutPre = raw.Split("_")[0]; - versionWithoutPre = versionWithoutPre.Split("-")[0]; - - // Fuck you 1.7.10 ;) - versionWithoutPre = versionWithoutPre.Replace("1.7.10", "1.7"); - - if (versionWithoutPre.Count(x => x == "."[0]) == 1) - versionWithoutPre += ".0"; - - var x = versionWithoutPre.Replace(".", ""); - - return int.Parse(x); - } - - public static string FirstPartStartingWithNumber(string raw) - { - var numbers = "0123456789"; - var res = ""; - var found = false; - - foreach (var p in raw) - { - if (!found) - found = numbers.Contains(p); - - if (found) - res += p; - } - - return res; - } - - public static string ToDotnetVersionName(string raw) - { - var dockerImageTag = raw.Split(":").Last(); - - var name = dockerImageTag.Replace("_", ".") - .Replace("dotnetcore", ".NET Core ") - .Replace("dotnet", ".NET "); - - return name; - } - - public static string GetHighestVersion(string[] versions) - { - // Initialize the highest version to the first version in the array - string highestVersion = versions[0]; - - // Loop through the remaining versions in the array - for (int i = 1; i < versions.Length; i++) - { - // Compare the current version to the highest version - if (CompareVersions(versions[i], highestVersion) > 0) - { - // If the current version is higher, update the highest version - highestVersion = versions[i]; - } - } - - return highestVersion; - } - - public static int CompareVersions(string version1, string version2) - { - // Split the versions into their component parts - string[] version1Parts = version1.Split('.'); - string[] version2Parts = version2.Split('.'); - - // Compare each component part in turn - for (int i = 0; i < version1Parts.Length && i < version2Parts.Length; i++) - { - int part1 = int.Parse(version1Parts[i]); - int part2 = int.Parse(version2Parts[i]); - - if (part1 < part2) - { - return -1; - } - else if (part1 > part2) - { - return 1; - } - } - - // If we get here, the versions are equal up to the length of the shorter one. - // If one version has more parts than the other, the longer one is considered higher. - if (version1Parts.Length < version2Parts.Length) - { - return -1; - } - else if (version1Parts.Length > version2Parts.Length) - { - return 1; - } - else - { - return 0; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/PathBuilder.cs b/Moonlight/App/Helpers/PathBuilder.cs deleted file mode 100644 index 0b3e98bd..00000000 --- a/Moonlight/App/Helpers/PathBuilder.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class PathBuilder -{ - public static string Dir(params string[] parts) - { - var res = ""; - - foreach (var part in parts) - { - res += part + Path.DirectorySeparatorChar; - } - - return res; - } - - public static string File(params string[] parts) - { - var res = ""; - - foreach (var part in parts) - { - res += part + (part == parts.Last() ? "" : Path.DirectorySeparatorChar); - } - - return res; - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/PropBinder.cs b/Moonlight/App/Helpers/PropBinder.cs deleted file mode 100644 index ddb5a601..00000000 --- a/Moonlight/App/Helpers/PropBinder.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Reflection; - -namespace Moonlight.App.Helpers; - -public class PropBinder -{ - private PropertyInfo PropertyInfo; - private object DataObject; - - public PropBinder(PropertyInfo propertyInfo, object dataObject) - { - PropertyInfo = propertyInfo; - DataObject = dataObject; - } - - public string StringValue - { - get => (string)PropertyInfo.GetValue(DataObject)!; - set => PropertyInfo.SetValue(DataObject, value); - } - - public int IntValue - { - get => (int)PropertyInfo.GetValue(DataObject)!; - set => PropertyInfo.SetValue(DataObject, value); - } - - public long LongValue - { - get => (long)PropertyInfo.GetValue(DataObject)!; - set => PropertyInfo.SetValue(DataObject, value); - } - - public bool BoolValue - { - get => (bool)PropertyInfo.GetValue(DataObject)!; - set => PropertyInfo.SetValue(DataObject, value); - } - - public DateTime DateTimeValue - { - get => (DateTime)PropertyInfo.GetValue(DataObject)!; - set => PropertyInfo.SetValue(DataObject, value); - } - - public double DoubleValue - { - get => (double)PropertyInfo.GetValue(DataObject)!; - set => PropertyInfo.SetValue(DataObject, value); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Retry.cs b/Moonlight/App/Helpers/Retry.cs deleted file mode 100644 index 5af921d5..00000000 --- a/Moonlight/App/Helpers/Retry.cs +++ /dev/null @@ -1,66 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class Retry -{ - private List RetryExceptionTypes; - private List> RetryFilters; - private int RetryTimes = 1; - - public Retry() - { - RetryExceptionTypes = new(); - RetryFilters = new(); - } - - public Retry Times(int times) - { - RetryTimes = times; - return this; - } - - public Retry At(Func filter) - { - RetryFilters.Add(filter); - return this; - } - - public Retry At() - { - RetryExceptionTypes.Add(typeof(T)); - return this; - } - - public async Task Call(Func method) - { - int triesLeft = RetryTimes; - - do - { - try - { - await method.Invoke(); - return; - } - catch (Exception e) - { - if(triesLeft < 1) // Throw if no tries left - throw; - - if (RetryExceptionTypes.Any(x => x.FullName == e.GetType().FullName)) - { - triesLeft--; - continue; - } - - if (RetryFilters.Any(x => x.Invoke(e))) - { - triesLeft--; - continue; - } - - // Throw if not filtered -> unknown/unhandled - throw; - } - } while (triesLeft >= 0); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/SmartTranslateHelper.cs b/Moonlight/App/Helpers/SmartTranslateHelper.cs deleted file mode 100644 index 6ce8d656..00000000 --- a/Moonlight/App/Helpers/SmartTranslateHelper.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class SmartTranslateHelper -{ - private readonly Dictionary> Languages; - - public SmartTranslateHelper() - { - Languages = new(); - - foreach (var file in Directory.GetFiles(PathBuilder.Dir("storage", "resources", "lang"))) - { - if (Path.GetExtension(file) == ".lang") - { - var langKey = Path.GetFileName(file) - .Replace(Path.GetExtension(file), ""); - - var lines = File.ReadAllLines(file); - var content = new Dictionary(); - - foreach (var line in lines) - { - var parts = line.Split(";"); - - if(!content.ContainsKey(parts[0])) - content.Add(parts[0], parts[1]); - } - - Languages.Add(langKey, content); - } - } - } - - public string Translate(string langKey, string content) - { - if (!Languages.ContainsKey(langKey)) - Languages.Add(langKey, new Dictionary()); - - if (!Languages[langKey].ContainsKey(content)) - { - Languages[langKey].Add(content, content); - - File.WriteAllLines(PathBuilder.File("storage", "resources", "lang", $"{langKey}.lang"), GenerateData(Languages[langKey])); - } - - return Languages[langKey][content]; - } - - private string[] GenerateData(Dictionary data) - { - var dataList = new List(); - - foreach (var d in data) - dataList.Add($"{d.Key};{d.Value}"); - - return dataList.ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/StreamProgressHelper.cs b/Moonlight/App/Helpers/StreamProgressHelper.cs deleted file mode 100644 index ae669f4a..00000000 --- a/Moonlight/App/Helpers/StreamProgressHelper.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class StreamProgressHelper : Stream -{ - public Action? Progress { get; set; } - private int lastPercent = -1; - - Stream InnerStream { get; init; } - - public override int Read(byte[] buffer, int offset, int count) - { - var result = InnerStream.ReadAsync(buffer, offset, count).Result; - - int percentComplete = (int)Math.Round((double)(100 * Position) / Length); - - if (lastPercent != percentComplete) - { - Progress?.Invoke(percentComplete); - lastPercent = percentComplete; - } - - return result; - } - public override void Write(byte[] buffer, int offset, int count) - { - InnerStream.WriteAsync(buffer, offset, count); - } - public override bool CanRead => InnerStream.CanRead; - public override bool CanSeek => InnerStream.CanSeek; - public override bool CanWrite => InnerStream.CanWrite; - public override long Length => InnerStream.Length; - public override long Position { get => InnerStream.Position; set => InnerStream.Position = value; } - public StreamProgressHelper(Stream s) - { - this.InnerStream = s; - } - public override void Flush() => InnerStream.Flush(); - public override long Seek(long offset, SeekOrigin origin) => InnerStream.Seek(offset, origin); - public override void SetLength(long value)=> InnerStream.SetLength(value); -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/StringHelper.cs b/Moonlight/App/Helpers/StringHelper.cs deleted file mode 100644 index a8834c21..00000000 --- a/Moonlight/App/Helpers/StringHelper.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Text; - -namespace Moonlight.App.Helpers; - -public static class StringHelper -{ - public static string GenerateString(int length) - { - var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - var stringBuilder = new StringBuilder(); - var random = new Random(); - - for (int i = 0; i < length; i++) - { - stringBuilder.Append(chars[random.Next(chars.Length)]); - } - - return stringBuilder.ToString(); - } - - public static string IntToStringWithLeadingZeros(int number, int n) - { - string result = number.ToString(); - int length = result.Length; - - for (int i = length; i < n; i++) - { - result = "0" + result; - } - - return result; - } - - public static string CapitalizeFirstCharacter(string input) - { - if (string.IsNullOrEmpty(input)) - { - return input; - } - - char firstChar = char.ToUpper(input[0]); - string restOfString = input.Substring(1); - - return firstChar + restOfString; - } - - public static string CutInHalf(string input) - { - if (string.IsNullOrEmpty(input)) - return input; - - int length = input.Length; - int halfLength = length / 2; - - return input.Substring(0, halfLength); - } - - public static bool EndsInOneOf(string suffix, IEnumerable strings) - { - foreach (string str in strings) - { - if (suffix.EndsWith(str)) - { - return true; - } - } - - return false; - } - - public static bool ContainsOneOf(string textToSearch, IEnumerable strings, out string foundText) - { - foreach (string str in strings) - { - if (textToSearch.Contains(str)) - { - foundText = str; - return true; - } - } - - foundText = ""; - return false; - } - - public static bool ContainsOneOf(string textToSearch, IEnumerable strings) - { - return ContainsOneOf(textToSearch, strings, out _); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/SyncStreamAdapter.cs b/Moonlight/App/Helpers/SyncStreamAdapter.cs deleted file mode 100644 index 304b3f12..00000000 --- a/Moonlight/App/Helpers/SyncStreamAdapter.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace Moonlight.App.Helpers; - -public class SyncStreamAdapter : Stream -{ - private readonly Stream _stream; - - public SyncStreamAdapter(Stream stream) - { - _stream = stream ?? throw new ArgumentNullException(nameof(stream)); - } - - public override bool CanRead => _stream.CanRead; - public override bool CanSeek => _stream.CanSeek; - public override bool CanWrite => _stream.CanWrite; - public override long Length => _stream.Length; - - public override long Position - { - get => _stream.Position; - set => _stream.Position = value; - } - - public override void Flush() - { - _stream.Flush(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - var task = Task.Run(() => _stream.ReadAsync(buffer, offset, count)); - return task.GetAwaiter().GetResult(); - } - - public override long Seek(long offset, SeekOrigin origin) - { - return _stream.Seek(offset, origin); - } - - public override void SetLength(long value) - { - _stream.SetLength(value); - } - - public override void Write(byte[] buffer, int offset, int count) - { - var task = Task.Run(() => _stream.WriteAsync(buffer, offset, count)); - task.GetAwaiter().GetResult(); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - _stream?.Dispose(); - } - base.Dispose(disposing); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/Data/ConsoleMessage.cs b/Moonlight/App/Helpers/Wings/Data/ConsoleMessage.cs deleted file mode 100644 index 87d86f6d..00000000 --- a/Moonlight/App/Helpers/Wings/Data/ConsoleMessage.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Helpers.Wings.Data; - -public class ConsoleMessage -{ - public string Content { get; set; } = ""; - public bool IsInternal { get; set; } = false; -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/Data/ServerResource.cs b/Moonlight/App/Helpers/Wings/Data/ServerResource.cs deleted file mode 100644 index 2b7ec53f..00000000 --- a/Moonlight/App/Helpers/Wings/Data/ServerResource.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Helpers.Wings.Data; - -public class ServerResource -{ - [JsonProperty("memory_bytes")] - public long MemoryBytes { get; set; } - - [JsonProperty("memory_limit_bytes")] - public long MemoryLimitBytes { get; set; } - - [JsonProperty("cpu_absolute")] - public float CpuAbsolute { get; set; } - - [JsonProperty("network")] - public NetworkData Network { get; set; } - - [JsonProperty("uptime")] - public double Uptime { get; set; } - - [JsonProperty("state")] - public string State { get; set; } - - [JsonProperty("disk_bytes")] - public long DiskBytes { get; set; } - - public class NetworkData - { - [JsonProperty("rx_bytes")] - public long RxBytes { get; set; } - - [JsonProperty("tx_bytes")] - public long TxBytes { get; set; } - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/Enums/ConsoleState.cs b/Moonlight/App/Helpers/Wings/Enums/ConsoleState.cs deleted file mode 100644 index b2fce78e..00000000 --- a/Moonlight/App/Helpers/Wings/Enums/ConsoleState.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Helpers.Wings.Enums; - -public enum ConsoleState -{ - Disconnected, - Connecting, - Connected -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/Enums/ServerState.cs b/Moonlight/App/Helpers/Wings/Enums/ServerState.cs deleted file mode 100644 index 1ced0020..00000000 --- a/Moonlight/App/Helpers/Wings/Enums/ServerState.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.Helpers.Wings.Enums; - -public enum ServerState -{ - Starting, - Running, - Stopping, - Offline, - Installing -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/Events/BaseEvent.cs b/Moonlight/App/Helpers/Wings/Events/BaseEvent.cs deleted file mode 100644 index 9c0455bd..00000000 --- a/Moonlight/App/Helpers/Wings/Events/BaseEvent.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Helpers.Wings.Events; - -public class BaseEvent -{ - public string Event { get; set; } = ""; - public string[] Args { get; set; } = Array.Empty(); -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/Events/SendTokenEvent.cs b/Moonlight/App/Helpers/Wings/Events/SendTokenEvent.cs deleted file mode 100644 index 660ae448..00000000 --- a/Moonlight/App/Helpers/Wings/Events/SendTokenEvent.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Helpers.Wings.Events; - -public class SendTokenEvent -{ - public string Event { get; set; } = "auth"; - public List Args = new(); -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/WingsConsole.cs b/Moonlight/App/Helpers/Wings/WingsConsole.cs deleted file mode 100644 index ed9596be..00000000 --- a/Moonlight/App/Helpers/Wings/WingsConsole.cs +++ /dev/null @@ -1,400 +0,0 @@ -using System.Net.WebSockets; -using System.Text; -using Moonlight.App.Helpers.Wings.Data; -using Moonlight.App.Helpers.Wings.Enums; -using Moonlight.App.Helpers.Wings.Events; -using Newtonsoft.Json; -using ConsoleMessage = Moonlight.App.Helpers.Wings.Data.ConsoleMessage; - -namespace Moonlight.App.Helpers.Wings; - -public class WingsConsole : IDisposable -{ - private ClientWebSocket WebSocket; - public List Messages; - private Task? ConsoleTask; - - private string Socket = ""; - private string Origin = ""; - private string Token = ""; - - private bool Disconnecting; - - public ConsoleState ConsoleState { get; private set; } - public ServerState ServerState { get; private set; } - public ServerResource Resource { get; private set; } - - public EventHandler OnConsoleStateUpdated { get; set; } - public EventHandler OnServerStateUpdated { get; set; } - public EventHandler OnResourceUpdated { get; set; } - public EventHandler OnMessage { get; set; } - public Func> OnRequestNewToken { get; set; } - - public WingsConsole() - { - ConsoleState = ConsoleState.Disconnected; - ServerState = ServerState.Offline; - Messages = new(); - - Resource = new() - { - Network = new() - { - RxBytes = 0, - TxBytes = 0 - }, - State = "offline", - Uptime = 0, - CpuAbsolute = 0, - DiskBytes = 0, - MemoryBytes = 0, - MemoryLimitBytes = 0 - }; - } - - public Task Connect(string origin, string socket, string token) - { - Disconnecting = false; - WebSocket = new(); - ConsoleState = ConsoleState.Disconnected; - ServerState = ServerState.Offline; - Messages = new(); - - Resource = new() - { - Network = new() - { - RxBytes = 0, - TxBytes = 0 - }, - State = "offline", - Uptime = 0, - CpuAbsolute = 0, - DiskBytes = 0, - MemoryBytes = 0, - MemoryLimitBytes = 0 - }; - - Socket = socket; - Origin = origin; - Token = token; - - WebSocket.Options.SetRequestHeader("Origin", Origin); - WebSocket.Options.SetRequestHeader("Authorization", "Bearer " + Token); - - ConsoleTask = Task.Run(async () => - { - try - { - await Work(); - } - catch (Exception e) - { - Logger.Warn("Error connecting to wings console"); - Logger.Warn(e); - } - }); - - return Task.CompletedTask; - } - - private async Task Work() - { - await UpdateConsoleState(ConsoleState.Connecting); - - await WebSocket.ConnectAsync( - new Uri(Socket), - CancellationToken.None - ); - - if (WebSocket.State != WebSocketState.Connecting && WebSocket.State != WebSocketState.Open) - { - await SaveMessage("Unable to connect to websocket", true); - await UpdateConsoleState(ConsoleState.Disconnected); - return; - } - - await UpdateConsoleState(ConsoleState.Connected); - - await Send(new SendTokenEvent() - { - Args = { Token } - }); - - while (WebSocket.State == WebSocketState.Open) - { - try - { - var raw = await ReceiveRaw(); - - if(string.IsNullOrEmpty(raw)) - continue; - - var eventData = JsonConvert.DeserializeObject(raw); - - if (eventData == null) - { - await SaveMessage("Unable to parse event", true); - continue; - } - - switch (eventData.Event) - { - case "jwt error": - if (WebSocket != null) - { - if (WebSocket.State == WebSocketState.Connecting || WebSocket.State == WebSocketState.Open) - await WebSocket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None); - - WebSocket.Dispose(); - } - - await UpdateServerState(ServerState.Offline); - await UpdateConsoleState(ConsoleState.Disconnected); - - await SaveMessage("Received a jwt error. Disconnected", true); - break; - - case "token expired": - if (WebSocket != null) - { - if (WebSocket.State == WebSocketState.Connecting || WebSocket.State == WebSocketState.Open) - await WebSocket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None); - - WebSocket.Dispose(); - } - - await UpdateServerState(ServerState.Offline); - await UpdateConsoleState(ConsoleState.Disconnected); - - await SaveMessage("Token expired", true); - - break; - - case "token expiring": - await SaveMessage("Token will expire soon. Generating a new one", true); - - Token = await OnRequestNewToken.Invoke(this); - - await Send(new SendTokenEvent() - { - Args = { Token } - }); - break; - - case "auth success": - // Send intents - await SendRaw("{\"event\":\"send logs\",\"args\":[null]}"); - await SendRaw("{\"event\":\"send stats\",\"args\":[null]}"); - break; - - case "stats": - var stats = JsonConvert.DeserializeObject(eventData.Args[0]); - - if (stats == null) - break; - - var serverState = ParseServerState(stats.State); - - if (ServerState != serverState) - await UpdateServerState(serverState); - - await UpdateResource(stats); - break; - - case "status": - var serverStateParsed = ParseServerState(eventData.Args[0]); - - if (ServerState != serverStateParsed) - await UpdateServerState(serverStateParsed); - break; - - case "console output": - foreach (var line in eventData.Args) - { - await SaveMessage(line); - } - - break; - - case "install output": - if (ServerState != ServerState.Installing) - { - // Because wings is sending "install output" events BEFORE - // sending the "install started" event, - // we need to set the install state here - // See https://github.com/pterodactyl/panel/issues/4853 - // for more details - //await UpdateServerState(ServerState.Installing); - } - - foreach (var line in eventData.Args) - { - await SaveMessage(line); - } - - break; - - case "daemon message": - foreach (var line in eventData.Args) - { - await SaveMessage(line); - } - - break; - - case "install started": - await UpdateServerState(ServerState.Installing); - break; - - case "install completed": - await UpdateServerState(ServerState.Offline); - break; - } - } - catch(JsonReaderException){} - catch(JsonSerializationException){} - catch (Exception e) - { - if (!Disconnecting) - { - Logger.Warn("Error while performing websocket actions"); - Logger.Warn(e); - - await SaveMessage("A unknown error occured while processing websocket", true); - } - } - } - } - - private Task UpdateConsoleState(ConsoleState consoleState) - { - ConsoleState = consoleState; - OnConsoleStateUpdated?.Invoke(this, consoleState); - - return Task.CompletedTask; - } - private Task UpdateServerState(ServerState serverState) - { - ServerState = serverState; - OnServerStateUpdated?.Invoke(this, serverState); - - return Task.CompletedTask; - } - private Task UpdateResource(ServerResource resource) - { - Resource = resource; - OnResourceUpdated?.Invoke(this, Resource); - - return Task.CompletedTask; - } - - private Task SaveMessage(string content, bool internalMessage = false) - { - var msg = new ConsoleMessage() - { - Content = content, - IsInternal = internalMessage - }; - - lock (Messages) - { - Messages.Add(msg); - } - - OnMessage?.Invoke(this, msg); - - return Task.CompletedTask; - } - - private ServerState ParseServerState(string raw) - { - switch (raw) - { - case "offline": - return ServerState.Offline; - case "starting": - return ServerState.Starting; - case "running": - return ServerState.Running; - case "stopping": - return ServerState.Stopping; - case "installing": - return ServerState.Installing; - default: - return ServerState.Offline; - } - } - - public async Task EnterCommand(string content) - { - if (ConsoleState == ConsoleState.Connected) - { - await SendRaw("{\"event\":\"send command\",\"args\":[\"" + content + "\"]}"); - } - } - - public async Task SetPowerState(string state) - { - if (ConsoleState == ConsoleState.Connected) - { - await SendRaw("{\"event\":\"set state\",\"args\":[\"" + state + "\"]}"); - } - } - - private async Task Send(object data) - { - await SendRaw(JsonConvert.SerializeObject(data)); - } - - private async Task SendRaw(string data) - { - if (WebSocket.State == WebSocketState.Open) - { - byte[] byteContentBuffer = Encoding.UTF8.GetBytes(data); - await WebSocket.SendAsync(new ArraySegment(byteContentBuffer), WebSocketMessageType.Text, true, - CancellationToken.None); - } - } - - private async Task ReceiveRaw() - { - ArraySegment receivedBytes = new ArraySegment(new byte[1024]); - WebSocketReceiveResult result = await WebSocket.ReceiveAsync(receivedBytes, CancellationToken.None); - return Encoding.UTF8.GetString(receivedBytes.Array!, 0, result.Count); - } - - public async Task Disconnect() - { - Disconnecting = true; - Messages.Clear(); - - if (WebSocket != null) - { - if (WebSocket.State == WebSocketState.Connecting || WebSocket.State == WebSocketState.Open) - await WebSocket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None); - - WebSocket.Dispose(); - } - - if(ConsoleTask != null && ConsoleTask.IsCompleted) - ConsoleTask.Dispose(); - } - - public void Dispose() - { - Disconnecting = true; - Messages.Clear(); - - if (WebSocket != null) - { - if (WebSocket.State == WebSocketState.Connecting || WebSocket.State == WebSocketState.Open) - WebSocket.CloseAsync(WebSocketCloseStatus.Empty, null, CancellationToken.None).Wait(); - - WebSocket.Dispose(); - } - - if(ConsoleTask != null && ConsoleTask.IsCompleted) - ConsoleTask.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/WingsConsoleHelper.cs b/Moonlight/App/Helpers/Wings/WingsConsoleHelper.cs deleted file mode 100644 index 6741d3ee..00000000 --- a/Moonlight/App/Helpers/Wings/WingsConsoleHelper.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System.Security.Cryptography; -using System.Text; -using JWT.Algorithms; -using JWT.Builder; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Repositories.Servers; -using Moonlight.App.Services; - -namespace Moonlight.App.Helpers.Wings; - -public class WingsConsoleHelper -{ - private readonly ServerRepository ServerRepository; - private readonly string AppUrl; - - public WingsConsoleHelper( - ServerRepository serverRepository, - ConfigService configService) - { - ServerRepository = serverRepository; - - AppUrl = configService.Get().Moonlight.AppUrl; - } - - public async Task ConnectWings(WingsConsole console, Server server) - { - var serverData = ServerRepository - .Get() - .Include(x => x.Node) - .First(x => x.Id == server.Id); - - var token = await GenerateToken(serverData); - - if (serverData.Node.Ssl) - { - await console.Connect( - AppUrl, - $"wss://{serverData.Node.Fqdn}:{serverData.Node.HttpPort}/api/servers/{serverData.Uuid}/ws", - token - ); - } - else - { - await console.Connect( - AppUrl, - $"ws://{serverData.Node.Fqdn}:{serverData.Node.HttpPort}/api/servers/{serverData.Uuid}/ws", - token - ); - } - } - - public async Task GenerateToken(Server server) - { - var serverData = ServerRepository - .Get() - .Include(x => x.Node) - .First(x => x.Id == server.Id); - - var userid = 1; - var secret = serverData.Node.Token; - - - using (MD5 md5 = MD5.Create()) - { - var inputBytes = Encoding.ASCII.GetBytes(userid + server.Uuid.ToString()); - var outputBytes = md5.ComputeHash(inputBytes); - - var identifier = Convert.ToHexString(outputBytes).ToLower(); - var weirdId = StringHelper.GenerateString(16); - - var token = JwtBuilder.Create() - .AddHeader("jti", identifier) - .WithAlgorithm(new HMACSHA256Algorithm()) - .WithSecret(secret) - .AddClaim("user_id", userid) - .AddClaim("server_uuid", server.Uuid.ToString()) - .AddClaim("permissions", new[] - { - "*", - "admin.websocket.errors", - "admin.websocket.install", - "admin.websocket.transfer" - }) - .AddClaim("jti", identifier) - .AddClaim("unique_id", weirdId) - .AddClaim("iat", DateTimeOffset.Now.ToUnixTimeSeconds()) - .AddClaim("nbf", DateTimeOffset.Now.AddSeconds(-10).ToUnixTimeSeconds()) - .AddClaim("exp", DateTimeOffset.Now.AddMinutes(10).ToUnixTimeSeconds()) - .AddClaim("iss", AppUrl) - .AddClaim("aud", new[] - { - serverData.Node.Ssl ? $"https://{serverData.Node.Fqdn}" : $"http://{serverData.Node.Fqdn}" - }) - .MustVerifySignature() - .Encode(); - - return token; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/WingsJwtHelper.cs b/Moonlight/App/Helpers/Wings/WingsJwtHelper.cs deleted file mode 100644 index e45e314c..00000000 --- a/Moonlight/App/Helpers/Wings/WingsJwtHelper.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Security.Cryptography; -using System.Text; -using JWT.Algorithms; -using JWT.Builder; -using Moonlight.App.Services; - -namespace Moonlight.App.Helpers.Wings; - -public class WingsJwtHelper -{ - private readonly ConfigService ConfigService; - private readonly string AppUrl; - - public WingsJwtHelper(ConfigService configService) - { - ConfigService = configService; - - AppUrl = ConfigService.Get().Moonlight.AppUrl; - } - - public string Generate(string secret, Action> claimsAction) - { - var userid = 1; - - using MD5 md5 = MD5.Create(); - var inputBytes = Encoding.ASCII.GetBytes(userid + Guid.NewGuid().ToString()); - var outputBytes = md5.ComputeHash(inputBytes); - - var identifier = Convert.ToHexString(outputBytes).ToLower(); - var weirdId = StringHelper.GenerateString(16); - - var builder = JwtBuilder.Create() - .AddHeader("jti", identifier) - .WithAlgorithm(new HMACSHA256Algorithm()) - .WithSecret(secret) - .AddClaim("user_id", userid) - .AddClaim("jti", identifier) - .AddClaim("unique_id", weirdId) - .AddClaim("iat", DateTimeOffset.Now.ToUnixTimeSeconds()) - .AddClaim("nbf", DateTimeOffset.Now.AddSeconds(-10).ToUnixTimeSeconds()) - .AddClaim("exp", DateTimeOffset.Now.AddMinutes(10).ToUnixTimeSeconds()) - .AddClaim("iss", AppUrl) - .MustVerifySignature(); - - var additionalClaims = new Dictionary(); - - claimsAction.Invoke(additionalClaims); - - foreach (var claim in additionalClaims) - { - builder = builder.AddClaim(claim.Key, claim.Value); - } - - return builder.Encode(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Helpers/Wings/WingsServerConverter.cs b/Moonlight/App/Helpers/Wings/WingsServerConverter.cs deleted file mode 100644 index c0875ab1..00000000 --- a/Moonlight/App/Helpers/Wings/WingsServerConverter.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System.Text; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Http.Resources.Wings; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; - -namespace Moonlight.App.Helpers.Wings; - -public class WingsServerConverter -{ - private readonly ServerRepository ServerRepository; - private readonly ImageRepository ImageRepository; - - public WingsServerConverter(ServerRepository serverRepository, ImageRepository imageRepository) - { - ServerRepository = serverRepository; - ImageRepository = imageRepository; - } - - public WingsServer FromServer(Server s) - { - var server = ServerRepository - .Get() - .Include(x => x.Allocations) - .Include(x => x.Backups) - .Include(x => x.Variables) - .Include(x => x.Image) - .Include(x => x.MainAllocation) - .First(x => x.Id == s.Id); - - var wingsServer = new WingsServer - { - Uuid = server.Uuid - }; - - // Allocations - var def = server.MainAllocation; - - wingsServer.Settings.Allocations.Default.Ip = "0.0.0.0"; - wingsServer.Settings.Allocations.Default.Port = def.Port; - - foreach (var a in server.Allocations) - { - wingsServer.Settings.Allocations.Mappings.Ports.Add(a.Port); - } - - // Build - wingsServer.Settings.Build.Swap = server.Memory * 2; //TODO: Add config option - wingsServer.Settings.Build.Threads = null!; - wingsServer.Settings.Build.Cpu_Limit = server.Cpu; - wingsServer.Settings.Build.Disk_Space = server.Disk; - wingsServer.Settings.Build.Io_Weight = 500; - wingsServer.Settings.Build.Memory_Limit = server.Memory; - wingsServer.Settings.Build.Oom_Disabled = true; - wingsServer.Settings.Build.Oom_Killer = false; - - var image = ImageRepository - .Get() - .Include(x => x.DockerImages) - .First(x => x.Id == server.Image.Id); - - // Container - wingsServer.Settings.Container.Image = image.DockerImages[server.DockerImageIndex].Name; - - // Egg - wingsServer.Settings.Egg.Id = image.Uuid; - - // Settings - wingsServer.Settings.Skip_Egg_Scripts = false; - wingsServer.Settings.Suspended = server.Suspended; - wingsServer.Settings.Invocation = string.IsNullOrEmpty(server.OverrideStartup) ? image.Startup : server.OverrideStartup; - wingsServer.Settings.Uuid = server.Uuid; - - - // Environment - foreach (var v in server.Variables) - { - if (!wingsServer.Settings.Environment.ContainsKey(v.Key)) - { - wingsServer.Settings.Environment.Add(v.Key, v.Value); - } - } - - int i = 0; - foreach (var allocation in server.Allocations) - { - wingsServer.Settings.Environment.Add("ML_PORT_" + i, allocation.Port.ToString()); - i++; - } - - // Stop - if (image.StopCommand.StartsWith("!")) - { - wingsServer.Process_Configuration.Stop.Type = "stop"; - wingsServer.Process_Configuration.Stop.Value = null!; - } - else - { - wingsServer.Process_Configuration.Stop.Type = "command"; - wingsServer.Process_Configuration.Stop.Value = image.StopCommand; - } - - // Done - - wingsServer.Process_Configuration.Startup.Done = new() { image.StartupDetection }; - wingsServer.Process_Configuration.Startup.Strip_Ansi = false; - wingsServer.Process_Configuration.Startup.User_Interaction = new(); - - // Configs - var configData = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(image.ConfigFiles!)) - ).Build(); - - foreach (var child in configData.GetChildren()) - { - List replaces = new(); - - foreach (var section in child.GetSection("find").GetChildren()) - { - if (section.Value != null) - { - replaces.Add(new() - { - Match = section.Key, - Replace_With = section.Value - .Replace("{{server.build.default.port}}", def.Port.ToString()) - }); - } - } - - wingsServer.Process_Configuration.Configs.Add(new() - { - Parser = child.GetValue("parser"), - File = child.Key, - Replace = replaces - }); - } - - return wingsServer; - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/AvatarController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/AvatarController.cs deleted file mode 100644 index 5de6ca77..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/AvatarController.cs +++ /dev/null @@ -1,40 +0,0 @@ -using GravatarSharp; -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight; - -[ApiController] -[Route("api/moonlight/avatar")] -public class AvatarController : Controller -{ - private readonly UserRepository UserRepository; - - public AvatarController(UserRepository userRepository) - { - UserRepository = userRepository; - } - - [HttpGet("{id:int}")] - public async Task GetAvatar([FromRoute] int id) - { - var user = UserRepository.Get().FirstOrDefault(x => x.Id == id); - - if (user == null) - return NotFound(); - - try - { - var url = GravatarController.GetImageUrl(user.Email.ToLower(), 100); - - using var client = new HttpClient(); - var res = await client.GetByteArrayAsync(url); - - return File(res, "image/png"); - } - catch (Exception) - { - return BadRequest(); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/BillingController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/BillingController.cs deleted file mode 100644 index d31dd427..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/BillingController.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Services; -using Moonlight.App.Services.Sessions; -using Stripe; -using Stripe.Checkout; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight; - -[ApiController] -[Route("api/moonlight/billing")] -public class BillingController : Controller -{ - private readonly IdentityService IdentityService; - private readonly BillingService BillingService; - - public BillingController( - IdentityService identityService, - BillingService billingService) - { - IdentityService = identityService; - BillingService = billingService; - } - - [HttpGet("cancel")] - public async Task Cancel() - { - var user = IdentityService.User; - - if (user == null) - return Redirect("/login"); - - return Redirect("/profile/subscriptions/close"); - } - - [HttpGet("success")] - public async Task Success() - { - var user = IdentityService.User; - - if (user == null) - return Redirect("/login"); - - await BillingService.CompleteCheckout(user); - - return Redirect("/profile/subscriptions/close"); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/DiscordBotController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/DiscordBotController.cs deleted file mode 100644 index 94b65588..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/DiscordBotController.cs +++ /dev/null @@ -1,176 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.ApiClients.Wings; -using Moonlight.App.ApiClients.Wings.Resources; -using Moonlight.App.Database.Entities; -using Moonlight.App.Http.Requests.DiscordBot.Requests; -using Moonlight.App.Repositories; -using Moonlight.App.Services; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight; - -[ApiController] -[Route("api/moonlight/discordbot")] -public class DiscordBotController : Controller -{ - private readonly Repository UserRepository; - private readonly Repository ServerRepository; - private readonly ServerService ServerService; - private readonly string Token = ""; - private readonly bool Enable; - - public DiscordBotController( - Repository userRepository, - Repository serverRepository, - ServerService serverService, - ConfigService configService) - { - UserRepository = userRepository; - ServerRepository = serverRepository; - ServerService = serverService; - - var config = configService - .Get() - .Moonlight.DiscordBotApi; - - Enable = config.Enable; - - if (Enable) - { - Token = config.Token; - } - } - - [HttpGet("{id}/link")] - public async Task GetLink(ulong id) - { - if (!await IsAuth(Request)) - return StatusCode(403); - - if (await GetUserFromDiscordId(id) == null) - { - return BadRequest(); - } - - return Ok(); - } - - [HttpGet("{id}/servers")] - public async Task> GetServers(ulong id) - { - if (!await IsAuth(Request)) - return StatusCode(403); - - var user = await GetUserFromDiscordId(id); - - if (user == null) - return BadRequest(); - - return ServerRepository - .Get() - .Include(x => x.Owner) - .Include(x => x.Image) - .Where(x => x.Owner.Id == user.Id) - .ToArray(); - } - - [HttpPost("{id}/servers/{uuid}")] - public async Task SetPowerState(ulong id, Guid uuid, [FromBody] SetPowerSignal signal) - { - if (!await IsAuth(Request)) - return StatusCode(403); - - var user = await GetUserFromDiscordId(id); - - if (user == null) - return BadRequest(); - - var server = ServerRepository - .Get() - .Include(x => x.Owner) - .FirstOrDefault(x => x.Owner.Id == user.Id && x.Uuid == uuid); - - if (server == null) - return NotFound(); - - if (Enum.TryParse(signal.Signal, true, out PowerSignal powerSignal)) - { - await ServerService.SetPowerState(server, powerSignal); - return Ok(); - } - else - return BadRequest(); - } - - [HttpGet("{id}/servers/{uuid}/details")] - public async Task> GetServerDetails(ulong id, Guid uuid) - { - if (!await IsAuth(Request)) - return StatusCode(403); - - var user = await GetUserFromDiscordId(id); - - if (user == null) - return BadRequest(); - - var server = ServerRepository - .Get() - .Include(x => x.Owner) - .FirstOrDefault(x => x.Owner.Id == user.Id && x.Uuid == uuid); - - if (server == null) - return NotFound(); - - return await ServerService.GetDetails(server); - } - - [HttpGet("{id}/servers/{uuid}")] - public async Task> GetServer(ulong id, Guid uuid) - { - if (!await IsAuth(Request)) - return StatusCode(403); - - var user = await GetUserFromDiscordId(id); - - if (user == null) - return BadRequest(); - - var server = ServerRepository - .Get() - .Include(x => x.Owner) - .Include(x => x.Image) - .Include(x => x.Node) - .FirstOrDefault(x => x.Owner.Id == user.Id && x.Uuid == uuid); - - if (server == null) - return NotFound(); - - server.Node.Token = ""; - server.Node.TokenId = ""; - - return Ok(server); - } - - private Task GetUserFromDiscordId(ulong discordId) - { - var user = UserRepository - .Get() - .FirstOrDefault(x => x.DiscordId == discordId); - - return Task.FromResult(user); - } - - private Task IsAuth(HttpRequest request) - { - if (!Enable) - return Task.FromResult(false); - - if (string.IsNullOrEmpty(request.Headers.Authorization)) - return Task.FromResult(false); - - if(request.Headers.Authorization == Token) - return Task.FromResult(true); - - return Task.FromResult(false); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/ListenController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/ListenController.cs deleted file mode 100644 index 10b24a0f..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/ListenController.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Net.WebSockets; -using System.Text; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Database.Entities.Notification; -using Moonlight.App.Models.Notifications; -using Moonlight.App.Repositories; -using Moonlight.App.Services; -using Moonlight.App.Services.Notifications; -using Newtonsoft.Json; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight.Notifications; - -[ApiController] -[Route("api/moonlight/notification/listen")] -public class ListenController : Controller -{ - private WebSocket WebSocket; - private NotificationClient Client; - private CancellationTokenSource CancellationTokenSource = new(); - - private User? CurrentUser; - - private readonly OneTimeJwtService OneTimeJwtService; - private readonly NotificationServerService NotificationServerService; - private readonly Repository NotificationClientRepository; - - public ListenController( - OneTimeJwtService oneTimeJwtService, - NotificationServerService notificationServerService, Repository notificationClientRepository) - { - OneTimeJwtService = oneTimeJwtService; - NotificationServerService = notificationServerService; - NotificationClientRepository = notificationClientRepository; - } - - [Route("/api/moonlight/notifications/listen")] - public async Task Get() - { - if (HttpContext.WebSockets.IsWebSocketRequest) - { - WebSocket = await HttpContext.WebSockets.AcceptWebSocketAsync(); - - await ProcessWebsocket(); - - return new EmptyResult(); - } - else - { - return StatusCode(400); - } - } - - private async Task ProcessWebsocket() - { - while (!CancellationTokenSource.Token.IsCancellationRequested && WebSocket.State == WebSocketState.Open) - { - try - { - byte[] buffer = new byte[1024 * 16]; - _ = await WebSocket.ReceiveAsync(buffer, CancellationTokenSource.Token); - var text = Encoding.UTF8.GetString(buffer).Trim('\0'); - - var basicWsModel = JsonConvert.DeserializeObject(text) ?? new(); - - if (!string.IsNullOrWhiteSpace(basicWsModel.Action)) - { - await HandleRequest(text, basicWsModel.Action); - } - - if (WebSocket.State != WebSocketState.Open) - { - CancellationTokenSource.Cancel(); - } - } - catch (WebSocketException e) - { - CancellationTokenSource.Cancel(); - } - } - - await NotificationServerService.UnRegisterClient(Client); - } - - private async Task HandleRequest(string text, string action) - { - if (CurrentUser == null && action != "login") - { - await Send("{\"error\": \"Unauthorised\"}"); - } - - switch (action) - { - case "login": - await Login(text); - break; - case "received": - await Received(text); - break; - case "read": - await Read(text); - break; - } - } - - private async Task Send(string text) - { - await WebSocket.SendAsync( - Encoding.UTF8.GetBytes(text), - WebSocketMessageType.Text, - WebSocketMessageFlags.EndOfMessage, CancellationTokenSource.Token - ); - } - - private async Task Login(string json) - { - var loginModel = JsonConvert.DeserializeObject(json) ?? new(); - - var dict = await OneTimeJwtService.Validate(loginModel.Token); - - if (dict == null) - { - await Send("{\"status\":false}"); - return; - } - - if (!int.TryParse(dict["clientId"], out int clientId)) - { - await Send("{\"status\":false}"); - return; - } - - Client = NotificationClientRepository - .Get() - .Include(x => x.User) - .First(x => x.Id == clientId); - - CurrentUser = Client.User; - - await NotificationServerService.RegisterClient(WebSocket, Client); - - await Send("{\"status\":true}"); - } - - private async Task Received(string json) - { - var id = JsonConvert.DeserializeObject(json).Notification; - - //TODO: Implement ws notification received - } - - private async Task Read(string json) - { - var model = JsonConvert.DeserializeObject(json) ?? new(); - - await NotificationServerService.SendAction( - CurrentUser!, - JsonConvert.SerializeObject( - new NotificationById() - { - Action = "hide", Notification = model.Notification - } - ) - ); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/PullController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/PullController.cs deleted file mode 100644 index b86add6d..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/PullController.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Models.Notifications; -using Moonlight.App.Repositories; -using Moonlight.App.Services; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight.Notifications; - -[ApiController] -[Route("api/moonlight/notifications/pull")] -public class PullController : Controller -{ - private readonly IdentityService IdentityService; - private readonly NotificationRepository NotificationRepository; - private readonly OneTimeJwtService OneTimeJwtService; - - public PullController(IdentityService identityService, NotificationRepository notificationRepository, OneTimeJwtService oneTimeJwtService) - { - IdentityService = identityService; - NotificationRepository = notificationRepository; - OneTimeJwtService = oneTimeJwtService; - } - - [HttpPost] - public async Task> Pull() - { - Stream req = Request.Body; - string jwt = await new StreamReader(req).ReadToEndAsync(); - - var dict = await OneTimeJwtService.Validate(jwt); - - if (dict == null) - return NotFound(); - - var _clientId = dict["clientId"]; - var clientId = int.Parse(_clientId); - - var client = NotificationRepository.GetClients().First(x => x.Id == clientId); - - try - { - var strings = ""; - - var actions = NotificationRepository.GetActions().Where(x => x.NotificationClient == client).ToList(); - - foreach (var a in actions) - { - strings += a.Action + ","; - - NotificationRepository.RemoveAction(a); - } - - strings = strings.Trim(','); - - return $"[{strings}]"; - } - catch (Exception) - { - return BadRequest(); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/RegisterController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/RegisterController.cs deleted file mode 100644 index 8fc13ffb..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/Notifications/RegisterController.cs +++ /dev/null @@ -1,50 +0,0 @@ -using GravatarSharp; -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Models.Notifications; -using Moonlight.App.Repositories; -using Moonlight.App.Services; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight.Notifications; - -[ApiController] -[Route("api/moonlight/notifications/register")] -public class RegisterController : Controller -{ - private readonly IdentityService IdentityService; - private readonly NotificationRepository NotificationRepository; - private readonly OneTimeJwtService OneTimeJwtService; - - public RegisterController(IdentityService identityService, NotificationRepository notificationRepository, OneTimeJwtService oneTimeJwtService) - { - IdentityService = identityService; - NotificationRepository = notificationRepository; - OneTimeJwtService = oneTimeJwtService; - } - - [HttpGet] - public async Task> Register() - { - var user = IdentityService.User; - - if (user == null) - return NotFound(); - - try - { - var id = NotificationRepository.RegisterNewDevice(user); - - return new TokenRegister() - { - Token = OneTimeJwtService.Generate((dict) => - { - dict["clientId"] = id.ToString(); - }, TimeSpan.FromDays(31)) - }; - } - catch (Exception) - { - return BadRequest(); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/OAuth2Controller.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/OAuth2Controller.cs deleted file mode 100644 index a21b804f..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/OAuth2Controller.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Helpers; -using Moonlight.App.Services; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight; - -[ApiController] -[Route("api/moonlight/oauth2")] -public class OAuth2Controller : Controller -{ - private readonly UserService UserService; - private readonly OAuth2Service OAuth2Service; - private readonly DateTimeService DateTimeService; - private readonly IdentityService IdentityService; - - public OAuth2Controller( - UserService userService, - OAuth2Service oAuth2Service, - DateTimeService dateTimeService, - IdentityService identityService) - { - UserService = userService; - OAuth2Service = oAuth2Service; - DateTimeService = dateTimeService; - IdentityService = identityService; - } - - [HttpGet("{id}/start")] - public async Task Start([FromRoute] string id) - { - try - { - if (OAuth2Service.Providers.ContainsKey(id)) - { - return Redirect(await OAuth2Service.GetUrl(id)); - } - - Logger.Warn($"Someone tried to start an oauth2 flow using the id '{id}' which is not registered"); - - return Redirect("/"); - } - catch (Exception e) - { - Logger.Warn($"Error starting oauth2 flow for id: {id}"); - Logger.Warn(e); - - return Redirect("/"); - } - } - - [HttpGet("{id}")] - public async Task Hande([FromRoute] string id, [FromQuery] string code) - { - try - { - var currentUser = IdentityService.User; - - if (currentUser != null) - { - if (await OAuth2Service.CanBeLinked(id)) - { - await OAuth2Service.LinkToUser(id, currentUser, code); - - return Redirect("/profile"); - } - } - - var user = await OAuth2Service.HandleCode(id, code); - - Response.Cookies.Append("token", await UserService.GenerateToken(user), new() - { - Expires = new DateTimeOffset(DateTimeService.GetCurrent().AddDays(10)) - }); - - return Redirect("/"); - } - catch (Exception e) - { - Logger.Warn("An unexpected error occured while handling oauth2"); - Logger.Warn(e.Message); - - return Redirect("/login"); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Moonlight/ResourcesController.cs b/Moonlight/App/Http/Controllers/Api/Moonlight/ResourcesController.cs deleted file mode 100644 index beb07ddc..00000000 --- a/Moonlight/App/Http/Controllers/Api/Moonlight/ResourcesController.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Helpers; -using Moonlight.App.Services.Files; - -namespace Moonlight.App.Http.Controllers.Api.Moonlight; - -[ApiController] -[Route("api/moonlight/resources")] -public class ResourcesController : Controller -{ - private readonly BucketService BucketService; - - public ResourcesController(BucketService bucketService) - { - BucketService = bucketService; - } - - [HttpGet("images/{name}")] - public async Task GetImage([FromRoute] string name) - { - if (name.Contains("..")) - { - Logger.Warn($"Detected an attempted path transversal. Path: {name}", "security"); - - return NotFound(); - } - - if (System.IO.File.Exists(PathBuilder.File("storage", "resources", "public", "images", name))) - { - var fs = new FileStream(PathBuilder.File("storage", "resources", "public", "images", name), FileMode.Open); - - return File(fs, MimeTypes.GetMimeType(name), name); - } - - return NotFound(); - } - - [HttpGet("background/{name}")] - public async Task GetBackground([FromRoute] string name) - { - if (name.Contains("..")) - { - Logger.Warn($"Detected an attempted path transversal. Path: {name}", "security"); - - return NotFound(); - } - - if (System.IO.File.Exists(PathBuilder.File("storage", "resources", "public", "background", name))) - { - var fs = new FileStream(PathBuilder.File("storage", "resources", "public", "background", name), FileMode.Open); - - return File(fs, MimeTypes.GetMimeType(name), name); - } - - return NotFound(); - } - - [HttpGet("bucket/{bucket}/{name}")] - public async Task GetBucket([FromRoute] string bucket, [FromRoute] string name) - { - if (name.Contains("..")) - { - Logger.Warn($"Detected an attempted path transversal. Path: {name}", "security"); - - return NotFound(); - } - - try - { - var fs = await BucketService.GetFile(bucket, name); - - return File(fs, MimeTypes.GetMimeType(name), name); - } - catch (FileNotFoundException) - { - return NotFound(); - } - catch (Exception) - { - return Problem(); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Remote/ActivityController.cs b/Moonlight/App/Http/Controllers/Api/Remote/ActivityController.cs deleted file mode 100644 index e1be3ce8..00000000 --- a/Moonlight/App/Http/Controllers/Api/Remote/ActivityController.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace Moonlight.App.Http.Controllers.Api.Remote; - -[Route("api/remote/activity")] -[ApiController] -public class ActivityController : Controller -{ - [HttpPost] - public ActionResult SaveActivity() - { - return Ok(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Remote/BackupController.cs b/Moonlight/App/Http/Controllers/Api/Remote/BackupController.cs deleted file mode 100644 index 63bbe28b..00000000 --- a/Moonlight/App/Http/Controllers/Api/Remote/BackupController.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Events; -using Moonlight.App.Http.Requests.Wings; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; -using Moonlight.App.Services; - -namespace Moonlight.App.Http.Controllers.Api.Remote; - -[Route("api/remote/backups")] -[ApiController] -public class BackupController : Controller -{ - private readonly ServerBackupRepository ServerBackupRepository; - private readonly EventSystem Event; - private readonly NodeRepository NodeRepository; - - public BackupController( - ServerBackupRepository serverBackupRepository, - NodeRepository nodeRepository, - EventSystem eventSystem) - { - ServerBackupRepository = serverBackupRepository; - NodeRepository = nodeRepository; - Event = eventSystem; - } - - [HttpGet("{uuid}")] - public ActionResult Download(Guid uuid) - { - return ""; - } - - [HttpPost("{uuid}")] - public async Task SetStatus([FromRoute] Guid uuid, [FromBody] ReportBackupCompleteRequest request) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - var backup = ServerBackupRepository.Get().FirstOrDefault(x => x.Uuid == uuid); - - if (backup == null) - return NotFound(); - - if (request.Successful) - { - backup.Created = true; - backup.Bytes = request.Size; - - ServerBackupRepository.Update(backup); - - await Event.Emit($"wings.backups.create", backup); - } - else - { - await Event.Emit($"wings.backups.createFailed", backup); - ServerBackupRepository.Delete(backup); - } - - return NoContent(); - } - - [HttpPost("{uuid}/restore")] - public async Task SetRestoreStatus([FromRoute] Guid uuid) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - var backup = ServerBackupRepository.Get().FirstOrDefault(x => x.Uuid == uuid); - - if (backup == null) - return NotFound(); - - await Event.Emit($"wings.backups.restore", backup); - - return NoContent(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Remote/DdosController.cs b/Moonlight/App/Http/Controllers/Api/Remote/DdosController.cs deleted file mode 100644 index 55987b9e..00000000 --- a/Moonlight/App/Http/Controllers/Api/Remote/DdosController.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Http.Requests.Daemon; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Background; - -namespace Moonlight.App.Http.Controllers.Api.Remote; - -[ApiController] -[Route("api/remote/ddos")] -public class DdosController : Controller -{ - private readonly Repository NodeRepository; - private readonly DdosProtectionService DdosProtectionService; - - public DdosController(Repository nodeRepository, DdosProtectionService ddosProtectionService) - { - NodeRepository = nodeRepository; - DdosProtectionService = ddosProtectionService; - } - - [HttpPost("start")] - public async Task Start([FromBody] DdosStart ddosStart) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - await DdosProtectionService.ProcessDdosSignal(ddosStart.Ip, ddosStart.Packets); - - return Ok(); - } - - [HttpPost("stop")] - public async Task Stop([FromBody] DdosStop ddosStop) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - return Ok(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Remote/ServersController.cs b/Moonlight/App/Http/Controllers/Api/Remote/ServersController.cs deleted file mode 100644 index b7afee2e..00000000 --- a/Moonlight/App/Http/Controllers/Api/Remote/ServersController.cs +++ /dev/null @@ -1,212 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Events; -using Moonlight.App.Helpers; -using Moonlight.App.Helpers.Wings; -using Moonlight.App.Http.Resources.Wings; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; -using Moonlight.App.Services; - -namespace Moonlight.App.Http.Controllers.Api.Remote; - -[Route("api/remote/servers")] -[ApiController] -public class ServersController : Controller -{ - private readonly WingsServerConverter Converter; - private readonly ServerRepository ServerRepository; - private readonly NodeRepository NodeRepository; - private readonly EventSystem Event; - - public ServersController( - WingsServerConverter converter, - ServerRepository serverRepository, - NodeRepository nodeRepository, - EventSystem eventSystem) - { - Converter = converter; - ServerRepository = serverRepository; - NodeRepository = nodeRepository; - Event = eventSystem; - } - - [HttpGet] - public async Task>> GetServers( - [FromQuery(Name = "page")] int page, - [FromQuery(Name = "per_page")] int perPage) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - var servers = ServerRepository - .Get() - .Include(x => x.Node) - .Where(x => x.Node.Id == node.Id) - .ToArray(); - - List wingsServers = new(); - int totalPages = 1; - - if (servers.Length > 0) - { - var slice = servers.Chunk(perPage).ToArray(); - var part = slice[page]; - - foreach (var server in part) - { - wingsServers.Add(Converter.FromServer(server)); - } - - totalPages = slice.Length - 1; - } - - await Event.Emit($"wings.{node.Id}.serverList", node); - - //Logger.Debug($"[BRIDGE] Node '{node.Name}' is requesting server list page {page} with {perPage} items per page"); - - return PaginationResult.CreatePagination( - wingsServers.ToArray(), - page, - perPage, - totalPages, - servers.Length - ); - } - - - [HttpPost("reset")] - public async Task Reset() - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - await Event.Emit($"wings.{node.Id}.stateReset", node); - - foreach (var server in ServerRepository - .Get() - .Include(x => x.Node) - .Where(x => x.Node.Id == node.Id) - .ToArray() - ) - { - if (server.Installing) - { - server.Installing = false; - ServerRepository.Update(server); - } - } - - return Ok(); - } - - [HttpGet("{uuid}")] - public async Task> GetServer(Guid uuid) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - var server = ServerRepository.Get().FirstOrDefault(x => x.Uuid == uuid); - - if (server == null) - return NotFound(); - - await Event.Emit($"wings.{node.Id}.serverFetch", server); - - try //TODO: Remove - { - return Converter.FromServer(server); - } - catch (Exception e) - { - Console.WriteLine(e); - throw; - } - } - - [HttpGet("{uuid}/install")] - public async Task> GetServerInstall(Guid uuid) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - var server = ServerRepository.Get().Include(x => x.Image).FirstOrDefault(x => x.Uuid == uuid); - - if (server == null) - return NotFound(); - - await Event.Emit($"wings.{node.Id}.serverInstallFetch", server); - - return new WingsServerInstall() - { - Entrypoint = server.Image.InstallEntrypoint, - Script = server.Image.InstallScript!, - Container_Image = server.Image.InstallDockerImage - }; - } - - [HttpPost("{uuid}/install")] - public async Task SetInstallState(Guid uuid) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var id = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == id); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - var server = ServerRepository.Get().Include(x => x.Image).FirstOrDefault(x => x.Uuid == uuid); - - if (server == null) - return NotFound(); - - server.Installing = false; - ServerRepository.Update(server); - - await Event.Emit($"wings.{node.Id}.serverInstallComplete", server); - await Event.Emit($"server.{server.Uuid}.installComplete", server); - - return Ok(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/Api/Remote/SftpAuthController.cs b/Moonlight/App/Http/Controllers/Api/Remote/SftpAuthController.cs deleted file mode 100644 index 947f13f8..00000000 --- a/Moonlight/App/Http/Controllers/Api/Remote/SftpAuthController.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Http.Requests.Wings; -using Moonlight.App.Http.Resources.Wings; -using Moonlight.App.Repositories; -using Moonlight.App.Services; - -namespace Moonlight.App.Http.Controllers.Api.Remote; - -[ApiController] -[Route("api/remote/sftp/auth")] -public class SftpAuthController : Controller -{ - private readonly ServerService ServerService; - private readonly NodeRepository NodeRepository; - - public SftpAuthController( - ServerService serverService, - NodeRepository nodeRepository) - { - ServerService = serverService; - NodeRepository = nodeRepository; - } - - [HttpPost] - public async Task> Login(SftpLoginRequest request) - { - var tokenData = Request.Headers.Authorization.ToString().Replace("Bearer ", ""); - var tokenId = tokenData.Split(".")[0]; - var token = tokenData.Split(".")[1]; - - var node = NodeRepository.Get().FirstOrDefault(x => x.TokenId == tokenId); - - if (node == null) - return NotFound(); - - if (token != node.Token) - return Unauthorized(); - - if (request.Type == "public_key") // Deny public key authentication, because moonlight does not implement that - { - return StatusCode(403); - } - - // Parse the username - var parts = request.Username.Split("."); - - if (parts.Length < 2) - return BadRequest(); - - if (!int.TryParse(parts[0], out int id)) - return BadRequest(); - - if (!int.TryParse(parts[1], out int serverId)) - return BadRequest(); - - try - { - var server = await ServerService.SftpServerLogin(serverId, id, request.Password); - - return Ok(new SftpLoginResult() - { - Server = server.Uuid.ToString(), - User = "", - Permissions = new() - { - "control.console", - "control.start", - "control.stop", - "control.restart", - "websocket.connect", - "file.create", - "file.read", - "file.read-content", - "file.update", - "file.delete", - "file.archive", - "file.sftp", - "user.create", - "user.read", - "user.update", - "user.delete", - "backup.create", - "backup.read", - "backup.delete", - "backup.download", - "backup.restore", - "allocation.read", - "allocation.create", - "allocation.update", - "allocation.delete", - "startup.read", - "startup.update", - "startup.docker-image", - "database.create", - "database.read", - "database.update", - "database.delete", - "database.view_password", - "schedule.create", - "schedule.read", - "schedule.update", - "schedule.delete", - "settings.rename", - "settings.reinstall" - } - }); - } - catch (Exception e) - { - // Most of the exception here will be because of stuff like a invalid server id and simular things - // so we ignore them and return 403 - return StatusCode(403); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Controllers/WellKnown/AcmeController.cs b/Moonlight/App/Http/Controllers/WellKnown/AcmeController.cs deleted file mode 100644 index 0e6c64e9..00000000 --- a/Moonlight/App/Http/Controllers/WellKnown/AcmeController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Moonlight.App.Events; -using Moonlight.App.Services; - -namespace Moonlight.App.Http.Controllers.WellKnown; - -[ApiController] -[Route(".well-known/acme-challenge")] -public class AcmeController : Controller -{ - private readonly LetsEncryptService LetsEncryptService; - private readonly EventSystem Event; - - public AcmeController(LetsEncryptService letsEncryptService, EventSystem eventSystem) - { - LetsEncryptService = letsEncryptService; - Event = eventSystem; - } - - [HttpGet("{token}")] - public async Task Get([FromRoute] string token) - { - if (string.IsNullOrEmpty(LetsEncryptService.HttpChallenge) || string.IsNullOrEmpty(LetsEncryptService.HttpChallengeToken)) - return Problem(); - - if (string.IsNullOrEmpty(token) || LetsEncryptService.HttpChallengeToken != token) - return Problem(); - - await Event.Emit("letsEncrypt.challengeFetched"); - - return Ok(LetsEncryptService.HttpChallenge); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Requests/Daemon/DdosStart.cs b/Moonlight/App/Http/Requests/Daemon/DdosStart.cs deleted file mode 100644 index aab3c54e..00000000 --- a/Moonlight/App/Http/Requests/Daemon/DdosStart.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Http.Requests.Daemon; - -public class DdosStart -{ - public string Ip { get; set; } = ""; - public long Packets { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Requests/Daemon/DdosStop.cs b/Moonlight/App/Http/Requests/Daemon/DdosStop.cs deleted file mode 100644 index f131f204..00000000 --- a/Moonlight/App/Http/Requests/Daemon/DdosStop.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Http.Requests.Daemon; - -public class DdosStop -{ - public string Ip { get; set; } = ""; - public long Traffic { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Requests/DiscordBot/Requests/SetPowerSignal.cs b/Moonlight/App/Http/Requests/DiscordBot/Requests/SetPowerSignal.cs deleted file mode 100644 index 1d364053..00000000 --- a/Moonlight/App/Http/Requests/DiscordBot/Requests/SetPowerSignal.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Moonlight.App.ApiClients.Wings; - -namespace Moonlight.App.Http.Requests.DiscordBot.Requests; - -public class SetPowerSignal -{ - public string Signal { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Requests/Wings/ReportBackupCompleteRequest.cs b/Moonlight/App/Http/Requests/Wings/ReportBackupCompleteRequest.cs deleted file mode 100644 index cacacece..00000000 --- a/Moonlight/App/Http/Requests/Wings/ReportBackupCompleteRequest.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Http.Requests.Wings; - -public class ReportBackupCompleteRequest -{ - public bool Successful { get; set; } - public long Size { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Requests/Wings/SftpLoginRequest.cs b/Moonlight/App/Http/Requests/Wings/SftpLoginRequest.cs deleted file mode 100644 index 4057e986..00000000 --- a/Moonlight/App/Http/Requests/Wings/SftpLoginRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.Http.Requests.Wings; - -public class SftpLoginRequest -{ - public string Username { get; set; } - public string Password { get; set; } - public string Ip { get; set; } - public string Type { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Resources/Wings/PaginationResult.cs b/Moonlight/App/Http/Resources/Wings/PaginationResult.cs deleted file mode 100644 index 610e178b..00000000 --- a/Moonlight/App/Http/Resources/Wings/PaginationResult.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Http.Resources.Wings; - -public class PaginationResult -{ - [JsonProperty("data")] - public List Data { get; set; } - - [JsonProperty("meta")] - public MetaData Meta { get; set; } - - public PaginationResult() - { - Data = new List(); - Meta = new(); - } - - public static PaginationResult CreatePagination(T[] data, int page, int perPage, int totalPages, int totalItems) - { - var res = new PaginationResult(); - - foreach (var i in data) - { - res.Data.Add(i); - } - - res.Meta.Current_Page = page; - res.Meta.Total_Pages = totalPages; - res.Meta.Count = data.Length; - res.Meta.Total = totalItems; - res.Meta.Per_Page = perPage; - res.Meta.Last_Page = totalPages; - - return res; - } - - public class MetaData - { - public int Total { get; set; } - public int Count { get; set; } - public int Per_Page { get; set; } - public int Current_Page { get; set; } - public int Last_Page { get; set; } - public int Total_Pages { get; set; } - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Resources/Wings/SftpLoginResult.cs b/Moonlight/App/Http/Resources/Wings/SftpLoginResult.cs deleted file mode 100644 index 54d0ea63..00000000 --- a/Moonlight/App/Http/Resources/Wings/SftpLoginResult.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Http.Resources.Wings; - -public class SftpLoginResult -{ - public string Server { get; set; } - public string User { get; set; } - public List Permissions { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Resources/Wings/WingsServer.cs b/Moonlight/App/Http/Resources/Wings/WingsServer.cs deleted file mode 100644 index 8dafcd7e..00000000 --- a/Moonlight/App/Http/Resources/Wings/WingsServer.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Moonlight.App.Http.Resources.Wings; - -public class WingsServer -{ - [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } - - [JsonPropertyName("settings")] public WingsServerSettings Settings { get; set; } = new(); - - [JsonPropertyName("process_configuration")] - public WingsServerProcessConfiguration Process_Configuration { get; set; } = new(); - - public class WingsServerProcessConfiguration - { - [JsonPropertyName("startup")] public WingsServerStartup Startup { get; set; } = new(); - - [JsonPropertyName("stop")] public WingsServerStop Stop { get; set; } = new(); - - [JsonPropertyName("configs")] public List Configs { get; set; } = new(); - } - - public class WingsServerConfig - { - [JsonPropertyName("parser")] - public string Parser { get; set; } - - [JsonPropertyName("file")] - public string File { get; set; } - - [JsonPropertyName("replace")] public List Replace { get; set; } = new(); - } - - public class WingsServerReplace - { - [JsonPropertyName("match")] - public string Match { get; set; } - - [JsonPropertyName("replace_with")] - public string Replace_With { get; set; } - } - - public class WingsServerStartup - { - [JsonPropertyName("done")] public List Done { get; set; } = new(); - - [JsonPropertyName("user_interaction")] public List User_Interaction { get; set; } = new(); - - [JsonPropertyName("strip_ansi")] - public bool Strip_Ansi { get; set; } - } - - public class WingsServerStop - { - [JsonPropertyName("type")] - public string Type { get; set; } - - [JsonPropertyName("value")] - public string Value { get; set; } - } - - public class WingsServerSettings - { - [JsonPropertyName("uuid")] - public Guid Uuid { get; set; } - - [JsonPropertyName("suspended")] - public bool Suspended { get; set; } - - [JsonPropertyName("environment")] public Dictionary Environment { get; set; } = new(); - - [JsonPropertyName("invocation")] - public string Invocation { get; set; } - - [JsonPropertyName("skip_egg_scripts")] - public bool Skip_Egg_Scripts { get; set; } - - [JsonPropertyName("build")] public WingsServerBuild Build { get; set; } = new(); - - [JsonPropertyName("container")] public WingsServerContainer Container { get; set; } = new(); - - [JsonPropertyName("allocations")] public WingsServerAllocations Allocations { get; set; } = new(); - - [JsonPropertyName("mounts")] public List Mounts { get; set; } = new(); - - [JsonPropertyName("egg")] public WingsServerEgg Egg { get; set; } = new(); - } - - public class WingsServerAllocations - { - [JsonPropertyName("default")] public WingsServerDefault Default { get; set; } = new(); - - [JsonPropertyName("mappings")] public WingsServerMappings Mappings { get; set; } = new(); - } - - public class WingsServerDefault - { - [JsonPropertyName("ip")] - public string Ip { get; set; } - - [JsonPropertyName("port")] - public long Port { get; set; } - } - - public class WingsServerMappings - { - [JsonPropertyName("0.0.0.0")] public List Ports { get; set; } = new(); - } - - public class WingsServerBuild - { - [JsonPropertyName("memory_limit")] - public long Memory_Limit { get; set; } - - [JsonPropertyName("swap")] - public long Swap { get; set; } - - [JsonPropertyName("io_weight")] - public long Io_Weight { get; set; } - - [JsonPropertyName("cpu_limit")] - public long Cpu_Limit { get; set; } - - [JsonPropertyName("threads")] - public object Threads { get; set; } - - [JsonPropertyName("disk_space")] - public long Disk_Space { get; set; } - - [JsonPropertyName("oom_disabled")] - public bool Oom_Disabled { get; set; } - - [JsonPropertyName("oom_killer")] - public bool Oom_Killer { get; set; } - } - - public class WingsServerContainer - { - [JsonPropertyName("image")] - public string Image { get; set; } - - [JsonPropertyName("oom_disabled")] - public bool Oom_Disabled { get; set; } - - [JsonPropertyName("requires_rebuild")] - public bool Requires_Rebuild { get; set; } - } - - public class WingsServerEgg - { - [JsonPropertyName("id")] - public Guid Id { get; set; } - - [JsonPropertyName("file_denylist")] public List File_Denylist { get; set; } = new(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Http/Resources/Wings/WingsServerInstall.cs b/Moonlight/App/Http/Resources/Wings/WingsServerInstall.cs deleted file mode 100644 index 473338a3..00000000 --- a/Moonlight/App/Http/Resources/Wings/WingsServerInstall.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Http.Resources.Wings; - -public class WingsServerInstall -{ - public string Container_Image { get; set; } - public string Entrypoint { get; set; } - public string Script { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/LogMigrator/LogMigrator.cs b/Moonlight/App/LogMigrator/LogMigrator.cs deleted file mode 100644 index 0837ff3d..00000000 --- a/Moonlight/App/LogMigrator/LogMigrator.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Moonlight.App.Helpers; - -namespace Moonlight.App.LogMigrator; - -// This is used to migrate microsoft logging to logging.net -public class LogMigrator : ILogger -{ - private string Name; - - public LogMigrator(string name) - { - Name = name; - } - - public IDisposable BeginScope(TState state) - { - return null; - } - - public bool IsEnabled(LogLevel logLevel) - { - return true; - } - - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) - { - switch (logLevel) - { - case LogLevel.Critical: - Logger.Fatal(formatter(state, exception)); - - if(exception != null) - Logger.Fatal(exception); - - break; - case LogLevel.Warning: - Logger.Warn(formatter(state, exception)); - - if(exception != null) - Logger.Warn(exception); - - break; - case LogLevel.Debug: - Logger.Debug(formatter(state, exception)); - - if(exception != null) - Logger.Debug(exception); - - break; - case LogLevel.Error: - Logger.Error(formatter(state, exception)); - - if(exception != null) - Logger.Error(exception); - - break; - case LogLevel.Information: - Logger.Info(formatter(state, exception)); - - if(exception != null) - Logger.Info(exception); - - break; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/LogMigrator/LogMigratorLoggerFactoryExtension.cs b/Moonlight/App/LogMigrator/LogMigratorLoggerFactoryExtension.cs deleted file mode 100644 index caa78e8a..00000000 --- a/Moonlight/App/LogMigrator/LogMigratorLoggerFactoryExtension.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Moonlight.App.LogMigrator; - -public static class LogMigratorLoggerFactoryExtensions -{ - public static ILoggerFactory AddCustomLogger( - this ILoggerFactory factory, out LogMigratorProvider logProvider) - { - logProvider = new LogMigratorProvider(); - factory.AddProvider(logProvider); - return factory; - } -} \ No newline at end of file diff --git a/Moonlight/App/LogMigrator/LogMigratorProvider.cs b/Moonlight/App/LogMigrator/LogMigratorProvider.cs deleted file mode 100644 index 8b7ac313..00000000 --- a/Moonlight/App/LogMigrator/LogMigratorProvider.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Concurrent; - -namespace Moonlight.App.LogMigrator; - -public class LogMigratorProvider : ILoggerProvider -{ - public LogMigratorProvider() { } - public LogMigratorProvider(EventHandler onCreateLogger) - { - OnCreateLogger = onCreateLogger; - } - - private ConcurrentDictionary Loggers { get; set; } = new(); - - public ILogger CreateLogger(string categoryName) - { - App.LogMigrator.LogMigrator customLogger = Loggers.GetOrAdd(categoryName, new App.LogMigrator.LogMigrator(categoryName)); - OnCreateLogger?.Invoke(this, new LogMigratorProviderEventArgs(customLogger)); - return customLogger; - } - - public void Dispose() { } - - public event EventHandler OnCreateLogger = delegate { }; - - private class LogMigratorProviderEventArgs : EventArgs - { - private App.LogMigrator.LogMigrator CustomLogger { get; } - public LogMigratorProviderEventArgs(App.LogMigrator.LogMigrator logger) - { - CustomLogger = logger; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/LogMigrator/SentryDiagnosticsLogger.cs b/Moonlight/App/LogMigrator/SentryDiagnosticsLogger.cs deleted file mode 100644 index a042a88b..00000000 --- a/Moonlight/App/LogMigrator/SentryDiagnosticsLogger.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Moonlight.App.Helpers; -using Sentry; -using Sentry.Extensibility; - -namespace Moonlight.App.LogMigrator; - -public class SentryDiagnosticsLogger : IDiagnosticLogger -{ - private readonly SentryLevel Level; - - public SentryDiagnosticsLogger(SentryLevel level) - { - Level = level; - } - - public bool IsEnabled(SentryLevel level) - { - if ((int)level >= (int)Level) - { - return true; - } - - return false; - } - - public void Log(SentryLevel logLevel, string message, Exception? exception = null, params object?[] args) - { - switch (logLevel) - { - case SentryLevel.Debug: - Logger.Debug(string.Format(message, args)); - - if(exception != null) - Logger.Debug(exception); - - break; - - case SentryLevel.Info: - Logger.Info(string.Format(message, args)); - - if(exception != null) - Logger.Info(exception); - - break; - - case SentryLevel.Warning: - Logger.Warn(string.Format(message, args)); - - if(exception != null) - Logger.Warn(exception); - - break; - - case SentryLevel.Error: - Logger.Error(string.Format(message, args)); - - if(exception != null) - Logger.Error(exception); - - break; - - case SentryLevel.Fatal: - Logger.Fatal(string.Format(message, args)); - - if(exception != null) - Logger.Fatal(exception); - - break; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/MalwareScans/BadScriptsScan.cs b/Moonlight/App/MalwareScans/BadScriptsScan.cs deleted file mode 100644 index 7b9c4ec4..00000000 --- a/Moonlight/App/MalwareScans/BadScriptsScan.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Services; - -namespace Moonlight.App.MalwareScans; - -public class BadScriptsScan : MalwareScan -{ - public override string Name => "BadScripts Scan"; - public override string Description => "This scanner tries to find scripts like proxies or other bad stuff"; - public async override Task Scan(Server server, IServiceProvider serviceProvider) - { - var serverService = serviceProvider.GetRequiredService(); - var fileAccess = await serverService.CreateFileAccess(server, null!); - - string[] fileExtensions = - { - ".py", - ".js", - ".json", - ".txt", - ".sh", - ".env", - ".md", - ".html", - ".htm" - }; - - string[] badWords = - { - "cloudscraper", - "shadowsocks", - "karma-ddos", - "quake", - "nuked by", - "nuke bot", - "t-e-s-tweb", - "nezha", - "rblxwild.com", - "proxyscrape", - "vless://", - "vmess://", - "trojan://", - "shadowrocket", - "urfate/afk-bot", - "token vc spammer", - "pretreer.com", - "madfutters.com", - "ultrafut", - "selfcord.py", - "https://github.com/go-gost/gost", - "nodejs-proxy" - }; - - var files = await fileAccess.Ls(); - var filteredFiles = files.Where(x => - StringHelper.EndsInOneOf(x.Name, fileExtensions)); - - foreach (var file in filteredFiles) - { - var content = await fileAccess.Read(file); - var processableContent = content.ToLower(); - - if (StringHelper.ContainsOneOf(processableContent, badWords, out string foundText)) - { - return new() - { - Title = "Software which is not allowed", - Description = $"Found bad word in script '{file.Name}': '{foundText}'", - Author = "Marcel Baumgartner" - }; - } - } - - return null; - } -} \ No newline at end of file diff --git a/Moonlight/App/MalwareScans/FakePlayerPluginScan.cs b/Moonlight/App/MalwareScans/FakePlayerPluginScan.cs deleted file mode 100644 index 8c235fe6..00000000 --- a/Moonlight/App/MalwareScans/FakePlayerPluginScan.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; -using Moonlight.App.Services; - -namespace Moonlight.App.MalwareScans; - -public class FakePlayerPluginScan : MalwareScan -{ - public override string Name => "Fake player plugin scan"; - public override string Description => "This scan is a simple fake player plugin scan provided by moonlight"; - - public override async Task Scan(Server server, IServiceProvider serviceProvider) - { - var serverService = serviceProvider.GetRequiredService(); - var access = await serverService.CreateFileAccess(server, null!); - var fileElements = await access.Ls(); - - if (fileElements.Any(x => !x.IsFile && x.Name == "plugins")) // Check for plugins folder - { - await access.Cd("plugins"); - fileElements = await access.Ls(); - - foreach (var fileElement in fileElements) - { - if (fileElement.Name.ToLower().Contains("fakeplayer")) - { - return new() - { - Title = "Fake player plugin", - Description = $"Suspicious plugin file: {fileElement.Name}", - Author = "Marcel Baumgartner" - }; - } - } - } - - return null; - } -} \ No newline at end of file diff --git a/Moonlight/App/MalwareScans/MinerJarScan.cs b/Moonlight/App/MalwareScans/MinerJarScan.cs deleted file mode 100644 index a11ccd4c..00000000 --- a/Moonlight/App/MalwareScans/MinerJarScan.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; -using Moonlight.App.Services; - -namespace Moonlight.App.MalwareScans; - -public class MinerJarScan : MalwareScan -{ - public override string Name => "Miner jar scan"; - public override string Description => "This scan is a simple miner jar scan provided by moonlight"; - - public override async Task Scan(Server server, IServiceProvider serviceProvider) - { - var serverService = serviceProvider.GetRequiredService(); - var access = await serverService.CreateFileAccess(server, null!); - var fileElements = await access.Ls(); - - if (fileElements.Any(x => x.Name == "libraries" && !x.IsFile)) - { - await access.Cd("libraries"); - - fileElements = await access.Ls(); - - if (fileElements.Any(x => x.Name == "jdk" && !x.IsFile)) - { - return new() - { - Title = "Found Miner", - Description = "Detected suspicious library directory which may contain a script for miners", - Author = "Marcel Baumgartner" - }; - } - } - - return null; - } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/CloudPanelDataModel.cs b/Moonlight/App/Models/Forms/CloudPanelDataModel.cs deleted file mode 100644 index d08e9461..00000000 --- a/Moonlight/App/Models/Forms/CloudPanelDataModel.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class CloudPanelDataModel -{ - [Required(ErrorMessage = "You have to enter a name")] - [MaxLength(32, ErrorMessage = "The name should not be longer than 32 characters")] - public string Name { get; set; } - - [Required(ErrorMessage = "You need to specify the host")] - public string Host { get; set; } - - [Required(ErrorMessage = "You need to enter an api url")] - public string ApiUrl { get; set; } - - [Required(ErrorMessage = "You need to enter an api key")] - public string ApiKey { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/CreateTicketDataModel.cs b/Moonlight/App/Models/Forms/CreateTicketDataModel.cs deleted file mode 100644 index e733cc72..00000000 --- a/Moonlight/App/Models/Forms/CreateTicketDataModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Models.Forms; - -public class CreateTicketDataModel -{ - [Required(ErrorMessage = "You need to specify a issue topic")] - [MinLength(5, ErrorMessage = "The issue topic needs to be longer than 5 characters")] - public string IssueTopic { get; set; } - - [Required(ErrorMessage = "You need to specify a issue description")] - [MinLength(10, ErrorMessage = "The issue description needs to be longer than 10 characters")] - public string IssueDescription { get; set; } - - [Required(ErrorMessage = "You need to specify your tries to solve this issue")] - public string IssueTries { get; set; } - - public TicketSubject Subject { get; set; } - public int SubjectId { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/DatabaseDataModel.cs b/Moonlight/App/Models/Forms/DatabaseDataModel.cs deleted file mode 100644 index b298512d..00000000 --- a/Moonlight/App/Models/Forms/DatabaseDataModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class DatabaseDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MinLength(8, ErrorMessage = "The name should be at least 8 characters long")] - [MaxLength(32, ErrorMessage = "The database name should be maximal 32 characters")] - [RegularExpression(@"^[a-z0-9]+$", ErrorMessage = "The name should only contain of lower case characters and numbers")] - public string Name { get; set; } = ""; - - [Required(ErrorMessage = "You need to enter a password")] - [MinLength(8, ErrorMessage = "The password should be at least 8 characters long")] - [MaxLength(32, ErrorMessage = "The password name should be maximal 32 characters")] - public string Password { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/DomainDataModel.cs b/Moonlight/App/Models/Forms/DomainDataModel.cs deleted file mode 100644 index ce1bbc5a..00000000 --- a/Moonlight/App/Models/Forms/DomainDataModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class DomainDataModel -{ - [Required(ErrorMessage = "You need to specify a name")] - [MaxLength(32, ErrorMessage = "The max lenght for the name is 32 characters")] - [RegularExpression(@"^[a-z]+$", ErrorMessage = "The name should only consist of lower case characters")] - public string Name { get; set; } = ""; - - [Required(ErrorMessage = "You need to specify a shared domain")] - public SharedDomain SharedDomain { get; set; } - - [Required(ErrorMessage = "You need to specify a owner")] - public User Owner { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/DomainOrderDataModel.cs b/Moonlight/App/Models/Forms/DomainOrderDataModel.cs deleted file mode 100644 index b3b8a93f..00000000 --- a/Moonlight/App/Models/Forms/DomainOrderDataModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class DomainOrderDataModel -{ - [Required(ErrorMessage = "You need to specify a name")] - [MaxLength(32, ErrorMessage = "The max lenght for the name is 32 characters")] - [RegularExpression(@"^[a-z0-9]+$", ErrorMessage = "The name should only consist of lower case characters or numbers")] - public string Name { get; set; } = ""; - - [Required(ErrorMessage = "You need to specify a shared domain")] - public SharedDomain SharedDomain { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/LoginDataModel.cs b/Moonlight/App/Models/Forms/LoginDataModel.cs deleted file mode 100644 index 63a5ac28..00000000 --- a/Moonlight/App/Models/Forms/LoginDataModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class LoginDataModel -{ - [Required(ErrorMessage = "You need to enter an email address")] - [EmailAddress(ErrorMessage = "You need to enter a valid email address")] - public string Email { get; set; } - - [Required(ErrorMessage = "You need to enter a password")] - [MinLength(8, ErrorMessage = "You need to enter a password with minimum 8 characters in lenght")] - public string Password { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/LoginTotpDataModel.cs b/Moonlight/App/Models/Forms/LoginTotpDataModel.cs deleted file mode 100644 index b1dcca02..00000000 --- a/Moonlight/App/Models/Forms/LoginTotpDataModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class LoginTotpDataModel -{ - [Required(ErrorMessage = "You need to enter a 2fa code")] - public string Code { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/NameModel.cs b/Moonlight/App/Models/Forms/NameModel.cs deleted file mode 100644 index 17d832ab..00000000 --- a/Moonlight/App/Models/Forms/NameModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class NameModel -{ - [Required] - [MinLength(2, ErrorMessage = "Do you think, that works?")] - public string FirstName { get; set; } - - [Required] - [MinLength(2, ErrorMessage = "Do you think, that works?")] - public string LastName { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/PasswordModel.cs b/Moonlight/App/Models/Forms/PasswordModel.cs deleted file mode 100644 index 237f6a43..00000000 --- a/Moonlight/App/Models/Forms/PasswordModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class PasswordModel -{ - [Required(ErrorMessage = "You need to enter a password")] - [MinLength(8, ErrorMessage = "You need to enter a password with minimum 8 characters in lenght")] - public string Password { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/PleskServerDataModel.cs b/Moonlight/App/Models/Forms/PleskServerDataModel.cs deleted file mode 100644 index 78e4920a..00000000 --- a/Moonlight/App/Models/Forms/PleskServerDataModel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class PleskServerDataModel -{ - [Required(ErrorMessage = "You have to enter a name")] - [MaxLength(32, ErrorMessage = "The name should not be longer than 32 characters")] - public string Name { get; set; } - - [Required(ErrorMessage = "You need to enter an api url")] - public string ApiUrl { get; set; } - - [Required(ErrorMessage = "You need to enter an api key")] - public string ApiKey { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerDataModel.cs b/Moonlight/App/Models/Forms/ServerDataModel.cs deleted file mode 100644 index 4838a55b..00000000 --- a/Moonlight/App/Models/Forms/ServerDataModel.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class ServerDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MaxLength(32, ErrorMessage = "The name cannot be longer that 32 characters")] - public string Name { get; set; } - - [Required(ErrorMessage = "You need to specify a owner")] - public User Owner { get; set; } - - [Required(ErrorMessage = "You need to specify cpu amount")] - public int Cpu { get; set; } = 100; - - [Required(ErrorMessage = "You need to specify a memory amount")] - public int Memory { get; set; } = 1024; - - [Required(ErrorMessage = "You need to specify a disk amount")] - public int Disk { get; set; } = 1024; - - [Required(ErrorMessage = "You need to specify a image")] - public Image Image { get; set; } - - [Required(ErrorMessage = "You need to specify a node")] - public Node Node { get; set; } - - public string OverrideStartup { get; set; } = ""; - - public int DockerImageIndex { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerEditDataModel.cs b/Moonlight/App/Models/Forms/ServerEditDataModel.cs deleted file mode 100644 index 22adcbaf..00000000 --- a/Moonlight/App/Models/Forms/ServerEditDataModel.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class ServerEditDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MaxLength(32, ErrorMessage = "The name cannot be longer that 32 characters")] - public string Name { get; set; } - - [Required(ErrorMessage = "You need to specify a user")] - public User Owner { get; set; } - - [Required(ErrorMessage = "You need to specify the cpu cores")] - public int Cpu { get; set; } - - [Required(ErrorMessage = "You need to specify the memory")] - public long Memory { get; set; } - - [Required(ErrorMessage = "You need to specify the disk")] - public long Disk { get; set; } - - public string OverrideStartup { get; set; } - - public int DockerImageIndex { get; set; } - - public bool IsCleanupException { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerImageDataModel.cs b/Moonlight/App/Models/Forms/ServerImageDataModel.cs deleted file mode 100644 index e881b797..00000000 --- a/Moonlight/App/Models/Forms/ServerImageDataModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Models.Forms; - -public class ServerImageDataModel -{ - public string OverrideStartup { get; set; } - - public int DockerImageIndex { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerOrderDataModel.cs b/Moonlight/App/Models/Forms/ServerOrderDataModel.cs deleted file mode 100644 index 778096f5..00000000 --- a/Moonlight/App/Models/Forms/ServerOrderDataModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class ServerOrderDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MaxLength(32, ErrorMessage = "The name cannot be longer that 32 characters")] - public string Name { get; set; } = ""; - - [Required(ErrorMessage = "You need to specify a server image")] - public Image Image { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerOverviewDataModel.cs b/Moonlight/App/Models/Forms/ServerOverviewDataModel.cs deleted file mode 100644 index 2079970d..00000000 --- a/Moonlight/App/Models/Forms/ServerOverviewDataModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class ServerOverviewDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MaxLength(32, ErrorMessage = "The name cannot be longer that 32 characters")] - public string Name { get; set; } - - [Required(ErrorMessage = "You need to specify a owner")] - public User Owner { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerRenameDataModel.cs b/Moonlight/App/Models/Forms/ServerRenameDataModel.cs deleted file mode 100644 index 619ee328..00000000 --- a/Moonlight/App/Models/Forms/ServerRenameDataModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class ServerRenameDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MaxLength(32, ErrorMessage = "The name cannot be longer that 32 characters")] - public string Name { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/ServerResourcesDataModel.cs b/Moonlight/App/Models/Forms/ServerResourcesDataModel.cs deleted file mode 100644 index 87f358e9..00000000 --- a/Moonlight/App/Models/Forms/ServerResourcesDataModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class ServerResourcesDataModel -{ - [Required(ErrorMessage = "You need to specify the cpu cores")] - public int Cpu { get; set; } - - [Required(ErrorMessage = "You need to specify the memory")] - public long Memory { get; set; } - - [Required(ErrorMessage = "You need to specify the disk")] - public long Disk { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/SubscriptionDataModel.cs b/Moonlight/App/Models/Forms/SubscriptionDataModel.cs deleted file mode 100644 index 2f7c7185..00000000 --- a/Moonlight/App/Models/Forms/SubscriptionDataModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Models.Forms; - -public class SubscriptionDataModel -{ - [Required(ErrorMessage = "You need to enter a name")] - [MaxLength(32, ErrorMessage = "Max lenght for name is 32")] - public string Name { get; set; } = ""; - - [Required(ErrorMessage = "You need to enter a description")] - public string Description { get; set; } = ""; - - public double Price { get; set; } = 0; - public Currency Currency { get; set; } = Currency.USD; - public int Duration { get; set; } = 30; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/TestDataModel.cs b/Moonlight/App/Models/Forms/TestDataModel.cs deleted file mode 100644 index 0fecab72..00000000 --- a/Moonlight/App/Models/Forms/TestDataModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class TestDataModel -{ - [Required] - public User User { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/UserDataModel.cs b/Moonlight/App/Models/Forms/UserDataModel.cs deleted file mode 100644 index bc2ff8ef..00000000 --- a/Moonlight/App/Models/Forms/UserDataModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class UserDataModel -{ - [Required] - public string FirstName { get; set; } = ""; - - [Required] - public string LastName { get; set; } = ""; - - [Required] - public string Email { get; set; } = ""; - - [Required] - public string Address { get; set; } = ""; - - [Required] - public string City { get; set; } = ""; - - [Required] - public string State { get; set; } = ""; - - [Required] - public string Country { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/UserEditDataModel.cs b/Moonlight/App/Models/Forms/UserEditDataModel.cs deleted file mode 100644 index 1af0ccb0..00000000 --- a/Moonlight/App/Models/Forms/UserEditDataModel.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.Models.Forms; - -public class UserEditDataModel -{ - [Required] - public string FirstName { get; set; } = ""; - - [Required] - public string LastName { get; set; } = ""; - - [Required] - public string Email { get; set; } = ""; - - [Required] - public string Address { get; set; } = ""; - - [Required] - public string City { get; set; } = ""; - - [Required] - public string State { get; set; } = ""; - - [Required] - public string Country { get; set; } = ""; - - public bool Admin { get; set; } - public bool TotpEnabled { get; set; } - public ulong DiscordId { get; set; } - public PermissionGroup? PermissionGroup { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/UserPreferencesDataModel.cs b/Moonlight/App/Models/Forms/UserPreferencesDataModel.cs deleted file mode 100644 index 7314ccf2..00000000 --- a/Moonlight/App/Models/Forms/UserPreferencesDataModel.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.Models.Forms; - -public class UserPreferencesDataModel -{ - public bool StreamerMode { get; set; } = false; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/UserRegisterModel.cs b/Moonlight/App/Models/Forms/UserRegisterModel.cs deleted file mode 100644 index b8ee21d4..00000000 --- a/Moonlight/App/Models/Forms/UserRegisterModel.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Models.Forms; - -public class UserRegisterModel -{ - [Required(ErrorMessage = "You need to specify a email address")] - [EmailAddress(ErrorMessage = "You need to specify a valid email address")] - public string Email { get; set; } - - [Required(ErrorMessage = "You need to specify a first name")] - [MinLength(3, ErrorMessage = "You need to specify a valid first name")] - [MaxLength(30, ErrorMessage = "You need to specify a valid first name")] - public string FirstName { get; set; } - - - [Required(ErrorMessage = "You need to specify a last name")] - [MinLength(3, ErrorMessage = "You need to specify a valid last name")] - [MaxLength(30, ErrorMessage = "You need to specify a valid last name")] - public string LastName { get; set; } - - [Required(ErrorMessage = "You need to specify a password")] - public string Password { get; set; } - - [Required(ErrorMessage = "You need to specify a password")] - public string ConfirmPassword { get; set; } - - [MustBeTrue(ErrorMessage = "Please solve the captcha")] - public bool Captcha { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/WebsiteAdminDataModel.cs b/Moonlight/App/Models/Forms/WebsiteAdminDataModel.cs deleted file mode 100644 index f3884d06..00000000 --- a/Moonlight/App/Models/Forms/WebsiteAdminDataModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Forms; - -public class WebsiteAdminDataModel -{ - [Required(ErrorMessage = "You need a domain")] - [RegularExpression(@"([a-z0-9|-]+\.)*[a-z0-9|-]+\.[a-z]+", ErrorMessage = "You need to enter a valid domain")] - public string BaseDomain { get; set; } = ""; - - [Required(ErrorMessage = "You need to specify a owner")] - public User User { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/WebsiteDataModel.cs b/Moonlight/App/Models/Forms/WebsiteDataModel.cs deleted file mode 100644 index 9bc9d2df..00000000 --- a/Moonlight/App/Models/Forms/WebsiteDataModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class WebsiteDataModel -{ - [Required(ErrorMessage = "You need to enter a domain")] - [RegularExpression(@"([a-z0-9|-]+\.)*[a-z0-9|-]+\.[a-z]+", ErrorMessage = "You need to enter a valid domain")] - public string BaseDomain { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Forms/WebsiteOrderDataModel.cs b/Moonlight/App/Models/Forms/WebsiteOrderDataModel.cs deleted file mode 100644 index 0c5a388e..00000000 --- a/Moonlight/App/Models/Forms/WebsiteOrderDataModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Moonlight.App.Models.Forms; - -public class WebsiteOrderDataModel -{ - [Required(ErrorMessage = "You need to enter a domain")] - [RegularExpression(@"([a-z0-9|-]+\.)*[a-z0-9|-]+\.[a-z]+", ErrorMessage = "You need to enter a valid domain")] - public string BaseDomain { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Log/LogData.cs b/Moonlight/App/Models/Log/LogData.cs deleted file mode 100644 index 645a666f..00000000 --- a/Moonlight/App/Models/Log/LogData.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Models.Log; - -public class LogData -{ - public Type Type { get; set; } - public string Value { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/ActiveNotificationClient.cs b/Moonlight/App/Models/Misc/ActiveNotificationClient.cs deleted file mode 100644 index 43c95fac..00000000 --- a/Moonlight/App/Models/Misc/ActiveNotificationClient.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Net.WebSockets; -using System.Text; -using Moonlight.App.Database.Entities.Notification; - -namespace Moonlight.App.Models.Misc; - -public class ActiveNotificationClient -{ - public WebSocket WebSocket { get; set; } - public NotificationClient Client { get; set; } - - public async Task SendAction(string action) - { - await WebSocket.SendAsync( - Encoding.UTF8.GetBytes(action), - WebSocketMessageType.Text, - WebSocketMessageFlags.EndOfMessage, CancellationToken.None); - } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/Currency.cs b/Moonlight/App/Models/Misc/Currency.cs deleted file mode 100644 index 195ae285..00000000 --- a/Moonlight/App/Models/Misc/Currency.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum Currency -{ - USD = 1, - EUR = 2 -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/DnsRecord.cs b/Moonlight/App/Models/Misc/DnsRecord.cs deleted file mode 100644 index 59147c7f..00000000 --- a/Moonlight/App/Models/Misc/DnsRecord.cs +++ /dev/null @@ -1,14 +0,0 @@ -using CloudFlare.Client.Enumerators; - -namespace Moonlight.App.Models.Misc; - -public class DnsRecord -{ - public string Name { get; set; } - public string Content { get; set; } - public DnsRecordType Type { get; set; } - public string Id { get; set; } - public bool Proxied { get; set; } - public int Priority { get; set; } - public int Ttl { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/HealthCheck.cs b/Moonlight/App/Models/Misc/HealthCheck.cs deleted file mode 100644 index c7df29b7..00000000 --- a/Moonlight/App/Models/Misc/HealthCheck.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Misc; - -public class HealthCheck -{ - public string Status { get; set; } - public TimeSpan TotalDuration { get; set; } - public Dictionary Entries { get; set; } = new(); - - public class HealthCheckEntry - { - public Dictionary Data { get; set; } = new(); - public string Description { get; set; } - public TimeSpan Duration { get; set; } - public string Status { get; set; } - public List Tags { get; set; } = new(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/LogEntry.cs b/Moonlight/App/Models/Misc/LogEntry.cs deleted file mode 100644 index 09258f4a..00000000 --- a/Moonlight/App/Models/Misc/LogEntry.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public class LogEntry -{ - public string Level { get; set; } - public string Message { get; set; } - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/MailTemplate.cs b/Moonlight/App/Models/Misc/MailTemplate.cs deleted file mode 100644 index 1d67cdcf..00000000 --- a/Moonlight/App/Models/Misc/MailTemplate.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Moonlight.App.Helpers.Files; - -namespace Moonlight.App.Models.Misc; - -public class MailTemplate // This is just for the blazor table at /admin/system/mail -{ - public string Name { get; set; } = ""; - public FileData File { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/MalwareScan.cs b/Moonlight/App/Models/Misc/MalwareScan.cs deleted file mode 100644 index 9660868c..00000000 --- a/Moonlight/App/Models/Misc/MalwareScan.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Misc; - -public abstract class MalwareScan -{ - public abstract string Name { get; } - public abstract string Description { get; } - public abstract Task Scan(Server server, IServiceProvider serviceProvider); -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/MalwareScanResult.cs b/Moonlight/App/Models/Misc/MalwareScanResult.cs deleted file mode 100644 index 4f78885a..00000000 --- a/Moonlight/App/Models/Misc/MalwareScanResult.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public class MalwareScanResult -{ - public string Title { get; set; } - public string Description { get; set; } = ""; - public string Author { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/OAuth2ProviderConfig.cs b/Moonlight/App/Models/Misc/OAuth2ProviderConfig.cs deleted file mode 100644 index de914010..00000000 --- a/Moonlight/App/Models/Misc/OAuth2ProviderConfig.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public class OAuth2ProviderConfig -{ - public string Id { get; set; } = ""; - public string ClientId { get; set; } = ""; - public string ClientSecret { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/OfficialMoonlightPlugin.cs b/Moonlight/App/Models/Misc/OfficialMoonlightPlugin.cs deleted file mode 100644 index 2b3d090d..00000000 --- a/Moonlight/App/Models/Misc/OfficialMoonlightPlugin.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public class OfficialMoonlightPlugin -{ - public string Name { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/QuestionType.cs b/Moonlight/App/Models/Misc/QuestionType.cs deleted file mode 100644 index 75acdc9d..00000000 --- a/Moonlight/App/Models/Misc/QuestionType.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum QuestionType -{ - ServerUrl -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/RunningServer.cs b/Moonlight/App/Models/Misc/RunningServer.cs deleted file mode 100644 index 6bf9a14e..00000000 --- a/Moonlight/App/Models/Misc/RunningServer.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Moonlight.App.ApiClients.Daemon.Resources; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Models.Misc; - -public class RunningServer -{ - public Server Server { get; set; } - public Container Container { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/ServerGroup.cs b/Moonlight/App/Models/Misc/ServerGroup.cs deleted file mode 100644 index 07694ad8..00000000 --- a/Moonlight/App/Models/Misc/ServerGroup.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public class ServerGroup -{ - public string Name { get; set; } = ""; - public List Servers { get; set; } = new(); -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/StatisticsTimeSpan.cs b/Moonlight/App/Models/Misc/StatisticsTimeSpan.cs deleted file mode 100644 index 6341be6f..00000000 --- a/Moonlight/App/Models/Misc/StatisticsTimeSpan.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum StatisticsTimeSpan -{ - Hour = 1, - Day = 24, - Month = Day * 31, - Year = 365 * Day, - AllTime = Year * 99 -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/SubscriptionLimit.cs b/Moonlight/App/Models/Misc/SubscriptionLimit.cs deleted file mode 100644 index 21d59100..00000000 --- a/Moonlight/App/Models/Misc/SubscriptionLimit.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public class SubscriptionLimit -{ - public string Identifier { get; set; } = ""; - public int Amount { get; set; } - public List Options { get; set; } = new(); - - public string? ReadValue(string key) - { - var d = Options.FirstOrDefault(x => string.Equals(x.Key, key, StringComparison.InvariantCultureIgnoreCase)); - return d?.Value; - } - - public class LimitOption - { - public string Key { get; set; } = ""; - public string Value { get; set; } = ""; - } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/TicketPriority.cs b/Moonlight/App/Models/Misc/TicketPriority.cs deleted file mode 100644 index 97fc5489..00000000 --- a/Moonlight/App/Models/Misc/TicketPriority.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum TicketPriority -{ - Low = 0, - Medium = 1, - High = 2, - Critical = 3 -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/TicketStatus.cs b/Moonlight/App/Models/Misc/TicketStatus.cs deleted file mode 100644 index 2a59fae9..00000000 --- a/Moonlight/App/Models/Misc/TicketStatus.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum TicketStatus -{ - Closed = 0, - Open = 1, - WaitingForUser = 2, - Pending = 3 -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/TicketSubject.cs b/Moonlight/App/Models/Misc/TicketSubject.cs deleted file mode 100644 index ed6d4579..00000000 --- a/Moonlight/App/Models/Misc/TicketSubject.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum TicketSubject -{ - Webspace = 0, - Server = 1, - Domain = 2, - Other = 3 -} \ No newline at end of file diff --git a/Moonlight/App/Models/Misc/UserStatus.cs b/Moonlight/App/Models/Misc/UserStatus.cs deleted file mode 100644 index a270ead5..00000000 --- a/Moonlight/App/Models/Misc/UserStatus.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Moonlight.App.Models.Misc; - -public enum UserStatus -{ - Unverified, - Verified, - VerifyPending, - VerifyFailed, - Warned, - Banned, - Disabled, - DataPending, - PasswordPending -} \ No newline at end of file diff --git a/Moonlight/App/Models/Notifications/BasicWSModel.cs b/Moonlight/App/Models/Notifications/BasicWSModel.cs deleted file mode 100644 index 76e26896..00000000 --- a/Moonlight/App/Models/Notifications/BasicWSModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Notifications; - -public class BasicWSModel -{ - [JsonProperty("action")] - public string Action { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Notifications/Login.cs b/Moonlight/App/Models/Notifications/Login.cs deleted file mode 100644 index 4f6bc979..00000000 --- a/Moonlight/App/Models/Notifications/Login.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Notifications; - -public class Login : BasicWSModel -{ - [JsonProperty("token")] public string Token { get; set; } = ""; -} \ No newline at end of file diff --git a/Moonlight/App/Models/Notifications/NotificationById.cs b/Moonlight/App/Models/Notifications/NotificationById.cs deleted file mode 100644 index 12e4dc11..00000000 --- a/Moonlight/App/Models/Notifications/NotificationById.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Newtonsoft.Json; - -namespace Moonlight.App.Models.Notifications; - -public class NotificationById : BasicWSModel -{ - [JsonProperty("notification")] - public int Notification { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Models/Notifications/TokenRegister.cs b/Moonlight/App/Models/Notifications/TokenRegister.cs deleted file mode 100644 index bc6331c5..00000000 --- a/Moonlight/App/Models/Notifications/TokenRegister.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.Models.Notifications; - -public class TokenRegister -{ - public string Token { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/OAuth2/OAuth2Provider.cs b/Moonlight/App/OAuth2/OAuth2Provider.cs deleted file mode 100644 index bad02d7e..00000000 --- a/Moonlight/App/OAuth2/OAuth2Provider.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; - -namespace Moonlight.App.OAuth2; - -public abstract class OAuth2Provider -{ - public OAuth2ProviderConfig Config { get; set; } - public string Url { get; set; } - public IServiceScopeFactory ServiceScopeFactory { get; set; } - public string DisplayName { get; set; } - public bool CanBeLinked { get; set; } = false; - - public abstract Task GetUrl(); - public abstract Task HandleCode(string code); - public abstract Task LinkToUser(User user, string code); -} \ No newline at end of file diff --git a/Moonlight/App/OAuth2/Providers/DiscordOAuth2Provider.cs b/Moonlight/App/OAuth2/Providers/DiscordOAuth2Provider.cs deleted file mode 100644 index 0b8e7bde..00000000 --- a/Moonlight/App/OAuth2/Providers/DiscordOAuth2Provider.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System.Text; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; -using Moonlight.App.Services; -using RestSharp; - -namespace Moonlight.App.OAuth2.Providers; - -public class DiscordOAuth2Provider : OAuth2Provider -{ - public DiscordOAuth2Provider() - { - CanBeLinked = true; - } - - public override Task GetUrl() - { - string url = $"https://discord.com/api/oauth2/authorize?client_id={Config.ClientId}" + - $"&redirect_uri={Url}/api/moonlight/oauth2/discord" + - "&response_type=code&scope=identify%20email"; - - return Task.FromResult( - url - ); - } - - public override async Task HandleCode(string code) - { - // Endpoints - - var endpoint = Url + "/api/moonlight/oauth2/discord"; - var discordUserDataEndpoint = "https://discordapp.com/api/users/@me"; - var discordEndpoint = "https://discordapp.com/api/oauth2/token"; - - // Generate access token - - using var client = new RestClient(); - var request = new RestRequest(discordEndpoint); - - request.AddParameter("client_id", Config.ClientId); - request.AddParameter("client_secret", Config.ClientSecret); - request.AddParameter("grant_type", "authorization_code"); - request.AddParameter("code", code); - request.AddParameter("redirect_uri", endpoint); - - var response = await client.ExecutePostAsync(request); - - if (!response.IsSuccessful) - { - Logger.Warn("Error verifying oauth2 code"); - Logger.Warn(response.ErrorMessage); - throw new DisplayException("An error occured while verifying oauth2 code"); - } - - // parse response - - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(response.Content!)) - ).Build(); - - var accessToken = data.GetValue("access_token"); - - // Now, we will call the discord api with our access token to get the data we need - - var getRequest = new RestRequest(discordUserDataEndpoint); - getRequest.AddHeader("Authorization", $"Bearer {accessToken}"); - - var getResponse = await client.ExecuteGetAsync(getRequest); - - if (!getResponse.IsSuccessful) - { - Logger.Warn("An unexpected error occured while fetching user data from remote api"); - Logger.Warn(getResponse.ErrorMessage); - - throw new DisplayException("An unexpected error occured while fetching user data from remote api"); - } - - // Parse response - - var getData = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(getResponse.Content!)) - ).Build(); - - var email = getData.GetValue("email"); - var id = getData.GetValue("id"); - var verified = getData.GetValue("verified"); - - if (!verified) - { - Logger.Warn("A user tried to use an unverified discord account to login", "security"); - throw new DisplayException("You can only use verified discord accounts for oauth signin"); - } - - // Handle data - - using var scope = ServiceScopeFactory.CreateScope(); - - var userRepo = scope.ServiceProvider.GetRequiredService>(); - var userService = scope.ServiceProvider.GetRequiredService(); - - if (userRepo.Get().Any(x => x.Email == email)) - { - var user = userRepo.Get().First(x => x.Email == email); - - user.DiscordId = id; - - userRepo.Update(user); - - return user; - } - else - { - await userService.Register( - email, - StringHelper.GenerateString(32), - "User", - "User" - ); - - var user = userRepo.Get().First(x => x.Email == email); - user.Status = UserStatus.DataPending; - - user.DiscordId = id; - - userRepo.Update(user); - - return user; - } - } - - public override async Task LinkToUser(User user, string code) - { - // Endpoints - - var endpoint = Url + "/api/moonlight/oauth2/discord"; - var discordUserDataEndpoint = "https://discordapp.com/api/users/@me"; - var discordEndpoint = "https://discordapp.com/api/oauth2/token"; - - // Generate access token - - using var client = new RestClient(); - var request = new RestRequest(discordEndpoint); - - request.AddParameter("client_id", Config.ClientId); - request.AddParameter("client_secret", Config.ClientSecret); - request.AddParameter("grant_type", "authorization_code"); - request.AddParameter("code", code); - request.AddParameter("redirect_uri", endpoint); - - var response = await client.ExecutePostAsync(request); - - if (!response.IsSuccessful) - { - Logger.Warn("Error verifying oauth2 code"); - Logger.Warn(response.ErrorMessage); - throw new DisplayException("An error occured while verifying oauth2 code"); - } - - // parse response - - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(response.Content!)) - ).Build(); - - var accessToken = data.GetValue("access_token"); - - // Now, we will call the discord api with our access token to get the data we need - - var getRequest = new RestRequest(discordUserDataEndpoint); - getRequest.AddHeader("Authorization", $"Bearer {accessToken}"); - - var getResponse = await client.ExecuteGetAsync(getRequest); - - if (!getResponse.IsSuccessful) - { - Logger.Warn("An unexpected error occured while fetching user data from remote api"); - Logger.Warn(getResponse.ErrorMessage); - - throw new DisplayException("An unexpected error occured while fetching user data from remote api"); - } - - // Parse response - - var getData = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(getResponse.Content!)) - ).Build(); - - var id = getData.GetValue("id"); - - // Handle data - - using var scope = ServiceScopeFactory.CreateScope(); - - var userRepo = scope.ServiceProvider.GetRequiredService>(); - - user.DiscordId = id; - - userRepo.Update(user); - } -} \ No newline at end of file diff --git a/Moonlight/App/OAuth2/Providers/GoogleOAuth2Provider.cs b/Moonlight/App/OAuth2/Providers/GoogleOAuth2Provider.cs deleted file mode 100644 index 50bb78b4..00000000 --- a/Moonlight/App/OAuth2/Providers/GoogleOAuth2Provider.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.Text; -using Moonlight.App.ApiClients.Google.Requests; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; -using Moonlight.App.Services; -using RestSharp; - -namespace Moonlight.App.OAuth2.Providers; - -public class GoogleOAuth2Provider : OAuth2Provider -{ - public GoogleOAuth2Provider() - { - CanBeLinked = false; - } - - public override Task GetUrl() - { - var endpoint = Url + "/api/moonlight/oauth2/google"; - var scope = "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"; - - return Task.FromResult( - $"https://accounts.google.com/o/oauth2/auth?response_type=code&client_id={Config.ClientId}&redirect_uri={endpoint}&scope={scope}" - ); - } - - public override async Task HandleCode(string code) - { - // Endpoints - var endpoint = Url + "/api/moonlight/oauth2/google"; - var googleEndpoint = "https://oauth2.googleapis.com/token"; - var googlePeopleEndpoint = "https://people.googleapis.com/v1/people/me"; - - // Generate access token - - // Setup payload - var payload = new GoogleOAuth2CodePayload() - { - Code = code, - RedirectUri = endpoint, - ClientId = Config.ClientId, - ClientSecret = Config.ClientSecret - }; - - using var client = new RestClient(); - var request = new RestRequest(googleEndpoint); - - request.AddBody(payload); - var response = await client.ExecutePostAsync(request); - - if (!response.IsSuccessful) - { - Logger.Warn("Error verifying oauth2 code"); - Logger.Warn(response.ErrorMessage); - throw new DisplayException("An error occured while verifying oauth2 code"); - } - - // parse response - - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(response.Content!)) - ).Build(); - - var accessToken = data.GetValue("access_token"); - - // Now, we will call the google api with our access token to get the data we need - - var getRequest = new RestRequest(googlePeopleEndpoint); - getRequest.AddHeader("Authorization", $"Bearer {accessToken}"); - getRequest.AddParameter("personFields", "names,emailAddresses"); - - var getResponse = await client.ExecuteGetAsync(getRequest); - - if (!getResponse.IsSuccessful) - { - Logger.Warn("An unexpected error occured while fetching user data from remote api"); - Logger.Warn(getResponse.ErrorMessage); - - throw new DisplayException("An unexpected error occured while fetching user data from remote api"); - } - - // Parse response - - var getData = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(getResponse.Content!)) - ).Build(); - - var firstName = getData - .GetSection("names") - .GetChildren() - .First() - .GetValue("givenName"); - - var lastName = getData - .GetSection("names") - .GetChildren() - .First() - .GetValue("familyName"); - - var email = getData - .GetSection("emailAddresses") - .GetChildren() - .First() - .GetValue("value"); - - using var scope = ServiceScopeFactory.CreateScope(); - - var userRepo = scope.ServiceProvider.GetRequiredService>(); - var userService = scope.ServiceProvider.GetRequiredService(); - - if (userRepo.Get().Any(x => x.Email == email)) - { - var user = userRepo.Get().First(x => x.Email == email); - - return user; - } - else - { - await userService.Register( - email, - StringHelper.GenerateString(32), - firstName, - lastName - ); - - var user = userRepo.Get().First(x => x.Email == email); - - return user; - } - } - - public override Task LinkToUser(User user, string code) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Perms/Permission.cs b/Moonlight/App/Perms/Permission.cs deleted file mode 100644 index affffd75..00000000 --- a/Moonlight/App/Perms/Permission.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Moonlight.App.Perms; - -public class Permission -{ - public int Index { get; set; } = 0; - public string Name { get; set; } = ""; - public string Description { get; set; } = ""; - - public static implicit operator int(Permission permission) => permission.Index; -} \ No newline at end of file diff --git a/Moonlight/App/Perms/PermissionRequired.cs b/Moonlight/App/Perms/PermissionRequired.cs deleted file mode 100644 index c6e321b8..00000000 --- a/Moonlight/App/Perms/PermissionRequired.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Moonlight.App.Perms; - -public class PermissionRequired : Attribute -{ - public string Name { get; private set; } - - public PermissionRequired(string name) - { - Name = name; - } -} \ No newline at end of file diff --git a/Moonlight/App/Perms/PermissionStorage.cs b/Moonlight/App/Perms/PermissionStorage.cs deleted file mode 100644 index f5ddaa91..00000000 --- a/Moonlight/App/Perms/PermissionStorage.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Data; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Perms; - -public class PermissionStorage -{ - public byte[] Data; - public bool IsReadyOnly; - - public PermissionStorage(byte[] data, bool isReadyOnly = false) - { - Data = data; - IsReadyOnly = isReadyOnly; - } - - public bool this[Permission permission] - { - get - { - try - { - return BitHelper.ReadBit(Data, permission.Index); - } - catch (ArgumentOutOfRangeException) - { - return false; - } - catch (Exception e) - { - Logger.Verbose("Error reading permissions. (Can be intentional)"); - Logger.Verbose(e); - return false; - } - } - set - { - if (IsReadyOnly) - throw new ReadOnlyException(); - - Data = BitHelper.WriteBit(Data, permission.Index, value); - } - } - - public bool HasAnyPermissions() - { - foreach (var permission in Permissions.GetAllPermissions()) - { - if (this[permission]) - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Perms/Permissions.cs b/Moonlight/App/Perms/Permissions.cs deleted file mode 100644 index cb6f4dab..00000000 --- a/Moonlight/App/Perms/Permissions.cs +++ /dev/null @@ -1,452 +0,0 @@ -namespace Moonlight.App.Perms; - -public static class Permissions -{ - public static Permission AdminDashboard = new() - { - Index = 0, - Name = "Admin Dashboard", - Description = "Access the main admin dashboard page" - }; - - public static Permission AdminStatistics = new() - { - Index = 1, - Name = "Admin Statistics", - Description = "View statistical information about the moonlight instance" - }; - - public static Permission AdminSysPlugins = new() - { - Index = 2, - Name = "Admin system plugins", - Description = "View and install plugins" - }; - - public static Permission AdminDomains = new() - { - Index = 4, - Name = "Admin Domains", - Description = "Manage domains in the admin area" - }; - - public static Permission AdminNewDomain = new() - { - Index = 5, - Name = "Admin New Domain", - Description = "Create a new domain in the admin area" - }; - - public static Permission AdminSharedDomains = new() - { - Index = 6, - Name = "Admin Shared Domains", - Description = "Manage shared domains in the admin area" - }; - - public static Permission AdminNewSharedDomain = new() - { - Index = 7, - Name = "Admin New Shared Domain", - Description = "Create a new shared domain in the admin area" - }; - - public static Permission AdminNodeEdit = new() - { - Index = 9, - Name = "Admin Node Edit", - Description = "Edit node settings in the admin area" - }; - - public static Permission AdminNodes = new() - { - Index = 10, - Name = "Admin Node", - Description = "Access the node management page in the admin area" - }; - - public static Permission AdminNewNode = new() - { - Index = 11, - Name = "Admin New Node", - Description = "Create a new node in the admin area" - }; - - public static Permission AdminNodeSetup = new() - { - Index = 12, - Name = "Admin Node Setup", - Description = "Set up a node in the admin area" - }; - - public static Permission AdminNodeView = new() - { - Index = 13, - Name = "Admin Node View", - Description = "View node details in the admin area" - }; - - public static Permission AdminNotificationDebugging = new() - { - Index = 14, - Name = "Admin Notification Debugging", - Description = "Manage debugging notifications in the admin area" - }; - - public static Permission AdminServerCleanup = new() - { - Index = 15, - Name = "Admin Server Cleanup", - Description = "Perform server cleanup tasks in the admin area" - }; - - public static Permission AdminServerEdit = new() - { - Index = 16, - Name = "Admin Server Edit", - Description = "Edit server settings in the admin area" - }; - - public static Permission AdminServers = new() - { - Index = 17, - Name = "Admin Server", - Description = "Access the server management page in the admin area" - }; - - public static Permission AdminServerManager = new() - { - Index = 18, - Name = "Admin Server Manager", - Description = "Manage servers in the admin area" - }; - - public static Permission AdminNewServer = new() - { - Index = 19, - Name = "Admin New Server", - Description = "Create a new server in the admin area" - }; - - public static Permission AdminServerImageEdit = new() - { - Index = 20, - Name = "Admin Server Image Edit", - Description = "Edit server image settings in the admin area" - }; - - public static Permission AdminServerImages = new() - { - Index = 21, - Name = "Admin Server Images", - Description = "Access the server image management page in the admin area" - }; - - public static Permission AdminServerImageNew = new() - { - Index = 22, - Name = "Admin Server Image New", - Description = "Create a new server image in the admin area" - }; - - public static Permission AdminServerViewAllocations = new() - { - Index = 23, - Name = "Admin Server View Allocations", - Description = "View server allocations in the admin area" - }; - - public static Permission AdminServerViewArchive = new() - { - Index = 24, - Name = "Admin Server View Archive", - Description = "View server archive in the admin area" - }; - - public static Permission AdminServerViewDebug = new() - { - Index = 25, - Name = "Admin Server View Debug", - Description = "View server debugging information in the admin area" - }; - - public static Permission AdminServerViewImage = new() - { - Index = 26, - Name = "Admin Server View Image", - Description = "View server image details in the admin area" - }; - - public static Permission AdminServerViewIndex = new() - { - Index = 27, - Name = "Admin Server View", - Description = "Access the server view page in the admin area" - }; - - public static Permission AdminServerViewOverview = new() - { - Index = 28, - Name = "Admin Server View Overview", - Description = "View server overview in the admin area" - }; - - public static Permission AdminServerViewResources = new() - { - Index = 29, - Name = "Admin Server View Resources", - Description = "View server resources in the admin area" - }; - - public static Permission AdminSubscriptionEdit = new() - { - Index = 30, - Name = "Admin Subscription Edit", - Description = "Edit subscription settings in the admin area" - }; - - public static Permission AdminSubscriptions = new() - { - Index = 31, - Name = "Admin Subscriptions", - Description = "Access the subscription management page in the admin area" - }; - - public static Permission AdminNewSubscription = new() - { - Index = 32, - Name = "Admin New Subscription", - Description = "Create a new subscription in the admin area" - }; - - public static Permission AdminSupport = new() - { - Index = 33, - Name = "Admin Support", - Description = "Access the support page in the admin area" - }; - - public static Permission AdminSupportView = new() - { - Index = 34, - Name = "Admin Support View", - Description = "View support details in the admin area" - }; - - public static Permission AdminSysConfiguration = new() - { - Index = 35, - Name = "Admin system Configuration", - Description = "Access system configuration settings in the admin area" - }; - - public static Permission AdminSysDiscordBot = new() - { - Index = 36, - Name = "Admin system Discord Bot", - Description = "Manage Discord bot settings in the admin area" - }; - - public static Permission AdminSystem = new() - { - Index = 37, - Name = "Admin system", - Description = "Access the system management page in the admin area" - }; - - public static Permission AdminSysMail = new() - { - Index = 38, - Name = "Admin system Mail", - Description = "Manage mail settings in the admin area" - }; - - public static Permission AdminSecurityMalware = new() - { - Index = 39, - Name = "Admin security Malware", - Description = "Manage malware settings in the admin area" - }; - - public static Permission AdminSysResources = new() - { - Index = 40, - Name = "Admin system Resources", - Description = "View system resources in the admin area" - }; - - public static Permission AdminSecurity = new() - { - Index = 41, - Name = "Admin Security", - Description = "View security logs in the admin area" - }; - - public static Permission AdminSysSentry = new() - { - Index = 42, - Name = "Admin system Sentry", - Description = "Manage Sentry settings in the admin area" - }; - - public static Permission AdminSysNewsEdit = new() - { - Index = 43, - Name = "Admin system News Edit", - Description = "Edit system news in the admin area" - }; - - public static Permission AdminSysNews = new() - { - Index = 44, - Name = "Admin system News", - Description = "Access the system news management page in the admin area" - }; - - public static Permission AdminSysNewsNew = new() - { - Index = 45, - Name = "Admin system News New", - Description = "Create new system news in the admin area" - }; - - public static Permission AdminUserEdit = new() - { - Index = 46, - Name = "Admin User Edit", - Description = "Edit user settings in the admin area" - }; - - public static Permission AdminUsers = new() - { - Index = 47, - Name = "Admin Users", - Description = "Access the user management page in the admin area" - }; - - public static Permission AdminNewUser = new() - { - Index = 48, - Name = "Admin New User", - Description = "Create a new user in the admin area" - }; - - public static Permission AdminUserSessions = new() - { - Index = 49, - Name = "Admin User Sessions", - Description = "View user sessions in the admin area" - }; - - public static Permission AdminUserView = new() - { - Index = 50, - Name = "Admin User View", - Description = "View user details in the admin area" - }; - - public static Permission AdminWebspaces = new() - { - Index = 51, - Name = "Admin Webspaces", - Description = "Access the webspaces management page in the admin area" - }; - - public static Permission AdminNewWebspace = new() - { - Index = 52, - Name = "Admin New Webspace", - Description = "Create a new webspace in the admin area" - }; - - public static Permission AdminWebspacesServerEdit = new() - { - Index = 53, - Name = "Admin Webspaces Server Edit", - Description = "Edit webspace server settings in the admin area" - }; - - public static Permission AdminWebspacesServers = new() - { - Index = 54, - Name = "Admin Webspaces Servers", - Description = "Access the webspace server management page in the admin area" - }; - - public static Permission AdminWebspacesServerNew = new() - { - Index = 55, - Name = "Admin Webspaces Server New", - Description = "Create a new webspace server in the admin area" - }; - - public static Permission AdminSecurityIpBans = new() - { - Index = 56, - Name = "Admin security ip bans", - Description = "Manage ip bans in the admin area" - }; - - public static Permission AdminSecurityPermissionGroups = new() - { - Index = 57, - Name = "Admin security permission groups", - Description = "View, add and delete permission groups" - }; - - public static Permission AdminSecurityLogs = new() - { - Index = 58, - Name = "Admin security logs", - Description = "View the security logs" - }; - - public static Permission AdminSecurityDdos = new() - { - Index = 59, - Name = "Admin security ddos", - Description = "Manage the integrated ddos protection" - }; - - public static Permission AdminChangelog = new() - { - Index = 60, - Name = "Admin changelog", - Description = "View the changelog" - }; - - public static Permission AdminStatisticsLive = new() - { - Index = 61, - Name = "Admin statistics live", - Description = "View the live statistics" - }; - - public static Permission? FromString(string name) - { - var type = typeof(Permissions); - - var field = type - .GetFields() - .FirstOrDefault(x => x.FieldType == typeof(Permission) && x.Name == name); - - if (field != null) - { - var value = field.GetValue(null); - return value as Permission; - } - - return null; - } - - public static Permission[] GetAllPermissions() - { - var type = typeof(Permissions); - - return type - .GetFields() - .Where(x => x.FieldType == typeof(Permission)) - .Select(x => (x.GetValue(null) as Permission)!) - .ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Plugin/MoonlightPlugin.cs b/Moonlight/App/Plugin/MoonlightPlugin.cs deleted file mode 100644 index 15fcf482..00000000 --- a/Moonlight/App/Plugin/MoonlightPlugin.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Moonlight.App.Models.Misc; -using Moonlight.App.Plugin.UI.Servers; -using Moonlight.App.Plugin.UI.Webspaces; - -namespace Moonlight.App.Plugin; - -public abstract class MoonlightPlugin -{ - public string Name { get; set; } = "N/A"; - public string Author { get; set; } = "N/A"; - public string Version { get; set; } = "N/A"; - - public Func? OnBuildServerPage { get; set; } - public Func? OnBuildWebspacePage { get; set; } - public Func? OnBuildServices { get; set; } - public Func, Task>>? OnBuildMalwareScans { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Plugin/UI/Servers/ServerPageContext.cs b/Moonlight/App/Plugin/UI/Servers/ServerPageContext.cs deleted file mode 100644 index 8179035a..00000000 --- a/Moonlight/App/Plugin/UI/Servers/ServerPageContext.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Plugin.UI.Servers; - -public class ServerPageContext -{ - public List Tabs { get; set; } = new(); - public List Settings { get; set; } = new(); - public Server Server { get; set; } - public User User { get; set; } - public string[] ImageTags { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Plugin/UI/Servers/ServerSetting.cs b/Moonlight/App/Plugin/UI/Servers/ServerSetting.cs deleted file mode 100644 index b032c66d..00000000 --- a/Moonlight/App/Plugin/UI/Servers/ServerSetting.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Moonlight.App.Plugin.UI.Servers; - -public class ServerSetting -{ - public string Name { get; set; } - public RenderFragment Component { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Plugin/UI/Servers/ServerTab.cs b/Moonlight/App/Plugin/UI/Servers/ServerTab.cs deleted file mode 100644 index 8a31e6f9..00000000 --- a/Moonlight/App/Plugin/UI/Servers/ServerTab.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Moonlight.App.Plugin.UI.Servers; - -public class ServerTab -{ - public string Name { get; set; } - public string Route { get; set; } - public string Icon { get; set; } - public RenderFragment Component { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Plugin/UI/Webspaces/WebspacePageContext.cs b/Moonlight/App/Plugin/UI/Webspaces/WebspacePageContext.cs deleted file mode 100644 index a8b8d700..00000000 --- a/Moonlight/App/Plugin/UI/Webspaces/WebspacePageContext.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Plugin.UI.Webspaces; - -public class WebspacePageContext -{ - public List Tabs { get; set; } = new(); - public User User { get; set; } - public WebSpace WebSpace { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Plugin/UI/Webspaces/WebspaceTab.cs b/Moonlight/App/Plugin/UI/Webspaces/WebspaceTab.cs deleted file mode 100644 index 70d02c88..00000000 --- a/Moonlight/App/Plugin/UI/Webspaces/WebspaceTab.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Moonlight.App.Plugin.UI.Webspaces; - -public class WebspaceTab -{ - public string Name { get; set; } = "N/A"; - public string Route { get; set; } = "/"; - public RenderFragment Component { get; set; } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/DdosAttackRepository.cs b/Moonlight/App/Repositories/DdosAttackRepository.cs deleted file mode 100644 index 2e1138c4..00000000 --- a/Moonlight/App/Repositories/DdosAttackRepository.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories; - -public class DdosAttackRepository -{ - private readonly DataContext DataContext; - - public DdosAttackRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.DdosAttacks; - } - - public DdosAttack Add(DdosAttack ddosAttack) - { - var x = DataContext.DdosAttacks.Add(ddosAttack); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(DdosAttack ddosAttack) - { - DataContext.DdosAttacks.Update(ddosAttack); - DataContext.SaveChanges(); - } - - public void Delete(DdosAttack ddosAttack) - { - DataContext.DdosAttacks.Remove(ddosAttack); - DataContext.SaveChanges(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/Domains/DomainRepository.cs b/Moonlight/App/Repositories/Domains/DomainRepository.cs deleted file mode 100644 index 6cacef2a..00000000 --- a/Moonlight/App/Repositories/Domains/DomainRepository.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories.Domains; - -public class DomainRepository : IDisposable -{ - private readonly DataContext DataContext; - - public DomainRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.Domains; - } - - public Domain Add(Domain domain) - { - var x = DataContext.Domains.Add(domain); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(Domain domain) - { - DataContext.Domains.Update(domain); - DataContext.SaveChanges(); - } - - public void Delete(Domain domain) - { - DataContext.Domains.Remove(domain); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/Domains/SharedDomainRepository.cs b/Moonlight/App/Repositories/Domains/SharedDomainRepository.cs deleted file mode 100644 index 614869ab..00000000 --- a/Moonlight/App/Repositories/Domains/SharedDomainRepository.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories.Domains; - -public class SharedDomainRepository : IDisposable -{ - private readonly DataContext DataContext; - - public SharedDomainRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.SharedDomains; - } - - public SharedDomain Add(SharedDomain sharedDomain) - { - var x = DataContext.SharedDomains.Add(sharedDomain); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(SharedDomain sharedDomain) - { - DataContext.SharedDomains.Update(sharedDomain); - DataContext.SaveChanges(); - } - - public void Delete(SharedDomain domain) - { - DataContext.SharedDomains.Remove(domain); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/ImageRepository.cs b/Moonlight/App/Repositories/ImageRepository.cs deleted file mode 100644 index e36f790c..00000000 --- a/Moonlight/App/Repositories/ImageRepository.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 ImageRepository : IDisposable -{ - private readonly DataContext DataContext; - - public ImageRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.Images; - } - - public Image Add(Image image) - { - var x = DataContext.Images.Add(image); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(Image image) - { - DataContext.Images.Update(image); - DataContext.SaveChanges(); - } - - public void Delete(Image image) - { - DataContext.Images.Remove(image); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/LoadingMessageRepository.cs b/Moonlight/App/Repositories/LoadingMessageRepository.cs deleted file mode 100644 index 8575ff74..00000000 --- a/Moonlight/App/Repositories/LoadingMessageRepository.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 LoadingMessageRepository : IDisposable -{ - private readonly DataContext DataContext; - - public LoadingMessageRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.LoadingMessages; - } - - public LoadingMessage Add(LoadingMessage loadingMessage) - { - var x = DataContext.LoadingMessages.Add(loadingMessage); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(LoadingMessage loadingMessage) - { - DataContext.LoadingMessages.Update(loadingMessage); - DataContext.SaveChanges(); - } - - public void Delete(LoadingMessage loadingMessage) - { - DataContext.LoadingMessages.Remove(loadingMessage); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/NewsEntryRepository.cs b/Moonlight/App/Repositories/NewsEntryRepository.cs deleted file mode 100644 index edd01181..00000000 --- a/Moonlight/App/Repositories/NewsEntryRepository.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 NewsEntryRepository -{ - private readonly DataContext DataContext; - - public NewsEntryRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.NewsEntries; - } - - public NewsEntry Add(NewsEntry newsEntry) - { - var x = DataContext.NewsEntries.Add(newsEntry); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(NewsEntry newsEntry) - { - DataContext.NewsEntries.Update(newsEntry); - DataContext.SaveChanges(); - } - - public void Delete(NewsEntry newsEntry) - { - DataContext.NewsEntries.Remove(newsEntry); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/NodeAllocationRepository.cs b/Moonlight/App/Repositories/NodeAllocationRepository.cs deleted file mode 100644 index 529c9fbc..00000000 --- a/Moonlight/App/Repositories/NodeAllocationRepository.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories; - -public class NodeAllocationRepository : IDisposable -{ - // This repository is ONLY for the server creation service, so allocations can be found - // using raw sql. DO NOT use this in any other component - - private readonly DataContext DataContext; - - public NodeAllocationRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.NodeAllocations; - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/NodeRepository.cs b/Moonlight/App/Repositories/NodeRepository.cs deleted file mode 100644 index 09ff9c80..00000000 --- a/Moonlight/App/Repositories/NodeRepository.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 NodeRepository : IDisposable -{ - private readonly DataContext DataContext; - - public NodeRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.Nodes; - } - - public Node Add(Node node) - { - var x = DataContext.Nodes.Add(node); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(Node node) - { - DataContext.Nodes.Update(node); - DataContext.SaveChanges(); - } - - public void Delete(Node node) - { - DataContext.Nodes.Remove(node); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/NotificationRepository.cs b/Moonlight/App/Repositories/NotificationRepository.cs deleted file mode 100644 index e635e17b..00000000 --- a/Moonlight/App/Repositories/NotificationRepository.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; -using Moonlight.App.Database.Entities.Notification; - -namespace Moonlight.App.Repositories; - -public class NotificationRepository : IDisposable -{ - private readonly DataContext DataContext; - - public NotificationRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public int RegisterNewDevice(User user) - { - var x = DataContext.NotificationClients.Add(new NotificationClient() {User = user}); - DataContext.SaveChanges(); - return x.Entity.Id; - } - - public DbSet GetClients() => DataContext.NotificationClients; - public DbSet GetActions() => DataContext.NotificationActions; - - public void Dispose() - { - DataContext.Dispose(); - } - - public void AddAction(NotificationAction action) - { - DataContext.NotificationActions.Add(action); - DataContext.SaveChanges(); - } - - public void RemoveAction(NotificationAction action) - { - DataContext.NotificationActions.Remove(action); - DataContext.SaveChanges(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/Repository.cs b/Moonlight/App/Repositories/Repository.cs deleted file mode 100644 index 1c46f6ab..00000000 --- a/Moonlight/App/Repositories/Repository.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; - -namespace Moonlight.App.Repositories; - -public class Repository where TEntity : class -{ - private readonly DataContext DataContext; - private readonly DbSet DbSet; - - public Repository(DataContext dbContext) - { - DataContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); - DbSet = DataContext.Set(); - } - - public DbSet Get() - { - return DbSet; - } - - public TEntity Add(TEntity entity) - { - var x = DbSet.Add(entity); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(TEntity entity) - { - DbSet.Update(entity); - DataContext.SaveChanges(); - } - - public void Delete(TEntity entity) - { - DbSet.Remove(entity); - DataContext.SaveChanges(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/RevokeRepository.cs b/Moonlight/App/Repositories/RevokeRepository.cs deleted file mode 100644 index 22c0c517..00000000 --- a/Moonlight/App/Repositories/RevokeRepository.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories; - -public class RevokeRepository : IDisposable -{ - private readonly DataContext DataContext; - - public RevokeRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public Revoke Add(Revoke revoke) - { - var x = DataContext.Revokes.Add(revoke); - DataContext.SaveChanges(); - return x.Entity; - } - - public DbSet Get() - { - return DataContext.Revokes; - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/Servers/ServerBackupRepository.cs b/Moonlight/App/Repositories/Servers/ServerBackupRepository.cs deleted file mode 100644 index 39f6395d..00000000 --- a/Moonlight/App/Repositories/Servers/ServerBackupRepository.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories.Servers; - -public class ServerBackupRepository : IDisposable -{ - private readonly DataContext DataContext; - - public ServerBackupRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.ServerBackups; - } - - public ServerBackup Add(ServerBackup serverBackup) - { - var x = DataContext.ServerBackups.Add(serverBackup); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(ServerBackup serverBackup) - { - DataContext.ServerBackups.Update(serverBackup); - DataContext.SaveChanges(); - } - - public void Delete(ServerBackup serverBackup) - { - DataContext.ServerBackups.Remove(serverBackup); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/Servers/ServerRepository.cs b/Moonlight/App/Repositories/Servers/ServerRepository.cs deleted file mode 100644 index 2a6784c8..00000000 --- a/Moonlight/App/Repositories/Servers/ServerRepository.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Repositories.Servers; - -public class ServerRepository : IDisposable -{ - private readonly DataContext DataContext; - - public ServerRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.Servers; - } - - public Server Add(Server server) - { - var x = DataContext.Servers.Add(server); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(Server server) - { - DataContext.Servers.Update(server); - DataContext.SaveChanges(); - } - - public void Delete(Server server) - { - DataContext.Servers.Remove(server); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/StatisticsRepository.cs b/Moonlight/App/Repositories/StatisticsRepository.cs deleted file mode 100644 index 69630abe..00000000 --- a/Moonlight/App/Repositories/StatisticsRepository.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; -using Moonlight.App.Services; - -namespace Moonlight.App.Repositories; - -public class StatisticsRepository : IDisposable -{ - private readonly DataContext DataContext; - private readonly DateTimeService DateTimeService; - - public StatisticsRepository(DataContext dataContext, DateTimeService dateTimeService) - { - DataContext = dataContext; - DateTimeService = dateTimeService; - } - - public DbSet Get() - { - return DataContext.Statistics; - } - - public StatisticsData Add(StatisticsData data) - { - var x = DataContext.Statistics.Add(data); - DataContext.SaveChanges(); - return x.Entity; - } - - public StatisticsData Add(string chart, double value) - { - return Add(new StatisticsData() {Chart = chart, Value = value, Date = DateTimeService.GetCurrent()}); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/SubscriptionRepository.cs b/Moonlight/App/Repositories/SubscriptionRepository.cs deleted file mode 100644 index 3ffb678f..00000000 --- a/Moonlight/App/Repositories/SubscriptionRepository.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 SubscriptionRepository : IDisposable -{ - private readonly DataContext DataContext; - - public SubscriptionRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.Subscriptions; - } - - public Subscription Add(Subscription subscription) - { - var x = DataContext.Subscriptions.Add(subscription); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(Subscription subscription) - { - DataContext.Subscriptions.Update(subscription); - DataContext.SaveChanges(); - } - - public void Delete(Subscription subscription) - { - DataContext.Subscriptions.Remove(subscription); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Repositories/UserRepository.cs b/Moonlight/App/Repositories/UserRepository.cs deleted file mode 100644 index e1899588..00000000 --- a/Moonlight/App/Repositories/UserRepository.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 UserRepository : IDisposable -{ - private readonly DataContext DataContext; - - public UserRepository(DataContext dataContext) - { - DataContext = dataContext; - } - - public DbSet Get() - { - return DataContext.Users; - } - - public User Add(User user) - { - var x = DataContext.Users.Add(user); - DataContext.SaveChanges(); - return x.Entity; - } - - public void Update(User user) - { - DataContext.Users.Update(user); - DataContext.SaveChanges(); - } - - public void Delete(User user) - { - DataContext.Users.Remove(user); - DataContext.SaveChanges(); - } - - public void Dispose() - { - DataContext.Dispose(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Addon/ServerAddonPluginService.cs b/Moonlight/App/Services/Addon/ServerAddonPluginService.cs deleted file mode 100644 index dc00b72a..00000000 --- a/Moonlight/App/Services/Addon/ServerAddonPluginService.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Moonlight.App.ApiClients.Modrinth; -using Moonlight.App.ApiClients.Modrinth.Resources; -using Moonlight.App.Exceptions; -using FileAccess = Moonlight.App.Helpers.Files.FileAccess; -using Version = Moonlight.App.ApiClients.Modrinth.Resources.Version; - -namespace Moonlight.App.Services.Addon; - -public class ServerAddonPluginService -{ - private readonly ModrinthApiHelper ModrinthApiHelper; - private readonly ServerService ServerService; - - public ServerAddonPluginService(ModrinthApiHelper modrinthApiHelper) - { - ModrinthApiHelper = modrinthApiHelper; - } - - public async Task GetPluginsForVersion(string version, string search = "") - { - string resource; - var filter = - "[[\"categories:\'bukkit\'\",\"categories:\'paper\'\",\"categories:\'spigot\'\"],[\"versions:" + version + "\"],[\"project_type:mod\"]]"; - - if (string.IsNullOrEmpty(search)) - resource = "search?limit=21&index=relevance&facets=" + filter; - else - resource = $"search?query={search}&limit=21&index=relevance&facets=" + filter; - - var result = await ModrinthApiHelper.Get(resource); - - return result.Hits; - } - - public async Task InstallPlugin(FileAccess fileAccess, string version, Project project, Action? onStateUpdated = null) - { - // Resolve plugin download - - onStateUpdated?.Invoke($"Resolving {project.Slug}"); - - var filter = "game_versions=[\"" + version + "\"]&loaders=[\"bukkit\", \"paper\", \"spigot\"]"; - - var versions = await ModrinthApiHelper.Get( - $"project/{project.Slug}/version?" + filter); - - if (!versions.Any()) - throw new DisplayException("No plugin download for your minecraft version found"); - - var installVersion = versions.OrderByDescending(x => x.DatePublished).First(); - var fileToInstall = installVersion.Files.First(); - - // Download plugin in a stream cached mode - - var httpClient = new HttpClient(); - var stream = await httpClient.GetStreamAsync(fileToInstall.Url); - var dataStream = new MemoryStream(1024 * 1024 * 40); - await stream.CopyToAsync(dataStream); - stream.Close(); - dataStream.Position = 0; - - // Install plugin - - await fileAccess.SetDir("/"); - - try - { - await fileAccess.MkDir("plugins"); - } - catch (Exception) - { - // Ignored - } - - await fileAccess.SetDir("plugins"); - - onStateUpdated?.Invoke($"Installing {project.Slug}"); - await fileAccess.Upload(fileToInstall.Filename, dataStream); - - await dataStream.DisposeAsync(); - - //TODO: At some point of time, create a dependency resolver - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Background/CleanupService.cs b/Moonlight/App/Services/Background/CleanupService.cs deleted file mode 100644 index 0492c5f4..00000000 --- a/Moonlight/App/Services/Background/CleanupService.cs +++ /dev/null @@ -1,245 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using MineStatLib; -using Moonlight.App.ApiClients.Daemon.Resources; -using Moonlight.App.ApiClients.Wings; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; -using Newtonsoft.Json; - -namespace Moonlight.App.Services.Background; - -public class CleanupService -{ - #region Stats - public DateTime StartedAt { get; private set; } - public DateTime CompletedAt { get; private set; } - public int ServersCleaned { get; private set; } - public int CleanupsPerformed { get; private set; } - public int ServersRunning { get; private set; } - public bool IsRunning { get; private set; } - #endregion - - private readonly ConfigService ConfigService; - private readonly DateTimeService DateTimeService; - private readonly EventSystem Event; - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly PeriodicTimer Timer; - - public CleanupService( - ConfigService configService, - IServiceScopeFactory serviceScopeFactory, - DateTimeService dateTimeService, - EventSystem eventSystem) - { - ServiceScopeFactory = serviceScopeFactory; - DateTimeService = dateTimeService; - ConfigService = configService; - Event = eventSystem; - - StartedAt = DateTimeService.GetCurrent(); - CompletedAt = DateTimeService.GetCurrent(); - IsRunning = false; - - var config = ConfigService.Get().Moonlight.Cleanup; - - if (!config.Enable || ConfigService.DebugMode) - { - Logger.Info("Disabling cleanup service"); - return; - } - - Timer = new(TimeSpan.FromMinutes(config.Wait)); - - Task.Run(Run); - } - - private async Task Run() - { - while (await Timer.WaitForNextTickAsync()) - { - IsRunning = true; - - using var scope = ServiceScopeFactory.CreateScope(); - var config = ConfigService.Get().Moonlight.Cleanup; - - var maxCpu = config.Cpu; - var minMemory = config.Memory; - var maxUptime = config.Uptime; - var minUptime = config.MinUptime; - - var nodeRepository = scope.ServiceProvider.GetRequiredService(); - var nodeService = scope.ServiceProvider.GetRequiredService(); - - var nodes = nodeRepository - .Get() - .ToArray(); - - foreach (var node in nodes) - { - try - { - var cpuMetrics = await nodeService.GetCpuMetrics(node); - var memoryMetrics = await nodeService.GetMemoryMetrics(node); - - bool executeCleanup; - - if (cpuMetrics.CpuUsage > maxCpu) - { - Logger.Debug($"{node.Name}: CPU Usage is too high"); - Logger.Debug($"Usage: {cpuMetrics.CpuUsage}"); - Logger.Debug($"Max CPU: {maxCpu}"); - executeCleanup = true; - } - else if (ByteSizeValue.FromKiloBytes(memoryMetrics.Total).MegaBytes - ByteSizeValue.FromKiloBytes(memoryMetrics.Used).MegaBytes < - minMemory) - { - Logger.Debug($"{node.Name}: Memory Usage is too high"); - Logger.Debug($"Memory (Total): {ByteSizeValue.FromKiloBytes(memoryMetrics.Total).MegaBytes}"); - Logger.Debug($"Memory (Used): {ByteSizeValue.FromKiloBytes(memoryMetrics.Used).MegaBytes}"); - Logger.Debug( - $"Memory (Free): {ByteSizeValue.FromKiloBytes(memoryMetrics.Total).MegaBytes - ByteSizeValue.FromKiloBytes(memoryMetrics.Used).MegaBytes}"); - Logger.Debug($"Min Memory: {minMemory}"); - executeCleanup = true; - } - else - executeCleanup = false; - - if (executeCleanup) - { - var dockerMetrics = await nodeService.GetDockerMetrics(node); - - var serverRepository = scope.ServiceProvider.GetRequiredService(); - var imageRepository = scope.ServiceProvider.GetRequiredService(); - - var images = imageRepository - .Get() - .ToArray(); - - var imagesWithFlag = images - .Where(x => - (JsonConvert.DeserializeObject(x.TagsJson) ?? Array.Empty()).Contains("cleanup") - ) - .ToArray(); - - var containerMappedToServers = new Dictionary(); - - foreach (var container in dockerMetrics.Containers) - { - if (Guid.TryParse(container.Name, out Guid uuid)) - { - var server = serverRepository - .Get() - .Include(x => x.Image) - .Include(x => x.MainAllocation) - .Include(x => x.Variables) - .FirstOrDefault(x => x.Uuid == uuid); - - if (server != null && imagesWithFlag.Any(y => y.Id == server.Image.Id)) - { - containerMappedToServers.Add(container, server); - } - } - } - - var serverService = scope.ServiceProvider.GetRequiredService(); - - foreach (var containerMapped in containerMappedToServers) - { - var server = containerMapped.Value; - - try - { - var stats = await serverService.GetDetails(server); - - if (server.IsCleanupException) - { - if (stats.Utilization.Uptime > TimeSpan.FromHours(maxUptime).TotalMilliseconds) - { - var players = GetPlayers(node, server.MainAllocation); - - if (players == 0) - { - Logger.Debug($"Restarted {server.Name} ({server.Uuid}) on node {node.Name}"); - await serverService.SetPowerState(server, PowerSignal.Restart); - - ServersCleaned++; - } - else - { - ServersRunning++; - } - - await Event.Emit("cleanup.updated"); - } - } - else - { - if (stats.Utilization.Uptime > TimeSpan.FromMinutes(minUptime).TotalMilliseconds) - { - var players = GetPlayers(node, server.MainAllocation); - - if (players < 1) - { - var j2SVar = server.Variables.FirstOrDefault(x => x.Key == "J2S"); - var handleJ2S = j2SVar != null && j2SVar.Value == "1"; - - if (handleJ2S) - { - Logger.Debug($"Restarted (cleanup) {server.Name} ({server.Uuid}) on node {node.Name}"); - await serverService.SetPowerState(server, PowerSignal.Restart); - } - else - { - Logger.Debug($"Stopped {server.Name} ({server.Uuid}) on node {node.Name}"); - await serverService.SetPowerState(server, PowerSignal.Stop); - } - - ServersCleaned++; - } - else - { - ServersRunning++; - } - - await Event.Emit("cleanup.updated"); - } - } - } - catch (Exception e) - { - Logger.Warn($"Error checking server {server.Name} ({server.Id})"); - Logger.Warn(e); - } - } - } - } - catch (Exception e) - { - Logger.Error($"Error performing cleanup on node {node.Name} ({node.Id})"); - Logger.Error(e); - } - } - - IsRunning = false; - CleanupsPerformed++; - await Event.Emit("cleanup.updated"); - } - } - - private int GetPlayers(Node node, NodeAllocation allocation) - { - var ms = new MineStat(node.Fqdn, (ushort)allocation.Port); - - //TODO: Add fake player check - - if (ms.ServerUp) - { - return ms.CurrentPlayersInt; - } - - return -1; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Background/DdosProtectionService.cs b/Moonlight/App/Services/Background/DdosProtectionService.cs deleted file mode 100644 index e11d5008..00000000 --- a/Moonlight/App/Services/Background/DdosProtectionService.cs +++ /dev/null @@ -1,129 +0,0 @@ -using Moonlight.App.ApiClients.Daemon; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Background; - -public class DdosProtectionService -{ - private readonly IServiceScopeFactory ServiceScopeFactory; - - public DdosProtectionService(IServiceScopeFactory serviceScopeFactory) - { - ServiceScopeFactory = serviceScopeFactory; - - Task.Run(UnBlocker); - } - - private async Task UnBlocker() - { - var periodicTimer = new PeriodicTimer(TimeSpan.FromMinutes(5)); - - while (true) - { - using var scope = ServiceScopeFactory.CreateScope(); - var blocklistIpRepo = scope.ServiceProvider.GetRequiredService>(); - - var ips = blocklistIpRepo - .Get() - .ToArray(); - - foreach (var ip in ips) - { - if (DateTime.UtcNow > ip.ExpiresAt) - { - blocklistIpRepo.Delete(ip); - } - } - - var newCount = blocklistIpRepo - .Get() - .Count(); - - if (newCount != ips.Length) - { - await RebuildNodeFirewalls(); - } - - await periodicTimer.WaitForNextTickAsync(); - } - } - - public async Task RebuildNodeFirewalls() - { - using var scope = ServiceScopeFactory.CreateScope(); - var blocklistIpRepo = scope.ServiceProvider.GetRequiredService>(); - var nodeRepo = scope.ServiceProvider.GetRequiredService>(); - var nodeService = scope.ServiceProvider.GetRequiredService(); - - var ips = blocklistIpRepo - .Get() - .Select(x => x.Ip) - .ToArray(); - - foreach (var node in nodeRepo.Get().ToArray()) - { - try - { - await nodeService.RebuildFirewall(node, ips); - } - catch (Exception e) - { - Logger.Warn($"Error rebuilding firewall on node {node.Name}"); - Logger.Warn(e); - } - } - } - - public async Task ProcessDdosSignal(string ip, long packets) - { - using var scope = ServiceScopeFactory.CreateScope(); - - var blocklistRepo = scope.ServiceProvider.GetRequiredService>(); - var whitelistRepo = scope.ServiceProvider.GetRequiredService>(); - - var whitelistIps = whitelistRepo.Get().ToArray(); - - if(whitelistIps.Any(x => x.Ip == ip)) - return; - - var blocklistIps = blocklistRepo.Get().ToArray(); - - if(blocklistIps.Any(x => x.Ip == ip)) - return; - - await BlocklistIp(ip, packets); - } - - public async Task BlocklistIp(string ip, long packets) - { - using var scope = ServiceScopeFactory.CreateScope(); - var blocklistRepo = scope.ServiceProvider.GetRequiredService>(); - var configService = scope.ServiceProvider.GetRequiredService(); - var eventSystem = scope.ServiceProvider.GetRequiredService(); - - var blocklistIp = blocklistRepo.Add(new() - { - Ip = ip, - Packets = packets, - ExpiresAt = DateTime.UtcNow.AddMinutes(configService.Get().Moonlight.Security.BlockIpDuration), - CreatedAt = DateTime.UtcNow - }); - - await RebuildNodeFirewalls(); - await eventSystem.Emit("ddos.add", blocklistIp); - } - - public async Task UnBlocklistIp(string ip) - { - using var scope = ServiceScopeFactory.CreateScope(); - var blocklistRepo = scope.ServiceProvider.GetRequiredService>(); - - var blocklist = blocklistRepo.Get().First(x => x.Ip == ip); - blocklistRepo.Delete(blocklist); - - await RebuildNodeFirewalls(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Background/DiscordNotificationService.cs b/Moonlight/App/Services/Background/DiscordNotificationService.cs deleted file mode 100644 index 15d810ee..00000000 --- a/Moonlight/App/Services/Background/DiscordNotificationService.cs +++ /dev/null @@ -1,129 +0,0 @@ -using Discord; -using Discord.Webhook; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Helpers; -using Moonlight.App.Services.Files; - -namespace Moonlight.App.Services.Background; - -public class DiscordNotificationService -{ - private readonly EventSystem Event; - private readonly ResourceService ResourceService; - private readonly DiscordWebhookClient Client; - private readonly string AppUrl; - - public DiscordNotificationService( - EventSystem eventSystem, - ConfigService configService, - ResourceService resourceService) - { - Event = eventSystem; - ResourceService = resourceService; - - var config = configService.Get().Moonlight.DiscordNotifications; - - if (config.Enable) - { - Logger.Info("Discord notifications enabled"); - - Client = new(config.WebHook); - AppUrl = configService.Get().Moonlight.AppUrl; - - Event.On("tickets.new", this, OnNewTicket); - Event.On("tickets.status", this, OnTicketStatusUpdated); - Event.On("user.rating", this, OnUserRated); - Event.On("billing.completed", this, OnBillingCompleted); - Event.On("ddos.add", this, OnIpBlockListed); - } - else - { - Logger.Info("Discord notifications disabled"); - } - } - - private async Task OnTicketStatusUpdated(Ticket ticket) - { - await SendNotification("", builder => - { - builder.Title = "Ticket status has been updated"; - builder.AddField("Issue topic", ticket.IssueTopic); - builder.AddField("Status", ticket.Status); - - if (ticket.AssignedTo != null) - { - builder.AddField("Assigned to", $"{ticket.AssignedTo.FirstName} {ticket.AssignedTo.LastName}"); - } - - builder.Color = Color.Green; - builder.Url = $"{AppUrl}/admin/support/view/{ticket.Id}"; - }); - } - - private async Task OnIpBlockListed(BlocklistIp blocklistIp) - { - await SendNotification("", builder => - { - builder.Color = Color.Red; - builder.Title = "New ddos attack detected"; - - builder.AddField("IP", blocklistIp.Ip); - builder.AddField("Packets", blocklistIp.Packets); - }); - } - - private async Task OnBillingCompleted(User user) - { - await SendNotification("", builder => - { - builder.Color = Color.Red; - builder.Title = "New payment received"; - - builder.AddField("User", user.Email); - builder.AddField("Firstname", user.FirstName); - builder.AddField("Lastname", user.LastName); - builder.AddField("Amount", user.CurrentSubscription!.Price); - builder.AddField("Currency", user.CurrentSubscription!.Currency); - }); - } - - private async Task OnUserRated(User user) - { - await SendNotification("", builder => - { - builder.Color = Color.Gold; - builder.Title = "New user rating"; - - builder.AddField("User", user.Email); - builder.AddField("Firstname", user.FirstName); - builder.AddField("Lastname", user.LastName); - builder.AddField("Rating", new string('⭐', user.Rating)); - }); - } - - private async Task OnNewTicket(Ticket ticket) - { - await SendNotification("", builder => - { - builder.Title = "A new ticket has been created"; - builder.AddField("Issue topic", ticket.IssueTopic); - builder.Color = Color.Green; - builder.Url = $"{AppUrl}/admin/support/view/{ticket.Id}"; - }); - } - - private async Task SendNotification(string content, Action? embed = null) - { - var e = new EmbedBuilder(); - embed?.Invoke(e); - - await Client.SendMessageAsync( - content, - false, - new []{e.Build()}, - "Moonlight Notification", - ResourceService.Image("logo.svg") - ); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Background/MalwareBackgroundScanService.cs b/Moonlight/App/Services/Background/MalwareBackgroundScanService.cs deleted file mode 100644 index 282fa275..00000000 --- a/Moonlight/App/Services/Background/MalwareBackgroundScanService.cs +++ /dev/null @@ -1,148 +0,0 @@ -using Moonlight.App.ApiClients.Daemon.Resources; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Background; - -public class MalwareBackgroundScanService -{ - private readonly EventSystem Event; - private readonly IServiceScopeFactory ServiceScopeFactory; - - public bool IsRunning => !ScanTask?.IsCompleted ?? false; - public bool ScanAllServers { get; set; } - public readonly Dictionary ScanResults; - public string Status { get; private set; } = "N/A"; - - private Task? ScanTask; - - public MalwareBackgroundScanService(IServiceScopeFactory serviceScopeFactory, EventSystem eventSystem) - { - ServiceScopeFactory = serviceScopeFactory; - Event = eventSystem; - ScanResults = new(); - } - - public Task Start() - { - if (IsRunning) - throw new DisplayException("Malware scan is already running"); - - ScanTask = Task.Run(Run); - - return Task.CompletedTask; - } - - private async Task Run() - { - // Clean results - Status = "Clearing last results"; - await Event.Emit("malwareScan.status", IsRunning); - - lock (ScanResults) - ScanResults.Clear(); - - await Event.Emit("malwareScan.result"); - - using var scope = ServiceScopeFactory.CreateScope(); - var serverRepo = scope.ServiceProvider.GetRequiredService>(); - var malwareScanService = scope.ServiceProvider.GetRequiredService(); - - Status = "Fetching servers to scan"; - await Event.Emit("malwareScan.status", IsRunning); - - Server[] servers; - - if (ScanAllServers) - servers = serverRepo.Get().ToArray(); - else - servers = await GetOnlineServers(); - - // Perform scan - - int i = 1; - foreach (var server in servers) - { - Status = $"[{i} / {servers.Length}] Scanning server {server.Name}"; - await Event.Emit("malwareScan.status", IsRunning); - - var result = await malwareScanService.Perform(server); - - if (result != null) - { - lock (ScanResults) - { - ScanResults.Add(server, result); - } - - await Event.Emit("malwareScan.result", server); - } - - i++; - } - - Task.Run(async () => // Because we use the task as the status indicator we need to notify the event system in a new task - { - await Task.Delay(TimeSpan.FromSeconds(5)); - await Event.Emit("malwareScan.status", IsRunning); - }); - } - - private async Task GetOnlineServers() - { - using var scope = ServiceScopeFactory.CreateScope(); - - // Load services from di scope - var nodeRepo = scope.ServiceProvider.GetRequiredService>(); - var serverRepo = scope.ServiceProvider.GetRequiredService>(); - var nodeService = scope.ServiceProvider.GetRequiredService(); - - var nodes = nodeRepo.Get().ToArray(); - var containers = new List(); - - // Fetch and summarize all running containers from all nodes - Logger.Verbose("Fetching and summarizing all running containers from all nodes"); - - Status = "Fetching and summarizing all running containers from all nodes"; - await Event.Emit("malwareScan.status", IsRunning); - - foreach (var node in nodes) - { - var metrics = await nodeService.GetDockerMetrics(node); - - foreach (var container in metrics.Containers) - { - containers.Add(container); - } - } - - var containerServerMapped = new Dictionary(); - - // Map all the containers to their corresponding server if existing - Logger.Verbose("Mapping all the containers to their corresponding server if existing"); - - Status = "Mapping all the containers to their corresponding server if existing"; - await Event.Emit("malwareScan.status", IsRunning); - - foreach (var container in containers) - { - if (Guid.TryParse(container.Name, out Guid uuid)) - { - var server = serverRepo - .Get() - .FirstOrDefault(x => x.Uuid == uuid); - - if(server == null) - continue; - - containerServerMapped.Add(server, container); - } - } - - return containerServerMapped.Keys.ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Background/TelemetryService.cs b/Moonlight/App/Services/Background/TelemetryService.cs deleted file mode 100644 index 53e1131f..00000000 --- a/Moonlight/App/Services/Background/TelemetryService.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Moonlight.App.ApiClients.Telemetry; -using Moonlight.App.ApiClients.Telemetry.Requests; -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Background; - -public class TelemetryService -{ - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly ConfigService ConfigService; - - public TelemetryService( - ConfigService configService, - IServiceScopeFactory serviceScopeFactory) - { - ServiceScopeFactory = serviceScopeFactory; - ConfigService = configService; - - if(!ConfigService.DebugMode) - Task.Run(Run); - } - - private async Task Run() - { - var timer = new PeriodicTimer(TimeSpan.FromMinutes(15)); - - while (true) - { - using var scope = ServiceScopeFactory.CreateScope(); - - var serversRepo = scope.ServiceProvider.GetRequiredService>(); - var nodesRepo = scope.ServiceProvider.GetRequiredService>(); - var usersRepo = scope.ServiceProvider.GetRequiredService>(); - var webspacesRepo = scope.ServiceProvider.GetRequiredService>(); - var databaseRepo = scope.ServiceProvider.GetRequiredService>(); - - var apiHelper = scope.ServiceProvider.GetRequiredService(); - - try - { - await apiHelper.Post("telemetry", new TelemetryData() - { - Servers = serversRepo.Get().Count(), - Databases = databaseRepo.Get().Count(), - Nodes = nodesRepo.Get().Count(), - Users = usersRepo.Get().Count(), - Webspaces = webspacesRepo.Get().Count(), - AppUrl = ConfigService.Get().Moonlight.AppUrl - }); - } - catch (Exception e) - { - Logger.Warn("Error sending telemetry"); - Logger.Warn(e); - } - - await timer.WaitForNextTickAsync(); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Background/TempMailService.cs b/Moonlight/App/Services/Background/TempMailService.cs deleted file mode 100644 index 57832d42..00000000 --- a/Moonlight/App/Services/Background/TempMailService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Net.Mail; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Services.Background; - -public class TempMailService -{ - private string[] Domains = Array.Empty(); - - public TempMailService() - { - Task.Run(Init); - } - - private async Task Init() - { - var client = new HttpClient(); - var text = await client.GetStringAsync("https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf"); - - Domains = text - .Split("\n") - .Select(x => x.Trim()) - .ToArray(); - - Logger.Info($"Fetched {Domains.Length} temp mail domains"); - } - - public Task IsTempMail(string mail) - { - var address = new MailAddress(mail); - - if (Domains.Contains(address.Host)) - return Task.FromResult(true); - - return Task.FromResult(false); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/BillingService.cs b/Moonlight/App/Services/BillingService.cs deleted file mode 100644 index 9b13af1a..00000000 --- a/Moonlight/App/Services/BillingService.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System.Globalization; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Exceptions; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Mail; -using Moonlight.App.Services.Sessions; -using Stripe.Checkout; -using Subscription = Moonlight.App.Database.Entities.Subscription; - -namespace Moonlight.App.Services; - -public class BillingService -{ - private readonly ConfigService ConfigService; - private readonly SubscriptionService SubscriptionService; - private readonly Repository SubscriptionRepository; - private readonly SessionServerService SessionServerService; - private readonly EventSystem Event; - private readonly MailService MailService; - - public BillingService( - ConfigService configService, - SubscriptionService subscriptionService, - Repository subscriptionRepository, - EventSystem eventSystem, - SessionServerService sessionServerService, - MailService mailService) - { - ConfigService = configService; - SubscriptionService = subscriptionService; - SubscriptionRepository = subscriptionRepository; - Event = eventSystem; - SessionServerService = sessionServerService; - MailService = mailService; - } - - public async Task StartCheckout(User user, Subscription subscription) - { - var appUrl = ConfigService.Get().Moonlight.AppUrl; - var controllerUrl = appUrl + "/api/moonlight/billing"; - - var options = new SessionCreateOptions() - { - LineItems = new() - { - new() - { - Price = subscription.StripePriceId, - Quantity = 1 - } - }, - Mode = "payment", - SuccessUrl = controllerUrl + "/success", - CancelUrl = controllerUrl + "/cancel", - AutomaticTax = new SessionAutomaticTaxOptions() - { - Enabled = true - }, - CustomerEmail = user.Email.ToLower(), - Metadata = new() - { - { - "productId", - subscription.StripeProductId - } - } - }; - - var service = new SessionService(); - - var session = await service.CreateAsync(options); - - return session.Url; - } - public async Task CompleteCheckout(User user) - { - var sessionService = new SessionService(); - - var sessionsPerUser = await sessionService.ListAsync(new SessionListOptions() - { - CustomerDetails = new() - { - Email = user.Email - } - }); - - var latestCompletedSession = sessionsPerUser - .Where(x => x.Status == "complete") - .Where(x => x.PaymentStatus == "paid") - .MaxBy(x => x.Created); - - if (latestCompletedSession == null) - throw new DisplayException("No completed session found"); - - var productId = latestCompletedSession.Metadata["productId"]; - - var subscription = SubscriptionRepository - .Get() - .FirstOrDefault(x => x.StripeProductId == productId); - - if (subscription == null) - throw new DisplayException("No subscription for this product found"); - - // if (await SubscriptionService.GetActiveSubscription(user) != null) - // { - // return; - // } - - await SubscriptionService.SetActiveSubscription(user, subscription); - - await MailService.SendMail(user, "checkoutComplete", values => - { - values.Add("SubscriptionName", subscription.Name); - values.Add("SubscriptionPrice", subscription.Price - .ToString(CultureInfo.InvariantCulture)); - values.Add("SubscriptionCurrency", subscription.Currency - .ToString()); - values.Add("SubscriptionDuration", subscription.Duration - .ToString(CultureInfo.InvariantCulture)); - }); - - await Event.Emit("billing.completed", user); - - await SessionServerService.ReloadUserSessions(user); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/ConfigService.cs b/Moonlight/App/Services/ConfigService.cs deleted file mode 100644 index 3be2fa22..00000000 --- a/Moonlight/App/Services/ConfigService.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Moonlight.App.Configuration; -using Moonlight.App.Helpers; -using Moonlight.App.Services.Files; -using Newtonsoft.Json; - -namespace Moonlight.App.Services; - -public class ConfigService -{ - private readonly StorageService StorageService; - private readonly string Path; - private ConfigV1 Configuration; - - public bool DebugMode { get; private set; } = false; - public bool SqlDebugMode { get; private set; } = false; - - public ConfigService(StorageService storageService) - { - StorageService = storageService; - - if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ML_CONFIG_PATH"))) - Path = Environment.GetEnvironmentVariable("ML_CONFIG_PATH")!; - else - Path = PathBuilder.File("storage", "configs", "config.json"); - - Reload(); - - // Env vars - var debugVar = Environment.GetEnvironmentVariable("ML_DEBUG"); - - if (debugVar != null) - DebugMode = bool.Parse(debugVar); - - if (DebugMode) - Logger.Debug("Debug mode enabled"); - - var sqlDebugVar = Environment.GetEnvironmentVariable("ML_SQL_DEBUG"); - - if (sqlDebugVar != null) - SqlDebugMode = bool.Parse(sqlDebugVar); - - if (SqlDebugMode) - Logger.Debug("Sql debug mode enabled"); - } - - public void Reload() - { - if (!File.Exists(Path)) - { - File.WriteAllText(Path, "{}"); - } - - Configuration = JsonConvert.DeserializeObject( - File.ReadAllText(Path) - ) ?? new ConfigV1(); - - File.WriteAllText(Path, JsonConvert.SerializeObject(Configuration, Formatting.Indented)); - } - - public void Save(ConfigV1 configV1) - { - Configuration = configV1; - Save(); - } - - public void Save() - { - if (!File.Exists(Path)) - { - File.WriteAllText(Path, "{}"); - } - - File.WriteAllText(Path, JsonConvert.SerializeObject(Configuration, Formatting.Indented)); - - Reload(); - } - - public ConfigV1 Get() - { - return Configuration; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DateTimeService.cs b/Moonlight/App/Services/DateTimeService.cs deleted file mode 100644 index 40b0231e..00000000 --- a/Moonlight/App/Services/DateTimeService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Moonlight.App.Helpers; - -namespace Moonlight.App.Services; - -public class DateTimeService -{ - public long GetCurrentUnix() - { - return new DateTimeOffset(GetCurrent()).ToUnixTimeMilliseconds(); - } - - public long GetCurrentUnixSeconds() - { - return new DateTimeOffset(GetCurrent()).ToUnixTimeSeconds(); - } - - public DateTime GetCurrent() - { - return DateTime.UtcNow; - } - - public string GetDate() - { - return Formatter.FormatDateOnly(GetCurrent()); - } - - public string GetDateTime() - { - return Formatter.FormatDate(GetCurrent()); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/BaseModule.cs b/Moonlight/App/Services/DiscordBot/BaseModule.cs deleted file mode 100644 index 17e2360e..00000000 --- a/Moonlight/App/Services/DiscordBot/BaseModule.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Discord.WebSocket; - -namespace Moonlight.App.Services.DiscordBot; - -public abstract class BaseModule -{ - public DiscordSocketClient Client { get; set; } - public ConfigService ConfigService { get; set; } - public IServiceScope Scope { get; set; } - - public abstract Task RegisterCommands(); - - public BaseModule( - DiscordSocketClient client, - ConfigService configService, - IServiceScope scope) - { - Client = client; - ConfigService = configService; - Scope = scope; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Commands/ClearChannelCommand.cs b/Moonlight/App/Services/DiscordBot/Commands/ClearChannelCommand.cs deleted file mode 100644 index 75bffe64..00000000 --- a/Moonlight/App/Services/DiscordBot/Commands/ClearChannelCommand.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Discord; -using Discord.WebSocket; - -namespace Moonlight.App.Services.DiscordBot.Commands; - -public class ClearChannelCommand : BaseModule -{ - public ClearChannelCommand(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { - Client.SlashCommandExecuted += ClearChannel; - Client.ButtonExecuted += ButtonHandler; - } - - private async Task ClearChannel(SocketSlashCommand command) - { - EmbedBuilder embed; - if(command.User.IsBot) return; - if(command.CommandName != "clear") return; - if(command.IsDMInteraction) - { - embed = new EmbedBuilder() - .WithAuthor($"Clear DM's > {command.User.Username}", Client.CurrentUser.GetAvatarUrl()) - .WithDescription($"Please press the button below. **This can't be undone!**") - .WithColor(Color.Purple); - - var button = new ComponentBuilder() - .WithButton("Clear", emote: new Emoji("🚮"), style: ButtonStyle.Danger, customId: $"clearDM"); - - await command.RespondAsync(embed: embed.Build(), components: button.Build()); - } - else - { - embed = new EmbedBuilder() - .WithAuthor($"Error > {command.User.Username}", Client.CurrentUser.GetAvatarUrl()) - .WithDescription($"Please use this Command here in your DM's") - .WithColor(Color.Red); - - await command.RespondAsync(embed: embed.Build(),ephemeral: true); - } - } - - private async Task ButtonHandler(SocketMessageComponent component) - { - if (component.Data.CustomId == "clearDM") - { - var button = new ComponentBuilder() - .WithButton("Clear", emote: new Emoji("🚮"), style: ButtonStyle.Danger, customId: $"clearDM", disabled: true); - - await component.RespondAsync("Please wait...", ephemeral: true); - - ulong userId = component.User.Id; - - int messagesDeleted = 0; - var dmChannel = await component.User.CreateDMChannelAsync(); - IEnumerable messages = await dmChannel.GetMessagesAsync().FlattenAsync(); - - foreach (var message in messages) - { - if (message.Author.IsBot) - { - await message.DeleteAsync(); - await Task.Delay(500); - messagesDeleted++; - } - } - - var embed = new EmbedBuilder() - .WithAuthor("Messages Delete!", Client.CurrentUser.GetAvatarUrl()) - .WithDescription($"I deleted {messagesDeleted} messages.") - .WithColor(Color.Green); - - IUserMessage response = await dmChannel.SendMessageAsync(embed: embed.Build()); - await Task.Delay(TimeSpan.FromSeconds(5)); - await response.DeleteAsync(); - } - } - public async override Task RegisterCommands() - { - var command = new SlashCommandBuilder() - .WithName("clear") - .WithDescription("Clear your DM Channel"); - - await Client.CreateGlobalApplicationCommandAsync(command.Build()); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs b/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs deleted file mode 100644 index b2856331..00000000 --- a/Moonlight/App/Services/DiscordBot/Commands/ServerListCommand.cs +++ /dev/null @@ -1,91 +0,0 @@ -using Discord; -using Discord.WebSocket; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; - - -namespace Moonlight.App.Services.DiscordBot.Commands; - -public class ServerListCommand : BaseModule -{ - public ServerListCommand(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { - Client.SlashCommandExecuted += ServerMenuCommand; - } - private async Task ServerMenuCommand(SocketSlashCommand command) - { - EmbedBuilder embed; - ComponentBuilder components; - var dcs = Scope.ServiceProvider.GetRequiredService(); - - if (command.User.IsBot) return; - if (command.CommandName != "servers") return; - var usersRepo = Scope.ServiceProvider.GetRequiredService(); - var user = usersRepo.Get().FirstOrDefault(x => x.DiscordId == command.User.Id); - //var user = usersRepo.Get().FirstOrDefault(x => x.Id == 1); - - if (user == null) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, command.User); - components = new ComponentBuilder(); - components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.Get().Moonlight.AppUrl); - - await command.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true); - return; - } - var serversRepo = Scope.ServiceProvider.GetRequiredService(); - var servers = serversRepo.Get().Include(x => x.Owner).Where(x => x.Owner.Id == user.Id).ToList(); - - var selectOptions = new List(); - - foreach (var server in servers.Take(25)) - { - selectOptions.Add(new SelectMenuOptionBuilder() - .WithLabel($"{server.Id} - {server.Name}") - .WithEmote(Emote.Parse("<:server3:968614410228736070>")) - .WithValue(server.Id.ToString())); - } - - components = new ComponentBuilder(); - - components.WithSelectMenu( - "ServerSelectorList", - selectOptions, - "Select the server you want to edit."); - - components.WithButton("Panel", - emote: Emote.Parse(""), - style: ButtonStyle.Link, - url: $"{ConfigService.Get().Moonlight.AppUrl}"); - - if (servers.Count > 25) - { - components.WithButton("Previous-page", - emote: Emote.Parse("<:arrowLeft:1101182242908278817>"), - style: ButtonStyle.Secondary, - customId:"SmPreviousPage.0", - disabled: true); - - components.WithButton("Next-page", - emote: Emote.Parse("<:arrowRight:1101182245408096336>"), - style: ButtonStyle.Secondary, - customId:"SmNextPage.0", - disabled: false); - } - - embed = dcs.EmbedBuilderModule.StandardEmbed("Server Manager", Color.Blue, command.User); - - - await command.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true); - } - - public override async Task RegisterCommands() - { - var command = new SlashCommandBuilder() - .WithName("servers") - .WithDescription("Creates a list from all your servers"); - - await Client.CreateGlobalApplicationCommandAsync(command.Build()); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/DiscordBotService.cs b/Moonlight/App/Services/DiscordBot/DiscordBotService.cs deleted file mode 100644 index 21c7b711..00000000 --- a/Moonlight/App/Services/DiscordBot/DiscordBotService.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System.Diagnostics; -using Discord; -using Discord.WebSocket; -using Moonlight.App.Helpers; -using Moonlight.App.Services.DiscordBot.Commands; -using Moonlight.App.Services.DiscordBot.Modules; - -namespace Moonlight.App.Services.DiscordBot; - -public class DiscordBotService -{ - public static bool MaintenanceMode = false; - - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly ConfigService ConfigService; - - private IServiceScope ServiceScope; - - private readonly DiscordSocketClient Client; - - // References - public RemoveCommandsModule RemoveCommandsModule { get; private set; } - public PermissionCheckModule PermissionCheckModule { get; private set; } - public EmbedBuilderModule EmbedBuilderModule { get; private set; } - public ServerListCommand ServerListCommand { get; private set; } - public ServerListComponentHandlerModule ServerListComponentHandlerModule { get; private set; } - public ActivityStatusModule ActivityStatusModule { get; private set; } - public CommonComponentHandlerModule CommonComponentHandlerModule { get; private set; } - public ClearChannelCommand ClearChannelCommand { get; private set; } - -public DiscordBotService( - IServiceScopeFactory serviceScopeFactory, - ConfigService configService) - { - ServiceScopeFactory = serviceScopeFactory; - ConfigService = configService; - Client = new(); - - Task.Run(MainAsync); - } - - private async Task MainAsync() - { - ServiceScope = ServiceScopeFactory.CreateScope(); - - var discordConfig = ConfigService - .Get() - .Moonlight.DiscordBot; - - if (!discordConfig.Enable) - return; - - Client.Log += Log; - Client.Ready += OnReady; - - //Module - ServerListCommand = new(Client, ConfigService, ServiceScope); - ClearChannelCommand = new(Client, ConfigService, ServiceScope); - - //Commands - EmbedBuilderModule = new(Client, ConfigService, ServiceScope); - PermissionCheckModule = new(Client, ConfigService, ServiceScope); - RemoveCommandsModule = new(Client, ConfigService, ServiceScope); - ActivityStatusModule = new(Client, ConfigService, ServiceScope); - ServerListComponentHandlerModule = new(Client, ConfigService, ServiceScope); - CommonComponentHandlerModule = new(Client, ConfigService, ServiceScope); - - await ActivityStatusModule.UpdateActivityStatusList(); - - await Client.LoginAsync(TokenType.Bot, discordConfig.Token); - await Client.StartAsync(); - - await Task.Delay(-1); - } - private async Task OnReady() - { - //await Client.SetGameAsync(name: "https://endelon-hosting.de", type: ActivityType.Watching); - await Client.SetStatusAsync(UserStatus.Idle); - //await Client.SetStatusAsync(UserStatus.Online); - - Logger.Info($"Invite link: https://discord.com/api/oauth2/authorize?client_id={Client.CurrentUser.Id}&permissions=1099511696391&scope=bot%20applications.commands"); - Logger.Info($"Login as {Client.CurrentUser.Username}#{Client.CurrentUser.DiscriminatorValue}"); - - Task.Run(ActivityStatusModule.ActivityStatusScheduler); - } - - private Task Log(LogMessage message) - { - if (message.Exception is { } exception) - { - Logger.Error(exception); - if (exception.InnerException != null) - { - Logger.Error(exception.InnerException); - } - return Task.CompletedTask; - } - - Logger.Info(message.Message); - return Task.CompletedTask; - } - - public async Task CreateCommands() - { - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - - var type = this.GetType(); - var properties = type.GetProperties(); - Logger.Debug("Start Initializing Commands"); - foreach (var property in properties) - { - if (property.PropertyType.IsSubclassOf(typeof(BaseModule))) - { - try - { - var instance = (BaseModule)property.GetValue(this)!; - await instance.RegisterCommands(); - Logger.Debug("Registered" + instance); - await Task.Delay(TimeSpan.FromMilliseconds(1000)); - } - catch (Exception ex) - { - Logger.Error($"Module Error {ex.Message}"); - Logger.Error(ex.InnerException); - } - } - } - - stopwatch.Stop(); - Logger.Info($"Registered all commands. Done in {stopwatch.ElapsedMilliseconds}ms"); - } - -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Modules/ActivityStatusModule.cs b/Moonlight/App/Services/DiscordBot/Modules/ActivityStatusModule.cs deleted file mode 100644 index 175b72bf..00000000 --- a/Moonlight/App/Services/DiscordBot/Modules/ActivityStatusModule.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Discord; -using Discord.WebSocket; -using Moonlight.App.Database.Entities; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.DiscordBot.Modules; - -public class ActivityStatusModule : BaseModule -{ - - private List LoadingMessages; - - private readonly PeriodicTimer Timer = new(TimeSpan.FromMinutes(1)); - - public ActivityStatusModule(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { } - public override Task RegisterCommands() - { return Task.CompletedTask; } - - public Task UpdateActivityStatusList() - { - var loadingMessageRepo = Scope.ServiceProvider.GetRequiredService(); - LoadingMessages = loadingMessageRepo.Get().ToList(); - - return Task.CompletedTask; - } - - public async void ActivityStatusScheduler() - { - while (await Timer.WaitForNextTickAsync()) - { - String random = "https://endelon-hosting.de"; - if (LoadingMessages.Any()) - { - Random rand = new Random(); - random = LoadingMessages[rand.Next(LoadingMessages.Count)].Message; - } - - await Client.SetGameAsync(random, "https://www.endelon.team", ActivityType.Streaming); - } - } - -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Modules/CommonComponentHandlerModule.cs b/Moonlight/App/Services/DiscordBot/Modules/CommonComponentHandlerModule.cs deleted file mode 100644 index eb4234f8..00000000 --- a/Moonlight/App/Services/DiscordBot/Modules/CommonComponentHandlerModule.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Discord; -using Discord.WebSocket; - -namespace Moonlight.App.Services.DiscordBot.Modules; - -public class CommonComponentHandlerModule : BaseModule -{ - public CommonComponentHandlerModule(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { - Client.ButtonExecuted += CommonButtonHandler; - } - public override Task RegisterCommands() - { return Task.CompletedTask; } - - private async Task CommonButtonHandler(SocketMessageComponent component) - { - EmbedBuilder embed; - switch (component.Data.CustomId) - { - case "clear": - await component.Message.DeleteAsync(); - var dcs = Scope.ServiceProvider.GetRequiredService(); - embed = dcs.EmbedBuilderModule.StandardEmbed("Cleared!", Color.Green, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - - break; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Modules/EmbedBuilderModule.cs b/Moonlight/App/Services/DiscordBot/Modules/EmbedBuilderModule.cs deleted file mode 100644 index 8f604278..00000000 --- a/Moonlight/App/Services/DiscordBot/Modules/EmbedBuilderModule.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Discord; -using Discord.WebSocket; -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Services.DiscordBot.Modules; - -public class EmbedBuilderModule : BaseModule -{ - - public EmbedBuilderModule(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { } - public override Task RegisterCommands() - { - return Task.CompletedTask; - } - - public EmbedBuilder StandardEmbed(string message, Color embedColor, IUser user, Dictionary? fields = null) - { - var embed = new EmbedBuilder - { - Author = AThing(user), - Description = message, - Timestamp = DateTimeOffset.UtcNow, - Color = embedColor - }; - - if (fields != null) - { - foreach (var field in fields) - { - embed.AddField(field.Key, field.Value); - } - } - - return embed; - } - - public EmbedBuilder ServerManagerEmbed(string message, Color embedColor, IUser user, Server server) - { - var embed = new EmbedBuilder - { - Author = AThing(user), - Description = message, - Timestamp = DateTimeOffset.UtcNow, - Color = embedColor - }; - - embed.AddField("Server Name", $"```{server.Id} - {server.Name}```", inline: true); - embed.AddField("Owner", $"```{server.Owner.FirstName} {server.Owner.LastName}```", inline: true); - embed.AddField("Node", $"```{server.Node.Name}```", inline: true); - embed.AddField("Cpu", $"```{server.Cpu.ToString()}```", inline: true); - embed.AddField("Ram", $"```{server.Memory.ToString()}```", inline: true); - embed.AddField("Disk", $"```{server.Cpu.ToString()}```", inline: true); - embed.AddField("\u200b", "\u200b"); - embed.AddField("Address", $"```{server.Node.Fqdn}:{server.MainAllocation.Port.ToString()}```", inline: false); - - - return embed; - } - - public EmbedBuilder ColorChangerServerManagerEmbed(Embed? oldEmbed, Color embedColor, IUser user) - { - var embed = new EmbedBuilder - { - Author = AThing(user), - Description = oldEmbed.Description, - Timestamp = DateTimeOffset.UtcNow, - Color = embedColor - }; - - foreach (var field in oldEmbed.Fields) - { - embed.AddField(field.Name, field.Value, field.Inline); - } - - return embed; - } - - private EmbedAuthorBuilder AThing(IUser user) - { - #region Don't Show - if (user.Id == 223109865197928448) - return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username + "❤️").WithUrl("https://masulinchen.love").WithIconUrl("https://cdn.discordapp.com/attachments/750696464014901268/1092782904385474650/papagei.png"); - #endregion - - Random random = new Random(); - int[] randomNumbers = new int[] { 1, 3, 8, 11, 20 }; - - if (randomNumbers.Contains(random.Next(1, 24))) - return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username + " - The Rick version").WithUrl(ConfigService.Get().Moonlight.AppUrl).WithIconUrl("https://cdn.discordapp.com/attachments/750696464014901268/1092783310129860618/rick.gif"); - - return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username).WithUrl(ConfigService.Get().Moonlight.AppUrl).WithIconUrl(Client.CurrentUser.GetAvatarUrl()); - } -} diff --git a/Moonlight/App/Services/DiscordBot/Modules/PermissionCheckModule.cs b/Moonlight/App/Services/DiscordBot/Modules/PermissionCheckModule.cs deleted file mode 100644 index ff7398dd..00000000 --- a/Moonlight/App/Services/DiscordBot/Modules/PermissionCheckModule.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Discord.WebSocket; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; - -namespace Moonlight.App.Services.DiscordBot.Modules; - -public class PermissionCheckModule : BaseModule -{ - - public PermissionCheckModule(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { } - public override Task RegisterCommands() - { return Task.CompletedTask; } - - public bool IsAdminByDiscordId(ulong discordId) - { - - var usersRepo = Scope.ServiceProvider.GetRequiredService(); - - var user = usersRepo.Get().FirstOrDefault(x => x.DiscordId == discordId); - - if (user != null) - { - return user.Admin; - } - - return false; - } - - public bool HasViewPermissionByDiscordId(ulong discordId, int serverId) - { - var serversRepo = Scope.ServiceProvider.GetRequiredService(); - - var server = serversRepo.Get().Include(x => x.Owner).FirstOrDefault(x => x.Id == serverId); - - if (server != null && server.Owner.DiscordId == discordId) - { - return true; - } - - return false; - } - -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Modules/RemoveCommandsModule.cs b/Moonlight/App/Services/DiscordBot/Modules/RemoveCommandsModule.cs deleted file mode 100644 index 4b605c9e..00000000 --- a/Moonlight/App/Services/DiscordBot/Modules/RemoveCommandsModule.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics; -using Discord.WebSocket; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Services.DiscordBot.Modules; - -public class RemoveCommandsModule : BaseModule -{ - public RemoveCommandsModule(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { } - public override Task RegisterCommands() - { return Task.CompletedTask; } - - public async void VoidCommands() - { - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - - var commands = await Client.GetGlobalApplicationCommandsAsync(); - if (commands == null) return; - - foreach (var slashCommand in commands) - { - if(slashCommand.Name == "commands") continue; - - await slashCommand.DeleteAsync(); - Logger.Debug($"Deleted {slashCommand.Name}, {slashCommand.Id}"); - await Task.Delay(TimeSpan.FromMilliseconds(1000)); - } - - stopwatch.Stop(); - Logger.Info($"Deleted all commands. Done in {stopwatch.ElapsedMilliseconds}ms"); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs b/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs deleted file mode 100644 index 6dd5111f..00000000 --- a/Moonlight/App/Services/DiscordBot/Modules/ServerListComponentHandlerModule.cs +++ /dev/null @@ -1,419 +0,0 @@ -using Discord; -using Discord.WebSocket; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.ApiClients.Wings; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; - -namespace Moonlight.App.Services.DiscordBot.Modules; - -public class ServerListComponentHandlerModule : BaseModule -{ - public ServerListComponentHandlerModule(DiscordSocketClient client, ConfigService configService, IServiceScope scope) : base(client, configService, scope) - { - Client.SelectMenuExecuted += MenuHandler; - Client.ButtonExecuted += ManagerButtonHandler; - Client.ButtonExecuted += PagesButtonHandler; - Client.ModalSubmitted += ModalHandler; - } - - public override Task RegisterCommands() - { - return Task.CompletedTask; - } - - private async Task ManagerButtonHandler(SocketMessageComponent component) - { - var nodeService = Scope.ServiceProvider.GetRequiredService(); - var serverRepo = Scope.ServiceProvider.GetRequiredService(); - var dcs = Scope.ServiceProvider.GetRequiredService(); - var costomId = component.Data.CustomId.Split("."); - EmbedBuilder embed = dcs.EmbedBuilderModule.StandardEmbed("Something went terribly wrong! \n Mission failed please try again later.", Color.Red, component.User); - - if (costomId.Length < 3) return; - - if(costomId[0] is not "Sm") return; - - int id = int.Parse(costomId[2]); - var server = serverRepo.Get() - .Include(x => x.Owner) - .Include(x => x.Node) - .Include(x => x.MainAllocation) - .FirstOrDefault(x => x.Id == id); - - if (server == null) - { - await ErrorEmbedSnippet(component); - return; - } - - if (server.Owner.DiscordId != component.User.Id) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Is this your Server? I don't think so. \n Yes i did think of that.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - var data = await nodeService.GetStatus(server.Node); - - if (data == null) - { - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - var serverService = Scope.ServiceProvider.GetRequiredService(); - var serverDetails = await serverService.GetDetails(server); - - // serverDetails.State == "STATE" - // here a secret for masu :) look at the number on the left <<<--- - // starting - // running - // stopping - // offline - // installing - if (!ConfigService.Get().Moonlight.DiscordBot.PowerActions && costomId[1] is "Start" or "Restart" or "Stop" or "Kill" or "Update") - { - embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - await component.DeleteOriginalResponseAsync(); - return; - } - - if (!ConfigService.Get().Moonlight.DiscordBot.SendCommands && costomId[1] is "SendCommand") - { - embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - await component.DeleteOriginalResponseAsync(); - return; - } - - if (serverDetails.State == "installing") - { - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), Color.Blue, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - - embed = dcs.EmbedBuilderModule.StandardEmbed("Server is in Installing \n please try again later.", Color.Blue, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - switch (costomId[1]) - { - case "Start": - if (serverDetails.State != "offline") - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Server is in a Invalid State \n please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - await serverService.SetPowerState(server, PowerSignal.Start); - - await component.DeferAsync(); - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), Color.Green, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - - break; - - - case "Restart": - if (serverDetails.State == "running") - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Server is in a Invalid State \n please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - await serverService.SetPowerState(server, PowerSignal.Restart); - - await component.DeferAsync(); - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), Color.Orange, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - - break; - - - case "Stop": - if (serverDetails.State is not ("starting" or "stopping")) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Server is in a Invalid State \n please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - await serverService.SetPowerState(server, PowerSignal.Stop); - - await component.DeferAsync(); - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), Color.Red, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - - break; - - - case "Kill": - if (serverDetails.State != "stopping") - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Server is in a Invalid State \n please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - await serverService.SetPowerState(server, PowerSignal.Kill); - - await component.DeferAsync(); - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), Color.DarkRed, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - - break; - - case "SendCommand": - if (serverDetails.State != "running") - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Server is not Online! \n The server must be Online", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - ModalBuilder modal = new ModalBuilder() - .WithTitle("Send Command To Server") - .WithCustomId($"Sm.SendCommand.{costomId[2]}") - .AddTextInput("Command", "Command", TextInputStyle.Short, "Type here Your Command", 1, 169, true); - - await component.RespondWithModalAsync(modal.Build()); - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), Color.Green, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - break; - - case "Update": - Color serverStateColor; - switch (serverDetails.State) - { - case "starting": - serverStateColor = Color.Orange; - break; - - case "running": - serverStateColor = Color.Green; - break; - - case "stopping": - serverStateColor = Color.Orange; - break; - - case "offline": - serverStateColor = Color.DarkerGrey; - break; - - default: - serverStateColor = Color.DarkPurple; - break; - } - await component.DeferAsync(); - embed = dcs.EmbedBuilderModule.ColorChangerServerManagerEmbed(component.Message.Embeds.FirstOrDefault(), serverStateColor, component.User); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - break; - } - } - - private async Task ModalHandler(SocketModal component) - { - var nodeService = Scope.ServiceProvider.GetRequiredService(); - var serverRepo = Scope.ServiceProvider.GetRequiredService(); - var dcs = Scope.ServiceProvider.GetRequiredService(); - var costomId = component.Data.CustomId.Split("."); - EmbedBuilder embed; - - if(costomId[0] != "Sm" && costomId[1] == "SendCommand") return; - - var details = component.Data.Components.FirstOrDefault(x => x.CustomId == "Command"); - - int id = int.Parse(costomId[2]); - var server = serverRepo.Get() - .Include(x => x.Owner) - .Include(x => x.Node) - .Include(x => x.MainAllocation) - .FirstOrDefault(x => x.Id == id); - - if (server == null || details == null) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry :( \n Something went wrong. \n Please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - if (server.Owner.DiscordId != component.User.Id) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Is this your Server? I don't think so. \n Yes i did think of that.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - var data = await nodeService.GetStatus(server.Node); - if (data == null) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("The node might be down. \n Please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - return; - } - - var serverService = Scope.ServiceProvider.GetRequiredService(); - Logger.Info(server.Id + " - " + server.Name); - Logger.Info(details.Value); - //Execute in console. - - embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - await component.DeleteOriginalResponseAsync(); - return; - - - - - } - - private async Task PagesButtonHandler(SocketMessageComponent component) - { - ComponentBuilder components; - EmbedBuilder embed; - var dcs = Scope.ServiceProvider.GetRequiredService(); - var usersRepo = Scope.ServiceProvider.GetRequiredService(); - var serverRepo = Scope.ServiceProvider.GetRequiredService(); - var user = usersRepo.Get().FirstOrDefault(x => x.DiscordId == component.User.Id); - var costomId = component.Data.CustomId.Split("."); - - if (costomId.Length < 2) return; - int nextPage; - switch (costomId[0]) - { - case "SmPreviousPage": - nextPage = int.Parse(costomId[1]) -1; - break; - - case "SmNextPage": - nextPage = int.Parse(costomId[1]) +1; - break; - - default: - return; - } - - if (user == null) - { - embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, component.User); - components = new ComponentBuilder(); - components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.Get().Moonlight.AppUrl); - - await component.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true); - return; - } - - var servers = serverRepo.Get().Include(x => x.Owner).Where(x => x.Owner.Id == user.Id).ToList(); - var selectOptions = new List(); - - foreach (var server in servers.Skip(nextPage * 25).Take(25).ToList()) - { - selectOptions.Add(new SelectMenuOptionBuilder() - .WithLabel($"{server.Id} - {server.Name}") - .WithEmote(Emote.Parse("<:server3:968614410228736070>")) - .WithValue(server.Id.ToString())); - } - - int totalPages = (int)Math.Ceiling((double)servers.Count / 25 -1); - bool lastPage = nextPage == totalPages; - bool firstPage = nextPage == 0; - - components = new ComponentBuilder(); - components.WithSelectMenu( - "ServerSelectorList", - selectOptions, - "Select the server you want to edit."); - - components.WithButton("Panel", - emote: Emote.Parse(""), - style: ButtonStyle.Link, - url: $"{ConfigService.Get().Moonlight.AppUrl}"); - - components.WithButton("Previous-page", - emote: Emote.Parse("<:ArrowLeft:1101547474180649030>"), - style: ButtonStyle.Secondary, - customId:$"SmPreviousPage.{nextPage}", - disabled: firstPage); - - components.WithButton("Next-page", - emote: Emote.Parse("<:ArrowRight:1101547475380228257>"), - style: ButtonStyle.Secondary, - customId:$"SmNextPage.{nextPage}", - disabled: lastPage); - - await component.DeferAsync(); - await component.ModifyOriginalResponseAsync(x => x.Components = components.Build()); - } - - private async Task MenuHandler(SocketMessageComponent component) - { - if (component.Data.CustomId != "ServerSelectorList") return; - - var dcs = Scope.ServiceProvider.GetRequiredService(); - if (!int.TryParse(component.Data.Values.FirstOrDefault(), out int serverId)) - { - await ErrorEmbedSnippet(component); - return; - } - - var serverRepo = Scope.ServiceProvider.GetRequiredService(); - var server = serverRepo.Get() - .Include(x => x.Owner) - .Include(x => x.Node) - .Include(x => x.MainAllocation) - .FirstOrDefault(x => x.Id == serverId); - - if (server == null || server.Owner.DiscordId != component.User.Id) - { - await ErrorEmbedSnippet(component); - return; - } - - var embed = dcs.EmbedBuilderModule.ServerManagerEmbed("You're server", Color.Blue, component.User, server); - - var components = new ComponentBuilder(); - - if (ConfigService.Get().Moonlight.DiscordBot.PowerActions) - { - components.WithButton("Start", style: ButtonStyle.Success, customId: $"Sm.Start.{server.Id}", disabled: false); - components.WithButton("Restart", style: ButtonStyle.Primary, customId: $"Sm.Restart.{server.Id}", disabled: false); - components.WithButton("Stop", style: ButtonStyle.Danger, customId: $"Sm.Stop.{server.Id}", disabled: false); - components.WithButton("Kill", style: ButtonStyle.Danger, customId: $"Sm.Kill.{server.Id}", disabled: false); - } - - components.WithButton("Way2Server", - emote: Emote.Parse(""), - style: ButtonStyle.Link, - url: $"{ConfigService.Get().Moonlight.AppUrl}/server/{server.Uuid}"); - - components.WithButton("Update", - emote: Emote.Parse("<:refresh:1101547898803605605>"), - style: ButtonStyle.Secondary, - customId: $"Sm.Update.{server.Id}"); - - if (ConfigService.Get().Moonlight.DiscordBot.SendCommands) - { - components.WithButton("SendCommand", - emote: Emote.Parse("<:Console:1101547358157819944>"), - style: ButtonStyle.Secondary, - customId: $"Sm.SendCommand.{server.Id}"); - } - - await component.DeferAsync(); - await component.ModifyOriginalResponseAsync(x => x.Embed = embed.Build()); - await component.ModifyOriginalResponseAsync(x => x.Components = components.Build()); - } - - private async Task ErrorEmbedSnippet(SocketMessageComponent component) - { - var dcs = Scope.ServiceProvider.GetRequiredService(); - - var embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry :( \n Something went wrong. \n Please try again later.", Color.Red, component.User); - await component.RespondAsync(embed: embed.Build(), ephemeral: true); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/DomainService.cs b/Moonlight/App/Services/DomainService.cs deleted file mode 100644 index 8abcc1b3..00000000 --- a/Moonlight/App/Services/DomainService.cs +++ /dev/null @@ -1,348 +0,0 @@ -using CloudFlare.Client; -using CloudFlare.Client.Api.Authentication; -using CloudFlare.Client.Api.Display; -using CloudFlare.Client.Api.Parameters.Data; -using CloudFlare.Client.Api.Result; -using CloudFlare.Client.Api.Zones; -using CloudFlare.Client.Api.Zones.DnsRecord; -using CloudFlare.Client.Client.Zones; -using CloudFlare.Client.Enumerators; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories.Domains; -using DnsRecord = Moonlight.App.Models.Misc.DnsRecord; -using MatchType = CloudFlare.Client.Enumerators.MatchType; - -namespace Moonlight.App.Services; - -public class DomainService -{ - private readonly DomainRepository DomainRepository; - private readonly ConfigService ConfigService; - private readonly SharedDomainRepository SharedDomainRepository; - private readonly CloudFlareClient Client; - private readonly string AccountId; - - public DomainService( - ConfigService configService, - DomainRepository domainRepository, - SharedDomainRepository sharedDomainRepository) - { - ConfigService = configService; - DomainRepository = domainRepository; - SharedDomainRepository = sharedDomainRepository; - - var config = configService - .Get() - .Moonlight.Domains; - - AccountId = config.AccountId; - - Client = new( - new ApiKeyAuthentication( - config.Email, - config.Key - ) - ); - } - - public Task Create(string domain, SharedDomain sharedDomain, User user) - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - throw new DisplayException("This operation is disabled"); - - if (DomainRepository.Get().Where(x => x.SharedDomain.Id == sharedDomain.Id).Any(x => x.Name == domain)) - throw new DisplayException("A domain with this name does already exist for this shared domain"); - - var res = DomainRepository.Add(new() - { - Name = domain, - SharedDomain = sharedDomain, - Owner = user - }); - - return Task.FromResult(res); - } - - public Task Delete(Domain domain) - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - throw new DisplayException("This operation is disabled"); - - DomainRepository.Delete(domain); - - return Task.CompletedTask; - } - - public async Task - GetAvailableDomains() // This method returns all available domains which are not added as a shared domain - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - return Array.Empty(); - - var domains = new List(); - - var initialResponse = await Client.Zones.GetAsync(); - - domains.AddRange(GetData(initialResponse)); - - // Check if there are more pages - while (initialResponse.ResultInfo.Page < initialResponse.ResultInfo.TotalPage) - { - // Get the next page of data - var nextPageResponse = await Client.Zones.GetAsync( - displayOptions: new() - { - Page = initialResponse.ResultInfo.Page + 1 - } - ); - var nextPageZones = GetData(nextPageResponse); - - domains.AddRange(nextPageZones); - initialResponse = nextPageResponse; - } - - var sharedDomains = SharedDomainRepository.Get().ToArray(); - - var freeDomains = domains - .Where(x => sharedDomains.FirstOrDefault - ( - y => y.CloudflareId == x.Id - ) == null - ) - .ToArray(); - - return freeDomains; - } - - public async Task GetDnsRecords(Domain d) - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - return Array.Empty(); - - var domain = EnsureData(d); - - var records = new List(); - - // Load paginated - // TODO: Find an alternative option. This way to load the records is NOT optimal - // and can result in long loading time when there are many dns records. - // As cloudflare does not offer a way to search dns records which starts - // with a specific string we are not able to filter it using the api (client) - var initialResponse = await Client.Zones.DnsRecords.GetAsync(domain.SharedDomain.CloudflareId); - - records.AddRange(GetData(initialResponse)); - - // Check if there are more pages - while (initialResponse.ResultInfo.Page < initialResponse.ResultInfo.TotalPage) - { - // Get the next page of data - var nextPageResponse = await Client.Zones.DnsRecords.GetAsync( - domain.SharedDomain.CloudflareId, - displayOptions: new() - { - Page = initialResponse.ResultInfo.Page + 1 - } - ); - var nextPageRecords = GetData(nextPageResponse); - - // Append the records from the next page to the existing records - records.AddRange(nextPageRecords); - - // Update the initial response to the next page response - initialResponse = nextPageResponse; - } - - var rname = $"{domain.Name}.{domain.SharedDomain.Name}"; - var dname = $".{rname}"; - - var result = new List(); - - foreach (var record in records) - { - if (record.Name.EndsWith(dname)) - { - result.Add(new() - { - Name = record.Name.Replace(dname, ""), - Content = record.Content, - Priority = record.Priority ?? 0, - Proxied = record.Proxied ?? false, - Id = record.Id, - Ttl = record.Ttl ?? 0, - Type = record.Type - }); - } - else if (record.Name == rname) - { - result.Add(new() - { - Name = record.Name.Replace(rname, ""), - Content = record.Content, - Priority = record.Priority ?? 0, - Proxied = record.Proxied ?? false, - Id = record.Id, - Ttl = record.Ttl ?? 0, - Type = record.Type - }); - } - } - - return result.ToArray(); - } - - public async Task AddDnsRecord(Domain d, DnsRecord dnsRecord) - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - throw new DisplayException("This operation is disabled"); - - try - { - var domain = EnsureData(d); - - var rname = $"{domain.Name}.{domain.SharedDomain.Name}"; - var dname = $".{rname}"; - - if (dnsRecord.Type == DnsRecordType.Srv) - { - var parts = dnsRecord.Name.Split("."); - - Protocol protocol = Protocol.Tcp; - - if (parts[1].Contains("udp")) - protocol = Protocol.Udp; - - var valueParts = dnsRecord.Content.Split(" "); - - var nameWithoutProt = dnsRecord.Name.Replace($"{parts[0]}.{parts[1]}.", ""); - nameWithoutProt = nameWithoutProt.Replace($"{parts[0]}.{parts[1]}", ""); - var name = nameWithoutProt == "" ? rname : nameWithoutProt + dname; - - var srv = new NewDnsRecord() - { - Type = dnsRecord.Type, - Data = new() - { - Service = parts[0], - Protocol = protocol, - Name = name, - Weight = int.Parse(valueParts[0]), - Port = int.Parse(valueParts[1]), - Target = valueParts[2], - Priority = dnsRecord.Priority - }, - Proxied = dnsRecord.Proxied, - Ttl = dnsRecord.Ttl, - }; - - GetData(await Client.Zones.DnsRecords.AddAsync(d.SharedDomain.CloudflareId, srv)); - } - else - { - var name = string.IsNullOrEmpty(dnsRecord.Name) ? rname : dnsRecord.Name + dname; - - GetData(await Client.Zones.DnsRecords.AddAsync(d.SharedDomain.CloudflareId, new NewDnsRecord() - { - Type = dnsRecord.Type, - Priority = dnsRecord.Priority, - Content = dnsRecord.Content, - Proxied = dnsRecord.Proxied, - Ttl = dnsRecord.Ttl, - Name = name - })); - } - } - catch (OverflowException) - { - throw new DisplayException("Invalid dns record values"); - } - catch (FormatException) - { - throw new DisplayException("Invalid dns record values"); - } - - //TODO: AuditLog - } - - public async Task UpdateDnsRecord(Domain d, DnsRecord dnsRecord) - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - throw new DisplayException("This operation is disabled"); - - var domain = EnsureData(d); - - var rname = $"{domain.Name}.{domain.SharedDomain.Name}"; - var dname = $".{rname}"; - - if (dnsRecord.Type == DnsRecordType.Srv) - { - throw new DisplayException( - "SRV records cannot be updated thanks to the cloudflare api client. Please delete the record and create a new one"); - } - else - { - var name = dnsRecord.Name == "" ? rname : dnsRecord.Name + dname; - - GetData(await Client.Zones.DnsRecords.UpdateAsync(d.SharedDomain.CloudflareId, dnsRecord.Id, - new ModifiedDnsRecord() - { - Content = dnsRecord.Content, - Proxied = dnsRecord.Proxied, - Ttl = dnsRecord.Ttl, - Name = name, - Type = dnsRecord.Type - })); - } - - //TODO: AuditLog - } - - public async Task DeleteDnsRecord(Domain d, DnsRecord dnsRecord) - { - if (!ConfigService.Get().Moonlight.Domains.Enable) - throw new DisplayException("This operation is disabled"); - - var domain = EnsureData(d); - - GetData( - await Client.Zones.DnsRecords.DeleteAsync(domain.SharedDomain.CloudflareId, dnsRecord.Id) - ); - - //TODO: AuditLog - } - - private Domain EnsureData(Domain domain) - { - if (domain.SharedDomain != null) - return domain; - else - return DomainRepository - .Get() - .Include(x => x.SharedDomain) - .First(x => x.Id == domain.Id); - } - - private T GetData(CloudFlareResult result) - { - if (!result.Success) - { - string message; - - try - { - message = result.Errors.First().ErrorChain.First().Message; - } - catch (Exception) - { - throw new CloudflareException("No error message provided"); - } - - throw new CloudflareException(message); - } - - return result.Result; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/FileDownloadService.cs b/Moonlight/App/Services/FileDownloadService.cs deleted file mode 100644 index ad85c010..00000000 --- a/Moonlight/App/Services/FileDownloadService.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Text; -using Microsoft.JSInterop; - -namespace Moonlight.App.Services; - -public class FileDownloadService -{ - private readonly IJSRuntime JSRuntime; - - public FileDownloadService(IJSRuntime jsRuntime) - { - JSRuntime = jsRuntime; - } - - public async Task DownloadStream(string fileName, Stream stream) - { - using var streamRef = new DotNetStreamReference(stream); - - await JSRuntime.InvokeVoidAsync("moonlight.downloads.downloadStream", fileName, streamRef); - } - - public async Task DownloadBytes(string fileName, byte[] bytes) - { - var ms = new MemoryStream(bytes); - - await DownloadStream(fileName, ms); - } - - public async Task DownloadString(string fileName, string content) - { - await DownloadBytes(fileName, Encoding.UTF8.GetBytes(content)); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Files/BucketService.cs b/Moonlight/App/Services/Files/BucketService.cs deleted file mode 100644 index e85fdaa6..00000000 --- a/Moonlight/App/Services/Files/BucketService.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Moonlight.App.Helpers; - -namespace Moonlight.App.Services.Files; - -public class BucketService -{ - private string BucketPath; - - public BucketService() - { - BucketPath = PathBuilder.Dir("storage", "uploads"); - } - - public Task GetBuckets() - { - var buckets = Directory.GetDirectories(BucketPath) - .Select(x => - x.Replace(BucketPath, "").TrimEnd('/') - ) - .ToArray(); - - return Task.FromResult(buckets); - } - - private Task EnsureBucket(string name) - { - Directory.CreateDirectory(BucketPath + name); - - return Task.CompletedTask; - } - - public async Task StoreFile(string bucket, Stream dataStream, string? name = null) - { - await EnsureBucket(bucket); - - var extension = ""; - - if (name != null) - extension = Path.GetExtension(name); - - var fileName = Path.GetRandomFileName() + extension; //TODO: Add check for existing file - var filePath = BucketPath + PathBuilder.File(bucket, fileName); - - var fileStream = File.Create(filePath); - - await dataStream.CopyToAsync(fileStream); - await fileStream.FlushAsync(); - - fileStream.Close(); - - return fileName; - } - - public Task GetFile(string bucket, string file) - { - var filePath = BucketPath + PathBuilder.File(bucket, file); - - if (File.Exists(filePath)) - { - var stream = File.Open(filePath, FileMode.Open); - - return Task.FromResult(stream); - } - else - throw new FileNotFoundException(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Files/ResourceService.cs b/Moonlight/App/Services/Files/ResourceService.cs deleted file mode 100644 index a113fad7..00000000 --- a/Moonlight/App/Services/Files/ResourceService.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Moonlight.App.Database.Entities; - -namespace Moonlight.App.Services.Files; - -public class ResourceService -{ - private readonly string AppUrl; - - public ResourceService(ConfigService configService) - { - AppUrl = configService.Get().Moonlight.AppUrl; - } - - public string Image(string name) - { - return $"{AppUrl}/api/moonlight/resources/images/{name}"; - } - - public string BackgroundImage(string name) - { - return $"{AppUrl}/api/moonlight/resources/background/{name}"; - } - - public string Avatar(User user) - { - return $"{AppUrl}/api/moonlight/avatar/{user.Id}"; - } - - public string BucketItem(string bucket, string name) - { - return $"{AppUrl}/api/moonlight/resources/bucket/{bucket}/{name}"; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Files/StorageService.cs b/Moonlight/App/Services/Files/StorageService.cs deleted file mode 100644 index 402664ca..00000000 --- a/Moonlight/App/Services/Files/StorageService.cs +++ /dev/null @@ -1,125 +0,0 @@ -using Moonlight.App.Helpers; -using Octokit; - -namespace Moonlight.App.Services.Files; - -public class StorageService -{ - public async Task EnsureCreated() - { - Directory.CreateDirectory(PathBuilder.Dir("storage", "uploads")); - Directory.CreateDirectory(PathBuilder.Dir("storage", "configs")); - Directory.CreateDirectory(PathBuilder.Dir("storage", "resources")); - Directory.CreateDirectory(PathBuilder.Dir("storage", "backups")); - Directory.CreateDirectory(PathBuilder.Dir("storage", "logs")); - Directory.CreateDirectory(PathBuilder.Dir("storage", "plugins")); - Directory.CreateDirectory(PathBuilder.Dir("storage", "certs")); - - await UpdateResources(); - - return; - if (IsEmpty(PathBuilder.Dir("storage", "resources"))) - { - Logger.Info("Default resources not found. Copying default resources"); - - CopyFilesRecursively( - PathBuilder.Dir("defaultstorage", "resources"), - PathBuilder.Dir("storage", "resources") - ); - } - - if (IsEmpty(PathBuilder.Dir("storage", "configs"))) - { - Logger.Info("Default configs not found. Copying default configs"); - - CopyFilesRecursively( - PathBuilder.Dir("defaultstorage", "configs"), - PathBuilder.Dir("storage", "configs") - ); - } - } - - private async Task UpdateResources() - { - try - { - Logger.Info("Checking resources"); - - var client = new GitHubClient( - new ProductHeaderValue("Moonlight-Panel")); - - var user = "Moonlight-Panel"; - var repo = "Resources"; - var resourcesDir = PathBuilder.Dir("storage", "resources"); - - async Task CopyDirectory(string dirPath, string localDir) - { - IReadOnlyList contents; - - if (string.IsNullOrEmpty(dirPath)) - contents = await client.Repository.Content.GetAllContents(user, repo); - else - contents = await client.Repository.Content.GetAllContents(user, repo, dirPath); - - foreach (var content in contents) - { - string localPath = Path.Combine(localDir, content.Name); - - if (content.Type == ContentType.File) - { - if (content.Name.EndsWith(".gitattributes")) - continue; - - if (File.Exists(localPath) && !content.Name.EndsWith(".lang")) - continue; - - if (content.Name.EndsWith(".lang") && File.Exists(localPath) && - new FileInfo(localPath).Length == content.Size) - continue; - - var fileContent = await client.Repository.Content.GetRawContent(user, repo, content.Path); - Directory.CreateDirectory(localDir); // Ensure the directory exists - await File.WriteAllBytesAsync(localPath, fileContent); - - Logger.Debug($"Synced file '{content.Path}'"); - } - else if (content.Type == ContentType.Dir) - { - await CopyDirectory(content.Path, localPath); - } - } - } - - await CopyDirectory("", resourcesDir); - } - catch (RateLimitExceededException) - { - Logger.Warn("Unable to sync resources due to your ip being rate-limited by github"); - } - catch (Exception e) - { - Logger.Warn("Unable to sync resources"); - Logger.Warn(e); - } - } - - private bool IsEmpty(string path) - { - return !Directory.EnumerateFileSystemEntries(path).Any(); - } - - private static void CopyFilesRecursively(string sourcePath, string targetPath) - { - //Now Create all of the directories - foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) - { - Directory.CreateDirectory(dirPath.Replace(sourcePath, targetPath)); - } - - //Copy all the files & Replaces any files with the same name - foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) - { - File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/AlertService.cs b/Moonlight/App/Services/Interop/AlertService.cs deleted file mode 100644 index a5cad8f1..00000000 --- a/Moonlight/App/Services/Interop/AlertService.cs +++ /dev/null @@ -1,156 +0,0 @@ -using CurrieTechnologies.Razor.SweetAlert2; -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Interop; - -public class AlertService -{ - private readonly SmartTranslateService SmartTranslateService; - private readonly IJSRuntime JsRuntime; - private SweetAlertService? SweetAlertService; - - public AlertService(SmartTranslateService smartTranslateService, IJSRuntime jsRuntime) - { - SmartTranslateService = smartTranslateService; - JsRuntime = jsRuntime; - } - - // We create the swal service here and not using the dependency injection - // because it initializes when instantiated which leads to js invoke errors - private Task EnsureService() - { - if (SweetAlertService == null) - { - SweetAlertService = new(JsRuntime, new() - { - Theme = SweetAlertTheme.Dark - }); - } - - return Task.CompletedTask; - } - - public async Task Info(string title, string desciption) - { - await EnsureService(); - - await SweetAlertService!.FireAsync(new SweetAlertOptions() - { - Title = title, - Text = desciption, - Icon = SweetAlertIcon.Info - }); - } - - public async Task Info(string desciption) - { - await Info("", desciption); - } - - public async Task Success(string title, string desciption) - { - await EnsureService(); - - await SweetAlertService!.FireAsync(new SweetAlertOptions() - { - Title = title, - Text = desciption, - Icon = SweetAlertIcon.Success - }); - } - - public async Task Success(string desciption) - { - await Success("", desciption); - } - - public async Task Warning(string title, string desciption) - { - await EnsureService(); - - await SweetAlertService!.FireAsync(new SweetAlertOptions() - { - Title = title, - Text = desciption, - Icon = SweetAlertIcon.Warning - }); - } - - public async Task Warning(string desciption) - { - await Warning("", desciption); - } - - public async Task Error(string title, string desciption) - { - await EnsureService(); - - await SweetAlertService!.FireAsync(new SweetAlertOptions() - { - Title = title, - Text = desciption, - Icon = SweetAlertIcon.Error - }); - } - - public async Task Error(string desciption) - { - await Error("", desciption); - } - - public async Task YesNo(string title, string desciption, string yesText, string noText) - { - await EnsureService(); - - var result = await SweetAlertService!.FireAsync(new SweetAlertOptions() - { - Title = title, - Text = desciption, - ShowCancelButton = false, - ShowDenyButton = true, - ShowConfirmButton = true, - ConfirmButtonText = yesText, - DenyButtonText = noText - }); - - return result.IsConfirmed; - } - - public async Task Text(string title, string desciption, string setValue) - { - await EnsureService(); - - var result = await SweetAlertService!.FireAsync(new SweetAlertOptions() - { - Title = title, - Text = desciption, - Input = SweetAlertInputType.Text, - InputValue = setValue - }); - - return result.Value; - } - - public async Task ConfirmMath() - { - var r = new Random(); - var i1 = r.Next(5, 15); - var i2 = r.Next(5, 15); - - var input = await Text( - SmartTranslateService.Translate("Confirm"), - $"{i1} + {i2} =", - "" - ); - - if (int.TryParse(input, out int i)) - { - if (i == i1 + i2) - { - return true; - } - } - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/ClipboardService.cs b/Moonlight/App/Services/Interop/ClipboardService.cs deleted file mode 100644 index 6a702282..00000000 --- a/Moonlight/App/Services/Interop/ClipboardService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Interop; - -public class ClipboardService -{ - private readonly IJSRuntime JsRuntime; - - public ClipboardService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } - - public async Task Copy(string data) - { - await JsRuntime.InvokeVoidAsync("moonlight.clipboard.copy", data); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/ModalService.cs b/Moonlight/App/Services/Interop/ModalService.cs deleted file mode 100644 index 881fb2ec..00000000 --- a/Moonlight/App/Services/Interop/ModalService.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Interop; - -public class ModalService -{ - private readonly IJSRuntime JsRuntime; - - public ModalService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } - - public async Task Show(string name) - { - await JsRuntime.InvokeVoidAsync("moonlight.modals.show", name); - } - - public async Task Hide(string name) - { - await JsRuntime.InvokeVoidAsync("moonlight.modals.hide", name); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/PopupService.cs b/Moonlight/App/Services/Interop/PopupService.cs deleted file mode 100644 index 7106e5da..00000000 --- a/Moonlight/App/Services/Interop/PopupService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Interop; - -public class PopupService -{ - private readonly IJSRuntime JsRuntime; - - public PopupService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } - - public async Task ShowCentered(string url, string title, int width = 500, int height = 500) - { - await JsRuntime.InvokeVoidAsync("moonlight.popup.showCentered", url, title, width, height); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/ReCaptchaService.cs b/Moonlight/App/Services/Interop/ReCaptchaService.cs deleted file mode 100644 index 159cce16..00000000 --- a/Moonlight/App/Services/Interop/ReCaptchaService.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.ComponentModel; -using System.Text; -using Microsoft.JSInterop; -using RestSharp; - -namespace Moonlight.App.Services.Interop; - -public class ReCaptchaService -{ - private readonly IJSRuntime JsRuntime; - private readonly ConfigService ConfigService; - - private readonly string SiteKey; - private readonly string SecretKey; - private readonly bool Enable = false; - - public Func? OnResponse { get; set; } - public Func? OnValidResponse { get; set; } - - public ReCaptchaService( - IJSRuntime jsRuntime, - ConfigService configService) - { - JsRuntime = jsRuntime; - ConfigService = configService; - - var recaptchaConfig = ConfigService - .Get() - .Moonlight.Security.ReCaptcha; - - Enable = recaptchaConfig.Enable; - - if (Enable) - { - SiteKey = recaptchaConfig.SiteKey; - SecretKey = recaptchaConfig.SecretKey; - } - } - - public Task IsEnabled() - { - return Task.FromResult(Enable); - } - - public async Task Create(string elementId) - { - var page = DotNetObjectReference.Create(this); - var res = await JsRuntime.InvokeAsync("moonlight.recaptcha.render", elementId, SiteKey, page); - - return res.ToString() ?? ""; - } - - [JSInvokable, EditorBrowsable(EditorBrowsableState.Never)] - public async void CallbackOnSuccess(string res) - { - if(OnResponse != null) - await OnResponse.Invoke(res); - - var b = await Validate(res); - - if (b) - { - if(OnValidResponse != null) - await OnValidResponse.Invoke(); - } - } - - [JSInvokable, EditorBrowsable(EditorBrowsableState.Never)] - public void CallbackOnExpired() - { - - } - - private async Task Validate(string res) - { - var url = "https://www.google.com/recaptcha/api/siteverify"; - - var client = new RestClient(); - var request = new RestRequest(url); - request.AddParameter("secret", SecretKey); - request.AddParameter("response", res); - - var resp = await client.PostAsync(request); - - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(resp.Content)) - ).Build(); - return data.GetValue("success"); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/ToastService.cs b/Moonlight/App/Services/Interop/ToastService.cs deleted file mode 100644 index af66d12a..00000000 --- a/Moonlight/App/Services/Interop/ToastService.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Interop; - -public class ToastService -{ - private readonly IJSRuntime JsRuntime; - - public ToastService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - } - - public async Task Info(string message) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.info", message); - } - - public async Task Error(string message) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.error", message); - } - - public async Task Warning(string message) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.warning", message); - } - - public async Task Success(string message) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.success", message); - } - - public async Task CreateProcessToast(string id, string text) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.create", id, text); - } - - public async Task UpdateProcessToast(string id, string text) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.modify", id, text); - } - - public async Task RemoveProcessToast(string id) - { - await JsRuntime.InvokeVoidAsync("moonlight.toasts.remove", id); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/IpVerificationService.cs b/Moonlight/App/Services/IpVerificationService.cs deleted file mode 100644 index af67b523..00000000 --- a/Moonlight/App/Services/IpVerificationService.cs +++ /dev/null @@ -1,91 +0,0 @@ -using Moonlight.App.Helpers; -using Whois.NET; - -namespace Moonlight.App.Services; - -public class IpVerificationService -{ - private readonly ConfigService ConfigService; - - public IpVerificationService(ConfigService configService) - { - ConfigService = configService; - } - - public async Task IsDatacenterOrVpn(string ip) - { - if (!ConfigService.Get().Moonlight.Security.BlockDatacenterIps) - return false; - - if (string.IsNullOrEmpty(ip)) - return false; - - var datacenterNames = new List() - { - "amazon", - "aws", - "microsoft", - "azure", - "google", - "google cloud", - "gcp", - "digitalocean", - "linode", - "vultr", - "ovh", - "ovhcloud", - "alibaba", - "oracle", - "ibm cloud", - "bluehost", - "godaddy", - "rackpace", - "hetzner", - "tencent", - "scaleway", - "softlayer", - "dreamhost", - "a2 hosting", - "inmotion hosting", - "red hat openstack", - "kamatera", - "hostgator", - "siteground", - "greengeeks", - "liquidweb", - "joyent", - "aruba", - "interoute", - "fastcomet", - "rosehosting", - "lunarpages", - "fatcow", - "jelastic", - "datacamp" - }; - - if(!ConfigService.Get().Moonlight.Security.AllowCloudflareIps) - datacenterNames.Add("cloudflare"); - - try - { - var response = await WhoisClient.QueryAsync(ip); - var responseText = response.Raw.ToLower(); - - foreach (var name in datacenterNames) - { - if (responseText.Contains(name)) - { - Logger.Debug(name); - return true; - } - } - } - catch (Exception) - { - return false; - } - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/LetsEncryptService.cs b/Moonlight/App/Services/LetsEncryptService.cs deleted file mode 100644 index c9b684cc..00000000 --- a/Moonlight/App/Services/LetsEncryptService.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Security.Cryptography.X509Certificates; -using Certes; -using Certes.Acme; -using Microsoft.AspNetCore.Connections; -using Microsoft.AspNetCore.Http.Connections; -using Moonlight.App.Events; -using Moonlight.App.Helpers; - -namespace Moonlight.App.Services; - -public class LetsEncryptService -{ - private readonly ConfigService ConfigService; - private readonly string LetsEncryptCertPath; - private readonly EventSystem Event; - private X509Certificate2 Certificate; - - public string HttpChallenge { get; private set; } = ""; - public string HttpChallengeToken { get; private set; } = ""; - - public LetsEncryptService(ConfigService configService, EventSystem eventSystem) - { - ConfigService = configService; - Event = eventSystem; - LetsEncryptCertPath = PathBuilder.File("storage", "certs", "letsencrypt.pfx"); - } - - public async Task AutoProcess() - { - if (!ConfigService.Get().Moonlight.LetsEncrypt.Enable) - return; - - if (await CheckNeedsRenewal()) - { - try - { - await Renew(); - } - catch (Exception e) - { - Logger.Error("Unable to issue lets encrypt certificate"); - Logger.Error(e); - } - } - else - Logger.Info("Skipping lets encrypt renewal"); - - await LoadCertificate(); - } - - private Task LoadCertificate() - { - try - { - Certificate = new X509Certificate2( - LetsEncryptCertPath, - ConfigService.Get().Moonlight.Security.Token - ); - - Logger.Info($"Loaded ssl certificate. '{Certificate.FriendlyName}' issued by '{Certificate.IssuerName.Name}'"); - } - catch (Exception e) - { - Logger.Warn("Unable to load ssl certificates"); - Logger.Warn(e); - } - - return Task.CompletedTask; - } - - private async Task Renew() - { - Logger.Info("Renewing lets encrypt certificate"); - - var uri = new Uri(ConfigService.Get().Moonlight.AppUrl); - var config = ConfigService.Get().Moonlight.LetsEncrypt; - - if (uri.HostNameType == UriHostNameType.IPv4 || uri.HostNameType == UriHostNameType.IPv6) - { - Logger.Warn("You cannot use an ip to issue a lets encrypt certificate"); - return; - } - - var acmeContext = new AcmeContext(WellKnownServers.LetsEncryptV2); - - Logger.Info($"Starting lets encrypt certificate issuing. Using acme server '{acmeContext.DirectoryUri}'"); - - var account = await acmeContext.NewAccount(config.ExpireEmail, true); - - Logger.Info("Creating order"); - var order = await acmeContext.NewOrder(new[] { uri.Host }); - var authZ = (await order.Authorizations()).First(); - - var challenge = await authZ.Http(); - - HttpChallengeToken = challenge.Token; - HttpChallenge = challenge.KeyAuthz; - - Logger.Info("Waiting for http challenge to complete"); - - Task.Run(async () => - { - await Task.Delay(TimeSpan.FromSeconds(3)); - - try - { - await challenge.Validate(); - } - catch (Exception e) - { - Logger.Error("Unable to validate challenge"); - Logger.Error(e); - } - }); - - await Event.WaitForEvent("letsEncrypt.challengeFetched", this); - - Logger.Info("Generating certificate"); - - var privateKey = KeyFactory.NewKey(KeyAlgorithm.ES256); - - var certificate = await order.Generate(new CsrInfo - { - CountryName = config.CountryCode, - State = config.State, - Locality = config.Locality, - Organization = config.Organization, - OrganizationUnit = "Dev", - CommonName = uri.Host - }, privateKey); - - var builder = certificate.ToPfx(privateKey); - - var certBytes = builder.Build( - uri.Host, - ConfigService.Get().Moonlight.Security.Token - ); - - Logger.Info($"Saved lets encrypt certificate to '{LetsEncryptCertPath}'"); - await File.WriteAllBytesAsync(LetsEncryptCertPath, certBytes); - } - - private Task CheckNeedsRenewal() - { - if (!File.Exists(LetsEncryptCertPath)) - { - Logger.Info("No lets encrypt certificate found"); - return Task.FromResult(true); - } - - var existingCert = new X509Certificate2(LetsEncryptCertPath, ConfigService.Get().Moonlight.Security.Token); - var expirationDate = existingCert.NotAfter; - - if (DateTime.Now < expirationDate) - { - Logger.Info($"Lets encrypt certificate valid until {Formatter.FormatDate(expirationDate)}"); - return Task.FromResult(false); - } - - Logger.Info("Lets encrypt certificate expired"); - return Task.FromResult(true); - } - - public X509Certificate2? SelectCertificate(ConnectionContext? context, string? domain) - { - if (context == null) - return null; - - return Certificate; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Mail/MailService.cs b/Moonlight/App/Services/Mail/MailService.cs deleted file mode 100644 index f362b6d7..00000000 --- a/Moonlight/App/Services/Mail/MailService.cs +++ /dev/null @@ -1,127 +0,0 @@ -using MimeKit; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; -using SmtpClient = MailKit.Net.Smtp.SmtpClient; - -namespace Moonlight.App.Services.Mail; - -public class MailService -{ - private readonly string Server; - private readonly string Password; - private readonly string Email; - private readonly int Port; - private readonly bool Ssl; - - private readonly Repository UserRepository; - - public MailService( - ConfigService configService, - Repository userRepository) - { - UserRepository = userRepository; - - var mailConfig = configService - .Get() - .Moonlight.Mail; - - Server = mailConfig.Server; - Password = mailConfig.Password; - Email = mailConfig.Email; - Port = mailConfig.Port; - Ssl = mailConfig.Ssl; - } - - public Task SendMailRaw(User user, string html) - { - Task.Run(async () => - { - try - { - using var client = new SmtpClient(); - - var mailMessage = new MimeMessage(); - mailMessage.From.Add(new MailboxAddress(Email, Email)); - mailMessage.To.Add(new MailboxAddress(user.Email, user.Email)); - mailMessage.Subject = $"Hey {user.FirstName}, there are news from moonlight"; - - var body = new BodyBuilder - { - HtmlBody = html - }; - mailMessage.Body = body.ToMessageBody(); - - using var smtpClient = new SmtpClient(); - await smtpClient.ConnectAsync(Server, Port, Ssl); - await smtpClient.AuthenticateAsync(Email, Password); - await smtpClient.SendAsync(mailMessage); - await smtpClient.DisconnectAsync(true); - } - catch (Exception e) - { - Logger.Warn("Error sending mail"); - Logger.Warn(e); - } - }); - - return Task.CompletedTask; - } - - public async Task SendMail(User user, string template, Action> values) - { - if (!File.Exists(PathBuilder.File("storage", "resources", "mail", $"{template}.html"))) - { - Logger.Warn($"Mail template '{template}' not found. Make sure to place one in the resources folder"); - throw new DisplayException("Mail template not found"); - } - - var rawHtml = await File.ReadAllTextAsync(PathBuilder.File("storage", "resources", "mail", $"{template}.html")); - - var val = new Dictionary(); - values.Invoke(val); - - val.Add("FirstName", user.FirstName); - val.Add("LastName", user.LastName); - - var parsed = ParseMail(rawHtml, val); - - await SendMailRaw(user, parsed); - } - - public async Task SendEmailToAll(string template, Action> values) - { - var users = UserRepository - .Get() - .ToArray(); - - foreach (var user in users) - { - await SendMail(user, template, values); - } - } - - public async Task SendEmailToAllAdmins(string template, Action> values) - { - var users = UserRepository - .Get() - .Where(x => x.Admin) - .ToArray(); - - foreach (var user in users) - { - await SendMail(user, template, values); - } - } - - private string ParseMail(string html, Dictionary values) - { - foreach (var kvp in values) - { - html = html.Replace("{{" + kvp.Key + "}}", kvp.Value); - } - - return html; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/MalwareScanService.cs b/Moonlight/App/Services/MalwareScanService.cs deleted file mode 100644 index 0481b450..00000000 --- a/Moonlight/App/Services/MalwareScanService.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.MalwareScans; -using Moonlight.App.Models.Misc; -using Moonlight.App.Services.Plugins; - -namespace Moonlight.App.Services; - -public class MalwareScanService -{ - private readonly PluginService PluginService; - private readonly IServiceScopeFactory ServiceScopeFactory; - - public MalwareScanService(PluginService pluginService, IServiceScopeFactory serviceScopeFactory) - { - PluginService = pluginService; - ServiceScopeFactory = serviceScopeFactory; - } - - public async Task Perform(Server server) - { - var defaultScans = new List - { - new MinerJarScan(), - new FakePlayerPluginScan(), - new BadScriptsScan() - }; - - var scans = await PluginService.BuildMalwareScans(defaultScans.ToArray()); - - using var scope = ServiceScopeFactory.CreateScope(); - - foreach (var scan in scans) - { - var result = await scan.Scan(server, scope.ServiceProvider); - - if (result != null) - return result; - } - - return null; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Minecraft/FabricService.cs b/Moonlight/App/Services/Minecraft/FabricService.cs deleted file mode 100644 index 8498a93b..00000000 --- a/Moonlight/App/Services/Minecraft/FabricService.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Text; -using Moonlight.App.Helpers; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Moonlight.App.Services.Minecraft; - -public class FabricService -{ - private readonly HttpClient Client; - - public FabricService() - { - Client = new(); - } - - public async Task GetLatestInstallerVersion() - { - var data = await Client - .GetStringAsync("https://meta.fabricmc.net/v2/versions/installer"); - - var x = JsonConvert.DeserializeObject(data) ?? Array.Empty(); - - var stableVersions = new List(); - - foreach (var y in x) - { - var section = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes( - y.Root.ToString() - ) - ) - ).Build(); - - if (section.GetValue("stable")) - { - stableVersions.Add(section.GetValue("version")); - } - } - - return ParseHelper.GetHighestVersion(stableVersions.ToArray()); - } - - public async Task GetLatestLoaderVersion() - { - var data = await Client - .GetStringAsync("https://meta.fabricmc.net/v2/versions/loader"); - - var x = JsonConvert.DeserializeObject(data) ?? Array.Empty(); - - var stableVersions = new List(); - - foreach (var y in x) - { - var section = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes( - y.Root.ToString() - ) - ) - ).Build(); - - if (section.GetValue("stable")) - { - stableVersions.Add(section.GetValue("version")); - } - } - - return ParseHelper.GetHighestVersion(stableVersions.ToArray()); - } - public async Task GetGameVersions() - { - var data = await Client - .GetStringAsync("https://meta.fabricmc.net/v2/versions/game"); - - var x = JsonConvert.DeserializeObject(data) ?? Array.Empty(); - - var stableVersions = new List(); - - foreach (var y in x) - { - var section = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes( - y.Root.ToString() - ) - ) - ).Build(); - - if (section.GetValue("stable")) - { - stableVersions.Add(section.GetValue("version")); - } - } - - return stableVersions.ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Minecraft/ForgeService.cs b/Moonlight/App/Services/Minecraft/ForgeService.cs deleted file mode 100644 index a268ec5d..00000000 --- a/Moonlight/App/Services/Minecraft/ForgeService.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Text; - -namespace Moonlight.App.Services.Minecraft; - -public class ForgeService -{ - private readonly HttpClient Client; - - public ForgeService() - { - Client = new(); - } - - // Key: 1.9.4-recommended Value: 12.17.0.2317 - public async Task> GetVersions() - { - var data = await Client.GetStringAsync( - "https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json"); - - var json = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes( - data - ) - ) - ).Build(); - - var d = new Dictionary(); - - foreach (var section in json.GetSection("promos").GetChildren()) - { - d.Add(section.Key, section.Value!); - } - - return d; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Minecraft/PaperService.cs b/Moonlight/App/Services/Minecraft/PaperService.cs deleted file mode 100644 index 239f9d6d..00000000 --- a/Moonlight/App/Services/Minecraft/PaperService.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Moonlight.App.ApiClients.Paper; -using Moonlight.App.ApiClients.Paper.Resources; - -namespace Moonlight.App.Services.Minecraft; - -public class PaperService -{ - private readonly PaperApiHelper ApiHelper; - - public PaperService(PaperApiHelper apiHelper) - { - ApiHelper = apiHelper; - } - - public async Task GetVersions() - { - var data = await ApiHelper.Get("paper"); - - return data.Versions.ToArray(); - } - - public async Task GetBuilds(string version) - { - var data = await ApiHelper.Get($"paper/versions/{version}"); - - return data.Builds.ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/MoonlightService.cs b/Moonlight/App/Services/MoonlightService.cs deleted file mode 100644 index f8699f4a..00000000 --- a/Moonlight/App/Services/MoonlightService.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Moonlight.App.Helpers; -using Octokit; -using Repository = LibGit2Sharp.Repository; - -namespace Moonlight.App.Services; - -public class MoonlightService -{ - private readonly ConfigService ConfigService; - public readonly DateTime StartTimestamp; - public readonly string AppVersion; - public readonly List ChangeLog = new(); - - public MoonlightService(ConfigService configService) - { - ConfigService = configService; - StartTimestamp = DateTime.UtcNow; - - if (File.Exists("version") && !ConfigService.DebugMode) - AppVersion = File.ReadAllText("version"); - else if (ConfigService.DebugMode) - { - string repositoryPath = Path.GetFullPath(".."); - using var repo = new Repository(repositoryPath); - var commit = repo.Head.Tip; - AppVersion = commit.Sha; - } - else - AppVersion = "unknown"; - - Task.Run(FetchChangeLog); - } - - private async Task FetchChangeLog() - { - if (ConfigService.DebugMode) - { - ChangeLog.Add(new[] - { - "Disabled", - "Fetching changelog from github is disabled in debug mode" - }); - - return; - } - - try - { - var client = new GitHubClient(new ProductHeaderValue("Moonlight-Panel")); - - var pullRequests = await client.PullRequest.GetAllForRepository("Moonlight-Panel", "Moonlight", new PullRequestRequest - { - State = ItemStateFilter.Closed, - SortDirection = SortDirection.Ascending, - SortProperty = PullRequestSort.Created - }); - - var groupedPullRequests = new Dictionary>(); - - foreach (var pullRequest in pullRequests) - { - if (pullRequest.MergedAt != null) - { - var date = pullRequest.MergedAt.Value.Date; - - if (!groupedPullRequests.ContainsKey(date)) - { - groupedPullRequests[date] = new List(); - } - - groupedPullRequests[date].Add(pullRequest.Title); - } - } - - int i = 1; - foreach (var group in groupedPullRequests) - { - var pullRequestsList = new List(); - var date = group.Key.ToString("dd.MM.yyyy"); - - pullRequestsList.Add($"Patch {i}, {date}"); - - foreach (var pullRequest in group.Value) - { - pullRequestsList.Add(pullRequest); - } - - ChangeLog.Add(pullRequestsList.ToArray()); - i++; - } - } - catch (Exception e) - { - Logger.Warn("Error fetching changelog"); - Logger.Warn(e); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/NodeService.cs b/Moonlight/App/Services/NodeService.cs deleted file mode 100644 index 704c22fc..00000000 --- a/Moonlight/App/Services/NodeService.cs +++ /dev/null @@ -1,91 +0,0 @@ -using Moonlight.App.ApiClients.Daemon; -using Moonlight.App.ApiClients.Daemon.Requests; -using Moonlight.App.ApiClients.Daemon.Resources; -using Moonlight.App.ApiClients.Wings; -using Moonlight.App.ApiClients.Wings.Resources; -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services; - -public class NodeService -{ - private readonly WingsApiHelper WingsApiHelper; - private readonly DaemonApiHelper DaemonApiHelper; - - public NodeService(WingsApiHelper wingsApiHelper, DaemonApiHelper daemonApiHelper) - { - WingsApiHelper = wingsApiHelper; - DaemonApiHelper = daemonApiHelper; - } - - public async Task GetStatus(Node node) - { - return await WingsApiHelper.Get(node, "api/system"); - } - - public async Task GetCpuMetrics(Node node) - { - return await DaemonApiHelper.Get(node, "metrics/cpu"); - } - - public async Task GetMemoryMetrics(Node node) - { - return await DaemonApiHelper.Get(node, "metrics/memory"); - } - - public async Task GetDiskMetrics(Node node) - { - return await DaemonApiHelper.Get(node, "metrics/disk"); - } - - public async Task GetSystemMetrics(Node node) - { - return await DaemonApiHelper.Get(node, "metrics/system"); - } - - public async Task GetDockerMetrics(Node node) - { - return await DaemonApiHelper.Get(node, "metrics/docker"); - } - - public async Task RebuildFirewall(Node node, string[] ips) - { - await DaemonApiHelper.Post(node, "firewall/rebuild", ips); - } - - public async Task Mount(Node node, string server, string serverPath, string path) - { - await DaemonApiHelper.Post(node, "mount", new Mount() - { - Server = server, - ServerPath = serverPath, - Path = path - }); - } - - public async Task Unmount(Node node, string path) - { - await DaemonApiHelper.Delete(node, "mount", new Unmount() - { - Path = path - }); - } - - public async Task IsHostUp(Node node) - { - try - { - await GetStatus(node); - - return true; - } - catch (Exception) - { - // ignored - } - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Notifications/NotificationAdminService.cs b/Moonlight/App/Services/Notifications/NotificationAdminService.cs deleted file mode 100644 index 38d98bd5..00000000 --- a/Moonlight/App/Services/Notifications/NotificationAdminService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moonlight.App.Services.Notifications; - -public class NotificationAdminService -{ - -} \ No newline at end of file diff --git a/Moonlight/App/Services/Notifications/NotificationServerService.cs b/Moonlight/App/Services/Notifications/NotificationServerService.cs deleted file mode 100644 index 9dd19b14..00000000 --- a/Moonlight/App/Services/Notifications/NotificationServerService.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System.Net.WebSockets; -using System.Text; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Database.Entities.Notification; -using Moonlight.App.Events; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Notifications; - -public class NotificationServerService -{ - private readonly List ActiveClients = new(); - - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly EventSystem Event; - - public NotificationServerService(IServiceScopeFactory serviceScopeFactory, EventSystem eventSystem) - { - ServiceScopeFactory = serviceScopeFactory; - Event = eventSystem; - } - - public Task GetActiveClients() - { - lock (ActiveClients) - { - return Task.FromResult(ActiveClients.ToArray()); - } - } - - public Task GetUserClients(User user) - { - lock (ActiveClients) - { - return Task.FromResult( - ActiveClients - .Where(x => x.Client.User.Id == user.Id) - .ToArray() - ); - } - } - - public async Task SendAction(User user, string action) - { - using var scope = ServiceScopeFactory.CreateScope(); - var notificationClientRepository = - scope.ServiceProvider.GetRequiredService>(); - - var clients = notificationClientRepository - .Get() - .Include(x => x.User) - .Where(x => x.User == user) - .ToList(); - - foreach (var client in clients) - { - ActiveNotificationClient[] connectedUserClients; - - lock (ActiveClients) - { - connectedUserClients = ActiveClients - .Where(x => x.Client.Id == user.Id) - .ToArray(); - } - - if (connectedUserClients.Length > 0) - { - await connectedUserClients[0].SendAction(action); - } - else - { - var notificationAction = new NotificationAction() - { - Action = action, - NotificationClient = client - }; - - var notificationActionsRepository = - scope.ServiceProvider.GetRequiredService>(); - - notificationActionsRepository.Add(notificationAction); - } - } - } - - public async Task RegisterClient(WebSocket webSocket, NotificationClient notificationClient) - { - var newClient = new ActiveNotificationClient() - { - WebSocket = webSocket, - Client = notificationClient - }; - - lock (ActiveClients) - { - ActiveClients.Add(newClient); - } - - await Event.Emit("notifications.addClient", notificationClient); - } - - public async Task UnRegisterClient(NotificationClient client) - { - lock (ActiveClients) - { - ActiveClients.RemoveAll(x => x.Client == client); - } - - await Event.Emit("notifications.removeClient", client); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/OAuth2Service.cs b/Moonlight/App/Services/OAuth2Service.cs deleted file mode 100644 index 87804732..00000000 --- a/Moonlight/App/Services/OAuth2Service.cs +++ /dev/null @@ -1,114 +0,0 @@ -using Mappy.Net; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.OAuth2; -using Moonlight.App.OAuth2.Providers; - -namespace Moonlight.App.Services; - -public class OAuth2Service -{ - public readonly Dictionary Providers = new(); - private readonly OAuth2ProviderConfig[] Configs; - - private readonly ConfigService ConfigService; - private readonly IServiceScopeFactory ServiceScopeFactory; - - private readonly string OverrideUrl; - private readonly bool EnableOverrideUrl; - private readonly string AppUrl; - - public OAuth2Service(ConfigService configService, IServiceScopeFactory serviceScopeFactory) - { - ConfigService = configService; - ServiceScopeFactory = serviceScopeFactory; - - var config = ConfigService - .Get() - .Moonlight.OAuth2; - - Configs = config.Providers - .Select(Mapper.Map) - .ToArray(); - - OverrideUrl = config.OverrideUrl; - EnableOverrideUrl = config.EnableOverrideUrl; - AppUrl = configService.Get().Moonlight.AppUrl; - - // Register additional providers here - RegisterOAuth2("discord"); - RegisterOAuth2("google"); - } - - private void RegisterOAuth2(string id, string displayName = "") - { - var name = - string.IsNullOrEmpty(displayName) ? - StringHelper.CapitalizeFirstCharacter(id) : displayName; - - if(Configs.All(x => x.Id != id)) - return; - - var provider = Activator.CreateInstance()! as OAuth2Provider; - - if (provider == null) - throw new Exception($"Unable to cast oauth2 provider '{typeof(T).Name}'"); - - provider.Config = Configs.First(x => x.Id == id); - provider.Url = GetAppUrl(); - provider.ServiceScopeFactory = ServiceScopeFactory; - provider.DisplayName = name; - - Providers.Add(id, provider); - } - - public async Task GetUrl(string id) - { - if (Providers.All(x => x.Key != id)) - throw new DisplayException("Invalid oauth2 id"); - - var provider = Providers[id]; - - return await provider.GetUrl(); - } - - public async Task HandleCode(string id, string code) - { - if (Providers.All(x => x.Key != id)) - throw new DisplayException("Invalid oauth2 id"); - - var provider = Providers[id]; - - return await provider.HandleCode(code); - } - - public Task CanBeLinked(string id) - { - if (Providers.All(x => x.Key != id)) - throw new DisplayException("Invalid oauth2 id"); - - var provider = Providers[id]; - - return Task.FromResult(provider.CanBeLinked); - } - - public async Task LinkToUser(string id, User user, string code) - { - if (Providers.All(x => x.Key != id)) - throw new DisplayException("Invalid oauth2 id"); - - var provider = Providers[id]; - - await provider.LinkToUser(user, code); - } - - private string GetAppUrl() - { - if (EnableOverrideUrl) - return OverrideUrl; - - return AppUrl; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/OneTimeJwtService.cs b/Moonlight/App/Services/OneTimeJwtService.cs deleted file mode 100644 index a4a377eb..00000000 --- a/Moonlight/App/Services/OneTimeJwtService.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.Text; -using JWT.Algorithms; -using JWT.Builder; -using JWT.Exceptions; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services; - -public class OneTimeJwtService -{ - private readonly ConfigService ConfigService; - private readonly RevokeRepository RevokeRepository; - - public OneTimeJwtService(ConfigService configService, - RevokeRepository revokeRepository) - { - ConfigService = configService; - RevokeRepository = revokeRepository; - } - - public string Generate(Action> options, TimeSpan? validTime = null) - { - var opt = new Dictionary(); - options.Invoke(opt); - - var secret = ConfigService - .Get() - .Moonlight.Security.Token; - - var id = StringHelper.GenerateString(16); - - var builder = JwtBuilder.Create() - .WithAlgorithm(new HMACSHA256Algorithm()) - .WithSecret(secret) - .AddClaim("unique_id", id) - .AddClaim("iat", DateTimeOffset.Now.ToUnixTimeSeconds()) - .AddClaim("nbf", DateTimeOffset.Now.AddSeconds(-10).ToUnixTimeSeconds()) - .MustVerifySignature(); - - if (validTime == null) - builder = builder.AddClaim("exp", DateTimeOffset.Now.AddMinutes(10).ToUnixTimeSeconds()); - else - builder = builder.AddClaim("exp", DateTimeOffset.Now.Add(validTime.Value).ToUnixTimeSeconds()); - - foreach (var o in opt) - { - builder = builder.AddClaim(o.Key, o.Value); - } - - return builder.Encode(); - } - - public async Task?> Validate(string token) - { - var secret = ConfigService - .Get() - .Moonlight.Security.Token; - - string json; - - try - { - json = JwtBuilder.Create() - .WithAlgorithm(new HMACSHA256Algorithm()) - .WithSecret(secret) - .Decode(token); - } - catch (SignatureVerificationException) - { - Logger.Warn($"Detected a manipulated JWT: {token}", "security"); - return null; - } - catch (Exception e) - { - return null; - } - - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(json)) - ).Build(); - - var id = data.GetValue("unique_id"); - - if (RevokeRepository - .Get() - .FirstOrDefault(x => x.Identifier == id) != null) - { - throw new DisplayException("This token has been already used"); - } - - var opt = new Dictionary(); - - foreach (var child in data.GetChildren()) - { - opt.Add(child.Key, child.Value!); - } - - return opt; - } - - public async Task Revoke(string token) - { - var values = await Validate(token); - - RevokeRepository.Add(new() - { - Identifier = values["unique_id"] - }); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Plugins/PluginService.cs b/Moonlight/App/Services/Plugins/PluginService.cs deleted file mode 100644 index ad2db1ae..00000000 --- a/Moonlight/App/Services/Plugins/PluginService.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Reflection; -using System.Runtime.Loader; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Plugin; -using Moonlight.App.Plugin.UI.Servers; -using Moonlight.App.Plugin.UI.Webspaces; - -namespace Moonlight.App.Services.Plugins; - -public class PluginService -{ - public readonly List Plugins = new(); - public readonly Dictionary PluginFiles = new(); - - public Task ReloadPlugins() - { - PluginFiles.Clear(); - Plugins.Clear(); - - // Try to update all plugins ending with .dll.cache - foreach (var pluginFile in Directory.EnumerateFiles( - PathBuilder.Dir(Directory.GetCurrentDirectory(), "storage", "plugins")) - .Where(x => x.EndsWith(".dll.cache"))) - { - try - { - var realPath = pluginFile.Replace(".cache", ""); - File.Copy(pluginFile, realPath, true); - File.Delete(pluginFile); - Logger.Info($"Updated plugin {realPath} on startup"); - } - catch (Exception) - { - // ignored - } - } - - var pluginType = typeof(MoonlightPlugin); - - foreach (var pluginFile in Directory.EnumerateFiles( - PathBuilder.Dir(Directory.GetCurrentDirectory(), "storage", "plugins")) - .Where(x => x.EndsWith(".dll"))) - { - var assembly = Assembly.LoadFile(pluginFile); - - foreach (var type in assembly.GetTypes()) - { - if (type.IsSubclassOf(pluginType)) - { - var plugin = (Activator.CreateInstance(type) as MoonlightPlugin)!; - - Logger.Info($"Loaded plugin '{plugin.Name}' ({plugin.Version}) by {plugin.Author}"); - - Plugins.Add(plugin); - PluginFiles.Add(plugin, pluginFile); - } - } - } - - Logger.Info($"Loaded {Plugins.Count} plugins"); - - return Task.CompletedTask; - } - - public async Task BuildServerPage(ServerPageContext context) - { - foreach (var plugin in Plugins) - { - if (plugin.OnBuildServerPage != null) - await plugin.OnBuildServerPage.Invoke(context); - } - - return context; - } - - public async Task BuildWebspacePage(WebspacePageContext context) - { - foreach (var plugin in Plugins) - { - if (plugin.OnBuildWebspacePage != null) - await plugin.OnBuildWebspacePage.Invoke(context); - } - - return context; - } - - public async Task BuildServices(IServiceCollection serviceCollection) - { - foreach (var plugin in Plugins) - { - if (plugin.OnBuildServices != null) - await plugin.OnBuildServices.Invoke(serviceCollection); - } - } - - public async Task BuildMalwareScans(MalwareScan[] defaultScans) - { - var scanList = defaultScans.ToList(); - - foreach (var plugin in Plugins) - { - if (plugin.OnBuildMalwareScans != null) - scanList = await plugin.OnBuildMalwareScans.Invoke(scanList); - } - - return scanList.ToArray(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Plugins/PluginStoreService.cs b/Moonlight/App/Services/Plugins/PluginStoreService.cs deleted file mode 100644 index 4d885d03..00000000 --- a/Moonlight/App/Services/Plugins/PluginStoreService.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Text; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Octokit; - -namespace Moonlight.App.Services.Plugins; - -public class PluginStoreService -{ - private readonly GitHubClient Client; - private readonly PluginService PluginService; - - public PluginStoreService(PluginService pluginService) - { - PluginService = pluginService; - Client = new(new ProductHeaderValue("Moonlight-Panel")); - } - - public async Task GetPlugins() - { - var items = await Client.Repository.Content.GetAllContents("Moonlight-Panel", "OfficialPlugins"); - - if (items == null) - { - Logger.Fatal("Unable to read plugin repo contents"); - return Array.Empty(); - } - - return items - .Where(x => x.Type == ContentType.Dir) - .Select(x => new OfficialMoonlightPlugin() - { - Name = x.Name - }) - .ToArray(); - } - - public async Task GetPluginReadme(OfficialMoonlightPlugin plugin) - { - var rawReadme = await Client.Repository.Content - .GetRawContent("Moonlight-Panel", "OfficialPlugins", $"{plugin.Name}/README.md"); - - if (rawReadme == null) - return "Error"; - - return Encoding.UTF8.GetString(rawReadme); - } - - public async Task InstallPlugin(OfficialMoonlightPlugin plugin, bool updating = false) - { - var rawPlugin = await Client.Repository.Content - .GetRawContent("Moonlight-Panel", "OfficialPlugins", $"{plugin.Name}/{plugin.Name}.dll"); - - if (updating) - { - await File.WriteAllBytesAsync(PathBuilder.File("storage", "plugins", $"{plugin.Name}.dll.cache"), rawPlugin); - return; - } - - await File.WriteAllBytesAsync(PathBuilder.File("storage", "plugins", $"{plugin.Name}.dll"), rawPlugin); - await PluginService.ReloadPlugins(); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/RatingService.cs b/Moonlight/App/Services/RatingService.cs deleted file mode 100644 index 083ed4cc..00000000 --- a/Moonlight/App/Services/RatingService.cs +++ /dev/null @@ -1,86 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services; - -public class RatingService -{ - private readonly IdentityService IdentityService; - private readonly EventSystem Event; - private readonly Repository UserRepository; - - private readonly bool Enabled = false; - private readonly string Url = ""; - private readonly int MinRating = 4; - private readonly int DaysSince = 5; - - public RatingService( - IdentityService identityService, - ConfigService configService, - EventSystem eventSystem, - Repository userRepository) - { - IdentityService = identityService; - Event = eventSystem; - UserRepository = userRepository; - - var config = configService.Get().Moonlight.Rating; - - Enabled = config.Enabled; - Url = config.Url; - MinRating = config.MinRating; - DaysSince = config.DaysSince; - } - - public async Task ShouldRate() - { - if (!Enabled) - return false; - - var user = IdentityService.User; - - if (user == null) - return false; - - if (user.HasRated) - return false; - - if ((DateTime.UtcNow - user.CreatedAt).TotalDays >= DaysSince) - { - return true; - } - - return false; - } - - public Task GetRateUrl() - { - return Task.FromResult(Url); - } - - public async Task Rate(int rate) - { - var user = IdentityService.User; - - // Double check states: - - if(user == null) - return false; - - if(user.HasRated) - return false; - - user.HasRated = true; - user.Rating = rate; - - UserRepository.Update(user); - await Event.Emit("user.rating", user); - - if (rate >= MinRating) - return true; - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/ServerService.cs b/Moonlight/App/Services/ServerService.cs deleted file mode 100644 index 11ec06ba..00000000 --- a/Moonlight/App/Services/ServerService.cs +++ /dev/null @@ -1,541 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.ApiClients.Wings; -using Moonlight.App.ApiClients.Wings.Requests; -using Moonlight.App.ApiClients.Wings.Resources; -using Moonlight.App.Database; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Helpers.Files; -using Moonlight.App.Helpers.Wings; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; -using Moonlight.App.Repositories.Servers; -using Moonlight.App.Services.Background; -using Moonlight.App.Services.Plugins; -using FileAccess = Moonlight.App.Helpers.Files.FileAccess; - -namespace Moonlight.App.Services; - -public class ServerService -{ - private readonly Repository ServerVariablesRepository; - private readonly ServerRepository ServerRepository; - private readonly UserRepository UserRepository; - private readonly ImageRepository ImageRepository; - private readonly NodeRepository NodeRepository; - private readonly NodeAllocationRepository NodeAllocationRepository; - private readonly WingsApiHelper WingsApiHelper; - private readonly UserService UserService; - private readonly ConfigService ConfigService; - private readonly WingsJwtHelper WingsJwtHelper; - private readonly NodeService NodeService; - private readonly DateTimeService DateTimeService; - private readonly EventSystem Event; - - // We inject the dependencies for the malware scan service here because otherwise it may result in - // a circular dependency injection which will crash the app - private readonly PluginService PluginService; - private readonly IServiceScopeFactory ServiceScopeFactory; - - public ServerService( - ServerRepository serverRepository, - WingsApiHelper wingsApiHelper, - UserRepository userRepository, - ImageRepository imageRepository, - NodeRepository nodeRepository, - UserService userService, - ConfigService configService, - WingsJwtHelper wingsJwtHelper, - NodeService nodeService, - NodeAllocationRepository nodeAllocationRepository, - DateTimeService dateTimeService, - EventSystem eventSystem, - Repository serverVariablesRepository, - PluginService pluginService, - IServiceScopeFactory serviceScopeFactory) - { - ServerRepository = serverRepository; - WingsApiHelper = wingsApiHelper; - UserRepository = userRepository; - ImageRepository = imageRepository; - NodeRepository = nodeRepository; - UserService = userService; - ConfigService = configService; - WingsJwtHelper = wingsJwtHelper; - NodeService = nodeService; - NodeAllocationRepository = nodeAllocationRepository; - DateTimeService = dateTimeService; - Event = eventSystem; - ServerVariablesRepository = serverVariablesRepository; - PluginService = pluginService; - ServiceScopeFactory = serviceScopeFactory; - } - - private Server EnsureNodeData(Server s) - { - if (s.Node == null) // Ensure node data is available - { - return ServerRepository - .Get() - .Include(x => x.Node) - .First(x => x.Id == s.Id); - } - else - return s; - } - - public async Task GetDetails(Server s) - { - Server server = EnsureNodeData(s); - - ServerDetails result = null!; - - await new Retry() - .Times(3) - .At(x => x.Message.Contains("A task was canceled")) - .Call(async () => - { - result = await WingsApiHelper.Get( - server.Node, - $"api/servers/{server.Uuid}" - ); - }); - - return result; - } - - public async Task SetPowerState(Server s, PowerSignal signal) - { - Server server = EnsureNodeData(s); - - if (ConfigService.Get().Moonlight.Security.MalwareCheckOnStart && signal == PowerSignal.Start || - signal == PowerSignal.Restart) - { - var result = await new MalwareScanService( - PluginService, - ServiceScopeFactory - ).Perform(server); - - if (result != null) - { - Logger.Warn($"Found malware on server {server.Uuid}. Result: " + result.Title, "security"); - - throw new DisplayException( - $"Unable to start server. Found following malware on this server: {result.Title}. Please contact the support if you think this detection is a false positive", - true); - } - } - - var rawSignal = signal.ToString().ToLower(); - - await WingsApiHelper.Post(server.Node, $"api/servers/{server.Uuid}/power", new ServerPower() - { - Action = rawSignal - }); - - //TODO: AuditLog - } - - public async Task CreateBackup(Server server) - { - var serverData = ServerRepository // Ensure data - .Get() - .Include(x => x.Node) - .Include(x => x.Backups) - .First(x => x.Id == server.Id); - - var backup = new ServerBackup() - { - Name = - $"Created at {DateTimeService.GetCurrent().ToShortDateString()} {DateTimeService.GetCurrent().ToShortTimeString()}", - Uuid = Guid.NewGuid(), - CreatedAt = DateTimeService.GetCurrent(), - Created = false - }; - - serverData.Backups.Add(backup); - ServerRepository.Update(serverData); - - await WingsApiHelper.Post(serverData.Node, $"api/servers/{serverData.Uuid}/backup", new CreateBackup() - { - Adapter = "wings", - Uuid = backup.Uuid, - Ignore = "" - }); - - //TODO: AuditLog - - return backup; - } - - public Task GetBackups(Server server, bool forceReload = false) - { - if (forceReload) //TODO: Find an alternative to avoid cache and the creation of a new db context - { - var serverData = new ServerRepository(new DataContext(ConfigService)) - .Get() - .Include(x => x.Backups) - .First(x => x.Id == server.Id); - - return Task.FromResult(serverData.Backups.ToArray()); - } - else - { - var serverData = ServerRepository - .Get() - .Include(x => x.Backups) - .First(x => x.Id == server.Id); - - return Task.FromResult(serverData.Backups.ToArray()); - } - } - - public async Task RestoreBackup(Server s, ServerBackup serverBackup) - { - Server server = EnsureNodeData(s); - - await WingsApiHelper.Post(server.Node, $"api/servers/{server.Uuid}/backup/{serverBackup.Uuid}/restore", - new RestoreBackup() - { - Adapter = "wings" - }); - - //TODO: AuditLog - } - - public async Task DeleteBackup(Server server, ServerBackup serverBackup) - { - var serverData = ServerRepository - .Get() - .Include(x => x.Node) - .Include(x => x.Backups) - .First(x => x.Id == server.Id); - - try - { - await new Retry() - .Times(3) - .At(x => x.Message.Contains("A task was canceled")) - .Call(async () => - { - await WingsApiHelper.Delete(serverData.Node, - $"api/servers/{serverData.Uuid}/backup/{serverBackup.Uuid}", - null); - }); - } - catch (WingsException e) - { - // when a backup is not longer there we can - // safely delete the backup so we ignore this error - if (e.StatusCode != 404) - { - throw; - } - } - - var backup = serverData.Backups.First(x => x.Uuid == serverBackup.Uuid); - serverData.Backups.Remove(backup); - - ServerRepository.Update(serverData); - - await Event.Emit("wings.backups.delete", backup); - - //TODO: AuditLog - } - - public async Task DownloadBackup(Server s, ServerBackup serverBackup) - { - Server server = EnsureNodeData(s); - - var token = WingsJwtHelper.Generate(server.Node.Token, claims => - { - claims.Add("server_uuid", server.Uuid.ToString()); - claims.Add("backup_uuid", serverBackup.Uuid.ToString()); - }); - - //TODO: AuditLog - - if (server.Node.Ssl) - return $"https://{server.Node.Fqdn}:{server.Node.HttpPort}/download/backup?token={token}"; - else - return $"http://{server.Node.Fqdn}:{server.Node.HttpPort}/download/backup?token={token}"; - } - - public Task CreateFileAccess(Server s, User user) // We need the user to create the launch url - { - Server server = EnsureNodeData(s); - - return Task.FromResult( - (FileAccess)new WingsFileAccess( - WingsApiHelper, - WingsJwtHelper, - server, - ConfigService, - user - ) - ); - } - - public async Task Create(string name, int cpu, long memory, long disk, User u, Image i, Node? n = null, - Action? modifyDetails = null) - { - var user = UserRepository - .Get() - .First(x => x.Id == u.Id); - - var image = ImageRepository - .Get() - .Include(x => x.Variables) - .Include(x => x.DockerImages) - .First(x => x.Id == i.Id); - - var allocations = image.Allocations; - - Node node = n ?? NodeRepository.Get().First(); - - NodeAllocation[] freeAllocations; - - try - { - // We have sadly no choice to use entity framework to do what the sql call does, there - // are only slower ways, so we will use a raw sql call as a exception - - freeAllocations = NodeAllocationRepository - .Get() - .FromSqlRaw( - $"SELECT * FROM `NodeAllocations` WHERE ServerId IS NULL AND NodeId={node.Id} LIMIT {allocations}") - .ToArray(); - } - catch (Exception) - { - throw new DisplayException("No allocation found"); - } - - if (!freeAllocations.Any()) - throw new DisplayException("No allocation found"); - - if (freeAllocations.Length != allocations) - throw new DisplayException("Not enough allocations found"); - - var server = new Server() - { - Cpu = cpu, - Memory = memory, - Disk = disk, - Name = name, - Image = image, - Owner = user, - Node = node, - Uuid = Guid.NewGuid(), - MainAllocation = freeAllocations.First(), - Allocations = freeAllocations.ToList(), - Backups = new(), - OverrideStartup = "", - DockerImageIndex = image.DockerImages.FindIndex(x => x.Default), - Installing = true - }; - - foreach (var imageVariable in image.Variables) - { - server.Variables.Add(new() - { - Key = imageVariable.Key, - Value = imageVariable.DefaultValue - }); - } - - if (modifyDetails != null) - modifyDetails.Invoke(server); - - var newServerData = ServerRepository.Add(server); - - try - { - await new Retry() - .Times(3) - .At(x => x.Message.Contains("A task was canceled")) - .Call(async () => - { - await WingsApiHelper.Post(node, $"api/servers", new CreateServer() - { - Uuid = newServerData.Uuid, - StartOnCompletion = false - }); - }); - - //TODO: AuditLog - - return newServerData; - } - catch (Exception e) - { - Logger.Error("Error creating server on wings"); - Logger.Error(e); - - ServerRepository.Delete(newServerData); //TODO Remove unsinged table stuff - - throw new DisplayException("Error creating server on wings"); - } - } - - public async Task Reinstall(Server s) - { - Server server = EnsureNodeData(s); - - await WingsApiHelper.Post(server.Node, $"api/servers/{server.Uuid}/reinstall", null); - - server.Installing = true; - ServerRepository.Update(server); - - //TODO: AuditLog - } - - public async Task SftpServerLogin(int serverId, int id, string password) - { - var server = ServerRepository.Get().FirstOrDefault(x => x.Id == serverId); - - if (server == null) - { - Logger.Warn($"Detected an sftp bruteforce attempt. ID: {id} Password: {password}", "security"); - throw new Exception("Server not found"); - } - - var user = await UserService.SftpLogin(id, password); - - if (server.Owner.Id == user.Id || user.Admin) - { - return server; - } - else - { - //TODO: Decide if logging - throw new Exception("User and owner id do not match"); - } - } - - public async Task Sync(Server s) - { - var server = EnsureNodeData(s); - - await WingsApiHelper.Post(server.Node, $"api/servers/{server.Uuid}/sync", null); - } - - public async Task Delete(Server s) - { - var backups = await GetBackups(s); - - foreach (var backup in backups) - { - try - { - await DeleteBackup(s, backup); - } - catch (Exception) - { - // ignored - } - } - - var server = ServerRepository - .Get() - .Include(x => x.Variables) - .Include(x => x.Node) - .First(x => x.Id == s.Id); - - try - { - await new Retry() - .Times(3) - .At(x => x.Message.Contains("A task was canceled")) - .Call(async () => { await WingsApiHelper.Delete(server.Node, $"api/servers/{server.Uuid}", null); }); - } - catch (WingsException e) - { - if (e.StatusCode != 404) - throw; - } - - foreach (var variable in server.Variables.ToArray()) - { - ServerVariablesRepository.Delete(variable); - } - - server.Allocations = new(); - server.MainAllocation = null; - server.Variables = new(); - server.Backups = new(); - - ServerRepository.Update(server); - ServerRepository.Delete(server); - } - - public async Task IsHostUp(Server s) - { - var server = EnsureNodeData(s); - - return await NodeService.IsHostUp(server.Node); - } - - public async Task ArchiveServer(Server server) - { - if (server.IsArchived) - throw new DisplayException("Unable to archive an already archived server"); - - // Archive server - - var backup = await CreateBackup(server); - server.IsArchived = true; - server.Archive = backup; - - ServerRepository.Update(server); - - await Event.WaitForEvent("wings.backups.create", this, x => backup.Id == x.Id); - - // Reset server - - var access = await CreateFileAccess(server, null!); - var files = await access.Ls(); - foreach (var file in files) - { - try - { - await access.Delete(file); - } - catch (Exception) - { - // ignored - } - } - - await Event.Emit($"server.{server.Uuid}.archiveStatusChanged", server); - } - - public async Task UnArchiveServer(Server s) - { - if (!s.IsArchived) - throw new DisplayException("Unable to unarchive a server which is not archived"); - - var server = ServerRepository - .Get() - .Include(x => x.Archive) - .First(x => x.Id == s.Id); - - if (server.Archive == null) - throw new DisplayException("Archive from server not found"); - - if (!server.Archive.Created) - throw new DisplayException("Creating the server archive is in progress"); - - await RestoreBackup(server, server.Archive); - - await Event.WaitForEvent("wings.backups.restore", this, - x => x.Id == server.Archive.Id); - - server.IsArchived = false; - ServerRepository.Update(server); - - await Event.Emit($"server.{server.Uuid}.archiveStatusChanged", server); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/CookieService.cs b/Moonlight/App/Services/Sessions/CookieService.cs deleted file mode 100644 index 77df98bf..00000000 --- a/Moonlight/App/Services/Sessions/CookieService.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Sessions; - -public class CookieService -{ - private readonly IJSRuntime JsRuntime; - private string Expires = ""; - - public CookieService(IJSRuntime jsRuntime) - { - JsRuntime = jsRuntime; - ExpireDays = 300; - } - - public async Task SetValue(string key, string value, int? days = null) - { - var curExp = (days != null) ? (days > 0 ? DateToUTC(days.Value) : "") : Expires; - await SetCookie($"{key}={value}; expires={curExp}; path=/"); - } - - public async Task GetValue(string key, string def = "") - { - var cValue = await GetCookie(); - if (string.IsNullOrEmpty(cValue)) return def; - - var vals = cValue.Split(';'); - foreach (var val in vals) - if(!string.IsNullOrEmpty(val) && val.IndexOf('=') > 0) - if(val.Substring(1, val.IndexOf('=') - 1).Trim().Equals(key, StringComparison.OrdinalIgnoreCase)) - return val.Substring(val.IndexOf('=') + 1); - return def; - } - - private async Task SetCookie(string value) - { - await JsRuntime.InvokeVoidAsync("eval", $"document.cookie = \"{value}\""); - } - - private async Task GetCookie() - { - return await JsRuntime.InvokeAsync("eval", $"document.cookie"); - } - - private int ExpireDays - { - set => Expires = DateToUTC(value); - } - - private static string DateToUTC(int days) => DateTime.Now.AddDays(days).ToUniversalTime().ToString("R"); -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/DynamicBackgroundService.cs b/Moonlight/App/Services/Sessions/DynamicBackgroundService.cs deleted file mode 100644 index ebc3edfb..00000000 --- a/Moonlight/App/Services/Sessions/DynamicBackgroundService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Moonlight.App.Services.Files; - -namespace Moonlight.App.Services.Sessions; - -public class DynamicBackgroundService -{ - public EventHandler OnBackgroundImageChanged { get; set; } - public string BackgroundImageUrl { get; private set; } - private string DefaultBackgroundImageUrl; - - public DynamicBackgroundService(ResourceService resourceService) - { - DefaultBackgroundImageUrl = resourceService.BackgroundImage("main.jpg"); - BackgroundImageUrl = DefaultBackgroundImageUrl; - } - - public Task Change(string url) - { - if(BackgroundImageUrl == url) // Prevent unnecessary updates - return Task.CompletedTask; - - BackgroundImageUrl = url; - OnBackgroundImageChanged?.Invoke(this, null!); - - return Task.CompletedTask; - } - - public Task Reset() - { - if(BackgroundImageUrl == DefaultBackgroundImageUrl) // Prevent unnecessary updates - return Task.CompletedTask; - - BackgroundImageUrl = DefaultBackgroundImageUrl; - OnBackgroundImageChanged?.Invoke(this, null!); - - return Task.CompletedTask; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/IdentityService.cs b/Moonlight/App/Services/Sessions/IdentityService.cs deleted file mode 100644 index 77582b70..00000000 --- a/Moonlight/App/Services/Sessions/IdentityService.cs +++ /dev/null @@ -1,284 +0,0 @@ -using System.Text; -using JWT.Algorithms; -using JWT.Builder; -using JWT.Exceptions; -using Microsoft.EntityFrameworkCore; -using Microsoft.JSInterop; -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers; -using Moonlight.App.Perms; -using Moonlight.App.Repositories; -using UAParser; - -namespace Moonlight.App.Services.Sessions; - -public class IdentityService -{ - private readonly Repository UserRepository; - private readonly CookieService CookieService; - private readonly IHttpContextAccessor HttpContextAccessor; - private readonly IJSRuntime JsRuntime; - private readonly string Secret; - - public User User { get; private set; } - public string Ip { get; private set; } = "N/A"; - public string Device { get; private set; } = "N/A"; - public PermissionStorage Permissions { get; private set; } - public PermissionStorage UserPermissions { get; private set; } - public PermissionStorage GroupPermissions { get; private set; } - - public IdentityService( - CookieService cookieService, - Repository userRepository, - IHttpContextAccessor httpContextAccessor, - ConfigService configService, - IJSRuntime jsRuntime) - { - CookieService = cookieService; - UserRepository = userRepository; - HttpContextAccessor = httpContextAccessor; - JsRuntime = jsRuntime; - - Secret = configService - .Get() - .Moonlight.Security.Token; - } - - public async Task Load() - { - await LoadIp(); - await LoadDevice(); - await LoadUser(); - } - - private async Task LoadUser() - { - try - { - var token = "none"; - - // Load token via http context if available - if (HttpContextAccessor.HttpContext != null) - { - var request = HttpContextAccessor.HttpContext.Request; - - if (request.Cookies.ContainsKey("token")) - { - token = request.Cookies["token"]; - } - } - else // if not we check the cookies manually via js. this may not often work - { - token = await CookieService.GetValue("token", "none"); - } - - if (token == "none") - { - return; - } - - if (string.IsNullOrEmpty(token)) - return; - - string json; - - try - { - json = JwtBuilder.Create() - .WithAlgorithm(new HMACSHA256Algorithm()) - .WithSecret(Secret) - .Decode(token); - } - catch (TokenExpiredException) - { - return; - } - catch (SignatureVerificationException) - { - Logger.Warn($"Detected a manipulated JWT: {token}", "security"); - return; - } - catch (Exception e) - { - Logger.Error("Error reading jwt"); - Logger.Error(e); - return; - } - - // To make it easier to use the json data - var data = new ConfigurationBuilder().AddJsonStream( - new MemoryStream(Encoding.ASCII.GetBytes(json)) - ).Build(); - - var userid = data.GetValue("userid"); - var user = UserRepository.Get().FirstOrDefault(y => y.Id == userid); - - if (user == null) - { - Logger.Warn( - $"Cannot find user with the id '{userid}' in the database. Maybe the user has been deleted or a token has been successfully faked by a hacker", "security"); - return; - } - - var iat = data.GetValue("iat", -1); - - if (iat == -1) - { - Logger.Debug("Legacy token found (without the time the token has been issued at)"); - return; - } - - var iatD = DateTimeOffset.FromUnixTimeSeconds(iat).ToUniversalTime().DateTime; - - if (iatD < user.TokenValidTime) - return; - - User = user; - - ConstructPermissions(); - - User.LastIp = Ip; - UserRepository.Update(User); - } - catch (Exception e) - { - Logger.Error("Unexpected error while processing token"); - Logger.Error(e); - return; - } - } - - private Task LoadIp() - { - if (HttpContextAccessor.HttpContext == null) - { - Ip = "N/A"; - return Task.CompletedTask; - } - - if (HttpContextAccessor.HttpContext.Request.Headers.ContainsKey("X-Real-IP")) - { - Ip = HttpContextAccessor.HttpContext.Request.Headers["X-Real-IP"]!; - return Task.CompletedTask; - } - - Ip = HttpContextAccessor.HttpContext.Connection.RemoteIpAddress!.ToString(); - return Task.CompletedTask; - } - - private Task LoadDevice() - { - if (HttpContextAccessor.HttpContext == null) - { - Device = "N/A"; - return Task.CompletedTask; - } - - try - { - var userAgent = HttpContextAccessor.HttpContext.Request.Headers.UserAgent.ToString(); - - if (userAgent.Contains("Moonlight.App")) - { - var version = userAgent.Remove(0, "Moonlight.App/".Length).Split(' ').FirstOrDefault(); - - Device = "Moonlight App " + version; - return Task.CompletedTask; - } - - var uaParser = Parser.GetDefault(); - var info = uaParser.Parse(userAgent); - - Device = $"{info.OS} - {info.Device}"; - return Task.CompletedTask; - } - catch (Exception e) - { - Device = "UserAgent not present"; - return Task.CompletedTask; - } - } - - public Task SavePermissions() - { - if (User != null) - { - User.Permissions = UserPermissions.Data; - UserRepository.Update(User); - ConstructPermissions(); - } - - return Task.CompletedTask; - } - - private void ConstructPermissions() - { - if (User == null) - { - UserPermissions = new(Array.Empty()); - GroupPermissions = new(Array.Empty(), true); - Permissions = new(Array.Empty(), true); - - return; - } - - var user = UserRepository - .Get() - .Include(x => x.PermissionGroup) - .First(x => x.Id == User.Id); - - UserPermissions = new PermissionStorage(user.Permissions); - - if (user.PermissionGroup == null) - GroupPermissions = new PermissionStorage(Array.Empty(), true); - else - GroupPermissions = new PermissionStorage(user.PermissionGroup.Permissions, true); - - if (user.Admin) - { - Permissions = new PermissionStorage(Array.Empty()); - - foreach (var permission in Perms.Permissions.GetAllPermissions()) - { - Permissions[permission] = true; - } - - Permissions.IsReadyOnly = true; - return; - } - - Permissions = new(Array.Empty()); - - foreach (var permission in Perms.Permissions.GetAllPermissions()) - { - Permissions[permission] = GroupPermissions[permission]; - } - - foreach (var permission in Perms.Permissions.GetAllPermissions()) - { - if (UserPermissions[permission]) - { - Permissions[permission] = true; - } - } - - Permissions.IsReadyOnly = true; - } - - public async Task GetBotStatus() - { - var webDriverStatus = await JsRuntime - .InvokeAsync("moonlight.utils.getWebDriverStatus"); - - if (webDriverStatus) - return true; - - var languagesStatus = await JsRuntime - .InvokeAsync("moonlight.utils.getLanguagesStatus"); - - if (languagesStatus) - return true; - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/IpBanService.cs b/Moonlight/App/Services/Sessions/IpBanService.cs deleted file mode 100644 index 1159b45a..00000000 --- a/Moonlight/App/Services/Sessions/IpBanService.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Sessions; - -public class IpBanService -{ - private readonly IdentityService IdentityService; - private readonly Repository IpBanRepository; - - public IpBanService( - IdentityService identityService, - Repository ipBanRepository) - { - IdentityService = identityService; - IpBanRepository = ipBanRepository; - } - - public Task IsBanned() - { - var ip = IdentityService.Ip; - - return Task.FromResult( - IpBanRepository - .Get() - .Any(x => x.Ip == ip) - ); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/IpLocateService.cs b/Moonlight/App/Services/Sessions/IpLocateService.cs deleted file mode 100644 index 4ce5a6bf..00000000 --- a/Moonlight/App/Services/Sessions/IpLocateService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Net; -using Moonlight.App.ApiClients.IpLocate.Resources; -using Newtonsoft.Json; - -namespace Moonlight.App.Services.Sessions; - -public class IpLocateService -{ - private readonly IdentityService IdentityService; - - public IpLocateService(IdentityService identityService) - { - IdentityService = identityService; - } - - public async Task GetLocation() - { - var ip = IdentityService.Ip; - var location = "N/A"; - - if (ip != "N/A") - { - using (var wc = new WebClient()) - { - var res = JsonConvert.DeserializeObject( - await wc.DownloadStringTaskAsync( - $"http://ip-api.com/json/{ip}" - ) - ); - - location = $"{res.Country} - {res.RegionName} - {res.City} ({res.Org})"; - } - } - - return location; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/KeyListenerService.cs b/Moonlight/App/Services/Sessions/KeyListenerService.cs deleted file mode 100644 index 29b93ff7..00000000 --- a/Moonlight/App/Services/Sessions/KeyListenerService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.JSInterop; - -namespace Moonlight.App.Services.Sessions; - -public class KeyListenerService -{ - private readonly IJSRuntime _jsRuntime; - private DotNetObjectReference _objRef; - - public event EventHandler KeyPressed; - - public KeyListenerService(IJSRuntime jsRuntime) - { - _jsRuntime = jsRuntime; - } - - public async Task Initialize() - { - _objRef = DotNetObjectReference.Create(this); - await _jsRuntime.InvokeVoidAsync("moonlight.keyListener.register", _objRef); - } - - [JSInvokable] - public void OnKeyPress(string key) - { - KeyPressed?.Invoke(this, key); - } - - public async ValueTask DisposeAsync() - { - try - { - await _jsRuntime.InvokeVoidAsync("moonlight.keyListener.unregister", _objRef); - _objRef.Dispose(); - } - catch (Exception) { /* ignored */} - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/SessionClientService.cs b/Moonlight/App/Services/Sessions/SessionClientService.cs deleted file mode 100644 index 8ff084f6..00000000 --- a/Moonlight/App/Services/Sessions/SessionClientService.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; -using Moonlight.App.Database.Entities; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Interop; - -namespace Moonlight.App.Services.Sessions; - -public class SessionClientService -{ - public readonly Guid Uuid = Guid.NewGuid(); - public readonly DateTime CreateTimestamp = DateTime.UtcNow; - public User? User { get; private set; } - public string Ip { get; private set; } = "N/A"; - public string Device { get; private set; } = "N/A"; - - public readonly IdentityService IdentityService; - public readonly AlertService AlertService; - public readonly NavigationManager NavigationManager; - public readonly IJSRuntime JsRuntime; - - private readonly SessionServerService SessionServerService; - private readonly Repository UserRepository; - - public SessionClientService( - IdentityService identityService, - AlertService alertService, - NavigationManager navigationManager, - IJSRuntime jsRuntime, - SessionServerService sessionServerService, - Repository userRepository) - { - IdentityService = identityService; - AlertService = alertService; - NavigationManager = navigationManager; - JsRuntime = jsRuntime; - SessionServerService = sessionServerService; - UserRepository = userRepository; - } - - public async Task Start() - { - User = IdentityService.User; - Ip = IdentityService.Ip; - Device = IdentityService.Device; - - if (User != null) // Track users last visit - { - User.LastVisitedAt = DateTime.UtcNow; - UserRepository.Update(User); - } - - await SessionServerService.Register(this); - } - - public async Task Stop() - { - await SessionServerService.UnRegister(this); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Sessions/SessionServerService.cs b/Moonlight/App/Services/Sessions/SessionServerService.cs deleted file mode 100644 index 525be5ed..00000000 --- a/Moonlight/App/Services/Sessions/SessionServerService.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; - -namespace Moonlight.App.Services.Sessions; - -public class SessionServerService -{ - private readonly List Sessions = new(); - private readonly EventSystem Event; - - public SessionServerService(EventSystem eventSystem) - { - Event = eventSystem; - } - - public async Task Register(SessionClientService sessionClientService) - { - lock (Sessions) - { - if(!Sessions.Contains(sessionClientService)) - Sessions.Add(sessionClientService); - } - - await Event.Emit("sessions.add", sessionClientService); - } - public async Task UnRegister(SessionClientService sessionClientService) - { - lock (Sessions) - { - if(Sessions.Contains(sessionClientService)) - Sessions.Remove(sessionClientService); - } - - await Event.Emit("sessions.remove", sessionClientService); - } - - public Task GetSessions() - { - lock (Sessions) - { - return Task.FromResult(Sessions.ToArray()); - } - } - - public async Task ReloadUserSessions(User user) - { - var sessions = await GetSessions(); - - foreach (var session in sessions) - { - if (session.User != null && session.User.Id == user.Id) - { - try - { - session.NavigationManager.NavigateTo(session.NavigationManager.Uri, true); - } - catch (Exception) - { - // ignore - } - } - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/SmartDeployService.cs b/Moonlight/App/Services/SmartDeployService.cs deleted file mode 100644 index b26aa7ed..00000000 --- a/Moonlight/App/Services/SmartDeployService.cs +++ /dev/null @@ -1,99 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services; - -public class SmartDeployService -{ - private readonly NodeRepository NodeRepository; - private readonly Repository CloudPanelRepository; - private readonly WebSpaceService WebSpaceService; - private readonly NodeService NodeService; - private readonly ConfigService ConfigService; - - public SmartDeployService( - NodeRepository nodeRepository, - NodeService nodeService, - WebSpaceService webSpaceService, - Repository cloudPanelRepository, - ConfigService configService) - { - NodeRepository = nodeRepository; - NodeService = nodeService; - WebSpaceService = webSpaceService; - CloudPanelRepository = cloudPanelRepository; - ConfigService = configService; - } - - public async Task GetNode() - { - var config = ConfigService - .Get() - .Moonlight.SmartDeploy.Server; - - if (config.EnableOverride) - { - var nodeId = config.OverrideNode; - - return NodeRepository.Get().FirstOrDefault(x => x.Id == nodeId); - } - - var data = new Dictionary(); - - foreach (var node in NodeRepository.Get().ToArray()) - { - var u = await GetUsageScore(node); - - if(u != 0) - data.Add(node, u); - } - - if (!data.Any()) - return null; - - return data.MaxBy(x => x.Value).Key; - } - - public async Task GetCloudPanel() - { - var result = new List(); - - foreach (var cloudPanel in CloudPanelRepository.Get().ToArray()) - { - if (await WebSpaceService.IsHostUp(cloudPanel)) - result.Add(cloudPanel); - } - - return result.FirstOrDefault(); - } - - private async Task GetUsageScore(Node node) - { - var score = 0; - - try - { - var cpuMetrics = await NodeService.GetCpuMetrics(node); - var memoryMetrics = await NodeService.GetMemoryMetrics(node); - var diskMetrics = await NodeService.GetDiskMetrics(node); - - var cpuWeight = 0.5; // Weight of CPU usage in the final score - var memoryWeight = 0.3; // Weight of memory usage in the final score - var diskSpaceWeight = 0.2; // Weight of free disk space in the final score - - var cpuScore = (1 - cpuMetrics.CpuUsage) * cpuWeight; // CPU score is based on the inverse of CPU usage - var memoryScore = (1 - (memoryMetrics.Used / 1024)) * memoryWeight; // Memory score is based on the percentage of free memory - var diskSpaceScore = (double) (diskMetrics.Total - diskMetrics.Used) / 1000000000 * diskSpaceWeight; // Disk space score is based on the amount of free disk space in GB - - var finalScore = cpuScore + memoryScore + diskSpaceScore; - - return finalScore; - } - catch (Exception e) - { - // ignored - } - - return score; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/SmartTranslateService.cs b/Moonlight/App/Services/SmartTranslateService.cs deleted file mode 100644 index f725f97d..00000000 --- a/Moonlight/App/Services/SmartTranslateService.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Moonlight.App.Helpers; - -namespace Moonlight.App.Services; - -public class SmartTranslateService -{ - private string LanguageCode { get; set; } = "en_us"; - private readonly string FallbackLanguage = "en_us"; - - private SmartTranslateHelper Helper { get; } - private HttpContext HttpContext { get; } - - public SmartTranslateService(SmartTranslateHelper helper, IHttpContextAccessor httpContextAccessor) - { - Helper = helper; - HttpContext = httpContextAccessor.HttpContext!; - - LanguageCode = FallbackLanguage; - - try - { - var langHeader = HttpContext.Request.Headers["Accept-Language"].ToString(); - var important = langHeader.Split(";").First().ToLower().Split(","); - - foreach (var v in important) - { - if (v.Contains("de")) - { - LanguageCode = "de_de"; - break; - } - else if (v.Contains("en")) - { - LanguageCode = "en_us"; - break; - } - } - - var cookies = HttpContext.Request.Headers["Cookie"].ToString() - .Split(new string[] { ",", ";" }, StringSplitOptions.TrimEntries); - - foreach (var cookie in cookies) - { - var name = cookie.Split("=").First().Trim(); - var value = cookie.Split("=").Last().Trim(); - - if (name == "lang") - { - if (value.Contains("de")) - { - LanguageCode = "de_de"; - break; - } - else if (value.Contains("en")) - { - LanguageCode = "en_us"; - break; - } - } - } - } - catch (Exception) - { - // ignored - } - } - - public string Translate(string key) - { - try - { - var text = Helper.Translate(LanguageCode, key); - - if (text == null) - return key; - - return text; - } - catch (Exception ex) - { - Logger.Error(ex); - return key; - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs b/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs deleted file mode 100644 index 43a0ec27..00000000 --- a/Moonlight/App/Services/Statistics/StatisticsCaptureService.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services.Statistics; - -public class StatisticsCaptureService -{ - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly DateTimeService DateTimeService; - private readonly PeriodicTimer Timer; - - public StatisticsCaptureService(IServiceScopeFactory serviceScopeFactory, ConfigService configService, DateTimeService dateTimeService) - { - ServiceScopeFactory = serviceScopeFactory; - DateTimeService = dateTimeService; - - var config = configService - .Get() - .Moonlight.Statistics; - - if(!config.Enabled) - return; - - var period = TimeSpan.FromMinutes(config.Wait); - Timer = new(period); - - Logger.Info("Starting statistics system"); - Task.Run(Run); - } - - private async Task Run() - { - try - { - while (await Timer.WaitForNextTickAsync()) - { - using var scope = ServiceScopeFactory.CreateScope(); - - var statisticsRepo = scope.ServiceProvider.GetRequiredService>(); - var usersRepo = scope.ServiceProvider.GetRequiredService>(); - var serversRepo = scope.ServiceProvider.GetRequiredService>(); - var domainsRepo = scope.ServiceProvider.GetRequiredService>(); - var webspacesRepo = scope.ServiceProvider.GetRequiredService>(); - var databasesRepo = scope.ServiceProvider.GetRequiredService>(); - var sessionService = scope.ServiceProvider.GetRequiredService(); - - void AddEntry(string chart, int value) - { - statisticsRepo!.Add(new StatisticsData() - { - Chart = chart, - Value = value, - Date = DateTimeService.GetCurrent() - }); - } - - AddEntry("usersCount", usersRepo.Get().Count()); - AddEntry("serversCount", serversRepo.Get().Count()); - AddEntry("domainsCount", domainsRepo.Get().Count()); - AddEntry("webspacesCount", webspacesRepo.Get().Count()); - AddEntry("databasesCount", databasesRepo.Get().Count()); - AddEntry("sessionsCount", (await sessionService.GetSessions()).Length); - } - } - catch (Exception e) - { - Logger.Error("An unexpected error occured while capturing statistics"); - Logger.Error(e); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Statistics/StatisticsViewService.cs b/Moonlight/App/Services/Statistics/StatisticsViewService.cs deleted file mode 100644 index 2a46fa0a..00000000 --- a/Moonlight/App/Services/Statistics/StatisticsViewService.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Statistics; - -public class StatisticsViewService -{ - private readonly StatisticsRepository StatisticsRepository; - private readonly Repository UserRepository; - private readonly DateTimeService DateTimeService; - - public StatisticsViewService(StatisticsRepository statisticsRepository, DateTimeService dateTimeService, Repository userRepository) - { - StatisticsRepository = statisticsRepository; - DateTimeService = dateTimeService; - UserRepository = userRepository; - } - - public StatisticsData[] GetData(string chart, StatisticsTimeSpan timeSpan) - { - var startDate = DateTimeService.GetCurrent() - TimeSpan.FromHours((int)timeSpan); - - var objs = StatisticsRepository - .Get() - .Where(x => x.Date > startDate && x.Chart == chart); - - return objs.ToArray(); - } - - public int GetActiveUsers(StatisticsTimeSpan timeSpan) - { - var startDate = DateTimeService.GetCurrent() - TimeSpan.FromHours((int)timeSpan); - - return UserRepository - .Get() - .Count(x => x.LastVisitedAt > startDate); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/SubscriptionService.cs b/Moonlight/App/Services/SubscriptionService.cs deleted file mode 100644 index 4da9138f..00000000 --- a/Moonlight/App/Services/SubscriptionService.cs +++ /dev/null @@ -1,200 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; -using Newtonsoft.Json; -using Stripe; -using File = System.IO.File; -using Subscription = Moonlight.App.Database.Entities.Subscription; - -namespace Moonlight.App.Services; - -public class SubscriptionService -{ - private readonly Repository SubscriptionRepository; - private readonly Repository UserRepository; - - public SubscriptionService( - Repository subscriptionRepository, - Repository userRepository) - { - SubscriptionRepository = subscriptionRepository; - UserRepository = userRepository; - } - - public async Task Create(string name, string description, Currency currency, double price, int duration) - { - var optionsProduct = new ProductCreateOptions - { - Name = name, - Description = description, - DefaultPriceData = new() - { - UnitAmount = (long)(price * 100), - Currency = currency.ToString().ToLower() - } - }; - - var productService = new ProductService(); - var product = await productService.CreateAsync(optionsProduct); - - var subscription = new Subscription() - { - Name = name, - Description = description, - Currency = currency, - Price = price, - Duration = duration, - LimitsJson = "[]", - StripeProductId = product.Id, - StripePriceId = product.DefaultPriceId - }; - - return SubscriptionRepository.Add(subscription); - } - public async Task Update(Subscription subscription) - { - // Create the new price object - - var optionsPrice = new PriceCreateOptions - { - UnitAmount = (long)(subscription.Price * 100), - Currency = subscription.Currency.ToString().ToLower(), - Product = subscription.StripeProductId - }; - - var servicePrice = new PriceService(); - var price = await servicePrice.CreateAsync(optionsPrice); - - // Update the product - - var productService = new ProductService(); - var product = await productService.UpdateAsync(subscription.StripeProductId, new() - { - Name = subscription.Name, - Description = subscription.Description, - DefaultPrice = price.Id - }); - - // Disable old price - await servicePrice.UpdateAsync(subscription.StripePriceId, new() - { - Active = false - }); - - // Update the model - - subscription.StripeProductId = product.Id; - subscription.StripePriceId = product.DefaultPriceId; - - SubscriptionRepository.Update(subscription); - } - public async Task Delete(Subscription subscription) - { - var productService = new ProductService(); - await productService.DeleteAsync(subscription.StripeProductId); - - SubscriptionRepository.Delete(subscription); - } - - public Task UpdateLimits(Subscription subscription, SubscriptionLimit[] limits) - { - subscription.LimitsJson = JsonConvert.SerializeObject(limits); - SubscriptionRepository.Update(subscription); - - return Task.CompletedTask; - } - public Task GetLimits(Subscription subscription) - { - var limits = - JsonConvert.DeserializeObject(subscription.LimitsJson) ?? Array.Empty(); - return Task.FromResult(limits); - } - - public async Task GetActiveSubscription(User u) - { - var user = await EnsureData(u); - - if (user.CurrentSubscription != null) - { - if (user.SubscriptionExpires < DateTime.UtcNow) - { - user.CurrentSubscription = null; - UserRepository.Update(user); - } - } - - return user.CurrentSubscription; - } - public async Task CancelSubscription(User u) - { - var user = await EnsureData(u); - - user.CurrentSubscription = null; - UserRepository.Update(user); - } - public async Task SetActiveSubscription(User u, Subscription subscription) - { - var user = await EnsureData(u); - - user.SubscriptionSince = DateTime.UtcNow; - user.SubscriptionExpires = DateTime.UtcNow.AddDays(subscription.Duration); - user.CurrentSubscription = subscription; - - UserRepository.Update(user); - } - - public async Task GetDefaultLimits() - { - var defaultSubscriptionJson = "[]"; - var path = PathBuilder.File("storage", "configs", "default_subscription.json"); - - if (File.Exists(path)) - { - defaultSubscriptionJson = - await File.ReadAllTextAsync(path); - } - - return JsonConvert.DeserializeObject(defaultSubscriptionJson) - ?? Array.Empty(); - } - public async Task GetLimit(User u, string identifier) - { - var subscription = await GetActiveSubscription(u); - var defaultLimits = await GetDefaultLimits(); - - if (subscription != null) // User has a active subscriptions - { - var subscriptionLimits = await GetLimits(subscription); - - var subscriptionLimit = subscriptionLimits - .FirstOrDefault(x => x.Identifier == identifier); - - if (subscriptionLimit != null) // Found subscription limit for the user's subscription - return subscriptionLimit; - } // If were are here, the user's subscription has no limit for this identifier, so we fallback to default - - var defaultSubscriptionLimit = defaultLimits - .FirstOrDefault(x => x.Identifier == identifier); - - if (defaultSubscriptionLimit != null) - return defaultSubscriptionLimit; // Default subscription limit found - - return new() // No default subscription limit found - { - Identifier = identifier, - Amount = 0 - }; - } - - private Task EnsureData(User u) - { - var user = UserRepository - .Get() - .Include(x => x.CurrentSubscription) - .First(x => x.Id == u.Id); - - return Task.FromResult(user); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs b/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs deleted file mode 100644 index 20c67290..00000000 --- a/Moonlight/App/Services/SupportChat/SupportChatAdminService.cs +++ /dev/null @@ -1,149 +0,0 @@ -using Microsoft.AspNetCore.Components.Forms; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Services.Files; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services.SupportChat; - -public class SupportChatAdminService : IDisposable -{ - private readonly EventSystem Event; - private readonly IdentityService IdentityService; - private readonly SupportChatServerService ServerService; - private readonly BucketService BucketService; - - public Func? OnMessage { get; set; } - public Func? OnTypingChanged { get; set; } - - private User? User; - private User Recipient = null!; - private readonly List TypingUsers = new(); - - public SupportChatAdminService( - EventSystem eventSystem, - SupportChatServerService serverService, - IdentityService identityService, - BucketService bucketService) - { - Event = eventSystem; - ServerService = serverService; - IdentityService = identityService; - BucketService = bucketService; - } - - public async Task Start(User recipient) - { - User = IdentityService.User; - Recipient = recipient; - - if (User != null) - { - await Event.On($"supportChat.{Recipient.Id}.message", this, async message => - { - if (OnMessage != null) - { - if(message.Sender != null && message.Sender.Id == User.Id) - return; - - await OnMessage.Invoke(message); - } - }); - - await Event.On($"supportChat.{Recipient.Id}.typing", this, async user => - { - await HandleTyping(user); - }); - } - } - - public async Task GetMessages() - { - if (User == null) - return Array.Empty(); - - return await ServerService.GetMessages(Recipient); - } - - public async Task SendMessage(string content, IBrowserFile? browserFile = null) - { - if (User != null) - { - string? attachment = null; - - if (browserFile != null) - { - attachment = await BucketService.StoreFile( - "supportChat", - browserFile.OpenReadStream(1024 * 1024 * 5), - browserFile.Name); - } - - return await ServerService.SendMessage(Recipient, content, User, attachment); - } - - return null!; - } - - private Task HandleTyping(User user) - { - lock (TypingUsers) - { - if (!TypingUsers.Contains(user)) - { - TypingUsers.Add(user); - - if (OnTypingChanged != null) - { - OnTypingChanged.Invoke( - TypingUsers - .Where(x => x.Id != User!.Id) - .Select(x => $"{x.FirstName} {x.LastName}") - .ToArray() - ); - } - - Task.Run(async () => - { - await Task.Delay(TimeSpan.FromSeconds(5)); - - if (TypingUsers.Contains(user)) - { - TypingUsers.Remove(user); - - if (OnTypingChanged != null) - { - await OnTypingChanged.Invoke( - TypingUsers - .Where(x => x.Id != User!.Id) - .Select(x => $"{x.FirstName} {x.LastName}") - .ToArray() - ); - } - } - }); - } - } - - return Task.CompletedTask; - } - - public async Task SendTyping() - { - await Event.Emit($"supportChat.{Recipient.Id}.typing", User); - } - - public async Task Close() - { - await ServerService.CloseChat(Recipient); - } - - public async void Dispose() - { - if (User != null) - { - await Event.Off($"supportChat.{Recipient.Id}.message", this); - await Event.Off($"supportChat.{Recipient.Id}.typing", this); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/SupportChat/SupportChatClientService.cs b/Moonlight/App/Services/SupportChat/SupportChatClientService.cs deleted file mode 100644 index c4f695ce..00000000 --- a/Moonlight/App/Services/SupportChat/SupportChatClientService.cs +++ /dev/null @@ -1,142 +0,0 @@ -using Microsoft.AspNetCore.Components.Forms; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Services.Files; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services.SupportChat; - -public class SupportChatClientService : IDisposable -{ - private readonly EventSystem Event; - private readonly BucketService BucketService; - private readonly IdentityService IdentityService; - private readonly SupportChatServerService ServerService; - - public Func? OnMessage { get; set; } - public Func? OnTypingChanged { get; set; } - - private User? User; - private readonly List TypingUsers = new(); - - public SupportChatClientService( - EventSystem eventSystem, - SupportChatServerService serverService, - IdentityService identityService, - BucketService bucketService) - { - Event = eventSystem; - ServerService = serverService; - IdentityService = identityService; - BucketService = bucketService; - } - - public async Task Start() - { - User = IdentityService.User; - - if (User != null) - { - await Event.On($"supportChat.{User.Id}.message", this, async message => - { - if (OnMessage != null) - { - if(message.Sender != null && message.Sender.Id == User.Id) - return; - - await OnMessage.Invoke(message); - } - }); - - await Event.On($"supportChat.{User.Id}.typing", this, async user => - { - await HandleTyping(user); - }); - } - } - - public async Task GetMessages() - { - if (User == null) - return Array.Empty(); - - return await ServerService.GetMessages(User); - } - - public async Task SendMessage(string content, IBrowserFile? browserFile = null) - { - if (User != null) - { - string? attachment = null; - - if (browserFile != null) - { - attachment = await BucketService.StoreFile( - "supportChat", - browserFile.OpenReadStream(1024 * 1024 * 5), - browserFile.Name); - } - - return await ServerService.SendMessage(User, content, User, attachment); - } - - return null!; - } - - private Task HandleTyping(User user) - { - lock (TypingUsers) - { - if (!TypingUsers.Contains(user)) - { - TypingUsers.Add(user); - - if (OnTypingChanged != null) - { - OnTypingChanged.Invoke( - TypingUsers - .Where(x => x.Id != User!.Id) - .Select(x => $"{x.FirstName} {x.LastName}") - .ToArray() - ); - } - - Task.Run(async () => - { - await Task.Delay(TimeSpan.FromSeconds(5)); - - if (TypingUsers.Contains(user)) - { - TypingUsers.Remove(user); - - if (OnTypingChanged != null) - { - await OnTypingChanged.Invoke( - TypingUsers - .Where(x => x.Id != User!.Id) - .Select(x => $"{x.FirstName} {x.LastName}") - .ToArray() - ); - } - } - }); - } - } - - return Task.CompletedTask; - } - - public async Task SendTyping() - { - await Event.Emit($"supportChat.{User!.Id}.typing", User); - } - - public async void Dispose() - { - if (User != null) - { - await Event.Off($"supportChat.{User.Id}.message", this); - await Event.Off($"supportChat.{User.Id}.typing", this); - } - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/SupportChat/SupportChatServerService.cs b/Moonlight/App/Services/SupportChat/SupportChatServerService.cs deleted file mode 100644 index 7fd0555c..00000000 --- a/Moonlight/App/Services/SupportChat/SupportChatServerService.cs +++ /dev/null @@ -1,146 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.SupportChat; - -public class SupportChatServerService -{ - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly DateTimeService DateTimeService; - private readonly EventSystem Event; - - public SupportChatServerService( - IServiceScopeFactory serviceScopeFactory, - DateTimeService dateTimeService, - EventSystem eventSystem) - { - ServiceScopeFactory = serviceScopeFactory; - DateTimeService = dateTimeService; - Event = eventSystem; - } - - public Task GetMessages(User recipient) - { - using var scope = ServiceScopeFactory.CreateScope(); - var msgRepo = scope.ServiceProvider.GetRequiredService>(); - - var messages = msgRepo - .Get() - .Include(x => x.Recipient) - .Include(x => x.Sender) - .Where(x => x.Recipient.Id == recipient.Id) - .OrderByDescending(x => x.CreatedAt) - .AsEnumerable() - .Take(50) - .ToArray(); - - return Task.FromResult(messages); - } - - public async Task SendMessage(User recipient, string content, User? sender, string? attachment = null) - { - using var scope = ServiceScopeFactory.CreateScope(); - var msgRepo = scope.ServiceProvider.GetRequiredService>(); - var userRepo = scope.ServiceProvider.GetRequiredService>(); - - var message = new SupportChatMessage() - { - CreatedAt = DateTimeService.GetCurrent(), - IsQuestion = false, - Sender = sender == null ? null : userRepo.Get().First(x => x.Id == sender.Id), - Recipient = userRepo.Get().First(x => x.Id == recipient.Id), - Answer = "", - Attachment = attachment ?? "", - Content = content, - UpdatedAt = DateTimeService.GetCurrent() - }; - - var finalMessage = msgRepo.Add(message); - - await Event.Emit($"supportChat.{recipient.Id}.message", finalMessage); - await Event.Emit("supportChat.message", finalMessage); - - if (!userRepo.Get().First(x => x.Id == recipient.Id).SupportPending) - { - var ticketStart = new SupportChatMessage() - { - CreatedAt = DateTimeService.GetCurrent(), - IsQuestion = false, - Sender = null, - Recipient = userRepo.Get().First(x => x.Id == recipient.Id), - Answer = "", - Attachment = "", - Content = "Support ticket open", //TODO: Config - UpdatedAt = DateTimeService.GetCurrent() - }; - - var ticketStartFinal = msgRepo.Add(ticketStart); - - var user = userRepo.Get().First(x => x.Id == recipient.Id); - user.SupportPending = true; - userRepo.Update(user); - - await Event.Emit($"supportChat.{recipient.Id}.message", ticketStartFinal); - await Event.Emit("supportChat.message", ticketStartFinal); - await Event.Emit("supportChat.new", recipient); - } - - return finalMessage; - } - - public Task> GetOpenChats() - { - var result = new Dictionary(); - - using var scope = ServiceScopeFactory.CreateScope(); - var userRepo = scope.ServiceProvider.GetRequiredService>(); - var msgRepo = scope.ServiceProvider.GetRequiredService>(); - - foreach (var user in userRepo.Get().Where(x => x.SupportPending).ToArray()) - { - var lastMessage = msgRepo - .Get() - .Include(x => x.Recipient) - .Include(x => x.Sender) - .Where(x => x.Recipient.Id == user.Id) - .OrderByDescending(x => x.CreatedAt) - .AsEnumerable() - .FirstOrDefault(); - - result.Add(user, lastMessage); - } - - return Task.FromResult(result); - } - - public async Task CloseChat(User recipient) - { - using var scope = ServiceScopeFactory.CreateScope(); - var msgRepo = scope.ServiceProvider.GetRequiredService>(); - var userRepo = scope.ServiceProvider.GetRequiredService>(); - - var ticketEnd = new SupportChatMessage() - { - CreatedAt = DateTimeService.GetCurrent(), - IsQuestion = false, - Sender = null, - Recipient = userRepo.Get().First(x => x.Id == recipient.Id), - Answer = "", - Attachment = "", - Content = "Support ticket closed", //TODO: Config - UpdatedAt = DateTimeService.GetCurrent() - }; - - var ticketEndFinal = msgRepo.Add(ticketEnd); - - var user = userRepo.Get().First(x => x.Id == recipient.Id); - user.SupportPending = false; - userRepo.Update(user); - - await Event.Emit($"supportChat.{recipient.Id}.message", ticketEndFinal); - await Event.Emit("supportChat.message", ticketEndFinal); - await Event.Emit("supportChat.close", recipient); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Tickets/TicketAdminService.cs b/Moonlight/App/Services/Tickets/TicketAdminService.cs deleted file mode 100644 index aefbf0b9..00000000 --- a/Moonlight/App/Services/Tickets/TicketAdminService.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Microsoft.AspNetCore.Components.Forms; -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; -using Moonlight.App.Services.Files; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services.Tickets; - -public class TicketAdminService -{ - private readonly TicketServerService TicketServerService; - private readonly IdentityService IdentityService; - private readonly BucketService BucketService; - - public Ticket? Ticket { get; set; } - - public TicketAdminService( - TicketServerService ticketServerService, - IdentityService identityService, - BucketService bucketService) - { - TicketServerService = ticketServerService; - IdentityService = identityService; - BucketService = bucketService; - } - - public async Task Send(string content, IBrowserFile? file = null) - { - string? attachment = null; - - if (file != null) - { - attachment = await BucketService.StoreFile( - "tickets", - file.OpenReadStream(1024 * 1024 * 5), - file.Name); - } - - return await TicketServerService.SendMessage( - Ticket!, - IdentityService.User, - content, - attachment, - true - ); - } - - public async Task UpdateStatus(TicketStatus status) - { - await TicketServerService.UpdateStatus(Ticket!, status); - } - - public async Task UpdatePriority(TicketPriority priority) - { - await TicketServerService.UpdatePriority(Ticket!, priority); - } - - public async Task GetMessages() - { - return await TicketServerService.GetMessages(Ticket!); - } - - public async Task SetClaim(User? user) - { - await TicketServerService.SetClaim(Ticket!, user); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Tickets/TicketClientService.cs b/Moonlight/App/Services/Tickets/TicketClientService.cs deleted file mode 100644 index dee6e7fe..00000000 --- a/Moonlight/App/Services/Tickets/TicketClientService.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Microsoft.AspNetCore.Components.Forms; -using Moonlight.App.Database.Entities; -using Moonlight.App.Models.Misc; -using Moonlight.App.Services.Files; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services.Tickets; - -public class TicketClientService -{ - private readonly TicketServerService TicketServerService; - private readonly IdentityService IdentityService; - private readonly BucketService BucketService; - - public Ticket? Ticket { get; set; } - - public TicketClientService( - TicketServerService ticketServerService, - IdentityService identityService, - BucketService bucketService) - { - TicketServerService = ticketServerService; - IdentityService = identityService; - BucketService = bucketService; - } - - public async Task Create(string issueTopic, string issueDescription, string issueTries, TicketSubject subject, int subjectId) - { - return await TicketServerService.Create( - IdentityService.User, - issueTopic, - issueDescription, - issueTries, - subject, - subjectId - ); - } - - public async Task Send(string content, IBrowserFile? file = null) - { - string? attachment = null; - - if (file != null) - { - attachment = await BucketService.StoreFile( - "tickets", - file.OpenReadStream(1024 * 1024 * 5), - file.Name); - } - - return await TicketServerService.SendMessage( - Ticket!, - IdentityService.User, - content, - attachment - ); - } - - public async Task GetMessages() - { - return await TicketServerService.GetMessages(Ticket!); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/Tickets/TicketServerService.cs b/Moonlight/App/Services/Tickets/TicketServerService.cs deleted file mode 100644 index a5e0f930..00000000 --- a/Moonlight/App/Services/Tickets/TicketServerService.cs +++ /dev/null @@ -1,181 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Moonlight.App.Database.Entities; -using Moonlight.App.Events; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; - -namespace Moonlight.App.Services.Tickets; - -public class TicketServerService -{ - private readonly IServiceScopeFactory ServiceScopeFactory; - private readonly EventSystem Event; - private readonly ConfigService ConfigService; - - public TicketServerService( - IServiceScopeFactory serviceScopeFactory, - EventSystem eventSystem, - ConfigService configService) - { - ServiceScopeFactory = serviceScopeFactory; - Event = eventSystem; - ConfigService = configService; - } - - public async Task Create(User creator, string issueTopic, string issueDescription, string issueTries, TicketSubject subject, int subjectId) - { - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - var userRepo = scope.ServiceProvider.GetRequiredService>(); - - var creatorUser = userRepo - .Get() - .First(x => x.Id == creator.Id); - - var ticket = ticketRepo.Add(new() - { - Priority = TicketPriority.Low, - Status = TicketStatus.Open, - AssignedTo = null, - IssueTopic = issueTopic, - IssueDescription = issueDescription, - IssueTries = issueTries, - Subject = subject, - SubjectId = subjectId, - CreatedBy = creatorUser - }); - - await Event.Emit("tickets.new", ticket); - - // Do automatic stuff here - await SendSystemMessage(ticket, ConfigService.Get().Moonlight.Tickets.WelcomeMessage); - - if (ticket.Subject != TicketSubject.Other) - { - await SendMessage(ticket, creatorUser, $"Subject :\n\n{ticket.Subject}: {ticket.SubjectId}"); - } - - //TODO: Check for opening times - - return ticket; - } - public async Task SendSystemMessage(Ticket t, string content, string? attachmentUrl = null) - { - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - - var ticket = ticketRepo.Get().First(x => x.Id == t.Id); - - var message = new TicketMessage() - { - Content = content, - Sender = null, - AttachmentUrl = attachmentUrl, - IsSystemMessage = true - }; - - ticket.Messages.Add(message); - ticketRepo.Update(ticket); - - await Event.Emit("tickets.message", message); - await Event.Emit($"tickets.{ticket.Id}.message", message); - } - public async Task UpdatePriority(Ticket t, TicketPriority priority) - { - if(t.Priority == priority) - return; - - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - - var ticket = ticketRepo.Get().First(x => x.Id == t.Id); - - ticket.Priority = priority; - - ticketRepo.Update(ticket); - - await Event.Emit("tickets.status", ticket); - await Event.Emit($"tickets.{ticket.Id}.status", ticket); - - await SendSystemMessage(ticket, $"The ticket priority has been changed to: {priority}"); - } - public async Task UpdateStatus(Ticket t, TicketStatus status) - { - if(t.Status == status) - return; - - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - - var ticket = ticketRepo.Get().First(x => x.Id == t.Id); - - ticket.Status = status; - - ticketRepo.Update(ticket); - - await Event.Emit("tickets.status", ticket); - await Event.Emit($"tickets.{ticket.Id}.status", ticket); - - await SendSystemMessage(ticket, $"The ticket status has been changed to: {status}"); - } - public async Task SendMessage(Ticket t, User sender, string content, string? attachmentUrl = null, bool isSupportMessage = false) - { - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - var userRepo = scope.ServiceProvider.GetRequiredService>(); - - var ticket = ticketRepo.Get().First(x => x.Id == t.Id); - var user = userRepo.Get().First(x => x.Id == sender.Id); - - var message = new TicketMessage() - { - Content = content, - Sender = user, - AttachmentUrl = attachmentUrl, - IsSupportMessage = isSupportMessage - }; - - ticket.Messages.Add(message); - ticketRepo.Update(ticket); - - await Event.Emit("tickets.message", message); - await Event.Emit($"tickets.{ticket.Id}.message", message); - - return message; - } - - public Task GetMessages(Ticket ticket) - { - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - - var tickets = ticketRepo - .Get() - .Include(x => x.CreatedBy) - .Include(x => x.Messages) - .ThenInclude(x => x.Sender) - .First(x => x.Id == ticket.Id); - - return Task.FromResult(tickets.Messages.ToArray()); - } - - public async Task SetClaim(Ticket t, User? u = null) - { - using var scope = ServiceScopeFactory.CreateScope(); - var ticketRepo = scope.ServiceProvider.GetRequiredService>(); - var userRepo = scope.ServiceProvider.GetRequiredService>(); - - var ticket = ticketRepo.Get().Include(x => x.AssignedTo).First(x => x.Id == t.Id); - var user = u == null ? u : userRepo.Get().First(x => x.Id == u.Id); - - ticket.AssignedTo = user; - - ticketRepo.Update(ticket); - - await Event.Emit("tickets.status", ticket); - await Event.Emit($"tickets.{ticket.Id}.status", ticket); - - var claimName = user == null ? "None" : user.FirstName + " " + user.LastName; - await SendSystemMessage(ticket, $"Ticked claim has been set to {claimName}"); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/TotpService.cs b/Moonlight/App/Services/TotpService.cs deleted file mode 100644 index 2d624d92..00000000 --- a/Moonlight/App/Services/TotpService.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Moonlight.App.Exceptions; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Sessions; -using OtpNet; - -namespace Moonlight.App.Services; - -public class TotpService -{ - private readonly IdentityService IdentityService; - private readonly UserRepository UserRepository; - - public TotpService( - IdentityService identityService, - UserRepository userRepository) - { - IdentityService = identityService; - UserRepository = userRepository; - } - - public Task Verify(string secret, string code) - { - var totp = new Totp(Base32Encoding.ToBytes(secret)); - var codeserver = totp.ComputeTotp(); - return Task.FromResult(codeserver == code); - } - - public Task GetEnabled() - { - return Task.FromResult(IdentityService.User.TotpEnabled); - } - - public Task GetSecret() - { - return Task.FromResult(IdentityService.User.TotpSecret); - } - - public Task GenerateSecret() - { - var user = IdentityService.User; - - user.TotpSecret = Base32Encoding.ToString(KeyGeneration.GenerateRandomKey(20));; - - UserRepository.Update(user); - - return Task.CompletedTask; - } - - public async Task Enable(string code) - { - var user = IdentityService.User; - - if (!await Verify(user.TotpSecret, code)) - { - throw new DisplayException("The 2fa code you entered is invalid"); - } - - user.TotpEnabled = true; - UserRepository.Update(user); - } - - public Task Disable() - { - var user = IdentityService.User; - - user.TotpEnabled = false; - user.TotpSecret = ""; - - UserRepository.Update(user); - - //TODO: AuditLog - - return Task.CompletedTask; - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/UserService.cs b/Moonlight/App/Services/UserService.cs deleted file mode 100644 index 00a30bc0..00000000 --- a/Moonlight/App/Services/UserService.cs +++ /dev/null @@ -1,285 +0,0 @@ -using JWT.Algorithms; -using JWT.Builder; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Models.Misc; -using Moonlight.App.Repositories; -using Moonlight.App.Services.Background; -using Moonlight.App.Services.Mail; -using Moonlight.App.Services.Sessions; - -namespace Moonlight.App.Services; - -public class UserService -{ - private readonly UserRepository UserRepository; - private readonly TotpService TotpService; - private readonly MailService MailService; - private readonly IdentityService IdentityService; - private readonly IpLocateService IpLocateService; - private readonly DateTimeService DateTimeService; - private readonly ConfigService ConfigService; - private readonly TempMailService TempMailService; - private readonly MoonlightService MoonlightService; - - private readonly string JwtSecret; - - public UserService( - UserRepository userRepository, - TotpService totpService, - ConfigService configService, - MailService mailService, - IdentityService identityService, - IpLocateService ipLocateService, - DateTimeService dateTimeService, - TempMailService tempMailService, - MoonlightService moonlightService) - { - UserRepository = userRepository; - TotpService = totpService; - ConfigService = configService; - MailService = mailService; - IdentityService = identityService; - IpLocateService = ipLocateService; - DateTimeService = dateTimeService; - TempMailService = tempMailService; - MoonlightService = moonlightService; - - JwtSecret = configService - .Get() - .Moonlight.Security.Token; - } - - public async Task Register(string email, string password, string firstname, string lastname) - { - if (ConfigService.Get().Moonlight.Auth.DenyRegister) - throw new DisplayException("This operation was disabled"); - - if (await TempMailService.IsTempMail(email)) - { - Logger.Warn($"A user tried to use a blacklisted domain to register. Email: '{email}'", "security"); - throw new DisplayException("This email is blacklisted"); - } - - if (ConfigService.Get().Moonlight.Auth.BlockLinuxUsers && IdentityService.Device.Contains("Linux")) - throw new DisplayException("This operation was disabled"); - - if (ConfigService.Get().Moonlight.Auth.CheckForBots) - { - var isABot = await IdentityService.GetBotStatus(); - - if (isABot) - { - throw new DisplayException("This operation was disabled"); - } - } - - // Check if the email is already taken - var emailTaken = UserRepository.Get().FirstOrDefault(x => x.Email == email) != null; - - if (emailTaken) - { - throw new DisplayException("The email is already in use"); - } - - bool admin = false; - - if (!UserRepository.Get().Any()) - { - if ((DateTime.UtcNow - MoonlightService.StartTimestamp).TotalMinutes < 15) - admin = true; - else - throw new DisplayException("You have to register within 15 minutes after the start of moonlight to get admin permissions. Please restart moonlight in order to register as admin. Please note that this will only works once and will be deactivated after a admin has registered"); - } - - // Add user - var user = UserRepository.Add(new() - { - Address = "", - Admin = admin, - City = "", - Country = "", - Email = email.ToLower(), - Password = BCrypt.Net.BCrypt.HashPassword(password), - FirstName = firstname, - LastName = lastname, - State = "", - Status = UserStatus.Unverified, - CreatedAt = DateTimeService.GetCurrent(), - DiscordId = 0, - TotpEnabled = false, - TotpSecret = "", - UpdatedAt = DateTimeService.GetCurrent(), - TokenValidTime = DateTimeService.GetCurrent().AddDays(-5), - LastIp = IdentityService.Ip, - RegisterIp = IdentityService.Ip - }); - - await MailService.SendMail(user!, "register", values => {}); - - //TODO: AuditLog - - return await GenerateToken(user); - } - - public async Task CheckTotp(string email, string password) - { - var user = UserRepository.Get() - .FirstOrDefault( - x => x.Email == email - ); - - if (user == null) - { - Logger.Warn($"Failed login attempt. Email: {email} Password: {StringHelper.CutInHalf(password)}", "security"); - throw new DisplayException("Email and password combination not found"); - } - - if (BCrypt.Net.BCrypt.Verify(password, user.Password)) - { - return user.TotpEnabled; - } - - Logger.Warn($"Failed login attempt. Email: {email} Password: {StringHelper.CutInHalf(password)}", "security"); - throw new DisplayException("Email and password combination not found");; - } - - public async Task Login(string email, string password, string totpCode = "") - { - if (ConfigService.Get().Moonlight.Auth.DenyLogin) - throw new DisplayException("This operation was disabled"); - - // First password check and check if totp is enabled - var needTotp = await CheckTotp(email, password); - - var user = UserRepository.Get() - .FirstOrDefault( - x => x.Email.Equals( - email - ) - ); - - if (needTotp) - { - if (string.IsNullOrEmpty(totpCode)) - throw new DisplayException("2FA code must be provided"); - - var totpCodeValid = await TotpService.Verify(user!.TotpSecret, totpCode); - - if (totpCodeValid) - { - //TODO: AuditLog - return await GenerateToken(user, true); - } - else - { - Logger.Warn($"Failed login attempt. Email: {email} Password: {StringHelper.CutInHalf(password)}", "security"); - throw new DisplayException("2FA code invalid"); - } - } - else - { - //TODO: AuditLog - return await GenerateToken(user!, true); - } - } - - public async Task ChangePassword(User user, string password, bool isSystemAction = false) - { - user.Password = BCrypt.Net.BCrypt.HashPassword(password); - user.TokenValidTime = DateTimeService.GetCurrent(); - UserRepository.Update(user); - - if (isSystemAction) - { - //TODO: AuditLog - } - else - { - var location = await IpLocateService.GetLocation(); - - await MailService.SendMail(user!, "passwordChange", values => - { - values.Add("Ip", IdentityService.Ip); - values.Add("Device", IdentityService.Device); - values.Add("Location", location); - }); - - //TODO: AuditLog - } - } - - public async Task SftpLogin(int id, string password) - { - var user = UserRepository.Get().FirstOrDefault(x => x.Id == id); - - if (user == null) - { - Logger.Warn($"Detected an sftp bruteforce attempt. ID: {id} Password: {StringHelper.CutInHalf(password)}", "security"); - - throw new Exception("Invalid username"); - } - - if (BCrypt.Net.BCrypt.Verify(password, user.Password)) - { - //TODO: AuditLog - return user; - } - - Logger.Warn($"Detected an sftp bruteforce attempt. ID: {id} Password: {StringHelper.CutInHalf(password)}", "security"); - throw new Exception("Invalid userid or password"); - } - - public async Task GenerateToken(User user, bool sendMail = false) - { - var location = await IpLocateService.GetLocation(); - - if (sendMail) - { - await MailService.SendMail(user!, "login", values => - { - values.Add("Ip", IdentityService.Ip); - values.Add("Device", IdentityService.Device); - values.Add("Location", location); - }); - } - - var token = JwtBuilder.Create() - .WithAlgorithm(new HMACSHA256Algorithm()) - .WithSecret(JwtSecret) - .AddClaim("exp", new DateTimeOffset(DateTimeService.GetCurrent().AddDays(10)).ToUnixTimeSeconds()) - .AddClaim("iat", DateTimeService.GetCurrentUnixSeconds()) - .AddClaim("userid", user.Id) - .Encode(); - - return token; - } - - public async Task ResetPassword(string email) - { - email = email.ToLower(); - - var user = UserRepository - .Get() - .FirstOrDefault(x => x.Email == email); - - if (user == null) - throw new DisplayException("A user with this email can not be found"); - - var newPassword = StringHelper.GenerateString(16); - await ChangePassword(user, newPassword, true); - - //TODO: AuditLog - - var location = await IpLocateService.GetLocation(); - - await MailService.SendMail(user, "passwordReset", values => - { - values.Add("Ip", IdentityService.Ip); - values.Add("Device", IdentityService.Device); - values.Add("Location", location); - values.Add("Password", newPassword); - }); - } -} \ No newline at end of file diff --git a/Moonlight/App/Services/WebSpaceService.cs b/Moonlight/App/Services/WebSpaceService.cs deleted file mode 100644 index b9c3d869..00000000 --- a/Moonlight/App/Services/WebSpaceService.cs +++ /dev/null @@ -1,247 +0,0 @@ -using DnsClient; -using Microsoft.EntityFrameworkCore; -using Moonlight.App.ApiClients.CloudPanel; -using Moonlight.App.ApiClients.CloudPanel.Requests; -using Moonlight.App.Database.Entities; -using Moonlight.App.Exceptions; -using Moonlight.App.Helpers; -using Moonlight.App.Helpers.Files; -using Moonlight.App.Repositories; -using FileAccess = Moonlight.App.Helpers.Files.FileAccess; - -namespace Moonlight.App.Services; - -public class WebSpaceService -{ - private readonly Repository CloudPanelRepository; - private readonly Repository WebSpaceRepository; - private readonly Repository DatabaseRepository; - - private readonly CloudPanelApiHelper CloudPanelApiHelper; - - public WebSpaceService(Repository cloudPanelRepository, Repository webSpaceRepository, - CloudPanelApiHelper cloudPanelApiHelper, Repository databaseRepository) - { - CloudPanelRepository = cloudPanelRepository; - WebSpaceRepository = webSpaceRepository; - CloudPanelApiHelper = cloudPanelApiHelper; - DatabaseRepository = databaseRepository; - } - - public async Task Create(string domain, User owner, CloudPanel? ps = null) - { - if (WebSpaceRepository.Get().Any(x => x.Domain == domain)) - throw new DisplayException("A website with this domain does already exist"); - - var cloudPanel = ps ?? CloudPanelRepository.Get().First(); - - var ftpLogin = domain.Replace(".", "_"); - var ftpPassword = StringHelper.GenerateString(16); - - var phpVersion = "8.1"; // TODO: Add config option or smth - - var w = new WebSpace() - { - CloudPanel = cloudPanel, - Owner = owner, - Domain = domain, - UserName = ftpLogin, - Password = ftpPassword, - VHostTemplate = "Generic" //TODO: Implement as select option - }; - - var webSpace = WebSpaceRepository.Add(w); - - try - { - await CloudPanelApiHelper.Post(cloudPanel, "site/php", new AddPhpSite() - { - VHostTemplate = w.VHostTemplate, - DomainName = w.Domain, - PhpVersion = phpVersion, - SiteUser = w.UserName, - SiteUserPassword = w.Password - }); - } - catch (Exception) - { - WebSpaceRepository.Delete(webSpace); - throw; - } - - return webSpace; - } - - public async Task Delete(WebSpace w) - { - var webSpace = WebSpaceRepository - .Get() - .Include(x => x.Databases) - .Include(x => x.CloudPanel) - .Include(x => x.Owner) - .First(x => x.Id == w.Id); - - foreach (var database in webSpace.Databases.ToArray()) - { - await DeleteDatabase(webSpace, database); - } - - await CloudPanelApiHelper.Delete(webSpace.CloudPanel, $"site/{webSpace.Domain}", null); - - WebSpaceRepository.Delete(webSpace); - } - - public async Task IsHostUp(CloudPanel cloudPanel) - { - try - { - await CloudPanelApiHelper.Post(cloudPanel, "", null); - - return true; - } - catch (CloudPanelException e) - { - if (e.StatusCode == 404) - return true; - } - catch (Exception) - { - // ignored - } - - return false; - } - - public async Task IsHostUp(WebSpace w) - { - var webSpace = EnsureData(w); - - return await IsHostUp(webSpace.CloudPanel); - } - - public async Task IssueSslCertificate(WebSpace w) - { - var webspace = EnsureData(w); - - var dns = new LookupClient(new LookupClientOptions() - { - CacheFailedResults = false, - UseCache = false - }); - - var ipOfWebspaceQuery = await dns.QueryAsync( - webspace.Domain, - QueryType.A - ); - - var ipOfWebspaceWwwQuery = await dns.QueryAsync( - "www." + webspace.Domain, - QueryType.CNAME - ); - - var ipOfWebspace = ipOfWebspaceQuery.Answers.ARecords().FirstOrDefault(); - var ipOfWebspaceWww = ipOfWebspaceWwwQuery.Answers.CnameRecords().FirstOrDefault(); - - if (ipOfWebspace == null) - throw new DisplayException($"Unable to find any a records for {webspace.Domain}", true); - - if (ipOfWebspaceWww == null) - throw new DisplayException($"Unable to find any cname records for www.{webspace.Domain}", true); - - var ipOfHostQuery = await dns.QueryAsync( - webspace.CloudPanel.Host, - QueryType.A - ); - - var ipOfHost = ipOfHostQuery.Answers.ARecords().FirstOrDefault(); - - - if (ipOfHost == null) - throw new DisplayException("Unable to find a record of host system"); - - if (ipOfHost.Address.ToString() != ipOfWebspace.Address.ToString()) - throw new DisplayException("The dns records of your webspace do not point to the host system"); - - Logger.Debug($"{ipOfWebspaceWww.CanonicalName.Value}"); - - if (ipOfWebspaceWww.CanonicalName.Value != webspace.CloudPanel.Host + ".") - throw new DisplayException( - $"The dns record www.{webspace.Domain} does not point to {webspace.CloudPanel.Host}", true); - - - await CloudPanelApiHelper.Post(webspace.CloudPanel, "letsencrypt/install/certificate", new InstallLetsEncrypt() - { - DomainName = webspace.Domain - }); - } - - #region Databases - - public Task GetDatabases(WebSpace w) - { - return Task.FromResult(WebSpaceRepository - .Get() - .Include(x => x.Databases) - .First(x => x.Id == w.Id) - .Databases.ToArray()); - } - - public async Task CreateDatabase(WebSpace w, string name, string password) - { - if (DatabaseRepository.Get().Any(x => x.UserName == name)) - throw new DisplayException("A database with this name does already exist"); - - var webspace = EnsureData(w); - - var database = new MySqlDatabase() - { - UserName = name, - Password = password - }; - - await CloudPanelApiHelper.Post(webspace.CloudPanel, "db", new AddDatabase() - { - DomainName = webspace.Domain, - DatabaseName = database.UserName, - DatabaseUserName = database.UserName, - DatabaseUserPassword = database.Password - }); - - webspace.Databases.Add(database); - WebSpaceRepository.Update(webspace); - } - - public async Task DeleteDatabase(WebSpace w, MySqlDatabase database) - { - var webspace = EnsureData(w); - - await CloudPanelApiHelper.Delete(webspace.CloudPanel, $"db/{database.UserName}", null); - - webspace.Databases.Remove(database); - WebSpaceRepository.Update(webspace); - } - - #endregion - - public Task CreateFileAccess(WebSpace w) - { - var webspace = EnsureData(w); - - return Task.FromResult( - new SftpFileAccess(webspace.CloudPanel.Host, webspace.UserName, webspace.Password, 22, true, - $"/htdocs/{webspace.Domain}") - ); - } - - private WebSpace EnsureData(WebSpace webSpace) - { - if (webSpace.CloudPanel == null || webSpace.Owner == null) - return WebSpaceRepository - .Get() - .Include(x => x.CloudPanel) - .Include(x => x.Owner) - .First(x => x.Id == webSpace.Id); - - return webSpace; - } -} \ No newline at end of file diff --git a/Moonlight/BlazorApp.razor b/Moonlight/BlazorApp.razor deleted file mode 100644 index 5119c0fe..00000000 --- a/Moonlight/BlazorApp.razor +++ /dev/null @@ -1,20 +0,0 @@ -@using Moonlight.Shared.Layouts - - - - - - - - - Not found - - - - - - -@code -{ - -} \ No newline at end of file diff --git a/Moonlight/Dockerfile b/Moonlight/Dockerfile deleted file mode 100644 index a0ccd337..00000000 --- a/Moonlight/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["Moonlight/Moonlight.csproj", "Moonlight/"] -RUN dotnet restore "Moonlight/Moonlight.csproj" -COPY . . -WORKDIR "/src/Moonlight" -RUN dotnet build "Moonlight.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "Moonlight.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -RUN mkdir -p /app/storage -RUN touch /app/storage/donttriggeranyerrors -RUN rm -r /app/storage/* -ENTRYPOINT ["dotnet", "Moonlight.dll"] \ No newline at end of file diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj deleted file mode 100644 index 73288185..00000000 --- a/Moonlight/Moonlight.csproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - net6.0 - enable - enable - 94bf7af9-8bb6-424b-ba9f-11ac92bd63aa - Linux - - - - - - - - - - - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - - - - - - - - <_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\css\bootstrap\bootstrap.min.css.map" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\FONT-LICENSE" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\css\open-iconic-bootstrap.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.eot" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.otf" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.svg" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\font\fonts\open-iconic.woff" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\ICON-LICENSE" /> - <_ContentIncludedByDefault Remove="wwwroot\css\open-iconic\README.md" /> - <_ContentIncludedByDefault Remove="wwwroot\css\site.css" /> - <_ContentIncludedByDefault Remove="Shared\Components\Tables\Column.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\Tables\Table.razor" /> - <_ContentIncludedByDefault Remove="Shared\Views\Admin\Servers\Cleanup\Exceptions\Add.razor" /> - <_ContentIncludedByDefault Remove="Shared\Views\Admin\Servers\Cleanup\Exceptions\Edit.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\News\NewsEditor.razor" /> - <_ContentIncludedByDefault Remove="Shared\News\Edit.razor" /> - <_ContentIncludedByDefault Remove="Shared\Views\Admin\AaPanels\Index.razor" /> - <_ContentIncludedByDefault Remove="Shared\Views\Admin\Databases\Index.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\StateLogic\OnlyAdmin.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryChangePassword.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryChangePowerState.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryLogin.razor" /> - <_ContentIncludedByDefault Remove="Shared\Components\AuditLogEntrys\AuditLogEntryRegister.razor" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-balloon-block.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-balloon.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-classic.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-document.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\ckeditor\ckeditor-inline.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cookiealert\cookiealert.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cookiealert\cookiealert.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cropper\cropper.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\cropper\cropper.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\datatables\datatables.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\datatables\datatables.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\draggable\draggable.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\flotcharts\flotcharts.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\formrepeater\formrepeater.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\fslightbox\fslightbox.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\fullcalendar\fullcalendar.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\fullcalendar\fullcalendar.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jkanban\jkanban.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jkanban\jkanban.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\images\jstree\32px.png" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\images\jstree\throbber.gif" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\jstree.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\jstree\jstree.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\leaflet\leaflet.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\leaflet\leaflet.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\prismjs\prismjs.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\prismjs\prismjs.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\dark\content.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\dark\content.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\default\content.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\default\content.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\document\content.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\document\content.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\writer\content.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\content\writer\content.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.inline.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.inline.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.mobile.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\content.mobile.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.mobile.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.mobile.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.shadowdom.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide-dark\skin.shadowdom.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.inline.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.inline.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.mobile.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\content.mobile.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.mobile.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.mobile.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.shadowdom.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\skins\ui\oxide\skin.shadowdom.min.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\tinymce\tinymce.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\typedjs\typedjs.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\vis-timeline\vis-timeline.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\custom\vis-timeline\vis-timeline.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-brands-400.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-brands-400.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-regular-400.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-regular-400.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-solid-900.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-solid-900.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-v4compatibility.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\@fortawesome\fa-v4compatibility.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\bootstrap-icons\bootstrap-icons.woff" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\bootstrap-icons\bootstrap-icons.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.eot" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.svg" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.woff" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\fonticon\fonticon.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.eot" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.svg" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.woff" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-brands-400.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.eot" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.svg" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.woff" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-regular-400.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.eot" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.svg" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.ttf" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.woff" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\fonts\line-awesome\la-solid-900.woff2" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\plugins.bundle.css" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\plugins.bundle.js" /> - <_ContentIncludedByDefault Remove="wwwroot\assets\plugins\global\sourcemaps\tiny-slider.css.map" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Moonlight/Moonlight.csproj.user b/Moonlight/Moonlight.csproj.user deleted file mode 100644 index e797fd12..00000000 --- a/Moonlight/Moonlight.csproj.user +++ /dev/null @@ -1,9 +0,0 @@ - - - - Moonlight - - - ProjectDebugger - - \ No newline at end of file diff --git a/Moonlight/Pages/Error.cshtml b/Moonlight/Pages/Error.cshtml deleted file mode 100644 index d1dc2cf7..00000000 --- a/Moonlight/Pages/Error.cshtml +++ /dev/null @@ -1,42 +0,0 @@ -@page -@model Moonlight.Pages.ErrorModel - - - - - - - - Error - - - - - -
-
-

Error.

-

An error occurred while processing your request.

- - @if (Model.ShowRequestId) - { -

- Request ID: @Model.RequestId -

- } - -

Development Mode

-

- Swapping to the Development environment displays detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

-
-
- - - diff --git a/Moonlight/Pages/Error.cshtml.cs b/Moonlight/Pages/Error.cshtml.cs deleted file mode 100644 index 7b7b8987..00000000 --- a/Moonlight/Pages/Error.cshtml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -using System.Diagnostics; - -namespace Moonlight.Pages -{ - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - [IgnoreAntiforgeryToken] - public class ErrorModel : PageModel - { - public string? RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) - { - _logger = logger; - } - - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} \ No newline at end of file diff --git a/Moonlight/Pages/_Host.cshtml b/Moonlight/Pages/_Host.cshtml deleted file mode 100644 index 1eb715d7..00000000 --- a/Moonlight/Pages/_Host.cshtml +++ /dev/null @@ -1,54 +0,0 @@ -@page "/" -@using Moonlight.App.Services -@namespace Moonlight.Pages - -@inject SmartTranslateService SmartTranslateService - -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -@{ - Layout = "_Layout"; -} - - - -
-
- -
-
- -
-
- -
-
\ No newline at end of file diff --git a/Moonlight/Pages/_Layout.cshtml b/Moonlight/Pages/_Layout.cshtml deleted file mode 100644 index 6dd42b6e..00000000 --- a/Moonlight/Pages/_Layout.cshtml +++ /dev/null @@ -1,134 +0,0 @@ -@using Microsoft.AspNetCore.Components.Web -@using Moonlight.App.Extensions -@using Moonlight.App.Repositories -@using Moonlight.App.Services -@using Moonlight.App.Services.Sessions -@namespace Moonlight.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - -@inject ConfigService ConfigService -@inject LoadingMessageRepository LoadingMessageRepository - -@{ - var headerConfig = ConfigService - .Get() - .Moonlight.Html.Headers; - - var moonlightConfig = ConfigService - .Get() - .Moonlight; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Loading - - - -@RenderBody() - -
- -
- Logo - - @{ - string loadingMessage; - - try - { - loadingMessage = LoadingMessageRepository.Get().Random().Message; - } - catch (Exception) - { - loadingMessage = ""; - } - } - -
- - @(loadingMessage) -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs deleted file mode 100644 index ef324b86..00000000 --- a/Moonlight/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Moonlight -{ - public class Program - { - private static readonly Startup Startup = new(); - - public static async Task Main(string[] args) - { - Console.WriteLine("Moonlight Panel"); - Console.WriteLine($"Copyright {DateTime.UtcNow.Year} moonlightpanel.xyz"); - Console.WriteLine(); - - await Startup.Init(args); - await Startup.Start(); - } - } -} \ No newline at end of file diff --git a/Moonlight/Properties/launchSettings.json b/Moonlight/Properties/launchSettings.json deleted file mode 100644 index bc35e03e..00000000 --- a/Moonlight/Properties/launchSettings.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "profiles": - { - "Default": - { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ML_DEBUG": "true" - }, - "applicationUrl": "http://localhost:5118;http://moonlight.owo:5118", - "dotnetRunMessages": true - }, - "Live DB": - { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ML_DEBUG": "true", - "ML_CONFIG_PATH": "storage\\configs\\live_config.json" - }, - "applicationUrl": "http://moonlight.owo:5118;http://localhost:5118", - "dotnetRunMessages": true - }, - "Dev DB 1": - { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ML_DEBUG": "true", - "ML_CONFIG_PATH": "storage\\configs\\dev_1_config.json" - }, - "applicationUrl": "http://moonlight.owo:5118;http://localhost:5118", - "dotnetRunMessages": true - }, - "Dev DB 2": - { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ML_DEBUG": "true", - "ML_CONFIG_PATH": "storage\\configs\\dev_2_config.json" - }, - "applicationUrl": "http://moonlight.owo:5118;http://localhost:5118", - "dotnetRunMessages": true - } - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Alerts/BannedAlert.razor b/Moonlight/Shared/Components/Alerts/BannedAlert.razor deleted file mode 100644 index 214ee81b..00000000 --- a/Moonlight/Shared/Components/Alerts/BannedAlert.razor +++ /dev/null @@ -1,16 +0,0 @@ -@using Moonlight.App.Services -@using Moonlight.App.Services.Files - -@inject ResourceService ResourceService - -
-
-
- Logo -
-

Your account is banned from moonlight

-
- Your account is banned from using moonlight. Your data will be deleted shortly -
-
-
\ No newline at end of file diff --git a/Moonlight/Shared/Components/Alerts/DisabledAlert.razor b/Moonlight/Shared/Components/Alerts/DisabledAlert.razor deleted file mode 100644 index cecd949b..00000000 --- a/Moonlight/Shared/Components/Alerts/DisabledAlert.razor +++ /dev/null @@ -1,16 +0,0 @@ -@using Moonlight.App.Services -@using Moonlight.App.Services.Files - -@inject ResourceService ResourceService - -
-
-
- Logo -
-

Your moonlight account is disabled

-
- Your moonlight account is currently disabled. But dont worry your data is still saved -
-
-
\ No newline at end of file diff --git a/Moonlight/Shared/Components/Alerts/NoPermissionAlert.razor b/Moonlight/Shared/Components/Alerts/NoPermissionAlert.razor deleted file mode 100644 index 1ae6e3c5..00000000 --- a/Moonlight/Shared/Components/Alerts/NoPermissionAlert.razor +++ /dev/null @@ -1,13 +0,0 @@ -
-
-
- Warning -
- - You have no permission to access this resource - -

- You have no permission to access this resource. This attempt has been logged ;) -

-
-
\ No newline at end of file diff --git a/Moonlight/Shared/Components/Alerts/NotFoundAlert.razor b/Moonlight/Shared/Components/Alerts/NotFoundAlert.razor deleted file mode 100644 index ae5070a9..00000000 --- a/Moonlight/Shared/Components/Alerts/NotFoundAlert.razor +++ /dev/null @@ -1,31 +0,0 @@ -
-
-
- Not found -
- - The requested resource was not found - -

- We were not able to find the requested resource. This can have following reasons - -

-
  • - The resource was deleted -
  • -
  • - You have no permission to access this resource -
  • -
  • - You may have entered invalid data -
  • -
  • - A unknown bug occured -
  • -
  • - An api was down and not proper handled -
  • -
    -

    -
    -
    \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/Login.razor b/Moonlight/Shared/Components/Auth/Login.razor deleted file mode 100644 index 2be673c2..00000000 --- a/Moonlight/Shared/Components/Auth/Login.razor +++ /dev/null @@ -1,193 +0,0 @@ -@page "/login" - -@* This is just a "virtual" route/page. The handling for that is -@* MainLayout doing for us. We need to put that here so the router -@* does not return the 404 page -*@ - -@using Moonlight.App.Services.Interop -@using Moonlight.App.Services -@using Moonlight.App.Exceptions -@using Moonlight.App.Database.Entities -@using Moonlight.App.Models.Misc -@using Moonlight.App.Services.Sessions -@using System.ComponentModel.DataAnnotations -@using Moonlight.App.Helpers -@using Moonlight.App.Models.Forms - -@inject AlertService AlertService -@inject UserService UserService -@inject SmartTranslateService SmartTranslateService -@inject CookieService CookieService -@inject NavigationManager NavigationManager -@inject OAuth2Service OAuth2Service - -
    -
    -
    -
    - @if (!TotpRequired) - { - -
    -

    - Sign In -

    -
    - Sign in to start with moonlight -
    -
    - - @foreach (var providers in OAuth2Service.Providers.Chunk(2)) - { -
    - @foreach (var provider in providers) - { - - } -
    - } - - @if (OAuth2Service.Providers.Any()) - { -
    - - Or with email - -
    - } - -
    - -
    - -
    - -
    - - - -
    - -
    - -
    - Not registered yet? - - - Sign up - -
    -
    - } - else - { - -
    - -
    -
    - -
    -
    - } -
    -
    -
    -
    - -@code -{ - private LoginDataModel LoginData = new(); - private LoginTotpDataModel TotpData = new(); - - private bool TotpRequired = false; - - private async Task DoLogin() - { - try - { - LoginData.Email = LoginData.Email.ToLower().Trim(); - - if (string.IsNullOrEmpty(TotpData.Code)) - { - TotpRequired = await UserService.CheckTotp(LoginData.Email, LoginData.Password); - - if (!TotpRequired) - { - var token = await UserService.Login(LoginData.Email, LoginData.Password); - await CookieService.SetValue("token", token, 10); - - if (NavigationManager.Uri.EndsWith("login")) - NavigationManager.NavigateTo("/", true); - else - NavigationManager.NavigateTo(NavigationManager.Uri, true); - } - else - { - await InvokeAsync(StateHasChanged); - } - } - else - { - var token = await UserService.Login(LoginData.Email, LoginData.Password, TotpData.Code); - await CookieService.SetValue("token", token, 10); - - if (NavigationManager.Uri.EndsWith("login")) - NavigationManager.NavigateTo("/", true); - else - NavigationManager.NavigateTo(NavigationManager.Uri, true); - } - } - catch (DisplayException e) - { - // Reset state - LoginData = new(); - TotpData = new(); - TotpRequired = false; - - await AlertService.Error( - SmartTranslateService.Translate("Error"), - SmartTranslateService.Translate(e.Message) - ); - } - catch (Exception e) - { - Logger.Error("Error while login"); - Logger.Error(e); - - // Reset state - LoginData = new(); - TotpData = new(); - TotpRequired = false; - - await AlertService.Error( - SmartTranslateService.Translate("Error"), - SmartTranslateService.Translate("An error occured while logging you in") - ); - } - } - - private async Task StartOAuth2(string id) - { - var url = await OAuth2Service.GetUrl(id); - NavigationManager.NavigateTo(url ,true); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/PasswordChangeView.razor b/Moonlight/Shared/Components/Auth/PasswordChangeView.razor deleted file mode 100644 index 38e0e866..00000000 --- a/Moonlight/Shared/Components/Auth/PasswordChangeView.razor +++ /dev/null @@ -1,65 +0,0 @@ -@using Moonlight.App.Services -@using Moonlight.App.Models.Forms -@using Moonlight.App.Services.Sessions -@using Moonlight.App.Database.Entities -@using Moonlight.App.Models.Misc -@using Moonlight.App.Repositories - -@inject SmartTranslateService SmartTranslateService -@inject IdentityService IdentityService -@inject UserService UserService -@inject UserRepository UserRepository -@inject NavigationManager NavigationManager - -
    -
    -
    -
    - - -
    -

    - Change your password -

    -
    - You need to change your password in order to use moonlight -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    -
    - -@code { - private PasswordModel Password = new(); - private User User; - - private Task Load(LazyLoader loader) - { - User = IdentityService.User; - return Task.CompletedTask; - } - - private async Task DoChange() - { - await UserService.ChangePassword(User, Password.Password); - User.Status = UserStatus.Unverified; - UserRepository.Update(User); - NavigationManager.NavigateTo(NavigationManager.Uri, true); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/PasswordReset.razor b/Moonlight/Shared/Components/Auth/PasswordReset.razor deleted file mode 100644 index ef34549b..00000000 --- a/Moonlight/Shared/Components/Auth/PasswordReset.razor +++ /dev/null @@ -1,73 +0,0 @@ -@page "/passwordreset" -@using Moonlight.App.Services - -@* This is just a "virtual" route/page. The handling for that is -@* MainLayout doing for us. We need to put that here so the router -@* does not return the 404 page -*@ - -@inject UserService UserService -@inject SmartTranslateService SmartTranslateService - -
    -
    -
    -
    - @if (Send) - { -
    -

    - Passwort reset successfull. Check your mail -

    -
    - } - else - { -
    -
    -

    - Password reset -

    -
    - Reset the password of your account -
    -
    - -
    - -
    - -
    - - -
    - -
    - Wrong here? - - - Sign in - -
    -
    - } -
    -
    -
    -
    - -@code -{ - private string Email = ""; - private bool Send = false; - - private async Task Submit() - { - await UserService.ResetPassword(Email); - Send = true; - await InvokeAsync(StateHasChanged); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/Register.razor b/Moonlight/Shared/Components/Auth/Register.razor deleted file mode 100644 index aa2346aa..00000000 --- a/Moonlight/Shared/Components/Auth/Register.razor +++ /dev/null @@ -1,136 +0,0 @@ -@page "/register" - -@* This is just a "virtual" route/page. The handling for that is -@* MainLayout doing for us. We need to put that here so the router -@* does not return the 404 page -*@ - -@using Moonlight.App.Services -@using Moonlight.App.Models.Forms -@using Moonlight.App.Services.Interop -@using Moonlight.App.Services.Sessions - -@inject SmartTranslateService SmartTranslateService -@inject NavigationManager NavigationManager -@inject AlertService AlertService -@inject UserService UserService -@inject CookieService CookieService -@inject OAuth2Service OAuth2Service - -
    -
    -
    -
    -
    -
    -

    - Sign Up -

    -
    - Sign up to start with moonlight -
    -
    - - @foreach (var providers in OAuth2Service.Providers.Chunk(2)) - { -
    - @foreach (var provider in providers) - { - - } -
    - } - - @if (OAuth2Service.Providers.Any()) - { -
    - - Or with email - -
    - } - - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    - - -
    - -
    - -
    -
    - -
    - Already registered? - - - Sign in - -
    -
    -
    -
    -
    -
    - -@code -{ - private UserRegisterModel UserRegisterModel = new(); - - private async Task StartOAuth2(string id) - { - var url = await OAuth2Service.GetUrl(id); - NavigationManager.NavigateTo(url ,true); - } - - private async Task CreateUser() - { - if (UserRegisterModel.ConfirmPassword != UserRegisterModel.Password) - { - await AlertService.Error(SmartTranslateService.Translate("Passwords need to match")); - return; - } - - var token = await UserService.Register(UserRegisterModel.Email, UserRegisterModel.Password, UserRegisterModel.FirstName, UserRegisterModel.LastName); - await CookieService.SetValue("token", token, 10); - - if (NavigationManager.Uri.EndsWith("register")) - NavigationManager.NavigateTo("/", true); - else - NavigationManager.NavigateTo(NavigationManager.Uri, true); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/Auth/UserDataSetView.razor b/Moonlight/Shared/Components/Auth/UserDataSetView.razor deleted file mode 100644 index f8c64e8a..00000000 --- a/Moonlight/Shared/Components/Auth/UserDataSetView.razor +++ /dev/null @@ -1,68 +0,0 @@ -@using Microsoft.AspNetCore.Components -@using Moonlight.App.Database.Entities -@using Moonlight.App.Models.Forms -@using Moonlight.App.Models.Misc -@using Moonlight.App.Repositories -@using Moonlight.App.Services -@using Moonlight.App.Services.Sessions - -@inject IdentityService IdentityService -@inject UserRepository UserRepository -@inject SmartTranslateService SmartTranslateService -@inject NavigationManager NavigationManager - -
    -
    -
    -
    - - -
    -

    - Enter your information -

    -
    - You need to enter your full name in order to use moonlight -
    -
    - -
    -
    - -
    - -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    - -@code { - private User User; - private NameModel Name = new (); - - private Task Load(LazyLoader loader) - { - User = IdentityService.User; - return Task.CompletedTask; - } - - private async Task SetName() - { - User.FirstName = Name.FirstName; - User.LastName = Name.LastName; - User.Status = UserStatus.Unverified; - - UserRepository.Update(User); - NavigationManager.NavigateTo(NavigationManager.Uri, true); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/ErrorBoundaries/GlobalErrorBoundary.razor b/Moonlight/Shared/Components/ErrorBoundaries/GlobalErrorBoundary.razor deleted file mode 100644 index 0419fc71..00000000 --- a/Moonlight/Shared/Components/ErrorBoundaries/GlobalErrorBoundary.razor +++ /dev/null @@ -1,66 +0,0 @@ -@using Moonlight.App.Services.Sessions -@using Moonlight.App.Helpers - -@inherits ErrorBoundary - -@inject IdentityService IdentityService - -@if (CurrentException is null) -{ - @ChildContent -} -else if (ErrorContent is not null) -{ -
    -
    -
    -
    - - Ooops. Your moonlight client is crashed - -
    -
    - This error has been reported to the moonlight team -
    -
    -
    -
    -} -else -{ -
    -
    -
    -
    - - Ooops. Your moonlight client is crashed - -
    -
    - This error has been reported to the moonlight team -
    -
    -
    -
    -} - -@code -{ - List receivedExceptions = new(); - - protected override async Task OnErrorAsync(Exception exception) - { - receivedExceptions.Add(exception); - - Logger.Error($"An unhanded exception occured:"); - Logger.Error(exception); - - await base.OnErrorAsync(exception); - } - - public new void Recover() - { - receivedExceptions.Clear(); - base.Recover(); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/ErrorBoundaries/PageErrorBoundary.razor b/Moonlight/Shared/Components/ErrorBoundaries/PageErrorBoundary.razor deleted file mode 100644 index 587e43f1..00000000 --- a/Moonlight/Shared/Components/ErrorBoundaries/PageErrorBoundary.razor +++ /dev/null @@ -1,89 +0,0 @@ -@using Moonlight.App.Exceptions -@using Moonlight.App.Helpers -@using Moonlight.App.Services -@using Moonlight.App.Services.Interop -@using Moonlight.App.Services.Sessions - -@inherits ErrorBoundary - -@inject IdentityService IdentityService -@inject AlertService AlertService -@inject SmartTranslateService SmartTranslateService - -@if (CurrentException is null) -{ - @ChildContent -} -else if (ErrorContent is not null) -{ -
    -
    -
    -
    - - Ooops. This page is crashed - -
    -
    - This page is crashed. The error has been reported to the moonlight team. Meanwhile you can try reloading the page -
    -
    -
    -
    -} -else -{ -
    -
    -
    -
    - - Ooops. This page is crashed - -
    -
    - This page is crashed. The error has been reported to the moonlight team. Meanwhile you can try reloading the page -
    -
    -
    -
    -} - -@code -{ - List receivedExceptions = new(); - - protected override async Task OnErrorAsync(Exception exception) - { - receivedExceptions.Add(exception); - - var user = IdentityService.User; - var id = user == null ? -1 : user.Id; - - Logger.Error($"[{id}] An unhanded exception occured:"); - Logger.Error(exception); - - await base.OnErrorAsync(exception); - - if (exception is DisplayException displayException) - { - Task.Run(async () => - { - await AlertService.Error( - SmartTranslateService.Translate("Error"), - SmartTranslateService.Translate(displayException.Message) - ); - }); - - Recover(); - - await InvokeAsync(StateHasChanged); - } - } - - public new void Recover() - { - receivedExceptions.Clear(); - base.Recover(); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor b/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor deleted file mode 100644 index 87812157..00000000 --- a/Moonlight/Shared/Components/ErrorBoundaries/SoftErrorBoundary.razor +++ /dev/null @@ -1,132 +0,0 @@ -@using Moonlight.App.Services.Interop -@using Moonlight.App.Exceptions -@using Moonlight.App.Services -@using Moonlight.App.ApiClients.CloudPanel -@using Moonlight.App.ApiClients.Daemon -@using Moonlight.App.ApiClients.Modrinth -@using Moonlight.App.ApiClients.Wings -@using Moonlight.App.Helpers -@using Stripe -@inherits ErrorBoundaryBase - -@inject AlertService AlertService -@inject ConfigService ConfigService -@inject SmartTranslateService SmartTranslateService -@inject NavigationManager NavigationManager - -@if (HardCrashed) -{ -
    -
    -
    -
    - - Ooops. This page is crashed - -
    -
    - This page is crashed. The error has been reported to the moonlight team. Meanwhile you can try reloading the page -
    -
    -
    -
    -} -else if (SoftCrashed) -{ -
    - - @(ErrorMessage) - -
    - - @ChildContent -} -else -{ - @ChildContent -} - -@code -{ - private bool HardCrashed = false; - private bool SoftCrashed = false; - private string ErrorMessage = ""; - - protected override void OnInitialized() - { - NavigationManager.LocationChanged += OnPathChanged; - } - - private void OnPathChanged(object? sender, LocationChangedEventArgs e) - { - if (SoftCrashed) - SoftCrashed = false; - - StateHasChanged(); - } - - protected override async Task OnErrorAsync(Exception exception) - { - if (ConfigService.DebugMode) - { - Logger.Verbose(exception); - } - - if (exception is DisplayException displayException) - { - if (displayException.DoNotTranslate) - { - await SoftCrash(displayException.Message); - } - else - { - await SoftCrash(SmartTranslateService.Translate(displayException.Message)); - } - } - else if (exception is CloudflareException cloudflareException) - { - await SoftCrash(SmartTranslateService.Translate("Error from cloudflare: ") + cloudflareException.Message); - } - else if (exception is WingsException wingsException) - { - await SoftCrash(SmartTranslateService.Translate("Error from wings: ") + wingsException.Message); - - Logger.Warn($"Wings exception status code: {wingsException.StatusCode}"); - } - else if (exception is DaemonException daemonException) - { - await SoftCrash(SmartTranslateService.Translate("Error from daemon: ") + daemonException.Message); - - Logger.Warn($"Wings exception status code: {daemonException.StatusCode}"); - } - else if (exception is ModrinthException modrinthException) - { - await SoftCrash(SmartTranslateService.Translate("Error from modrinth: ") + modrinthException.Message); - } - else if (exception is CloudPanelException cloudPanelException) - { - await SoftCrash(SmartTranslateService.Translate("Error from cloudpanel: ") + cloudPanelException.Message); - } - else if (exception is NotImplementedException) - { - await SoftCrash(SmartTranslateService.Translate("This function is not implemented")); - } - else if (exception is StripeException stripeException) - { - await SoftCrash(SmartTranslateService.Translate("Error from stripe: ") + stripeException.Message); - } - else - { - Logger.Warn(exception); - HardCrashed = true; - await InvokeAsync(StateHasChanged); - } - } - - private Task SoftCrash(string message) - { - SoftCrashed = true; - ErrorMessage = message; - return Task.CompletedTask; - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor b/Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor deleted file mode 100644 index 50f7eaef..00000000 --- a/Moonlight/Shared/Components/FileManagerPartials/ConnectionDetailsModal.razor +++ /dev/null @@ -1,87 +0,0 @@ -@using Moonlight.App.Helpers.Files -@using Moonlight.App.Services.Interop - -@inject ModalService ModalService - - - -@code -{ - [Parameter] - public FileAccess Access { get; set; } - - private string Host = ""; - private string Username = ""; - private int Port; - - protected override async Task OnParametersSetAsync() - { - try - { - Uri uri = new Uri(await Access.GetLaunchUrl()); - - Host = uri.Host; - Port = uri.Port; - Username = uri.UserInfo.Split(':')[0]; - } - catch (NotImplementedException) - { - Host = "N/A"; - Port = -1; - Username = "N/A"; - } - } - - public async Task Show() - { - await ModalService.Show("connectionDetails"); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor b/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor deleted file mode 100644 index 4f06d10a..00000000 --- a/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor +++ /dev/null @@ -1,148 +0,0 @@ -@using BlazorMonaco -@using Moonlight.App.Services -@using Moonlight.App.Services.Interop -@using Moonlight.App.Services.Sessions -@using Moonlight.Shared.Components.Partials - -@inject SmartTranslateService TranslationService -@inject KeyListenerService KeyListenerService -@inject IJSRuntime JsRuntime - -@implements IDisposable - -
    - @if (ShowHeader) - { -
    - @(Header) -
    - } - -
    - -
    - - @if (!HideControls) - { - - } -
    - -@code -{ - [Parameter] - public string InitialData { get; set; } - - [Parameter] - public string Language { get; set; } - - [Parameter] - public bool HideControls { get; set; } = false; - - [Parameter] - public bool ShowHeader { get; set; } = false; - - [Parameter] - public string Header { get; set; } = "Header.changeme.txt"; - - // Events - [Parameter] - public Action OnSubmit { get; set; } - - [Parameter] - public Action OnCancel { get; set; } - - // Monaco Editor - private MonacoEditor Editor; - private StandaloneEditorConstructionOptions EditorOptions; - - protected override void OnInitialized() - { - EditorOptions = new() - { - AutomaticLayout = true, - Language = "plaintext", - Value = "Loading content", - Theme = "moonlight-theme", - Contextmenu = false, - Minimap = new() - { - Enabled = false - }, - AutoIndent = true - }; - - KeyListenerService.KeyPressed += KeyPressed; - } - - private async void KeyPressed(object? sender, string e) - { - if (e == "saveShortcut") - { - await Submit(); - } - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - await JsRuntime.InvokeVoidAsync("moonlight.loading.loadMonaco"); - - Editor.OnDidInit = new EventCallback(this, async () => - { - EditorOptions.Language = Language; - - var model = await Editor.GetModel(); - await MonacoEditorBase.SetModelLanguage(model, EditorOptions.Language); - await Editor.SetPosition(new Position() - { - Column = 0, - LineNumber = 1 - }); - - await Editor.SetValue(InitialData); - - await Editor.Layout(new Dimension() - { - Height = 500, - Width = 1000 - }); - }); - } - } - - private async Task Submit() - { - var data = await Editor.GetValue(); - await InvokeAsync(() => OnSubmit?.Invoke(data)); - } - - private async Task Cancel() - { - await InvokeAsync(() => OnCancel?.Invoke()); - } - - public async Task GetData() - { - return await Editor.GetValue(); - } - - public void Dispose() - { - Editor.Dispose(); - KeyListenerService.KeyPressed -= KeyPressed; - } -} diff --git a/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor b/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor deleted file mode 100644 index ddd83588..00000000 --- a/Moonlight/Shared/Components/FileManagerPartials/FileManager.razor +++ /dev/null @@ -1,379 +0,0 @@ -@using Moonlight.App.Helpers.Files -@using Moonlight.App.Helpers -@using Moonlight.App.Services -@using Moonlight.App.Services.Interop -@using BlazorDownloadFile - -@inject ToastService ToastService -@inject NavigationManager NavigationManager -@inject AlertService AlertService -@inject SmartTranslateService SmartTranslateService -@inject IBlazorDownloadFileService FileService - -@if (Editing) -{ - - -} -else -{ -
    -
    -
    -
    - -
    -
    -
    -
    - @if (View != null && View.SelectedFiles.Any()) - { -
    - - @(View.SelectedFiles.Length) selected - -
    - - - - - - - - - - } - else - { -
    - - - -
    - -
    - - -
    - - - } -
    -
    -
    -
    - -
    - - -
    - - - - - -} - -@code -{ - [Parameter] - public FileAccess Access { get; set; } - - // File Editor - private bool Editing = false; - private string EditorInitialData = ""; - private string EditorLanguage = ""; - private FileData EditingFile; - private FileEditor Editor; - - // File View - private FileView? View; - - // File Move - private FileAccess MoveAccess; - private FileSelectModal FileSelectModal; - private FileData? SingleMoveFile = null; - - // Config - private ContextAction[] Actions = Array.Empty(); - - // Connection details - private ConnectionDetailsModal ConnectionDetailsModal; - - protected override void OnInitialized() - { - MoveAccess = (FileAccess)Access.Clone(); - - List actions = new(); - - actions.Add(new() - { - Id = "rename", - Name = "Rename", - Action = async (x) => - { - var name = await AlertService.Text( - SmartTranslateService.Translate("Rename"), - SmartTranslateService.Translate("Enter a new name"), - x.Name - ); - - if (name != x.Name) - { - await Access.Move(x, Access.CurrentPath + name); - } - - await View!.Refresh(); - } - }); - - actions.Add(new() - { - Id = "download", - Name = "Download", - Action = async (x) => - { - if (x.IsFile) - { - try - { - var stream = await Access.DownloadStream(x); - await ToastService.Info(SmartTranslateService.Translate("Starting download")); - stream.Position = 0; - await FileService.DownloadFile(fileName: x.Name, stream: stream, contentType: "application/octet-stream"); - } - catch (NotImplementedException) - { - var url = await Access.DownloadUrl(x); - NavigationManager.NavigateTo(url, true); - await ToastService.Info(SmartTranslateService.Translate("Starting download")); - } - } - else - await ToastService.Error(SmartTranslateService.Translate("You are not able to download folders using the moonlight file manager")); - } - }); - - actions.Add(new() - { - Id = "compress", - Name = "Compress", - Action = async (x) => - { - await Access.Compress(x); - await View!.Refresh(); - } - }); - - actions.Add(new() - { - Id = "decompress", - Name = "Decompress", - Action = async (x) => - { - await Access.Decompress(x); - await View!.Refresh(); - } - }); - - actions.Add(new() - { - Id = "move", - Name = "Move", - Action = async (x) => - { - SingleMoveFile = x; - await StartMoveFiles(); - } - }); - - actions.Add(new() - { - Id = "delete", - Name = "Delete", - Action = async (x) => - { - await Access.Delete(x); - await View!.Refresh(); - } - }); - - Actions = actions.ToArray(); - } - - private async Task OnElementClicked(FileData fileData) - { - if (fileData.IsFile) - { - EditorInitialData = await Access.Read(fileData); - EditorLanguage = MonacoTypeHelper.GetEditorType(fileData.Name); - EditingFile = fileData; - - Editing = true; - - await InvokeAsync(StateHasChanged); - return true; - } - - await InvokeAsync(StateHasChanged); - return false; - } - - private async void Save() - { - var data = await Editor.GetData(); - await Access.Write(EditingFile, data); - await ToastService.Success(SmartTranslateService.Translate("Successfully saved file")); - } - - private async void Cancel(bool save = false) - { - if (save) - { - var data = await Editor.GetData(); - await Access.Write(EditingFile, data); - } - - Editing = false; - await InvokeAsync(StateHasChanged); - } - - private async Task Launch() - { - var url = await Access.GetLaunchUrl(); - NavigationManager.NavigateTo(url, true); - } - - private async Task CreateFolder() - { - var name = await AlertService.Text( - SmartTranslateService.Translate("Create a new folder"), - SmartTranslateService.Translate("Enter a name"), - "" - ); - - if (string.IsNullOrEmpty(name)) - return; - - await Access.MkDir(name); - await View!.Refresh(); - } - - private async Task CreateFile() - { - var name = await AlertService.Text( - SmartTranslateService.Translate("Create a new file"), - SmartTranslateService.Translate("Enter a name"), - "" - ); - - if (string.IsNullOrEmpty(name)) - return; - - await Access.Write(new FileData { IsFile = true, Name = name }, ""); - await View!.Refresh(); - } - - private async Task OnSelectionChanged() - { - await InvokeAsync(StateHasChanged); - } - - private async Task StartMoveFiles() - { - await FileSelectModal.Show(); - } - - private async Task DeleteMultiple() - { - foreach (var data in View!.SelectedFiles) - { - await Access.Delete(data); - } - - await View!.Refresh(); - } - - private async Task CompressMultiple() - { - await Access.Compress(View!.SelectedFiles); - - await View!.Refresh(); - } - - private async Task OnFileMoveSubmit(string path) - { - foreach (var sFile in View!.SelectedFiles) - { - await Access.Move(sFile, path + sFile.Name); - } - - if (SingleMoveFile != null) - { - await Access.Move(SingleMoveFile, path + SingleMoveFile.Name); - SingleMoveFile = null; - } - - await View.Refresh(); - } - - // This method can be called by every component to refresh the view - private async Task OnComponentStateChanged() - { - await View!.Refresh(); - await InvokeAsync(StateHasChanged); - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/FileManagerPartials/FilePath.razor b/Moonlight/Shared/Components/FileManagerPartials/FilePath.razor deleted file mode 100644 index 93982da1..00000000 --- a/Moonlight/Shared/Components/FileManagerPartials/FilePath.razor +++ /dev/null @@ -1,47 +0,0 @@ -@using Moonlight.App.Helpers.Files - -
    -
    - @{ - var vx = "/"; - } - / - - - - - - @{ - var cp = "/"; - var lp = "/"; - var pathParts = Access.CurrentPath.Replace("\\", "/").Split('/', StringSplitOptions.RemoveEmptyEntries); - foreach (var path in pathParts) - { - lp = cp; - @(path) - - - - - - - cp += path + "/"; - } - } -
    -
    - -@code -{ - [Parameter] - public FileAccess Access { get; set; } - - [Parameter] - public Func? OnPathChanged { get; set; } - - public async Task SetPath(string path) - { - await Access.SetDir(path); - OnPathChanged?.Invoke(); - } -} diff --git a/Moonlight/Shared/Components/FileManagerPartials/FileSelectModal.razor b/Moonlight/Shared/Components/FileManagerPartials/FileSelectModal.razor deleted file mode 100644 index 9a9814f0..00000000 --- a/Moonlight/Shared/Components/FileManagerPartials/FileSelectModal.razor +++ /dev/null @@ -1,132 +0,0 @@ -@using Moonlight.App.Helpers.Files -@using Moonlight.App.Services -@using Moonlight.App.Services.Interop - -@inject ModalService ModalService -@inject SmartTranslateService SmartTranslateService - - - -@code -{ - [Parameter] - public FileAccess Access { get; set; } - - [Parameter] - public bool OnlyFolder { get; set; } = false; - - [Parameter] - public Func? Filter { get; set; } - - [Parameter] - public string Title { get; set; } = "Select file or folder"; - - [Parameter] - public Func? OnSubmit { get; set; } - - [Parameter] - public Func? OnCancel { get; set; } - - private int Id = 0; - private string Result = "/"; - - private FileView FileView; - - protected override void OnInitialized() - { - Id = this.GetHashCode(); - } - - public async Task Show() - { - // Reset - Result = "/"; - await Access.SetDir("/"); - await FileView.Refresh(); - - await ModalService.Show("fileView" + Id); - } - - public async Task Hide() - { - await Cancel(); - } - - private async Task Cancel() - { - await ModalService.Hide("fileView" + Id); - await OnCancel?.Invoke()!; - } - - private async Task Submit() - { - await ModalService.Hide("fileView" + Id); - await OnSubmit?.Invoke(Result)!; - } - - private bool DoFilter(FileData file) - { - if (OnlyFolder) - { - if (file.IsFile) - return false; - else - { - if (Filter != null) - return Filter.Invoke(file); - else - return true; - } - } - else - { - if (Filter != null) - return Filter.Invoke(file); - else - return true; - } - } - - private async Task OnElementClicked(FileData file) - { - Result = Access.CurrentPath + file.Name + (file.IsFile ? "" : "/"); - - if (!OnlyFolder && file.IsFile) - { - await Submit(); - } - - return false; - } -} \ No newline at end of file diff --git a/Moonlight/Shared/Components/FileManagerPartials/FileUpload.razor b/Moonlight/Shared/Components/FileManagerPartials/FileUpload.razor deleted file mode 100644 index 4bebc345..00000000 --- a/Moonlight/Shared/Components/FileManagerPartials/FileUpload.razor +++ /dev/null @@ -1,90 +0,0 @@ -@using Moonlight.App.Helpers.Files -@using Moonlight.App.Services -@using Moonlight.App.Services.Interop -@using Moonlight.App.Helpers - -@inject ToastService ToastService -@inject SmartTranslateService SmartTranslateService - -