chore: add new logic for the quota
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Collection, Entity, EntityRepositoryType, ManyToOne, OneToMany, OneToOne, Property } from "@mikro-orm/core";
|
||||
import { Collection, Entity, EntityRepositoryType, ManyToOne, OneToMany, OneToOne, Opt, Property } from "@mikro-orm/core";
|
||||
|
||||
import { RefreshToken } from "./refresh-token.entity";
|
||||
import { Role } from "./role.entity";
|
||||
@@ -19,30 +19,30 @@ export class User extends BaseEntity {
|
||||
@Property({ type: "varchar", length: 150, nullable: false })
|
||||
password!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 255, nullable: true })
|
||||
emailAddress?: string; // Full email address
|
||||
@Property({ type: "varchar", length: 255, nullable: false })
|
||||
emailAddress!: string;
|
||||
|
||||
@Property({ type: "boolean", default: false })
|
||||
emailEnabled: boolean = false; // Whether email is enabled for this user
|
||||
emailEnabled: boolean & Opt;
|
||||
|
||||
@Property({ type: "bigint", nullable: true, default: 1073741824 }) // 1GB default
|
||||
emailQuota?: number; // Email quota in bytes
|
||||
@Property({ type: "bigint", nullable: false, default: 134_217_728 }) // 128MB default
|
||||
emailQuota!: number;
|
||||
|
||||
@Property({ type: "bigint", nullable: true, default: 0 })
|
||||
emailQuotaUsed?: number; // Email quota used in bytes
|
||||
@Property({ type: "bigint", nullable: false, default: 0 })
|
||||
emailQuotaUsed!: number & Opt;
|
||||
|
||||
// Email account integration fields
|
||||
@Property({ type: "varchar", length: 255, nullable: false })
|
||||
wildduckUserId: string; // WildDuck user ID
|
||||
wildduckUserId!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 255, nullable: true })
|
||||
displayName?: string; // Display name for email
|
||||
displayName?: string;
|
||||
|
||||
@Property({ type: "timestamptz", nullable: true })
|
||||
lastQuotaSync?: Date; // Last time quota was synced with WildDuck
|
||||
lastQuotaSync?: Date;
|
||||
|
||||
@Property({ default: true, nullable: false })
|
||||
isActive: boolean = true;
|
||||
isActive: boolean & Opt;
|
||||
|
||||
//=========================
|
||||
|
||||
@@ -61,7 +61,7 @@ export class User extends BaseEntity {
|
||||
business!: Business;
|
||||
|
||||
@ManyToOne(() => Domain, { deleteRule: "restrict" })
|
||||
domain!: Domain; // The domain this email user belongs to
|
||||
domain!: Domain;
|
||||
|
||||
[EntityRepositoryType]?: UserRepository;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user