168 lines
2.1 KiB
JavaScript
168 lines
2.1 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 moderation_actions = sequelize.define(
|
|
'moderation_actions',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
action_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"kick",
|
|
|
|
|
|
"ban",
|
|
|
|
|
|
"perm_ban",
|
|
|
|
|
|
"unban",
|
|
|
|
|
|
"warn",
|
|
|
|
|
|
"note"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
reason: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
starts_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
ends_at: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
is_active: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
evidence_url: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
reference_code: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
moderation_actions.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.moderation_actions.belongsTo(db.players, {
|
|
as: 'target_player',
|
|
foreignKey: {
|
|
name: 'target_playerId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.moderation_actions.belongsTo(db.users, {
|
|
as: 'actioned_by',
|
|
foreignKey: {
|
|
name: 'actioned_byId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.moderation_actions.belongsTo(db.game_servers, {
|
|
as: 'server',
|
|
foreignKey: {
|
|
name: 'serverId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.moderation_actions.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.moderation_actions.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return moderation_actions;
|
|
};
|
|
|
|
|