4d1c98d5f578e9b79ffdad1713514e48a243eb6b
[motion.git] / server / config / ami / dial.js
1 function Dial() {
2   console.log('Dial Initialization...');
3 }
4
5 Dial.prototype.begin = function(evt) {
6   create(evt);
7 }
8
9 Dial.prototype.end = function(evt) {
10   findAndUpdate(evt);
11 }
12
13 function create(evt) {
14   var dial = require('../../models').ReportDial;
15   dial
16     .create(evt)
17     .then(function(dial) {
18       console.log('[dial] dial begin created');
19     })
20     .catch(function(err) {
21       console.error('[dial] dial begin error: ' + err);
22     });
23 }
24
25 function findAndUpdate(evt) {
26   var dial = require('../../models').ReportDial;
27   dial
28     .update(evt, {
29       where: {
30         uniqueid: evt.uniqueid
31       }
32     })
33     .then(function() {
34       console.info('[dial] dial end updated');
35     })
36     .catch(function(err) {
37       console.error('[dial] dial end error: ' + err);
38     });
39 }
40
41 module.exports = Dial;