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