2026-05-09 04:18:41 +00:00

134 lines
1.5 KiB
JavaScript

const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');
module.exports = function(sequelize, DataTypes) {
const ip_bans = sequelize.define(
'ip_bans',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
ip_address: {
type: DataTypes.TEXT,
},
ban_type: {
type: DataTypes.ENUM,
values: [
"hard",
"temporary"
],
},
banned_until: {
type: DataTypes.DATE,
},
reason: {
type: DataTypes.TEXT,
},
banned_at: {
type: DataTypes.DATE,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
ip_bans.associate = (db) => {
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
//end loop
db.ip_bans.belongsTo(db.users, {
as: 'banned_by_user',
foreignKey: {
name: 'banned_by_userId',
},
constraints: false,
});
db.ip_bans.belongsTo(db.users, {
as: 'createdBy',
});
db.ip_bans.belongsTo(db.users, {
as: 'updatedBy',
});
};
return ip_bans;
};