5 var crypto = require('crypto');
7 module.exports = function(sequelize, DataTypes) {
9 var FaxRoom = sequelize.define('FaxRoom', {
10 from: DataTypes.STRING,
11 account: DataTypes.STRING,
13 type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED', 'UNMANAGED'),
17 type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED', 'NOTE')
23 if (this.getDataValue('tags')) {
24 tags = this.getDataValue('tags').split(';');
32 this.setDataValue('tags', val && val.length ? val.join(';') + ';' : null);
36 type: DataTypes.BOOLEAN,
40 type: DataTypes.STRING
43 tableName: 'fax_rooms',
45 associate: function(models) {
47 FaxRoom.hasMany(models.FaxMessage);
48 FaxRoom.belongsTo(models.FaxAccount);
49 FaxRoom.belongsToMany(models.User, {
50 through: 'user_has_fax_rooms'
53 FaxRoom.addScope('default', {
58 model: models.FaxAccount
60 model: models.FaxMessage,
62 model: models.FaxAttachment
65 attributes: ['id', 'name', 'fullname', 'email']
69 attributes: ['id', 'name', 'fullname', 'email']