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