mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
[PM-22992] Send lastKnownRevisionDate with Attachment API calls (#16862)
* Add lastKnownRevisionDate to Attachment methods. * Address issues raised by Claude PR * Fix string errors * Show error to user in event of attachment upload failure * Improve error handling for missing cipher * Add unit tests for attachment lastKnownRevisionDate * Remove generic title from toast errors * Move lastKnwonRevisionDate to function input
This commit is contained in:
@@ -937,7 +937,12 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
cipher.attachments.forEach((attachment) => {
|
||||
if (attachment.key == null) {
|
||||
attachmentPromises.push(
|
||||
this.shareAttachmentWithServer(attachment, cipher.id, organizationId),
|
||||
this.shareAttachmentWithServer(
|
||||
attachment,
|
||||
cipher.id,
|
||||
organizationId,
|
||||
cipher.revisionDate,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1722,7 +1727,10 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
attachmentView: AttachmentView,
|
||||
cipherId: string,
|
||||
organizationId: string,
|
||||
lastKnownRevisionDate: Date,
|
||||
): Promise<any> {
|
||||
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
||||
|
||||
const attachmentResponse = await this.apiService.nativeFetch(
|
||||
new Request(attachmentView.url, { cache: "no-store" }),
|
||||
);
|
||||
@@ -1731,7 +1739,6 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
|
||||
const encBuf = await EncArrayBuffer.fromResponse(attachmentResponse);
|
||||
const activeUserId = await firstValueFrom(this.accountService.activeAccount$);
|
||||
const userKey = await this.keyService.getUserKey(activeUserId.id);
|
||||
const decBuf = await this.encryptService.decryptFileData(encBuf, userKey);
|
||||
|
||||
@@ -1752,9 +1759,11 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
const blob = new Blob([encData.buffer], { type: "application/octet-stream" });
|
||||
fd.append("key", dataEncKey[1].encryptedString);
|
||||
fd.append("data", blob, encFileName.encryptedString);
|
||||
fd.append("lastKnownRevisionDate", lastKnownRevisionDate.toISOString());
|
||||
} catch (e) {
|
||||
if (Utils.isNode && !Utils.isBrowser) {
|
||||
fd.append("key", dataEncKey[1].encryptedString);
|
||||
fd.append("lastKnownRevisionDate", lastKnownRevisionDate.toISOString());
|
||||
fd.append(
|
||||
"data",
|
||||
Buffer.from(encData.buffer) as any,
|
||||
|
||||
Reference in New Issue
Block a user