chore: bunch of improvements
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
+14
-35
@@ -2,18 +2,19 @@
|
||||
* Class model for Message/Entity Interface
|
||||
*/
|
||||
|
||||
import type { EntityInterface } from "@/types/entity";
|
||||
import type { MessageInterface, MessagePartInterface } from "@/types/message";
|
||||
import type { EntityInterface, EntityModelInterface } from "@/types/entity";
|
||||
import type { MessageInterface } from "@/types/message";
|
||||
import { MessageObject } from "./message";
|
||||
|
||||
export class EntityObject {
|
||||
export class EntityObject implements EntityModelInterface {
|
||||
|
||||
_data!: EntityInterface<MessageInterface>;
|
||||
_message!: MessageObject;
|
||||
private _data!: EntityInterface<MessageInterface>;
|
||||
private _properties!: MessageObject;
|
||||
|
||||
constructor() {
|
||||
this._data = {
|
||||
'@type': 'mail.entity',
|
||||
'@type': 'mail:entity',
|
||||
version: 1,
|
||||
provider: '',
|
||||
service: '',
|
||||
collection: '',
|
||||
@@ -21,24 +22,7 @@ export class EntityObject {
|
||||
signature: null,
|
||||
created: null,
|
||||
modified: null,
|
||||
properties: {
|
||||
'@type': 'mail.message',
|
||||
version: 1,
|
||||
urid: '',
|
||||
size: 0,
|
||||
receivedDate: undefined,
|
||||
date: undefined,
|
||||
subject: '',
|
||||
snippet: '',
|
||||
from: undefined,
|
||||
to: [],
|
||||
cc: [],
|
||||
bcc: [],
|
||||
replyTo: [],
|
||||
flags: {},
|
||||
body: undefined,
|
||||
attachments: [],
|
||||
}
|
||||
properties: {'@type': 'mail:message'},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,10 +37,10 @@ export class EntityObject {
|
||||
|
||||
clone(): EntityObject {
|
||||
const cloned = new EntityObject();
|
||||
cloned._data = {
|
||||
...this._data,
|
||||
properties: { ...this._data.properties }
|
||||
cloned._data = {
|
||||
...this._data
|
||||
};
|
||||
cloned._properties = this.properties.clone();
|
||||
return cloned;
|
||||
}
|
||||
|
||||
@@ -93,15 +77,10 @@ export class EntityObject {
|
||||
/** Message Object Properties */
|
||||
|
||||
get properties(): MessageObject {
|
||||
if (!this._message) {
|
||||
this._message = new MessageObject(this._data.properties);
|
||||
if (!this._properties) {
|
||||
this._properties = new MessageObject().fromJson(this._data.properties as MessageInterface);
|
||||
}
|
||||
return this._message;
|
||||
}
|
||||
|
||||
// Alias for backward compatibility
|
||||
get object(): MessageObject {
|
||||
return this.properties;
|
||||
return this._properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user