mirror of
https://github.com/bitwarden/server
synced 2025-12-20 02:03:46 +00:00
implement claude suggestions
This commit is contained in:
@@ -220,6 +220,8 @@ public static class BulkResourceCreationService
|
||||
ciphersTable.Columns.Add(deletedDateColumn);
|
||||
var archivedDateColumn = new DataColumn(nameof(c.ArchivedDate), typeof(DateTime));
|
||||
ciphersTable.Columns.Add(archivedDateColumn);
|
||||
var archivesColumn = new DataColumn(nameof(c.Archives), typeof(string));
|
||||
ciphersTable.Columns.Add(archivesColumn);
|
||||
var repromptColumn = new DataColumn(nameof(c.Reprompt), typeof(short));
|
||||
ciphersTable.Columns.Add(repromptColumn);
|
||||
var keyColummn = new DataColumn(nameof(c.Key), typeof(string));
|
||||
@@ -250,6 +252,7 @@ public static class BulkResourceCreationService
|
||||
row[revisionDateColumn] = cipher.RevisionDate;
|
||||
row[deletedDateColumn] = cipher.DeletedDate.HasValue ? (object)cipher.DeletedDate : DBNull.Value;
|
||||
row[archivedDateColumn] = cipher.ArchivedDate.HasValue ? cipher.ArchivedDate : DBNull.Value;
|
||||
row[archivesColumn] = cipher.Archives;
|
||||
row[repromptColumn] = cipher.Reprompt.HasValue ? cipher.Reprompt.Value : DBNull.Value;
|
||||
row[keyColummn] = cipher.Key;
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ public class UserCipherDetailsQuery : IQuery<CipherDetails>
|
||||
OrganizationUseTotp = o.UseTotp,
|
||||
c.Reprompt,
|
||||
c.Key,
|
||||
c.ArchivedDate
|
||||
c.ArchivedDate,
|
||||
c.Archives
|
||||
};
|
||||
|
||||
var query2 = from c in dbContext.Ciphers
|
||||
@@ -96,7 +97,8 @@ public class UserCipherDetailsQuery : IQuery<CipherDetails>
|
||||
OrganizationUseTotp = false,
|
||||
c.Reprompt,
|
||||
c.Key,
|
||||
c.ArchivedDate
|
||||
c.ArchivedDate,
|
||||
c.Archives
|
||||
};
|
||||
|
||||
var union = query.Union(query2).Select(c => new CipherDetails
|
||||
@@ -118,7 +120,8 @@ public class UserCipherDetailsQuery : IQuery<CipherDetails>
|
||||
Manage = c.Manage,
|
||||
OrganizationUseTotp = c.OrganizationUseTotp,
|
||||
Key = c.Key,
|
||||
ArchivedDate = c.ArchivedDate
|
||||
ArchivedDate = c.ArchivedDate,
|
||||
Archives = c.Archives
|
||||
});
|
||||
return union;
|
||||
}
|
||||
|
||||
@@ -808,7 +808,31 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
|
||||
await cipherEntitiesToModify.ForEachAsync(cipher =>
|
||||
{
|
||||
dbContext.Attach(cipher);
|
||||
cipher.ArchivedDate = action == CipherStateAction.Unarchive ? null : utcNow;
|
||||
|
||||
Dictionary<Guid, DateTime> archives;
|
||||
if (string.IsNullOrWhiteSpace(cipher.Archives))
|
||||
{
|
||||
archives = new Dictionary<Guid, DateTime>();
|
||||
}
|
||||
else
|
||||
{
|
||||
archives = JsonSerializer.Deserialize<Dictionary<Guid, DateTime>>(cipher.Archives)
|
||||
?? new Dictionary<Guid, DateTime>();
|
||||
}
|
||||
|
||||
if (action == CipherStateAction.Unarchive)
|
||||
{
|
||||
archives.Remove(userId);
|
||||
}
|
||||
else if (action == CipherStateAction.Archive)
|
||||
{
|
||||
archives[userId] = utcNow;
|
||||
}
|
||||
|
||||
cipher.Archives = archives.Count == 0
|
||||
? null
|
||||
: JsonSerializer.Serialize(archives);
|
||||
|
||||
cipher.RevisionDate = utcNow;
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ BEGIN
|
||||
SET
|
||||
[Archives] = JSON_MODIFY(
|
||||
COALESCE([Archives], N'{}'),
|
||||
'$."' + CONVERT(NVARCHAR(36), @UserId) + '"',
|
||||
CONCAT('$."', CONVERT(NVARCHAR(36), @UserId), '"'),
|
||||
CONVERT(NVARCHAR(30), @UtcNow, 127)
|
||||
),
|
||||
[RevisionDate] = @UtcNow
|
||||
|
||||
@@ -28,7 +28,7 @@ BEGIN
|
||||
SET
|
||||
[Archives] = JSON_MODIFY(
|
||||
COALESCE([Archives], N'{}'),
|
||||
'$."' + CONVERT(NVARCHAR(36), @UserId) + '"',
|
||||
CONCAT('$."', CONVERT(NVARCHAR(36), @UserId), '"'),
|
||||
NULL
|
||||
),
|
||||
[RevisionDate] = @UtcNow
|
||||
|
||||
@@ -197,7 +197,7 @@ BEGIN
|
||||
SET
|
||||
[Archives] = JSON_MODIFY(
|
||||
COALESCE([Archives], N'{}'),
|
||||
'$."' + CONVERT(NVARCHAR(36), @UserId) + '"',
|
||||
CONCAT('$."', CONVERT(NVARCHAR(36), @UserId), '"'),
|
||||
CONVERT(NVARCHAR(30), @UtcNow, 127)
|
||||
),
|
||||
[RevisionDate] = @UtcNow
|
||||
@@ -248,7 +248,7 @@ BEGIN
|
||||
SET
|
||||
[Archives] = JSON_MODIFY(
|
||||
COALESCE([Archives], N'{}'),
|
||||
'$."' + CONVERT(NVARCHAR(36), @UserId) + '"',
|
||||
CONCAT('$."', CONVERT(NVARCHAR(36), @UserId), '"'),
|
||||
NULL
|
||||
),
|
||||
[RevisionDate] = @UtcNow
|
||||
|
||||
Reference in New Issue
Block a user