Built motion from commit 48095ee.|0.0.102
[motion.git] / server / api / fax_message / fax_message.ami.js
index 2d69e42..f5a5e84 100644 (file)
@@ -1,64 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-
-var FaxMessage = require('../../models').FaxMessage;
-var Trunk = require('../../models').User;
-
-exports.register = function(ami) {
-
-  FaxMessage.afterCreate(function(doc) {
-    console.log('FaxMessage afterCreate');
-    onSave(ami, doc);
-  });
-};
-
-function onSave(ami, doc, cb) {
-  if (doc.status === 'NOT SENT' && !doc.actionid) {
-    // I have to send the fax with the Originate
-    var faxBody = JSON.parse(doc.body);
-    console.log('faxBody', faxBody);
-
-    Trunk
-      .findById(faxBody.trunk.id)
-      .then(function(trunk) {
-        var action = {
-          Action: 'originate',
-          CallerID: faxBody.from,
-          Channel: util.format('%s/%s@%s', faxBody.technology, faxBody.to, trunk.name),
-          Context: 'outbound-fax',
-          Exten: 's',
-          Priority: 1,
-          Async: 'true',
-          Variable: {
-            MAXRATE: faxBody.maxrate,
-            MINRATE: faxBody.minrate,
-            ECM: faxBody.ecm ? 'yes' : 'no',
-            LOCALID: faxBody.fax_localid,
-            FAXFILE: faxBody.fax_file,
-            // 'FAXFILE': 'test.tiff', // Scommentare se si fanno prove in locale!
-            FAXHEADER: faxBody.fax_header,
-            FAXUUID: faxBody.uuid
-          }
-        };
-
-        ami.action(action, function(err, res) {
-          if (err) {
-            doc.updateAttributes({
-              status: 'FAILED'
-            });
-          } else {
-            if (res.response && res.actionid) {
-              doc.updateAttributes({
-                actionid: res.actionid
-              });
-            }
-          }
-        });
-      })
-      .catch(function(err) {
-        console.error(err);
-      });
-  }
-}
+var _0xe7d5=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x72\x65\x67\x69\x73\x74\x65\x72","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65\x20\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x6C\x6F\x67","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x73\x74\x61\x74\x75\x73","\x4E\x4F\x54\x20\x53\x45\x4E\x54","\x61\x63\x74\x69\x6F\x6E\x69\x64","\x62\x6F\x64\x79","\x70\x61\x72\x73\x65","\x66\x61\x78\x42\x6F\x64\x79","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x6F\x72\x69\x67\x69\x6E\x61\x74\x65","\x66\x72\x6F\x6D","\x25\x73\x2F\x25\x73\x40\x25\x73","\x74\x65\x63\x68\x6E\x6F\x6C\x6F\x67\x79","\x74\x6F","\x6E\x61\x6D\x65","\x66\x6F\x72\x6D\x61\x74","\x6F\x75\x74\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x73","\x74\x72\x75\x65","\x6D\x61\x78\x72\x61\x74\x65","\x6D\x69\x6E\x72\x61\x74\x65","\x65\x63\x6D","\x79\x65\x73","\x6E\x6F","\x66\x61\x78\x5F\x6C\x6F\x63\x61\x6C\x69\x64","\x66\x61\x78\x5F\x66\x69\x6C\x65","\x66\x61\x78\x5F\x68\x65\x61\x64\x65\x72","\x75\x75\x69\x64","\x46\x41\x49\x4C\x45\x44","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x72\x65\x73\x70\x6F\x6E\x73\x65","\x61\x63\x74\x69\x6F\x6E","\x74\x68\x65\x6E","\x69\x64","\x74\x72\x75\x6E\x6B","\x66\x69\x6E\x64\x42\x79\x49\x64"];_0xe7d5[0];var _=require(_0xe7d5[1]);var util=require(_0xe7d5[2]);var FaxMessage=require(_0xe7d5[4])[_0xe7d5[3]];var Trunk=require(_0xe7d5[4])[_0xe7d5[5]];exports[_0xe7d5[6]]=function(_0x8fa0x5){FaxMessage[_0xe7d5[9]](function(_0x8fa0x6){console[_0xe7d5[8]](_0xe7d5[7])})};function onSave(_0x8fa0x5,_0x8fa0x6,_0x8fa0x8){if(_0x8fa0x6[_0xe7d5[10]]===_0xe7d5[11]&&!_0x8fa0x6[_0xe7d5[12]]){var _0x8fa0x9=JSON[_0xe7d5[14]](_0x8fa0x6[_0xe7d5[13]]);console[_0xe7d5[8]](_0xe7d5[15],_0x8fa0x9);Trunk[_0xe7d5[44]](_0x8fa0x9[_0xe7d5[43]][_0xe7d5[42]])[_0xe7d5[41]](function(_0x8fa0xb){var _0x8fa0xc={Action:_0xe7d5[18],CallerID:_0x8fa0x9[_0xe7d5[19]],Channel:util[_0xe7d5[24]](_0xe7d5[20],_0x8fa0x9[_0xe7d5[21]],_0x8fa0x9[_0xe7d5[22]],_0x8fa0xb[_0xe7d5[23]]),Context:_0xe7d5[25],Exten:_0xe7d5[26],Priority:1,Async:_0xe7d5[27],Variable:{MAXRATE:_0x8fa0x9[_0xe7d5[28]],MINRATE:_0x8fa0x9[_0xe7d5[29]],ECM:_0x8fa0x9[_0xe7d5[30]]?_0xe7d5[31]:_0xe7d5[32],LOCALID:_0x8fa0x9[_0xe7d5[33]],FAXFILE:_0x8fa0x9[_0xe7d5[34]],FAXHEADER:_0x8fa0x9[_0xe7d5[35]],FAXUUID:_0x8fa0x9[_0xe7d5[36]]}};_0x8fa0x5[_0xe7d5[40]](_0x8fa0xc,function(_0x8fa0xa,_0x8fa0xd){if(_0x8fa0xa){_0x8fa0x6[_0xe7d5[38]]({status:_0xe7d5[37]})}else {if(_0x8fa0xd[_0xe7d5[39]]&&_0x8fa0xd[_0xe7d5[12]]){_0x8fa0x6[_0xe7d5[38]]({actionid:_0x8fa0xd[_0xe7d5[12]]})}}})})[_0xe7d5[17]](function(_0x8fa0xa){console[_0xe7d5[16]](_0x8fa0xa)})}}
\ No newline at end of file