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.STRING
39 tableName: 'fax_rooms',
41 associate: function(models) {
43 FaxRoom.hasMany(models.FaxMessage);
44 FaxRoom.belongsTo(models.FaxAccount);
45 FaxRoom.belongsToMany(models.User, {
46 through: 'user_has_fax_rooms'
49 FaxRoom.addScope('default', {
54 model: models.FaxAccount
56 model: models.FaxMessage,
58 model: models.FaxAttachment
61 attributes: ['id', 'name', 'fullname', 'email']
65 attributes: ['id', 'name', 'fullname', 'email']