Built motion from commit 95b01fa.|0.0.70
[motion.git] / server / models / event.js
1 /**
2  * Event Model
3  */
4
5 module.exports = function(sequelize, DataTypes) {
6
7         var Event = sequelize.define('Event', {
8                 name: {
9                         type: DataTypes.ENUM('INCOMING', 'OUTGOING', 'ATTEMPT', 'ASSIGNED', 'UNASSIGNED')
10                 },
11                 channel: {
12                         type: DataTypes.ENUM('MAIL', 'CHAT', 'FAX', 'VOICE'),
13                 },
14                 timeout: {
15                         type: DataTypes.INTEGER
16                 },
17                 holdtime: {
18                         type: DataTypes.INTEGER
19                 }
20         }, {
21                 tableName: 'events',
22                 associate: function(models) {
23                         // USER RELATIONS
24                         Event.belongsTo(models.User);
25                         // MAIL RELATIONS
26                         Event.belongsTo(models.MailRoom);
27                         Event.belongsTo(models.MailMessage);
28                         Event.belongsTo(models.MailQueue);
29                         Event.belongsTo(models.MailAccount);
30                         Event.belongsTo(models.MailApplication);
31                         // FAX RELATIONS
32                         Event.belongsTo(models.FaxRoom);
33                         Event.belongsTo(models.FaxQueue);
34                         Event.belongsTo(models.FaxAccount);
35                         Event.belongsTo(models.FaxApplication);
36                         // CHAT RELATIONS
37                         Event.belongsTo(models.ChatRoom);
38                         Event.belongsTo(models.ChatQueue);
39                         Event.belongsTo(models.ChatWebsite);
40                         Event.belongsTo(models.ChatApplication);
41                 }
42         });
43
44         return Event;
45 };