-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
288 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class CreateNotificationTable1717147942177 | ||
implements MigrationInterface { | ||
name = 'CreateNotificationTable1717147942177'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."notification_type_enum" AS ENUM('post', 'comment', 'reaction')` | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "notification" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."notification_type_enum" NOT NULL, "resourceId" character varying NOT NULL, "message" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "leaveRequestId" uuid, CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY ("id"))` | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "notification" ADD CONSTRAINT "FK_d7dcd7fa90cc4542719b880bc7f" FOREIGN KEY ("leaveRequestId") REFERENCES "leave_request"("id") ON DELETE SET NULL ON UPDATE NO ACTION` | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "notification" DROP CONSTRAINT "FK_d7dcd7fa90cc4542719b880bc7f"` | ||
); | ||
await queryRunner.query(`DROP TABLE "notification"`); | ||
await queryRunner.query(`DROP TYPE "public"."notification_type_enum"`); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 @@ | ||
export interface IMattermostNotifier { | ||
createPost(channelId: string, message: string): Promise<object>; | ||
createComment( | ||
channelId: string, | ||
message: string, | ||
rootId: string | ||
): Promise<object>; | ||
createReaction(postId: string, emojiName: string): Promise<object>; | ||
} |
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,65 @@ | ||
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'; | ||
import { LeaveRequest } from '../HumanResource/Leave/LeaveRequest.entity'; | ||
|
||
export enum Type { | ||
POST = 'post', | ||
COMMENT = 'comment', | ||
REACTION = 'reaction' | ||
} | ||
|
||
@Entity() | ||
export class Notification { | ||
@PrimaryGeneratedColumn('uuid') | ||
private id: string; | ||
|
||
@Column('enum', { enum: Type, nullable: false }) | ||
private type: Type; | ||
|
||
@Column({ type: 'varchar', nullable: false }) | ||
private resourceId: string; | ||
|
||
@Column({ type: 'varchar', nullable: false }) | ||
private message: string; | ||
|
||
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) | ||
private createdAt: Date; | ||
|
||
@ManyToOne(type => LeaveRequest, { nullable: true, onDelete: 'SET NULL' }) | ||
private leaveRequest: LeaveRequest; | ||
|
||
constructor( | ||
type: Type, | ||
message: string, | ||
resourceId: string, | ||
leaveRequest: LeaveRequest | ||
) { | ||
this.type = type; | ||
this.message = message; | ||
this.resourceId = resourceId; | ||
this.leaveRequest = leaveRequest; | ||
} | ||
|
||
public getId(): string { | ||
return this.id; | ||
} | ||
|
||
public getType(): string { | ||
return this.type; | ||
} | ||
|
||
public getMessage(): string { | ||
return this.message; | ||
} | ||
|
||
public getResourceId(): string { | ||
return this.resourceId; | ||
} | ||
|
||
public getLeaveRequest(): LeaveRequest { | ||
return this.leaveRequest; | ||
} | ||
|
||
public getCreatedAt(): Date { | ||
return this.createdAt; | ||
} | ||
} |
Oops, something went wrong.