Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
send removePasswordWithServer and model updates (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Dec 30, 2020
1 parent 1420082 commit afa01f6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/abstractions/send.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export abstract class SendService {
clear: (userId: string) => Promise<any>;
delete: (id: string | string[]) => Promise<any>;
deleteWithServer: (id: string) => Promise<any>;
removePasswordWithServer: (id: string) => Promise<any>;
}
18 changes: 18 additions & 0 deletions src/models/view/sendView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ export class SendView implements View {
get urlB64Key(): string {
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();
}
}
8 changes: 7 additions & 1 deletion src/services/send.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export class SendService implements SendServiceAbstraction {
const userId = await this.userService.getUserId();
const data = new SendData(response, userId);
await this.upsert(data);

}

async upsert(send: SendData | SendData[]): Promise<any> {
Expand Down Expand Up @@ -215,6 +214,13 @@ export class SendService implements SendServiceAbstraction {
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> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
Expand Down

0 comments on commit afa01f6

Please sign in to comment.