1
0
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:
Nick Krantz
2025-09-30 15:58:46 -05:00
parent 721fda0aaa
commit 52294864aa
2 changed files with 9 additions and 2 deletions

View File

@@ -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);

View File

@@ -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;