mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
move domain models to ts
This commit is contained in:
43
src/models/domain/attachment.ts
Normal file
43
src/models/domain/attachment.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { AttachmentData } from '../data/attachmentData';
|
||||
|
||||
import { CipherString } from './cipherString';
|
||||
import Domain from './domain';
|
||||
|
||||
class Attachment extends Domain {
|
||||
id: string;
|
||||
url: string;
|
||||
size: number;
|
||||
sizeName: string;
|
||||
fileName: CipherString;
|
||||
|
||||
constructor(obj?: AttachmentData, alreadyEncrypted: boolean = false) {
|
||||
super();
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.size = obj.size;
|
||||
this.buildDomainModel(this, obj, {
|
||||
id: null,
|
||||
url: null,
|
||||
sizeName: null,
|
||||
fileName: null,
|
||||
}, alreadyEncrypted, ['id', 'url', 'sizeName']);
|
||||
}
|
||||
|
||||
decrypt(orgId: string): Promise<any> {
|
||||
const model = {
|
||||
id: this.id,
|
||||
size: this.size,
|
||||
sizeName: this.sizeName,
|
||||
url: this.url,
|
||||
};
|
||||
|
||||
return this.decryptObj(model, this, {
|
||||
fileName: null,
|
||||
}, orgId);
|
||||
}
|
||||
}
|
||||
|
||||
export { Attachment };
|
||||
(window as any).Attachment = Attachment;
|
||||
Reference in New Issue
Block a user