Adds Network Resource Uploading for admins. (#6904)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
Vera Aguilera Puerto
2022-03-26 12:46:37 +01:00
committed by GitHub
parent 5954b7668c
commit eb54f4b224
21 changed files with 2657 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,36 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Content.Server.Database.Migrations.Postgres
{
public partial class UploadedResourcesLog : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "uploaded_resource_log",
columns: table => new
{
uploaded_resource_log_id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
user_id = table.Column<Guid>(type: "uuid", nullable: false),
path = table.Column<string>(type: "text", nullable: false),
data = table.Column<byte[]>(type: "bytea", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_uploaded_resource_log", x => x.uploaded_resource_log_id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "uploaded_resource_log");
}
}
}

View File

@@ -793,6 +793,39 @@ namespace Content.Server.Database.Migrations.Postgres
b.ToTable("server_unban", (string)null);
});
modelBuilder.Entity("Content.Server.Database.UploadedResourceLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("uploaded_resource_log_id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<byte[]>("Data")
.IsRequired()
.HasColumnType("bytea")
.HasColumnName("data");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone")
.HasColumnName("date");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("text")
.HasColumnName("path");
b.Property<Guid>("UserId")
.HasColumnType("uuid")
.HasColumnName("user_id");
b.HasKey("Id")
.HasName("PK_uploaded_resource_log");
b.ToTable("uploaded_resource_log", (string)null);
});
modelBuilder.Entity("Content.Server.Database.Whitelist", b =>
{
b.Property<Guid>("UserId")

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Content.Server.Database.Migrations.Sqlite
{
public partial class UploadedResourcesLog : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "uploaded_resource_log",
columns: table => new
{
uploaded_resource_log_id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
date = table.Column<DateTime>(type: "TEXT", nullable: false),
user_id = table.Column<Guid>(type: "TEXT", nullable: false),
path = table.Column<string>(type: "TEXT", nullable: false),
data = table.Column<byte[]>(type: "BLOB", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_uploaded_resource_log", x => x.uploaded_resource_log_id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "uploaded_resource_log");
}
}
}

View File

@@ -737,6 +737,37 @@ namespace Content.Server.Database.Migrations.Sqlite
b.ToTable("server_unban", (string)null);
});
modelBuilder.Entity("Content.Server.Database.UploadedResourceLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uploaded_resource_log_id");
b.Property<byte[]>("Data")
.IsRequired()
.HasColumnType("BLOB")
.HasColumnName("data");
b.Property<DateTime>("Date")
.HasColumnType("TEXT")
.HasColumnName("date");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("path");
b.Property<Guid>("UserId")
.HasColumnType("TEXT")
.HasColumnName("user_id");
b.HasKey("Id")
.HasName("PK_uploaded_resource_log");
b.ToTable("uploaded_resource_log", (string)null);
});
modelBuilder.Entity("Content.Server.Database.Whitelist", b =>
{
b.Property<Guid>("UserId")

View File

@@ -33,6 +33,7 @@ namespace Content.Server.Database
public DbSet<ServerBanHit> ServerBanHit { get; set; } = default!;
public DbSet<ServerRoleBan> RoleBan { get; set; } = default!;
public DbSet<ServerRoleUnban> RoleUnban { get; set; } = default!;
public DbSet<UploadedResourceLog> UploadedResourceLog { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -459,4 +460,19 @@ namespace Content.Server.Database
public DateTime UnbanTime { get; set; }
}
[Table("uploaded_resource_log")]
public sealed class UploadedResourceLog
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public DateTime Date { get; set; }
public Guid UserId { get; set; }
public string Path { get; set; } = string.Empty;
public byte[] Data { get; set; } = default!;
}
}