mirror of
https://github.com/bitwarden/server
synced 2025-12-26 13:13:24 +00:00
add folders and favorites when sharing a cipher
This commit is contained in:
@@ -757,7 +757,7 @@ public class CiphersController : Controller
|
||||
ValidateClientVersionForFido2CredentialSupport(cipher);
|
||||
|
||||
var original = cipher.Clone();
|
||||
await _cipherService.ShareAsync(original, model.Cipher.ToCipher(cipher), new Guid(model.Cipher.OrganizationId),
|
||||
await _cipherService.ShareAsync(original, model.Cipher.ToCipher(cipher, user.Id), new Guid(model.Cipher.OrganizationId),
|
||||
model.CollectionIds.Select(c => new Guid(c)), user.Id, model.Cipher.LastKnownRevisionDate);
|
||||
|
||||
var sharedCipher = await GetByIdAsync(id, user.Id);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CipherRequestModel
|
||||
return existingCipher;
|
||||
}
|
||||
|
||||
public Cipher ToCipher(Cipher existingCipher)
|
||||
public Cipher ToCipher(Cipher existingCipher, Guid? userId = null)
|
||||
{
|
||||
// If Data field is provided, use it directly
|
||||
if (!string.IsNullOrWhiteSpace(Data))
|
||||
@@ -124,9 +124,16 @@ public class CipherRequestModel
|
||||
}
|
||||
}
|
||||
|
||||
var userIdKey = userId.HasValue ? $"\"{userId.ToString().ToUpperInvariant()}\"" : null;
|
||||
existingCipher.Reprompt = Reprompt;
|
||||
existingCipher.Key = Key;
|
||||
existingCipher.ArchivedDate = ArchivedDate;
|
||||
existingCipher.Folders = userIdKey != null && FolderId != null ?
|
||||
$"{{{userIdKey}:\"{FolderId.ToUpperInvariant()}\"}}" :
|
||||
null;
|
||||
existingCipher.Favorites = userIdKey != null && Favorite ?
|
||||
$"{{{userIdKey}:true}}" :
|
||||
null;
|
||||
|
||||
var hasAttachments2 = (Attachments2?.Count ?? 0) > 0;
|
||||
var hasAttachments = (Attachments?.Count ?? 0) > 0;
|
||||
|
||||
Reference in New Issue
Block a user