Files: added subject type, files link options
This commit is contained in:
parent
47600daa03
commit
8dfe176414
2704
migrations/mysql/FilesDbContext/20220908145301_FilesDbContext_Upgrade2.Designer.cs
generated
Normal file
2704
migrations/mysql/FilesDbContext/20220908145301_FilesDbContext_Upgrade2.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ASC.Migrations.MySql.Migrations.FilesDb
|
||||
{
|
||||
public partial class FilesDbContext_Upgrade2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "options",
|
||||
table: "files_security",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
collation: "utf8_general_ci")
|
||||
.Annotation("MySql:CharSet", "utf8");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "subject_type",
|
||||
table: "files_security",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "options",
|
||||
table: "files_security");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "subject_type",
|
||||
table: "files_security");
|
||||
}
|
||||
}
|
||||
}
|
@ -2301,6 +2301,12 @@ namespace ASC.Migrations.MySql.Migrations.FilesDb
|
||||
.UseCollation("utf8_general_ci")
|
||||
.HasAnnotation("MySql:CharSet", "utf8");
|
||||
|
||||
b.Property<string>("FileShareOptions")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("options")
|
||||
.UseCollation("utf8_general_ci")
|
||||
.HasAnnotation("MySql:CharSet", "utf8");
|
||||
|
||||
b.Property<string>("Owner")
|
||||
.IsRequired()
|
||||
.HasColumnType("char(38)")
|
||||
@ -2312,6 +2318,10 @@ namespace ASC.Migrations.MySql.Migrations.FilesDb
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("security");
|
||||
|
||||
b.Property<int>("SubjectType")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("subject_type");
|
||||
|
||||
b.Property<DateTime>("TimeStamp")
|
||||
.HasColumnType("timestamp")
|
||||
.HasColumnName("timestamp");
|
||||
|
2615
migrations/postgre/FilesDbContext/20220908145302_FilesDbContext_Upgrade2.Designer.cs
generated
Normal file
2615
migrations/postgre/FilesDbContext/20220908145302_FilesDbContext_Upgrade2.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ASC.Migrations.PostgreSql.Migrations.FilesDb
|
||||
{
|
||||
public partial class FilesDbContext_Upgrade2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "options",
|
||||
schema: "onlyoffice",
|
||||
table: "files_security",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "subject_type",
|
||||
schema: "onlyoffice",
|
||||
table: "files_security",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "options",
|
||||
schema: "onlyoffice",
|
||||
table: "files_security");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "subject_type",
|
||||
schema: "onlyoffice",
|
||||
table: "files_security");
|
||||
}
|
||||
}
|
||||
}
|
@ -2261,6 +2261,10 @@ namespace ASC.Migrations.PostgreSql.Migrations
|
||||
.HasColumnName("subject")
|
||||
.IsFixedLength();
|
||||
|
||||
b.Property<string>("FileShareOptions")
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("options");
|
||||
|
||||
b.Property<Guid>("Owner")
|
||||
.HasMaxLength(38)
|
||||
.HasColumnType("uuid")
|
||||
@ -2271,6 +2275,10 @@ namespace ASC.Migrations.PostgreSql.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("security");
|
||||
|
||||
b.Property<int>("SubjectType")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("subject_type");
|
||||
|
||||
b.Property<DateTime>("TimeStamp")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
|
@ -33,10 +33,12 @@ public class DbFilesSecurity : BaseEntity, IDbFile, IMapFrom<FileShareRecord>
|
||||
public int TenantId { get; set; }
|
||||
public string EntryId { get; set; }
|
||||
public FileEntryType EntryType { get; set; }
|
||||
public SubjectType SubjectType { get; set; }
|
||||
public Guid Subject { get; set; }
|
||||
public Guid Owner { get; set; }
|
||||
public FileShare Share { get; set; }
|
||||
public DateTime TimeStamp { get; set; }
|
||||
public string FileShareOptions { get; set; }
|
||||
|
||||
public override object[] GetKeys()
|
||||
{
|
||||
@ -46,7 +48,8 @@ public class DbFilesSecurity : BaseEntity, IDbFile, IMapFrom<FileShareRecord>
|
||||
public void Mapping(Profile profile)
|
||||
{
|
||||
profile.CreateMap<FileShareRecord, DbFilesSecurity>()
|
||||
.ForMember(dest => dest.TimeStamp, opt => opt.MapFrom(src => DateTime.UtcNow));
|
||||
.ForMember(dest => dest.TimeStamp, opt => opt.MapFrom(src => DateTime.UtcNow))
|
||||
.ForMember(dest => dest.FileShareOptions, opt => opt.MapFrom(src => JsonSerializer.Serialize(src.FileShareOptions, new JsonSerializerOptions())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +108,14 @@ public static class DbFilesSecurityExtension
|
||||
entity.Property(e => e.TimeStamp)
|
||||
.HasColumnName("timestamp")
|
||||
.HasColumnType("timestamp");
|
||||
|
||||
entity.Property(e => e.SubjectType).HasColumnName("subject_type");
|
||||
|
||||
entity.Property(e => e.FileShareOptions)
|
||||
.HasColumnName("options")
|
||||
.HasColumnType("text")
|
||||
.HasCharSet("utf8")
|
||||
.UseCollation("utf8_general_ci");
|
||||
});
|
||||
}
|
||||
public static void PgSqlAddDbFilesSecurity(this ModelBuilder modelBuilder)
|
||||
@ -146,6 +157,10 @@ public static class DbFilesSecurityExtension
|
||||
entity.Property(e => e.TimeStamp)
|
||||
.HasColumnName("timestamp")
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
|
||||
entity.Property(e => e.SubjectType).HasColumnName("subject_type");
|
||||
|
||||
entity.Property(e => e.FileShareOptions).HasColumnName("options");
|
||||
});
|
||||
}
|
||||
|
||||
|
34
products/ASC.Files/Core/Core/Security/FileShareOptions.cs
Normal file
34
products/ASC.Files/Core/Core/Security/FileShareOptions.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
||||
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
||||
// any third-party rights.
|
||||
//
|
||||
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Files.Core.Security;
|
||||
|
||||
[Serializable]
|
||||
public class FileShareOptions
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public DateTime ExpirationDate { get; set; }
|
||||
}
|
@ -31,11 +31,19 @@ public class FileShareRecord : IMapFrom<DbFilesSecurity>
|
||||
public int TenantId { get; set; }
|
||||
public object EntryId { get; set; }
|
||||
public FileEntryType EntryType { get; set; }
|
||||
public SubjectType SubjectType { get; set; }
|
||||
public Guid Subject { get; set; }
|
||||
public Guid Owner { get; set; }
|
||||
public FileShare Share { get; set; }
|
||||
public FileShareOptions FileShareOptions { get; set; }
|
||||
public int Level { get; set; }
|
||||
|
||||
public void Mapping(AutoMapper.Profile profile)
|
||||
{
|
||||
profile.CreateMap<DbFilesSecurity, FileShareRecord>()
|
||||
.ForMember(dest => dest.FileShareOptions, opt => opt.MapFrom(src => JsonSerializer.Deserialize<FileShareOptions>(src.FileShareOptions, new JsonSerializerOptions())));
|
||||
}
|
||||
|
||||
public class ShareComparer : IComparer<FileShare>
|
||||
{
|
||||
private static readonly int[] _shareOrder = new[]
|
||||
|
35
products/ASC.Files/Core/Core/Security/SubjectType.cs
Normal file
35
products/ASC.Files/Core/Core/Security/SubjectType.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
||||
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
||||
// any third-party rights.
|
||||
//
|
||||
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.Files.Core.Security;
|
||||
|
||||
public enum SubjectType
|
||||
{
|
||||
UserOrGroup = 0,
|
||||
ExternalLink = 1,
|
||||
Restriction = 2,
|
||||
InvintationLink = 3,
|
||||
}
|
Loading…
Reference in New Issue
Block a user