From 2cac99d6ef79df43e7e7a8466db91e8c859fdd60 Mon Sep 17 00:00:00 2001 From: John Harrington <84741727+harr1424@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:36:16 -0700 Subject: [PATCH] revert org import logic to preserve archive status for importing org user --- src/Core/Tools/ImportFeatures/ImportCiphersCommand.cs | 9 +++++---- .../ImportFeatures/ImportCiphersAsyncCommandTests.cs | 11 +++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Core/Tools/ImportFeatures/ImportCiphersCommand.cs b/src/Core/Tools/ImportFeatures/ImportCiphersCommand.cs index 8cf8989c3d..3f856e96fc 100644 --- a/src/Core/Tools/ImportFeatures/ImportCiphersCommand.cs +++ b/src/Core/Tools/ImportFeatures/ImportCiphersCommand.cs @@ -146,10 +146,11 @@ public class ImportCiphersCommand : IImportCiphersCommand // Init. ids for ciphers cipher.SetNewId(); - /* - * Archive functionality is a per-user function and should only ever be presented to the user who set the archive - * bit to ON for the item. No admin, other user or task should mark items as archived for other users. - */ + if (cipher.ArchivedDate.HasValue) + { + cipher.Archives = $"{{\"{importingUserId.ToString().ToUpperInvariant()}\":\"" + + $"{cipher.ArchivedDate.Value:yyyy-MM-ddTHH:mm:ss.fffffffZ}\"}}"; + } } var organizationCollectionsIds = (await _collectionRepository.GetManyByOrganizationIdAsync(org.Id)).Select(c => c.Id).ToList(); diff --git a/test/Core.Test/Tools/ImportFeatures/ImportCiphersAsyncCommandTests.cs b/test/Core.Test/Tools/ImportFeatures/ImportCiphersAsyncCommandTests.cs index 1b6e49f130..f6b1bd200a 100644 --- a/test/Core.Test/Tools/ImportFeatures/ImportCiphersAsyncCommandTests.cs +++ b/test/Core.Test/Tools/ImportFeatures/ImportCiphersAsyncCommandTests.cs @@ -361,11 +361,12 @@ public class ImportCiphersAsyncCommandTests } /* - * Archive functionality is a per-user function and should only ever be presented to the user who set the archive - * bit to ON for the item. No admin, other user or task should mark items as archived for other users + * Archive functionality is a per-user function. When importing archived ciphers into an organization vault, + * the Archives field should be set for the importing user only. This allows the importing user to see + * items as archived, while other organization members will not see them as archived. */ [Theory, BitAutoData] - public async Task ImportIntoOrganizationalVaultAsync_WithArchivedCiphers_DoesNotSetArchives( + public async Task ImportIntoOrganizationalVaultAsync_WithArchivedCiphers_SetsArchivesForImportingUserOnly( Organization organization, Guid importingUserId, OrganizationUser importingOrganizationUser, @@ -415,7 +416,9 @@ public class ImportCiphersAsyncCommandTests .CreateAsync( Arg.Is>(c => c[0].ArchivedDate == archivedDate && - c[0].Archives == null), + c[0].Archives != null && + c[0].Archives.Contains(importingUserId.ToString().ToUpperInvariant()) && + c[0].Archives.Contains(archivedDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"))), Arg.Any>(), Arg.Any>(), Arg.Any>());