mirror of
https://github.com/bitwarden/mobile
synced 2025-12-18 09:13:15 +00:00
Compare commits
9 Commits
v2024.7.0
...
vault/pm-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
485aca083b | ||
|
|
290266c262 | ||
|
|
c40eb9d3db | ||
|
|
df9fcd1aca | ||
|
|
890eff79a2 | ||
|
|
265c95b494 | ||
|
|
25e394eb5e | ||
|
|
354aec09d9 | ||
|
|
4332e7a498 |
@@ -571,29 +571,40 @@ namespace Bit.Core.Services
|
|||||||
await UpsertAsync(data);
|
await UpsertAsync(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds)
|
public async Task ShareWithServerAsync(CipherView cipherView, string organizationId, HashSet<string> collectionIds)
|
||||||
{
|
{
|
||||||
var attachmentTasks = new List<Task>();
|
var attachmentTasks = new List<Task>();
|
||||||
if (cipher.Attachments != null)
|
Cipher cipher = null;
|
||||||
|
//If the cipher doesn't have a key, we update it
|
||||||
|
if(cipherView.Key == null && await ShouldUseCipherKeyEncryptionAsync())
|
||||||
{
|
{
|
||||||
foreach (var attachment in cipher.Attachments)
|
await UpdateAndUpsertAsync(cipherView, cipher => _apiService.PutCipherAsync(cipherView.Id, new CipherRequest(cipher)));
|
||||||
|
cipher = await GetAsync(cipherView.Id);
|
||||||
|
cipherView = await cipher.DecryptAsync();
|
||||||
|
}
|
||||||
|
if (cipherView.Attachments != null)
|
||||||
|
{
|
||||||
|
foreach (var attachment in cipherView.Attachments)
|
||||||
{
|
{
|
||||||
if (attachment.Key == null)
|
if (attachment.Key == null)
|
||||||
{
|
{
|
||||||
attachmentTasks.Add(ShareAttachmentWithServerAsync(attachment, cipher.Id, organizationId));
|
attachmentTasks.Add(ShareAttachmentWithServerAsync(attachment, cipherView.Id, organizationId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await Task.WhenAll(attachmentTasks);
|
await Task.WhenAll(attachmentTasks);
|
||||||
cipher.OrganizationId = organizationId;
|
cipherView.OrganizationId = organizationId;
|
||||||
cipher.CollectionIds = collectionIds;
|
cipherView.CollectionIds = collectionIds;
|
||||||
var encCipher = await EncryptAsync(cipher);
|
await UpdateAndUpsertAsync(cipherView, cipher => _apiService.PutShareCipherAsync(cipherView.Id, new CipherShareRequest(cipher)), collectionIds);
|
||||||
var request = new CipherShareRequest(encCipher);
|
|
||||||
var response = await _apiService.PutShareCipherAsync(cipher.Id, request);
|
async Task UpdateAndUpsertAsync(CipherView cipherView, Func<Cipher,Task<CipherResponse>> callPutCipherApi, HashSet<string> collectionIds = null)
|
||||||
var userId = await _stateService.GetActiveUserIdAsync();
|
{
|
||||||
var data = new CipherData(response, userId, collectionIds);
|
var cipher = await EncryptAsync(cipherView);
|
||||||
|
var response = await callPutCipherApi(cipher);
|
||||||
|
var data = new CipherData(response, await _stateService.GetActiveUserIdAsync(), collectionIds);
|
||||||
await UpsertAsync(data);
|
await UpsertAsync(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data)
|
public async Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, CipherView cipherView, string filename, byte[] data)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user