2020-11-02 21:58:18 +01:00
|
|
|
import { SendType } from "../../enums/sendType";
|
|
|
|
import { Utils } from "../../misc/utils";
|
|
|
|
|
|
|
|
import { Send } from "../domain/send";
|
|
|
|
import { SymmetricCryptoKey } from "../domain/symmetricCryptoKey";
|
|
|
|
|
|
|
|
import { SendFileView } from "./sendFileView";
|
|
|
|
import { SendTextView } from "./sendTextView";
|
|
|
|
import { View } from "./view";
|
|
|
|
|
|
|
|
export class SendView implements View {
|
|
|
|
id: string = null;
|
|
|
|
accessId: string = null;
|
|
|
|
name: string = null;
|
|
|
|
notes: string = null;
|
|
|
|
key: ArrayBuffer;
|
|
|
|
cryptoKey: SymmetricCryptoKey;
|
|
|
|
type: SendType = null;
|
|
|
|
text = new SendTextView();
|
|
|
|
file = new SendFileView();
|
|
|
|
maxAccessCount?: number = null;
|
|
|
|
accessCount: number = 0;
|
|
|
|
revisionDate: Date = null;
|
|
|
|
deletionDate: Date = null;
|
|
|
|
expirationDate: Date = null;
|
|
|
|
password: string = null;
|
|
|
|
disabled: boolean = false;
|
2021-03-25 23:27:43 +01:00
|
|
|
hideEmail: boolean = false;
|
2020-11-02 21:58:18 +01:00
|
|
|
|
|
|
|
constructor(s?: Send) {
|
|
|
|
if (!s) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.id = s.id;
|
|
|
|
this.accessId = s.accessId;
|
|
|
|
this.type = s.type;
|
|
|
|
this.maxAccessCount = s.maxAccessCount;
|
|
|
|
this.accessCount = s.accessCount;
|
|
|
|
this.revisionDate = s.revisionDate;
|
|
|
|
this.deletionDate = s.deletionDate;
|
|
|
|
this.expirationDate = s.expirationDate;
|
|
|
|
this.disabled = s.disabled;
|
|
|
|
this.password = s.password;
|
|
|
|
this.hideEmail = s.hideEmail;
|
|
|
|
}
|
2020-12-30 22:23:52 +01:00
|
|
|
|
|
|
|
get urlB64Key(): string {
|
|
|
|
return Utils.fromBufferToUrlB64(this.key);
|
|
|
|
}
|
|
|
|
|
|
|
|
get maxAccessCountReached(): boolean {
|
|
|
|
if (this.maxAccessCount == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return this.accessCount >= this.maxAccessCount;
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-12-30 22:23:52 +01:00
|
|
|
|
|
|
|
get expired(): boolean {
|
|
|
|
if (this.expirationDate == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return this.expirationDate <= new Date();
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
|
|
|
|
2020-12-30 22:23:52 +01:00
|
|
|
get pendingDelete(): boolean {
|
|
|
|
return this.deletionDate <= new Date();
|
2021-12-16 13:36:21 +01:00
|
|
|
}
|
2020-11-02 21:58:18 +01:00
|
|
|
}
|