Merge branch 'develop' into feature/get-thumbnail-from-thirdparty

This commit is contained in:
pavelbannov 2022-06-24 16:24:26 +03:00
commit e8cf4e7906
5 changed files with 36 additions and 17 deletions

View File

@ -730,7 +730,7 @@ internal class TagDao<T> : AbstractDao, ITagDao<T>
.Where(r => r.mapping.TenantId == r.tagLink.Link.TenantId)
.Join(ctx.ThirdpartyAccount, r => r.mapping.TenantId, r => r.TenantId, (tagLinkMapping, account) => new { tagLinkMapping.tagLink, tagLinkMapping.mapping, account })
.Where(r => r.account.UserId != subject &&
r.account.RootFolderType == FolderType.USER &&
r.account.FolderType == FolderType.USER &&
(r.mapping.Id.StartsWith("sbox-" + r.account.Id) ||
r.mapping.Id.StartsWith("box-" + r.account.Id) ||
r.mapping.Id.StartsWith("dropbox-" + r.account.Id) ||
@ -801,7 +801,7 @@ internal class TagDao<T> : AbstractDao, ITagDao<T>
.Join(ctx.ThirdpartyIdMapping, r => r.Link.EntryId, r => r.HashId, (tagLink, mapping) => new { tagLink, mapping })
.Where(r => r.mapping.TenantId == tenantId && r.tagLink.Tag.Owner == subject && r.tagLink.Link.EntryType == FileEntryType.Folder)
.Join(ctx.ThirdpartyAccount, r => r.mapping.Id, r => r.FolderId, (tagLinkData, account) => new { tagLinkData, account })
.Where(r => r.tagLinkData.mapping.Id == r.account.FolderId && r.account.RootFolderType == FolderType.VirtualRooms)
.Where(r => r.tagLinkData.mapping.Id == r.account.FolderId && r.account.FolderType == FolderType.VirtualRooms)
.Select(r => r.tagLinkData.tagLink).Distinct()
);
@ -815,7 +815,7 @@ internal class TagDao<T> : AbstractDao, ITagDao<T>
static readonly Func<FilesDbContext, int, FolderType, Guid, IAsyncEnumerable<int>> _getThirdpartyAccountQuery = Microsoft.EntityFrameworkCore.EF.CompileAsyncQuery((FilesDbContext ctx, int tenantId, FolderType folderType, Guid subject) =>
ctx.ThirdpartyAccount
.Where(r => r.TenantId == tenantId)
.Where(r => r.RootFolderType == folderType)
.Where(r => r.FolderType == folderType)
.Where(r => folderType != FolderType.USER || r.UserId == subject)
.Select(r => r.Id));

View File

@ -35,8 +35,8 @@ public class DbFilesThirdpartyAccount : BaseEntity, IDbFile, IDbSearch
public string Password { get; set; }
public string Token { get; set; }
public Guid UserId { get; set; }
public FolderType RootFolderType { get; set; }
public FolderType FolderType { get; set; }
public FolderType RoomType { get; set; }
public DateTime CreateOn { get; set; }
public string Url { get; set; }
public int TenantId { get; set; }
@ -80,8 +80,8 @@ public static class DbFilesThirdpartyAccountExtension
.HasCharSet("utf8")
.UseCollation("utf8_general_ci");
entity.Property(e => e.RootFolderType).HasColumnName("root_folder_type");
entity.Property(e => e.FolderType).HasColumnName("folder_type");
entity.Property(e => e.RoomType).HasColumnName("room_type");
entity.Property(e => e.Password)
.IsRequired()
@ -150,8 +150,8 @@ public static class DbFilesThirdpartyAccountExtension
.HasColumnName("customer_title")
.HasMaxLength(400);
entity.Property(e => e.RootFolderType).HasColumnName("root_folder_type");
entity.Property(e => e.FolderType).HasColumnType("folder_type");
entity.Property(e => e.FolderType).HasColumnName("root_folder_type");
entity.Property(e => e.RoomType).HasColumnType("folder_type");
entity.Property(e => e.Password)
.IsRequired()

View File

@ -137,7 +137,7 @@ internal class ProviderAccountDao : IProviderDao
.Where(r => r.TenantId == tenantId)
.Where(r => !(folderType == FolderType.USER || folderType == FolderType.DEFAULT && linkId == -1) || r.UserId == userId)
.Where(r => linkId == -1 || r.Id == linkId)
.Where(r => folderType == FolderType.DEFAULT || r.RootFolderType == folderType)
.Where(r => folderType == FolderType.DEFAULT || r.FolderType == folderType)
.Where(r => searchText == "" || r.Title.ToLower().Contains(searchText)));
private IAsyncEnumerable<IProviderInfo> GetProvidersInfoInternalAsync(int linkId = -1, FolderType folderType = FolderType.DEFAULT, string searchText = null)
@ -186,7 +186,7 @@ internal class ProviderAccountDao : IProviderDao
Title = Global.ReplaceInvalidCharsAndTruncate(customerTitle),
UserName = authData.Login ?? "",
Password = EncryptPassword(authData.Password),
RootFolderType = folderType,
FolderType = folderType,
CreateOn = _tenantUtil.DateTimeToUtc(_tenantUtil.DateTimeNow()),
UserId = _securityContext.CurrentAccount.ID,
Token = EncryptPassword(authData.Token ?? ""),
@ -216,7 +216,7 @@ internal class ProviderAccountDao : IProviderDao
return false;
}
forUpdate.RootFolderType = rootFolderType;
forUpdate.FolderType = rootFolderType;
await FilesDbContext.SaveChangesAsync().ConfigureAwait(false);
@ -235,7 +235,7 @@ internal class ProviderAccountDao : IProviderDao
return false;
}
forUpdate.FolderType = folderType;
forUpdate.RoomType = folderType;
forUpdate.FolderId = folderId;
await FilesDbContext.SaveChangesAsync().ConfigureAwait(false);
@ -325,7 +325,7 @@ internal class ProviderAccountDao : IProviderDao
if (folderType != FolderType.DEFAULT)
{
t.RootFolderType = folderType;
t.FolderType = folderType;
}
if (userId.HasValue)
@ -409,7 +409,7 @@ internal class ProviderAccountDao : IProviderDao
UserName = authData.Login,
Password = EncryptPassword(authData.Password),
UserId = owner,
RootFolderType = type,
FolderType = type,
CreateOn = createOn,
Provider = providerKey.ToString()
};
@ -428,8 +428,8 @@ internal class ProviderAccountDao : IProviderDao
var providerTitle = input.Title ?? string.Empty;
var token = DecryptToken(input.Token, id);
var owner = input.UserId;
var rootFolderType = input.RootFolderType;
var folderType = input.FolderType;
var rootFolderType = input.FolderType;
var folderType = input.RoomType;
var folderId = input.FolderId;
var createOn = _tenantUtil.DateTimeFromUtc(input.CreateOn);
var authData = new AuthData(input.Url, input.UserName, DecryptPassword(input.Password, id), token);

View File

@ -1,2 +0,0 @@
ALTER TABLE files_thirdparty_account ADD folder_id TEXT NULL COLLATE UTF8_GENERAL_CI;
ALTER TABLE files_thirdparty_account ADD root_folder_type INT NOT NULL;

21
sql/docspace_upgrade1.sql Normal file
View File

@ -0,0 +1,21 @@
DELIMITER DLM00
CREATE PROCEDURE docspace_upgrade1()
BEGIN
IF EXISTS (SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'files_thirdparty_account' AND COLUMN_NAME = 'root_folder_type') THEN
ALTER TABLE files_thirdparty_account CHANGE root_folder_type room_type INT NOT NULL;
END IF;
IF NOT EXISTS (SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'files_thirdparty_account' AND COLUMN_NAME = 'room_type') THEN
ALTER TABLE files_thirdparty_account ADD room_type INT NOT NULL;
END IF;
IF NOT EXISTS (SELECT * FROM information_schema.`COLUMNS` WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'files_thirdparty_account' AND COLUMN_NAME = 'folder_Id') THEN
ALTER TABLE files_thirdparty_account ADD folder_id TEXT NULL COLLATE UTF8_GENERAL_CI;
END IF;
END DLM00
CALL docspace_upgrade1() DLM00
DELIMITER ;