mirror of
https://github.com/bitwarden/server
synced 2025-12-19 09:43:25 +00:00
fix test
This commit is contained in:
@@ -809,29 +809,29 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
|
|||||||
{
|
{
|
||||||
dbContext.Attach(cipher);
|
dbContext.Attach(cipher);
|
||||||
|
|
||||||
Dictionary<Guid, DateTime> archives;
|
// Build or load the per-user archives map
|
||||||
if (string.IsNullOrWhiteSpace(cipher.Archives))
|
var archives = string.IsNullOrWhiteSpace(cipher.Archives)
|
||||||
{
|
? new Dictionary<Guid, DateTime>()
|
||||||
archives = new Dictionary<Guid, DateTime>();
|
: CoreHelpers.LoadClassFromJsonData<Dictionary<Guid, DateTime>>(cipher.Archives)
|
||||||
}
|
?? new Dictionary<Guid, DateTime>();
|
||||||
else
|
|
||||||
{
|
|
||||||
archives = JsonSerializer.Deserialize<Dictionary<Guid, DateTime>>(cipher.Archives)
|
|
||||||
?? new Dictionary<Guid, DateTime>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action == CipherStateAction.Unarchive)
|
if (action == CipherStateAction.Unarchive)
|
||||||
{
|
{
|
||||||
|
// Remove this user's archive record
|
||||||
archives.Remove(userId);
|
archives.Remove(userId);
|
||||||
|
cipher.ArchivedDate = null;
|
||||||
}
|
}
|
||||||
else if (action == CipherStateAction.Archive)
|
else if (action == CipherStateAction.Archive)
|
||||||
{
|
{
|
||||||
|
// Set this user's archive date
|
||||||
archives[userId] = utcNow;
|
archives[userId] = utcNow;
|
||||||
|
cipher.ArchivedDate = utcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Persist the updated JSON or clear it if empty
|
||||||
cipher.Archives = archives.Count == 0
|
cipher.Archives = archives.Count == 0
|
||||||
? null
|
? null
|
||||||
: JsonSerializer.Serialize(archives);
|
: CoreHelpers.ClassToJsonData(archives);
|
||||||
|
|
||||||
cipher.RevisionDate = utcNow;
|
cipher.RevisionDate = utcNow;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user