add strike system (#18)
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m25s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m25s
This commit is contained in:
@@ -62,6 +62,9 @@ export class Report extends Model {
|
||||
@Column({ type: DataTypes.INTEGER })
|
||||
@ForeignKey(() => Admin)
|
||||
declare auditor_id: number;
|
||||
@Column({ type: DataTypes.INTEGER })
|
||||
@ForeignKey(() => StrikeReason)
|
||||
declare strike_reason_id: number | null;
|
||||
|
||||
@BelongsTo(() => User, 'reporter_id')
|
||||
declare reporter: User;
|
||||
@@ -69,6 +72,38 @@ export class Report extends Model {
|
||||
declare reported: User;
|
||||
@BelongsTo(() => Admin, 'auditor_id')
|
||||
declare auditor: Admin;
|
||||
@BelongsTo(() => StrikeReason, 'strike_reason_id')
|
||||
declare strike_reason: StrikeReason;
|
||||
}
|
||||
|
||||
@Table({ modelName: 'strike_reason', underscored: true })
|
||||
export class StrikeReason extends Model {
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false })
|
||||
declare weight: number;
|
||||
@Column({ type: DataTypes.STRING, allowNull: false })
|
||||
declare name: string;
|
||||
}
|
||||
|
||||
@Table({ modelName: 'strike_punishment', underscored: true })
|
||||
export class StrikePunishment extends Model {
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false })
|
||||
declare weight: number;
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false })
|
||||
declare ban_in_seconds: number;
|
||||
}
|
||||
|
||||
@Table({ modelName: 'strike', underscored: true })
|
||||
export class Strike extends Model {
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 })
|
||||
declare weight: number;
|
||||
@Column({ type: DataTypes.DATE, allowNull: false, defaultValue: 0 })
|
||||
declare ban_until: Date;
|
||||
@Column({ type: DataTypes.INTEGER, allowNull: false })
|
||||
@ForeignKey(() => User)
|
||||
declare user_id: number;
|
||||
|
||||
@BelongsTo(() => User, 'user_id')
|
||||
declare user: User;
|
||||
}
|
||||
|
||||
@Table({ modelName: 'admin', underscored: true })
|
||||
@@ -122,5 +157,5 @@ export class Settings extends Model {
|
||||
export const sequelize = new Sequelize(building ? 'sqlite::memory:' : env.DATABASE_URI, {
|
||||
// only log sql queries in dev mode
|
||||
logging: dev ? console.log : false,
|
||||
models: [User, Report, Admin, Settings]
|
||||
models: [User, Report, StrikeReason, StrikePunishment, Strike, Admin, Settings]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user