Built motion from commit (unavailable).|2.5.15
[motion2.git] / server / services / ami / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc88f=['getVoiceQueueHopperHistory','initVoiceQueueHopperHistory','initCampaignHopperHistory','getVoiceCallReports','initVoiceCallReports','log','listen','sync','catch','bluebird','util','moment','./server','./realtime','./trigger','./dialer','./fax','./rpc/voiceQueue','./rpc/voiceQueueReport','./rpc/voiceCallReport','./rpc/trunk','./rpc/trigger','./rpc/template','./rpc/cmHopperHistory','./rpc/campaign','./rpc/voiceExtension','./rpc/integrations/zendesk','./rpc/integrations/salesforce','./rpc/integrations/sugarcrm','./rpc/integrations/desk','./rpc/integrations/vtiger','./rpc/integrations/servicenow','./rpc/integrations/dynamics365','get','hour','resolve','then','getAgents','initAgents','getTelephones','initTelephones','getTrunks','initTrunks','initVoiceQueues','initTriggers','getTemplates','initTemplates','getZendeskAccounts','initZendeskAccounts','getSalesforceAccounts','initSalesforceAccounts','getSugarcrmAccounts','initSugarcrmAccounts','getFreshdeskAccounts','initFreshdeskAccounts','getDeskAccounts','initFreshsalesAccounts','initServicenowAccounts','initDynamics365Accounts','getCampaigns','initCampaigns','getVoiceExtensions','initVoiceExtensions','getFaxAccounts','initFaxAccounts','getVoiceQueueReports','initVoiceQueueReports'];(function(_0x131bef,_0x3c3583){var _0x3a9bed=function(_0x41ef9f){while(--_0x41ef9f){_0x131bef['push'](_0x131bef['shift']());}};_0x3a9bed(++_0x3c3583);}(_0xc88f,0x19b));var _0xfc88=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xc88f[_0x321bb2];return _0x9c12ed;};'use strict';var BPromise=require(_0xfc88('0x0'));var util=require(_0xfc88('0x1'));var moment=require(_0xfc88('0x2'));var server=require(_0xfc88('0x3'));var Realtime=require(_0xfc88('0x4'));var Report=require('./report');var Acw=require('./acw');var Trigger=require(_0xfc88('0x5'));var Dialer=require(_0xfc88('0x6'));var Preview=require('./preview');var Fax=require(_0xfc88('0x7'));var user=require('./rpc/user');var voiceQueue=require(_0xfc88('0x8'));var voiceQueueReport=require(_0xfc88('0x9'));var voiceCallReport=require(_0xfc88('0xa'));var trunk=require(_0xfc88('0xb'));var trigger=require(_0xfc88('0xc'));var template=require(_0xfc88('0xd'));var cmHopperHistory=require(_0xfc88('0xe'));var campaign=require(_0xfc88('0xf'));var voiceExtension=require(_0xfc88('0x10'));var faxAccount=require('./rpc/faxAccount');var zendesk=require(_0xfc88('0x11'));var salesforce=require(_0xfc88('0x12'));var sugarcrm=require(_0xfc88('0x13'));var freshdesk=require('./rpc/integrations/freshdesk');var desk=require(_0xfc88('0x14'));var zoho=require('./rpc/integrations/zoho');var vtiger=require(_0xfc88('0x15'));var freshsales=require('./rpc/integrations/freshsales');var servicenow=require(_0xfc88('0x16'));var dynamics365=require(_0xfc88('0x17'));var realtime=new Realtime();var report=new Report(realtime);var acw=new Acw(realtime);var channelTrigger=new Trigger(realtime);var preview=new Preview(realtime);var dialer=new Dialer(realtime,preview);var fax=new Fax(realtime);var isTrue=!![];var initP=!![];function ifMidnight(){if(moment()[_0xfc88('0x18')](_0xfc88('0x19'))===0x0&&initP){initP=![];isTrue=!![];initParams();}if(moment()[_0xfc88('0x18')]('hour')===0x1&&isTrue){isTrue=![];initP=!![];}}function initRealtime(){ifMidnight();return BPromise[_0xfc88('0x1a')]()[_0xfc88('0x1b')](user[_0xfc88('0x1c')]())['then'](realtime[_0xfc88('0x1d')]())[_0xfc88('0x1b')](user[_0xfc88('0x1e')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x1f')]())[_0xfc88('0x1b')](trunk[_0xfc88('0x20')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x21')]())[_0xfc88('0x1b')](voiceQueue['getVoiceQueues']())[_0xfc88('0x1b')](realtime[_0xfc88('0x22')]())[_0xfc88('0x1b')](trigger['getTriggers']())[_0xfc88('0x1b')](realtime[_0xfc88('0x23')]())[_0xfc88('0x1b')](template[_0xfc88('0x24')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x25')]())[_0xfc88('0x1b')](zendesk[_0xfc88('0x26')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x27')]())[_0xfc88('0x1b')](salesforce[_0xfc88('0x28')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x29')]())['then'](sugarcrm[_0xfc88('0x2a')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x2b')]())[_0xfc88('0x1b')](freshdesk[_0xfc88('0x2c')]())['then'](realtime[_0xfc88('0x2d')]())['then'](desk[_0xfc88('0x2e')]())[_0xfc88('0x1b')](realtime['initDeskAccounts']())[_0xfc88('0x1b')](zoho['getZohoAccounts']())['then'](realtime['initZohoAccounts']())[_0xfc88('0x1b')](vtiger['getVtigerAccounts']())['then'](realtime['initVtigerAccounts']())[_0xfc88('0x1b')](freshsales['getFreshsalesAccounts']())['then'](realtime[_0xfc88('0x2f')]())[_0xfc88('0x1b')](servicenow['getServicenowAccounts']())[_0xfc88('0x1b')](realtime[_0xfc88('0x30')]())[_0xfc88('0x1b')](dynamics365['getDynamics365Accounts']())[_0xfc88('0x1b')](realtime[_0xfc88('0x31')]())[_0xfc88('0x1b')](campaign[_0xfc88('0x32')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x33')]())['then'](voiceExtension[_0xfc88('0x34')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x35')]())[_0xfc88('0x1b')](faxAccount[_0xfc88('0x36')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x37')]())[_0xfc88('0x1b')](function(){return realtime;});}function initParams(){return BPromise[_0xfc88('0x1a')]()['then'](voiceQueueReport[_0xfc88('0x38')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x39')]())[_0xfc88('0x1b')](cmHopperHistory[_0xfc88('0x3a')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x3b')]())[_0xfc88('0x1b')](cmHopperHistory['getCampaignHopperHistory']())[_0xfc88('0x1b')](realtime[_0xfc88('0x3c')]())[_0xfc88('0x1b')](voiceCallReport[_0xfc88('0x3d')]())[_0xfc88('0x1b')](realtime[_0xfc88('0x3e')]())['then'](function(_0x86def5){})['catch'](function(_0x5a70e2){console[_0xfc88('0x3f')](_0x5a70e2);});}function main(){return server[_0xfc88('0x40')](realtime,preview,fax)[_0xfc88('0x1b')](function(_0x3e8aa2){return initRealtime();})['then'](function(){return initParams();})[_0xfc88('0x1b')](function(){report[_0xfc88('0x41')]();setInterval(initRealtime,0x1388);})[_0xfc88('0x42')](function(_0x290768){console[_0xfc88('0x3f')](_0x290768);});}main();