1
0
mirror of https://github.com/bitwarden/server synced 2026-01-03 17:14:00 +00:00

update cipher archive/unarchive and cipher deatils query

This commit is contained in:
jaasen-livefront
2025-12-02 16:17:04 -08:00
parent c5fbef4a92
commit 2671c23268
5 changed files with 118 additions and 3 deletions

View File

@@ -25,7 +25,10 @@ public class Cipher : ITableObject<Guid>, ICloneable
public DateTime? DeletedDate { get; set; }
public Enums.CipherRepromptType? Reprompt { get; set; }
public string Key { get; set; }
// Deprecated. Left for backwards compatibility with old archive handling.
// Remove after all clients migrate to the Archives JSON column.
public DateTime? ArchivedDate { get; set; }
public string Archives { get; set; }
public void SetNewId()
{

View File

@@ -34,7 +34,9 @@ public class CipherDetailsQuery : IQuery<CipherDetails>
FolderId = (_ignoreFolders || !_userId.HasValue || c.Folders == null || !c.Folders.ToLowerInvariant().Contains(_userId.Value.ToString())) ?
null :
CoreHelpers.LoadClassFromJsonData<Dictionary<Guid, Guid>>(c.Folders)[_userId.Value],
ArchivedDate = c.ArchivedDate,
ArchivedDate = !_userId.HasValue || c.Archives == null || !c.Archives.ToLowerInvariant().Contains(_userId.Value.ToString()) ?
null :
CoreHelpers.LoadClassFromJsonData<Dictionary<Guid, DateTime>>(c.Archives)[_userId.Value],
};
return query;
}

View File

@@ -26,7 +26,11 @@ BEGIN
UPDATE
[dbo].[Cipher]
SET
[ArchivedDate] = @UtcNow,
[ArchivedDate] = JSON_MODIFY(
COALESCE([Archives], N'{}'),
'$."' + CONVERT(NVARCHAR(36), @UserId) + '"',
@UtcNow
),
[RevisionDate] = @UtcNow
WHERE
[Id] IN (SELECT [Id] FROM #Temp)

View File

@@ -26,7 +26,11 @@ BEGIN
UPDATE
[dbo].[Cipher]
SET
[ArchivedDate] = NULL,
[Archives] = JSON_MODIFY(
COALESCE([Archives], N'{}'),
'$."' + CONVERT(NVARCHAR(36), @UserId) + '"',
NULL
),
[RevisionDate] = @UtcNow
WHERE
[Id] IN (SELECT [Id] FROM #Temp)