Built motion from commit (unavailable).|2.5.11
[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 _0xabfb=['getVoiceCallReports','initVoiceCallReports','catch','log','listen','sync','bluebird','moment','./realtime','./report','./acw','./trigger','./dialer','./preview','./fax','./rpc/user','./rpc/voiceQueue','./rpc/voiceCallReport','./rpc/trigger','./rpc/template','./rpc/cmHopperHistory','./rpc/campaign','./rpc/faxAccount','./rpc/integrations/zendesk','./rpc/integrations/sugarcrm','./rpc/integrations/desk','./rpc/integrations/zoho','./rpc/integrations/vtiger','./rpc/integrations/freshsales','./rpc/integrations/servicenow','./rpc/integrations/dynamics365','hour','get','resolve','then','initAgents','getTelephones','initTelephones','getTrunks','initTrunks','initVoiceQueues','initTriggers','initTemplates','getZendeskAccounts','getSalesforceAccounts','initSalesforceAccounts','initSugarcrmAccounts','initDeskAccounts','getZohoAccounts','initZohoAccounts','getVtigerAccounts','initVtigerAccounts','getFreshsalesAccounts','getServicenowAccounts','initServicenowAccounts','initDynamics365Accounts','initCampaigns','getVoiceExtensions','getFaxAccounts','initFaxAccounts','initVoiceQueueReports','getVoiceQueueHopperHistory','initVoiceQueueHopperHistory','initCampaignHopperHistory'];(function(_0x51020b,_0x38c2c7){var _0x371e47=function(_0x2a538f){while(--_0x2a538f){_0x51020b['push'](_0x51020b['shift']());}};_0x371e47(++_0x38c2c7);}(_0xabfb,0x146));var _0xbabf=function(_0x2118ad,_0xe8e3fd){_0x2118ad=_0x2118ad-0x0;var _0x4b5715=_0xabfb[_0x2118ad];return _0x4b5715;};'use strict';var BPromise=require(_0xbabf('0x0'));var util=require('util');var moment=require(_0xbabf('0x1'));var server=require('./server');var Realtime=require(_0xbabf('0x2'));var Report=require(_0xbabf('0x3'));var Acw=require(_0xbabf('0x4'));var Trigger=require(_0xbabf('0x5'));var Dialer=require(_0xbabf('0x6'));var Preview=require(_0xbabf('0x7'));var Fax=require(_0xbabf('0x8'));var user=require(_0xbabf('0x9'));var voiceQueue=require(_0xbabf('0xa'));var voiceQueueReport=require('./rpc/voiceQueueReport');var voiceCallReport=require(_0xbabf('0xb'));var trunk=require('./rpc/trunk');var trigger=require(_0xbabf('0xc'));var template=require(_0xbabf('0xd'));var cmHopperHistory=require(_0xbabf('0xe'));var campaign=require(_0xbabf('0xf'));var voiceExtension=require('./rpc/voiceExtension');var faxAccount=require(_0xbabf('0x10'));var zendesk=require(_0xbabf('0x11'));var salesforce=require('./rpc/integrations/salesforce');var sugarcrm=require(_0xbabf('0x12'));var freshdesk=require('./rpc/integrations/freshdesk');var desk=require(_0xbabf('0x13'));var zoho=require(_0xbabf('0x14'));var vtiger=require(_0xbabf('0x15'));var freshsales=require(_0xbabf('0x16'));var servicenow=require(_0xbabf('0x17'));var dynamics365=require(_0xbabf('0x18'));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()['get'](_0xbabf('0x19'))===0x0&&initP){initP=![];isTrue=!![];initParams();}if(moment()[_0xbabf('0x1a')](_0xbabf('0x19'))===0x1&&isTrue){isTrue=![];initP=!![];}}function initRealtime(){ifMidnight();return BPromise[_0xbabf('0x1b')]()[_0xbabf('0x1c')](user['getAgents']())['then'](realtime[_0xbabf('0x1d')]())[_0xbabf('0x1c')](user[_0xbabf('0x1e')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x1f')]())[_0xbabf('0x1c')](trunk[_0xbabf('0x20')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x21')]())['then'](voiceQueue['getVoiceQueues']())[_0xbabf('0x1c')](realtime[_0xbabf('0x22')]())[_0xbabf('0x1c')](trigger['getTriggers']())[_0xbabf('0x1c')](realtime[_0xbabf('0x23')]())[_0xbabf('0x1c')](template['getTemplates']())[_0xbabf('0x1c')](realtime[_0xbabf('0x24')]())[_0xbabf('0x1c')](zendesk[_0xbabf('0x25')]())[_0xbabf('0x1c')](realtime['initZendeskAccounts']())[_0xbabf('0x1c')](salesforce[_0xbabf('0x26')]())['then'](realtime[_0xbabf('0x27')]())[_0xbabf('0x1c')](sugarcrm['getSugarcrmAccounts']())[_0xbabf('0x1c')](realtime[_0xbabf('0x28')]())[_0xbabf('0x1c')](freshdesk['getFreshdeskAccounts']())[_0xbabf('0x1c')](realtime['initFreshdeskAccounts']())['then'](desk['getDeskAccounts']())[_0xbabf('0x1c')](realtime[_0xbabf('0x29')]())['then'](zoho[_0xbabf('0x2a')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x2b')]())[_0xbabf('0x1c')](vtiger[_0xbabf('0x2c')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x2d')]())[_0xbabf('0x1c')](freshsales[_0xbabf('0x2e')]())['then'](realtime['initFreshsalesAccounts']())['then'](servicenow[_0xbabf('0x2f')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x30')]())[_0xbabf('0x1c')](dynamics365['getDynamics365Accounts']())[_0xbabf('0x1c')](realtime[_0xbabf('0x31')]())['then'](campaign['getCampaigns']())[_0xbabf('0x1c')](realtime[_0xbabf('0x32')]())['then'](voiceExtension[_0xbabf('0x33')]())[_0xbabf('0x1c')](realtime['initVoiceExtensions']())[_0xbabf('0x1c')](faxAccount[_0xbabf('0x34')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x35')]())[_0xbabf('0x1c')](function(){return realtime;});}function initParams(){return BPromise['resolve']()['then'](voiceQueueReport['getVoiceQueueReports']())[_0xbabf('0x1c')](realtime[_0xbabf('0x36')]())[_0xbabf('0x1c')](cmHopperHistory[_0xbabf('0x37')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x38')]())[_0xbabf('0x1c')](cmHopperHistory['getCampaignHopperHistory']())[_0xbabf('0x1c')](realtime[_0xbabf('0x39')]())['then'](voiceCallReport[_0xbabf('0x3a')]())[_0xbabf('0x1c')](realtime[_0xbabf('0x3b')]())[_0xbabf('0x1c')](function(_0xe3064e){})[_0xbabf('0x3c')](function(_0x1f8093){console[_0xbabf('0x3d')](_0x1f8093);});}function main(){return server[_0xbabf('0x3e')](realtime,preview,fax)[_0xbabf('0x1c')](function(_0x1696c9){return initRealtime();})[_0xbabf('0x1c')](function(){return initParams();})[_0xbabf('0x1c')](function(){report[_0xbabf('0x3f')]();setInterval(initRealtime,0x1388);})['catch'](function(_0x5b7745){console[_0xbabf('0x3d')](_0x5b7745);});}main();