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 tableName: 'fax_rooms',
38 associate: function(models) {
40 FaxRoom.hasMany(models.FaxMessage);
41 FaxRoom.belongsTo(models.FaxAccount);
42 FaxRoom.belongsToMany(models.User, {
43 through: 'user_has_fax_rooms'
46 FaxRoom.addScope('default', {
51 model: models.FaxAccount
53 model: models.FaxMessage,
55 model: models.FaxAttachment
58 attributes: ['id', 'name', 'fullname', 'email']
62 attributes: ['id', 'name', 'fullname', 'email']