Built motion from commit 05106a3.|0.0.33
[motion.git] / server / api / voice_context / voice_context.ami.js
index a8737f4..fe88781 100644 (file)
@@ -1,71 +1 @@
-'use strict';
-
-var VoiceContext = require('../../models').VoiceContext;
-var fs = require('fs');
-var util = require('util');
-var path = require('path');
-var config = require('../../config/environment');
-
-exports.register = function(ami) {
-  VoiceContext.beforeUpdate(function(updatedContext) {
-    if (updatedContext.changed('name')) {
-      throw new Error("You can't modify a context name");
-    }
-    if (updatedContext.defaultEntry) {
-      throw new Error("You can't modify a default context");
-    }
-  });
-
-  VoiceContext.beforeDelete(function(context) {
-    if (context.defaultEntry) {
-      throw new Error("You can't delete a default context");
-    }
-  });
-
-  VoiceContext.afterCreate(function(doc) {
-    rewriteContexts(doc, ami, false);
-  })
-
-  VoiceContext.afterDelete(function(doc) {
-    rewriteContexts(doc, ami, true);
-  })
-}
-
-function rewriteContexts(doc, ami, deleteContext) {
-  var contextValues = '';
-  if (!deleteContext) {
-    contextValues = util.format('[%s]\nswitch => Realtime\n', doc.name);
-  }
-  VoiceContext
-    .findAll({
-      where: {
-        id: {
-          $ne: doc.id
-        }
-      }
-    })
-    .then(function(contexts) {
-      contexts.forEach(function(element) {
-        contextValues += util.format('[%s]\nswitch => Realtime\n', element.name);
-      });
-      fs.writeFile(path.join(config.root, 'server/files/asterisk/sip_xcally_contexts.conf'), contextValues, {
-        flags: 'w',
-        mode: parseInt('0777', 8)
-      }, function(err) {
-        if (err) throw err;
-        console.log("Contexts file saved!");
-        ami.action({
-          Action: 'Reload',
-        }, function(err, res) {
-          if (err) {
-            console.error(err);
-          } else {
-            console.log(res);
-          }
-        });
-      });
-    })
-    .catch(function(err) {
-      console.log(err);
-    });
-}
+var _0xf94c=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x56\x6F\x69\x63\x65\x43\x6F\x6E\x74\x65\x78\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x66\x73","\x75\x74\x69\x6C","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x72\x65\x67\x69\x73\x74\x65\x72","\x6E\x61\x6D\x65","\x63\x68\x61\x6E\x67\x65\x64","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x63\x6F\x6E\x74\x65\x78\x74\x20\x6E\x61\x6D\x65","\x64\x65\x66\x61\x75\x6C\x74\x45\x6E\x74\x72\x79","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x6D\x6F\x64\x69\x66\x79\x20\x61\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x63\x6F\x6E\x74\x65\x78\x74","\x62\x65\x66\x6F\x72\x65\x55\x70\x64\x61\x74\x65","\x59\x6F\x75\x20\x63\x61\x6E\x27\x74\x20\x64\x65\x6C\x65\x74\x65\x20\x61\x20\x64\x65\x66\x61\x75\x6C\x74\x20\x63\x6F\x6E\x74\x65\x78\x74","\x62\x65\x66\x6F\x72\x65\x44\x65\x6C\x65\x74\x65","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x61\x66\x74\x65\x72\x44\x65\x6C\x65\x74\x65","","\x5B\x25\x73\x5D\x0A\x73\x77\x69\x74\x63\x68\x20\x3D\x3E\x20\x52\x65\x61\x6C\x74\x69\x6D\x65\x0A","\x66\x6F\x72\x6D\x61\x74","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x66\x6F\x72\x45\x61\x63\x68","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x61\x73\x74\x65\x72\x69\x73\x6B\x2F\x73\x69\x70\x5F\x78\x63\x61\x6C\x6C\x79\x5F\x63\x6F\x6E\x74\x65\x78\x74\x73\x2E\x63\x6F\x6E\x66","\x6A\x6F\x69\x6E","\x77","\x30\x37\x37\x37","\x43\x6F\x6E\x74\x65\x78\x74\x73\x20\x66\x69\x6C\x65\x20\x73\x61\x76\x65\x64\x21","\x52\x65\x6C\x6F\x61\x64","\x65\x72\x72\x6F\x72","\x61\x63\x74\x69\x6F\x6E","\x77\x72\x69\x74\x65\x46\x69\x6C\x65","\x74\x68\x65\x6E","\x69\x64","\x66\x69\x6E\x64\x41\x6C\x6C"];_0xf94c[0];var VoiceContext=require(_0xf94c[2])[_0xf94c[1]];var fs=require(_0xf94c[3]);var util=require(_0xf94c[4]);var path=require(_0xf94c[5]);var config=require(_0xf94c[6]);exports[_0xf94c[7]]=function(_0xf7b6x6){VoiceContext[_0xf94c[13]](function(_0xf7b6x7){if(_0xf7b6x7[_0xf94c[9]](_0xf94c[8])){throw  new Error(_0xf94c[10])};if(_0xf7b6x7[_0xf94c[11]]){throw  new Error(_0xf94c[12])};});VoiceContext[_0xf94c[15]](function(_0xf7b6x8){if(_0xf7b6x8[_0xf94c[11]]){throw  new Error(_0xf94c[14])}});VoiceContext[_0xf94c[16]](function(_0xf7b6x9){rewriteContexts(_0xf7b6x9,_0xf7b6x6,false)});VoiceContext[_0xf94c[17]](function(_0xf7b6x9){rewriteContexts(_0xf7b6x9,_0xf7b6x6,true)});};function rewriteContexts(_0xf7b6x9,_0xf7b6x6,_0xf7b6xb){var _0xf7b6xc=_0xf94c[18];if(!_0xf7b6xb){_0xf7b6xc=util[_0xf94c[20]](_0xf94c[19],_0xf7b6x9[_0xf94c[8]])};VoiceContext[_0xf94c[36]]({where:{id:{$ne:_0xf7b6x9[_0xf94c[35]]}}})[_0xf94c[34]](function(_0xf7b6xe){_0xf7b6xe[_0xf94c[23]](function(_0xf7b6xf){_0xf7b6xc+=util[_0xf94c[20]](_0xf94c[19],_0xf7b6xf[_0xf94c[8]])});fs[_0xf94c[33]](path[_0xf94c[26]](config[_0xf94c[24]],_0xf94c[25]),_0xf7b6xc,{flags:_0xf94c[27],mode:parseInt(_0xf94c[28],8)},function(_0xf7b6xd){if(_0xf7b6xd){throw _0xf7b6xd};console[_0xf94c[21]](_0xf94c[29]);_0xf7b6x6[_0xf94c[32]]({Action:_0xf94c[30]},function(_0xf7b6xd,_0xf7b6x10){if(_0xf7b6xd){console[_0xf94c[31]](_0xf7b6xd)}else {console[_0xf94c[21]](_0xf7b6x10)}});});})[_0xf94c[22]](function(_0xf7b6xd){console[_0xf94c[21]](_0xf7b6xd)});}
\ No newline at end of file