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