summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/entities/InstanceBan.ts57
-rw-r--r--src/util/interfaces/Event.ts1
2 files changed, 58 insertions, 0 deletions
diff --git a/src/util/entities/InstanceBan.ts b/src/util/entities/InstanceBan.ts
new file mode 100644

index 00000000..8f8cd29d --- /dev/null +++ b/src/util/entities/InstanceBan.ts
@@ -0,0 +1,57 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, RelationId } from "typeorm"; +import { BaseClass } from "./BaseClass"; +import { Team } from "./Team"; +import { User } from "./User"; +import { Guild } from "./Guild"; + +@Entity({ + name: "instance_bans", +}) +export class InstanceBan extends BaseClass { + @Column({ type: "bigint" }) + @CreateDateColumn() + created_at: Date = new Date(); + + @Column() + reason: string; + + @Column({ nullable: true }) + user_id: string; + + @Column({ nullable: true }) + fingerprint: string; + + @Column({ nullable: true }) + ip_address: string; + + // chain of trust type tracking + + @Column() + is_from_other_instance_ban: boolean; + + @Column({ nullable: true }) + @RelationId((instance_ban: InstanceBan) => instance_ban.origin_instance_ban) + origin_instance_ban_id?: string; + + @JoinColumn({ name: "origin_instance_ban_id" }) + @OneToOne(() => InstanceBan, { nullable: true, onDelete: "SET NULL" }) + origin_instance_ban?: InstanceBan; +} diff --git a/src/util/interfaces/Event.ts b/src/util/interfaces/Event.ts
index 24157efd..d0a60493 100644 --- a/src/util/interfaces/Event.ts +++ b/src/util/interfaces/Event.ts
@@ -219,6 +219,7 @@ export interface GuildBanAddEvent extends Event { data: { guild_id: string; user: User; + delete_message_secs?: number }; }