chore: add new logic for the quota

This commit is contained in:
mahyargdz
2025-07-12 09:45:07 +03:30
parent a350f8af5a
commit 344bf1de0a
12 changed files with 169 additions and 39 deletions
+13 -13
View File
@@ -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;
}