1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

send removePasswordWithServer and model updates (#242)

This commit is contained in:
Kyle Spearrin 2020-12-30 16:23:52 -05:00 committed by GitHub
parent 1420082348
commit afa01f67f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -19,4 +19,5 @@ export abstract class SendService {
clear: (userId: string) => Promise<any>; clear: (userId: string) => Promise<any>;
delete: (id: string | string[]) => Promise<any>; delete: (id: string | string[]) => Promise<any>;
deleteWithServer: (id: string) => Promise<any>; deleteWithServer: (id: string) => Promise<any>;
removePasswordWithServer: (id: string) => Promise<any>;
} }

View File

@ -46,4 +46,22 @@ export class SendView implements View {
get urlB64Key(): string { get urlB64Key(): string {
return Utils.fromBufferToUrlB64(this.key); return Utils.fromBufferToUrlB64(this.key);
} }
get maxAccessCountReached(): boolean {
if (this.maxAccessCount == null) {
return false;
}
return this.accessCount >= this.maxAccessCount;
}
get expired(): boolean {
if (this.expirationDate == null) {
return false;
}
return this.expirationDate <= new Date();
}
get pendingDelete(): boolean {
return this.deletionDate <= new Date();
}
} }

View File

@ -152,7 +152,6 @@ export class SendService implements SendServiceAbstraction {
const userId = await this.userService.getUserId(); const userId = await this.userService.getUserId();
const data = new SendData(response, userId); const data = new SendData(response, userId);
await this.upsert(data); await this.upsert(data);
} }
async upsert(send: SendData | SendData[]): Promise<any> { async upsert(send: SendData | SendData[]): Promise<any> {
@ -215,6 +214,13 @@ export class SendService implements SendServiceAbstraction {
await this.delete(id); await this.delete(id);
} }
async removePasswordWithServer(id: string): Promise<any> {
const response = await this.apiService.putSendRemovePassword(id);
const userId = await this.userService.getUserId();
const data = new SendData(response, userId);
await this.upsert(data);
}
private parseFile(send: Send, file: File, key: SymmetricCryptoKey): Promise<ArrayBuffer> { private parseFile(send: Send, file: File, key: SymmetricCryptoKey): Promise<ArrayBuffer> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader();