Skip to content

Commit

Permalink
ASC.Files: FileMoveCopyOperation: reset lifetime settings when archiv…
Browse files Browse the repository at this point in the history
…ing a room
  • Loading branch information
andreysavihin committed Nov 12, 2024
1 parent 705d19f commit 125968b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ Task<int> GetFoldersCountAsync(T parentId, FilterType filterType, bool subjectGr
Task<T> SetWatermarkSettings(WatermarkSettings waterMarks, Folder<T> folder);
Task<WatermarkSettings> GetWatermarkSettings(Folder<T> room);
Task<Folder<T>> DeleteWatermarkSettings(Folder<T> room);
Task<Folder<T>> DeleteLifetimeSettings(Folder<T> room);
#endregion
}

Expand Down
12 changes: 12 additions & 0 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,18 @@ public async Task<Folder<int>> DeleteWatermarkSettings(Folder<int> room)
return room;
}

public async Task<Folder<int>> DeleteLifetimeSettings(Folder<int> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,12 @@ public Task<Folder<string>> DeleteWatermarkSettings(Folder<string> room)

return folderDao.DeleteWatermarkSettings(room);
}
public Task<Folder<string>> DeleteLifetimeSettings(Folder<string> room)
{
ArgumentNullException.ThrowIfNull(room);
var selector = _selectorFactory.GetSelector(room.Id);
var folderDao = selector.GetFolderDao(room.Id);

return folderDao.DeleteLifetimeSettings(room);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@ public Task<Folder<string>> DeleteWatermarkSettings(Folder<string> room)
{
throw new NotImplementedException();
}

public Task<Folder<string>> DeleteLifetimeSettings(Folder<string> room)
{
throw new NotImplementedException();
}
}

static file class Queries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ public Task<Folder<string>> DeleteWatermarkSettings(Folder<string> room)
{
throw new NotImplementedException();
}

public Task<Folder<string>> DeleteLifetimeSettings(Folder<string> room)
{
throw new NotImplementedException();
}
}

internal abstract class BaseFolderDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 125968b

Please sign in to comment.