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