172 lines
1.9 KiB
JavaScript
172 lines
1.9 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 chat_rules = sequelize.define(
|
|
'chat_rules',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
platform: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"twitch",
|
|
|
|
|
|
"kick",
|
|
|
|
|
|
"both"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
rule_name: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
is_enabled: {
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
rule_type: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"ignore_bots",
|
|
|
|
|
|
"block_keywords",
|
|
|
|
|
|
"allow_keywords",
|
|
|
|
|
|
"min_user_age_days",
|
|
|
|
|
|
"min_follow_age_minutes",
|
|
|
|
|
|
"max_message_length",
|
|
|
|
|
|
"cooldown_seconds",
|
|
|
|
|
|
"read_everything"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
pattern: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
int_value: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
decimal_value: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
chat_rules.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.chat_rules.belongsTo(db.streamer_profiles, {
|
|
as: 'streamer_profile',
|
|
foreignKey: {
|
|
name: 'streamer_profileId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.chat_rules.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.chat_rules.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return chat_rules;
|
|
};
|
|
|
|
|