import Column from "@entity-access/entity-access/dist/decorators/Column.js"; import { RelateTo } from "@entity-access/entity-access/dist/decorators/Relate.js"; import Table from "@entity-access/entity-access/dist/decorators/Table.js"; import { Email } from "./Email.js"; import EmailAddress from "./EmailAddress.js"; /** * This class is a separate entity instead of using EmailRecipient, * the reason is, for simplicity and faster index. * * 1. As EmailRecipients will be serialized for every email through JSON * 2. Adding filter to remove participants will be extra pressure on database * 3. Thread Participant may only exist at top thread. * 4. Normal email communication will not involve thread participants. * 5. This can further include fields related to Projects and other * Task Management related data such as assignee etc. Which will make * EmailRecipient simpler. */ @Table("ThreadParticipants") export default class ThreadParticipant { @Column({ dataType: "BigInt", key: true}) @RelateTo(Email, { property: (x) => x.email, inverseProperty: (x) => x.threadParticipants }) emailID: number; @Column({ dataType: "BigInt", key: true }) @RelateTo(EmailAddress, { property: (x) => x.emailAddress, inverseProperty: (x) => x.threadParticipants }) emailAddressID: number; @Column({ dataType: "Boolean", default: () => false}) unsubscribed: boolean; email: Email; emailAddress: EmailAddress; }