-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enable reporting users (#2577)
- Loading branch information
1 parent
23a7a5d
commit 9564be0
Showing
7 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
Column, | ||
Entity, | ||
Index, | ||
ManyToOne, | ||
PrimaryGeneratedColumn, | ||
} from 'typeorm'; | ||
import type { User } from './user'; | ||
import { ReportReason } from './common'; | ||
|
||
@Entity() | ||
export class UserReport { | ||
@PrimaryGeneratedColumn('uuid') | ||
id: string; | ||
|
||
@Column({ type: 'text' }) | ||
@Index('IDX_user_report_reported_user_id') | ||
reportedUserId: string; | ||
|
||
@Column({ type: 'text' }) | ||
userId: string; | ||
|
||
@Column({ default: () => 'now()' }) | ||
createdAt: Date; | ||
|
||
@Column({ length: 36, type: 'varchar' }) | ||
reason: ReportReason; | ||
|
||
@Column({ type: 'text', nullable: true }) | ||
note: string; | ||
|
||
@ManyToOne('User', { | ||
lazy: true, | ||
onDelete: 'CASCADE', | ||
}) | ||
user: Promise<User>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class UserReport1736363898760 implements MigrationInterface { | ||
name = 'UserReport1736363898760' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE IF NOT EXISTS "user_report" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "reportedUserId" text NOT NULL, "userId" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "reason" character varying(36) NOT NULL, "note" text, CONSTRAINT "PK_58c08f0e20fa66561b119421eb2" PRIMARY KEY ("id"))`); | ||
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_user_report_reported_user_id" ON "user_report" ("reportedUserId") `); | ||
await queryRunner.query(`ALTER TABLE "user_report" ADD CONSTRAINT "FK_cfc9cf9a552e98d6a634377496f" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "user_report" DROP CONSTRAINT "FK_cfc9cf9a552e98d6a634377496f"`); | ||
await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_user_report_reported_user_id"`); | ||
await queryRunner.query(`DROP TABLE IF EXISTS "user_report"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters