From 125968ba7296d708a38276708d32f119b26027d0 Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Tue, 12 Nov 2024 18:34:03 +0300 Subject: [PATCH] ASC.Files: FileMoveCopyOperation: reset lifetime settings when archiving a room --- .../ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs | 1 + .../ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs | 12 ++++++++++++ .../Core/Thirdparty/ProviderDao/ProviderFolderDao.cs | 8 ++++++++ .../Thirdparty/SharePoint/SharePointFolderDao.cs | 5 +++++ .../Core/Core/Thirdparty/ThirdPartyFolderDao.cs | 5 +++++ .../FileOperations/FileMoveCopyOperation.cs | 2 ++ 6 files changed, 33 insertions(+) diff --git a/products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs b/products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs index c36e94b1be9..eb26fadd3cd 100644 --- a/products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs +++ b/products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs @@ -418,6 +418,7 @@ Task GetFoldersCountAsync(T parentId, FilterType filterType, bool subjectGr Task SetWatermarkSettings(WatermarkSettings waterMarks, Folder folder); Task GetWatermarkSettings(Folder room); Task> DeleteWatermarkSettings(Folder room); + Task> DeleteLifetimeSettings(Folder room); #endregion } diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs index a3830a76aea..c77bd48557f 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs @@ -594,6 +594,18 @@ public async Task> DeleteWatermarkSettings(Folder room) return room; } + public async Task> DeleteLifetimeSettings(Folder room) + { + var tenantId = await _tenantManager.GetCurrentTenantIdAsync(); + + await using var filesDbContext = await _dbContextFactory.CreateDbContextAsync(); + var roomSettings = await filesDbContext.RoomSettingsAsync(tenantId, room.Id); + roomSettings.Lifetime = null; + filesDbContext.Update(roomSettings); + await filesDbContext.SaveChangesAsync(); + return room; + } + public async Task DeleteFolderAsync(int folderId) { if (folderId == default) diff --git a/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFolderDao.cs b/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFolderDao.cs index 1a96a02d6ef..476b2505fb4 100644 --- a/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFolderDao.cs +++ b/products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderFolderDao.cs @@ -700,4 +700,12 @@ public Task> DeleteWatermarkSettings(Folder room) return folderDao.DeleteWatermarkSettings(room); } + public Task> DeleteLifetimeSettings(Folder room) + { + ArgumentNullException.ThrowIfNull(room); + var selector = _selectorFactory.GetSelector(room.Id); + var folderDao = selector.GetFolderDao(room.Id); + + return folderDao.DeleteLifetimeSettings(room); + } } \ No newline at end of file diff --git a/products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs b/products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs index b084f0711e7..92d8362c26f 100644 --- a/products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs +++ b/products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs @@ -477,6 +477,11 @@ public Task> DeleteWatermarkSettings(Folder room) { throw new NotImplementedException(); } + + public Task> DeleteLifetimeSettings(Folder room) + { + throw new NotImplementedException(); + } } static file class Queries diff --git a/products/ASC.Files/Core/Core/Thirdparty/ThirdPartyFolderDao.cs b/products/ASC.Files/Core/Core/Thirdparty/ThirdPartyFolderDao.cs index efd1ce52854..b3d246c230a 100644 --- a/products/ASC.Files/Core/Core/Thirdparty/ThirdPartyFolderDao.cs +++ b/products/ASC.Files/Core/Core/Thirdparty/ThirdPartyFolderDao.cs @@ -697,6 +697,11 @@ public Task> DeleteWatermarkSettings(Folder room) { throw new NotImplementedException(); } + + public Task> DeleteLifetimeSettings(Folder room) + { + throw new NotImplementedException(); + } } internal abstract class BaseFolderDao diff --git a/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs b/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs index 0ba54b50f3f..d50ae8b53af 100644 --- a/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs +++ b/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs @@ -770,6 +770,8 @@ await socketManager.DeleteFolder(folder, action: async () => await TagDao.RemoveTagsAsync(pins); } + await FolderDao.DeleteLifetimeSettings(folder); + await filesMessageService.SendAsync(MessageAction.RoomArchived, folder, _headers, folder.Title); } else