4dde7c1e10d7aee50f811cc617a2d84d13f28d5d
[motion2.git] / server / api / cmHopper / cmHopper.rpc.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 _0xa12f=['push','all','GetContactDialer\x20hopperId\x20[%s]\x20-\x20contactId\x20[%s]\x20-\x20active\x20status\x20[%s]','dataValues','ContactId','MoveContactManagedDialer','CmHopperFinal','MoveContactManagedDialer\x20hopper\x20options\x20[%s]\x20active\x20status\x20[%s]','CountReScheduled','COUNT','literal','\x22%s\x22','format','\x20,\x201,\x20null','contactsRescheduled','GetContactRecallMe','findOne','phone','dialTimezone','DESC','getContactByPhone','ResetActiveCalls','CmHopperHandlePreviewRecallNotifications','voiceQueueId','interval','NOW()\x20+\x20INTERVAL\x20','User','List','\x20MINUTE','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then','info','request\x20sent','debug','CmHopper,\x20%s,\x20%s,\x20%s','stringify','error','message','CmHopper,\x20%s,\x20%s','result','catch','findAll','options','raw','where','attributes','limit','include','map','model','GetCmHopper','ShowCmHopper','CmHopper','find','CreateCmHopper','create','body','UpdateCmHopper','update','active','DestroyCmHopper','GetContactDialer','CmContact','describe','sequelize','transaction','order','LOCK','UPDATE','Contact','keys','Agent','name','voicePause','length','UserId','includes'];(function(_0x58e448,_0x5242fe){var _0x9f48a7=function(_0x2c628b){while(--_0x2c628b){_0x58e448['push'](_0x58e448['shift']());}};_0x9f48a7(++_0x5242fe);}(_0xa12f,0x1df));var _0xfa12=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0xa12f[_0x3b380d];return _0x54502b;};'use strict';var _=require(_0xfa12('0x0'));var util=require(_0xfa12('0x1'));var moment=require(_0xfa12('0x2'));var BPromise=require('bluebird');var rs=require(_0xfa12('0x3'));var fs=require('fs');var Redis=require(_0xfa12('0x4'));var db=require(_0xfa12('0x5'))['db'];var utils=require(_0xfa12('0x6'));var logger=require(_0xfa12('0x7'))(_0xfa12('0x8'));var config=require(_0xfa12('0x9'));var jayson=require(_0xfa12('0xa'));const {validateExpressRequest}=require('twilio/lib/webhooks/webhooks');var client=jayson[_0xfa12('0xb')][_0xfa12('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x2dbbeb,_0x47555a,_0x427ce4){return new BPromise(function(_0x39f423,_0x1e3273){return client[_0xfa12('0xd')](_0x2dbbeb,_0x427ce4)[_0xfa12('0xe')](function(_0x5e897e){logger[_0xfa12('0xf')]('CmHopper,\x20%s,\x20%s',_0x47555a,_0xfa12('0x10'));logger[_0xfa12('0x11')](_0xfa12('0x12'),_0x47555a,_0xfa12('0x10'),JSON[_0xfa12('0x13')](_0x5e897e));if(_0x5e897e[_0xfa12('0x14')]){if(_0x5e897e[_0xfa12('0x14')]['code']===0x1f4){logger[_0xfa12('0x14')]('CmHopper,\x20%s,\x20%s',_0x47555a,_0x5e897e['error']['message']);return _0x1e3273(_0x5e897e[_0xfa12('0x14')][_0xfa12('0x15')]);}logger[_0xfa12('0x14')](_0xfa12('0x16'),_0x47555a,_0x5e897e['error']['message']);return _0x39f423(_0x5e897e['error']['message']);}else{logger[_0xfa12('0xf')]('CmHopper,\x20%s,\x20%s',_0x47555a,_0xfa12('0x10'));_0x39f423(_0x5e897e[_0xfa12('0x17')][_0xfa12('0x15')]);}})[_0xfa12('0x18')](function(_0x398f44){logger[_0xfa12('0x14')](_0xfa12('0x16'),_0x47555a,_0x398f44);_0x1e3273(_0x398f44);});});}exports['GetCmHopper']=function(_0x4e48f1){var _0x5e597c=this;return new Promise(function(_0x4cf9a0,_0x44957c){return db['CmHopper'][_0xfa12('0x19')]({'raw':_0x4e48f1[_0xfa12('0x1a')]?_0x4e48f1[_0xfa12('0x1a')][_0xfa12('0x1b')]===undefined?!![]:![]:!![],'where':_0x4e48f1[_0xfa12('0x1a')]?_0x4e48f1[_0xfa12('0x1a')][_0xfa12('0x1c')]||null:null,'attributes':_0x4e48f1[_0xfa12('0x1a')]?_0x4e48f1[_0xfa12('0x1a')][_0xfa12('0x1d')]||null:null,'limit':_0x4e48f1['options']?_0x4e48f1[_0xfa12('0x1a')][_0xfa12('0x1e')]||null:null,'include':_0x4e48f1[_0xfa12('0x1a')]?_0x4e48f1[_0xfa12('0x1a')][_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0x4e48f1[_0xfa12('0x1a')]['include'],function(_0x3acbea){return{'model':db[_0x3acbea['model']],'as':_0x3acbea['as'],'attributes':_0x3acbea[_0xfa12('0x1d')],'include':_0x3acbea['include']?_[_0xfa12('0x20')](_0x3acbea['include'],function(_0xe9cdda){return{'model':db[_0xe9cdda[_0xfa12('0x21')]],'as':_0xe9cdda['as'],'attributes':_0xe9cdda['attributes'],'include':_0xe9cdda[_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0xe9cdda[_0xfa12('0x1f')],function(_0xf9de9c){return{'model':db[_0xf9de9c[_0xfa12('0x21')]],'as':_0xf9de9c['as'],'attributes':_0xf9de9c[_0xfa12('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfa12('0xe')](function(_0x6ee832){logger['info'](_0xfa12('0x22'),_0x4e48f1);logger['debug'](_0xfa12('0x22'),_0x4e48f1,JSON[_0xfa12('0x13')](_0x6ee832));_0x4cf9a0(_0x6ee832);})[_0xfa12('0x18')](function(_0x245c7c){logger[_0xfa12('0x14')](_0xfa12('0x22'),_0x245c7c[_0xfa12('0x15')],_0x4e48f1);_0x44957c(_0x5e597c['error'](0x1f4,_0x245c7c[_0xfa12('0x15')]));});});};exports[_0xfa12('0x23')]=function(_0x5705a1){var _0x4b0ec5=this;return new Promise(function(_0x4536c7,_0x4700a2){return db[_0xfa12('0x24')][_0xfa12('0x25')]({'raw':_0x5705a1[_0xfa12('0x1a')]?_0x5705a1[_0xfa12('0x1a')][_0xfa12('0x1b')]===undefined?!![]:![]:!![],'where':_0x5705a1[_0xfa12('0x1a')]?_0x5705a1[_0xfa12('0x1a')][_0xfa12('0x1c')]||null:null,'attributes':_0x5705a1[_0xfa12('0x1a')]?_0x5705a1['options']['attributes']||null:null,'include':_0x5705a1[_0xfa12('0x1a')]?_0x5705a1[_0xfa12('0x1a')]['include']?_[_0xfa12('0x20')](_0x5705a1[_0xfa12('0x1a')][_0xfa12('0x1f')],function(_0x24b07a){return{'model':db[_0x24b07a['model']],'as':_0x24b07a['as'],'attributes':_0x24b07a[_0xfa12('0x1d')],'include':_0x24b07a[_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0x24b07a[_0xfa12('0x1f')],function(_0x332b2c){return{'model':db[_0x332b2c[_0xfa12('0x21')]],'as':_0x332b2c['as'],'attributes':_0x332b2c[_0xfa12('0x1d')],'include':_0x332b2c['include']?_[_0xfa12('0x20')](_0x332b2c['include'],function(_0x3bc15d){return{'model':db[_0x3bc15d['model']],'as':_0x3bc15d['as'],'attributes':_0x3bc15d[_0xfa12('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2eb9c0){logger[_0xfa12('0xf')](_0xfa12('0x23'),_0x5705a1);logger[_0xfa12('0x11')](_0xfa12('0x23'),_0x5705a1,JSON['stringify'](_0x2eb9c0));_0x4536c7(_0x2eb9c0);})[_0xfa12('0x18')](function(_0x509e84){logger[_0xfa12('0x14')]('ShowCmHopper',_0x509e84['message'],_0x5705a1);_0x4700a2(_0x4b0ec5['error'](0x1f4,_0x509e84[_0xfa12('0x15')]));});});};exports[_0xfa12('0x26')]=function(_0x45321d){var _0x296ac7=this;return new Promise(function(_0x38cd9a,_0x41146a){return db[_0xfa12('0x24')][_0xfa12('0x27')](_0x45321d[_0xfa12('0x28')],{'raw':_0x45321d[_0xfa12('0x1a')]?_0x45321d[_0xfa12('0x1a')]['raw']===undefined?!![]:![]:!![]})[_0xfa12('0xe')](function(_0x3855fd){logger[_0xfa12('0xf')](_0xfa12('0x26'),_0x45321d);logger[_0xfa12('0x11')](_0xfa12('0x26'),_0x45321d,JSON[_0xfa12('0x13')](_0x3855fd));_0x38cd9a(_0x3855fd);})[_0xfa12('0x18')](function(_0x3c055e){logger[_0xfa12('0x14')](_0xfa12('0x26'),_0x3c055e[_0xfa12('0x15')],_0x45321d);_0x41146a(_0x296ac7[_0xfa12('0x14')](0x1f4,_0x3c055e[_0xfa12('0x15')]));});});};exports[_0xfa12('0x29')]=function(_0xa7e70c){var _0x79d806=this;return new Promise(function(_0x17a561,_0x5189b0){return db[_0xfa12('0x24')][_0xfa12('0x2a')](_0xa7e70c[_0xfa12('0x28')],{'raw':_0xa7e70c[_0xfa12('0x1a')]?_0xa7e70c[_0xfa12('0x1a')][_0xfa12('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xa7e70c[_0xfa12('0x1a')]?_0xa7e70c[_0xfa12('0x1a')]['where']||null:null,'attributes':_0xa7e70c[_0xfa12('0x1a')]?_0xa7e70c['options'][_0xfa12('0x1d')]||null:null,'limit':_0xa7e70c[_0xfa12('0x1a')]?_0xa7e70c[_0xfa12('0x1a')]['limit']||null:null})['then'](function(_0x2b6a50){logger[_0xfa12('0xf')](_0xfa12('0x29'),_0xa7e70c);logger[_0xfa12('0xf')]('UpdateCmHopper\x20hopper\x20options\x20[%s]\x20active\x20status\x20[%s]',JSON[_0xfa12('0x13')](_0xa7e70c[_0xfa12('0x1a')][_0xfa12('0x1c')]),_0xa7e70c[_0xfa12('0x28')][_0xfa12('0x2b')]);logger[_0xfa12('0x11')](_0xfa12('0x29'),_0xa7e70c,JSON['stringify'](_0x2b6a50));_0x17a561(_0x2b6a50);})[_0xfa12('0x18')](function(_0x40310f){logger['error'](_0xfa12('0x29'),_0x40310f[_0xfa12('0x15')],_0xa7e70c);_0x5189b0(_0x79d806[_0xfa12('0x14')](0x1f4,_0x40310f[_0xfa12('0x15')]));});});};exports[_0xfa12('0x2c')]=function(_0x2042f8){var _0x28aea5=this;return new Promise(function(_0x58d6c7,_0x3cb234){return db['CmHopper']['destroy']({'where':_0x2042f8[_0xfa12('0x1a')]?_0x2042f8[_0xfa12('0x1a')]['where']||null:null})['then'](function(_0x3869da){logger[_0xfa12('0xf')](_0xfa12('0x2c'),_0x2042f8);logger[_0xfa12('0x11')](_0xfa12('0x2c'),_0x2042f8,JSON[_0xfa12('0x13')](_0x3869da));_0x58d6c7(_0x3869da);})[_0xfa12('0x18')](function(_0x45744a){logger['error'](_0xfa12('0x2c'),_0x45744a[_0xfa12('0x15')],_0x2042f8);_0x3cb234(_0x28aea5[_0xfa12('0x14')](0x1f4,_0x45744a[_0xfa12('0x15')]));});});};exports[_0xfa12('0x2d')]=function(_0x477810){var _0x1e5ea2=this;return new Promise(function(_0x59534e,_0x4b7065){return db[_0xfa12('0x2e')][_0xfa12('0x2f')]()[_0xfa12('0xe')](function(_0x524d76){return db[_0xfa12('0x30')][_0xfa12('0x31')](function(_0x288345){return db[_0xfa12('0x24')][_0xfa12('0x19')]({'where':_0x477810[_0xfa12('0x1a')]?_0x477810[_0xfa12('0x1a')][_0xfa12('0x1c')]||null:null,'attributes':_0x477810[_0xfa12('0x1a')]?_0x477810[_0xfa12('0x1a')][_0xfa12('0x1d')]||null:null,'limit':_0x477810[_0xfa12('0x1a')]?_0x477810[_0xfa12('0x1a')][_0xfa12('0x1e')]||null:null,'order':_0x477810[_0xfa12('0x1a')]?_0x477810[_0xfa12('0x1a')][_0xfa12('0x32')]||null:null,'transaction':_0x288345,'lock':_0x288345[_0xfa12('0x33')][_0xfa12('0x34')],'include':[{'model':db[_0xfa12('0x2e')],'as':_0xfa12('0x35'),'attributes':_[_0xfa12('0x36')](_0x524d76)},{'model':db['User'],'as':_0xfa12('0x37'),'attributes':['id',_0xfa12('0x38'),_0xfa12('0x39')]}]})[_0xfa12('0xe')](function(_0xbebe5d){var _0x4d1713=[];var _0x29187e=[];for(var _0x3a5bef=0x0;_0x3a5bef<_0xbebe5d[_0xfa12('0x3a')];_0x3a5bef+=0x1){var _0x4e8798=_0xbebe5d[_0x3a5bef][_0xfa12('0x3b')];if(_0x4e8798===null){_0x4d1713['push'](_0xbebe5d[_0x3a5bef]['update'](_0x477810['body'],{'transaction':_0x288345}));}else if(!_0x29187e[_0xfa12('0x3c')](_0x4e8798)){_0x29187e[_0xfa12('0x3d')](_0x4e8798);_0x4d1713[_0xfa12('0x3d')](_0xbebe5d[_0x3a5bef][_0xfa12('0x2a')](_0x477810[_0xfa12('0x28')],{'transaction':_0x288345}));}}return BPromise[_0xfa12('0x3e')](_0x4d1713);});})[_0xfa12('0xe')](function(_0x2d13b9){logger['info'](_0xfa12('0x2d'),_0x477810);if(_0x2d13b9[_0xfa12('0x3a')]>0x0){logger[_0xfa12('0xf')](_0xfa12('0x3f'),_0x2d13b9[0x0][_0xfa12('0x40')]['id'],_0x2d13b9[0x0][_0xfa12('0x40')][_0xfa12('0x41')],_0x2d13b9[0x0][_0xfa12('0x40')]['active']);}logger[_0xfa12('0x11')]('GetContactDialer',_0x477810,JSON[_0xfa12('0x13')](_0x2d13b9));_0x59534e(_0x2d13b9);})[_0xfa12('0x18')](function(_0x462169){logger[_0xfa12('0x14')](_0xfa12('0x2d'),_0x462169[_0xfa12('0x15')],_0x477810);_0x4b7065(_0x1e5ea2[_0xfa12('0x14')](0x1f4,_0x462169[_0xfa12('0x15')]));});});});};exports[_0xfa12('0x42')]=function(_0x3b4102){var _0x325885=this;return new Promise(function(_0x4a1703,_0x30bf7b){return db['sequelize'][_0xfa12('0x31')](function(_0x531e32){return db[_0xfa12('0x43')][_0xfa12('0x27')](_0x3b4102['body'],{'raw':_0x3b4102[_0xfa12('0x1a')]?_0x3b4102[_0xfa12('0x1a')][_0xfa12('0x1b')]===undefined?!![]:![]:!![],'transaction':_0x531e32})[_0xfa12('0xe')](function(){logger['info'](_0xfa12('0x44'),JSON[_0xfa12('0x13')](_0x3b4102['options']['where']),_0x3b4102[_0xfa12('0x1a')][_0xfa12('0x1c')]['active']);return db[_0xfa12('0x24')]['destroy']({'where':_0x3b4102[_0xfa12('0x1a')]?_0x3b4102['options'][_0xfa12('0x1c')]||null:null,'transaction':_0x531e32});});})[_0xfa12('0xe')](function(_0x13ed2a){logger[_0xfa12('0xf')](_0xfa12('0x42'),_0x3b4102);logger[_0xfa12('0x11')](_0xfa12('0x42'),_0x3b4102,JSON[_0xfa12('0x13')](_0x13ed2a));_0x4a1703(_0x13ed2a);})[_0xfa12('0x18')](function(_0x38c3c4){logger[_0xfa12('0x14')](_0xfa12('0x42'),_0x38c3c4[_0xfa12('0x15')],_0x3b4102);_0x30bf7b(_0x325885['error'](0x1f4,_0x38c3c4['message']));});});};exports[_0xfa12('0x45')]=function(_0x111ee0){var _0x4ee212=this;return new Promise(function(_0x5e36c2,_0x3650a7){return db['CmHopper'][_0xfa12('0x19')]({'raw':_0x111ee0['options']?_0x111ee0[_0xfa12('0x1a')][_0xfa12('0x1b')]===undefined?!![]:![]:!![],'where':_0x111ee0['options']?_0x111ee0[_0xfa12('0x1a')]['where']||null:null,'attributes':[[db['sequelize']['fn'](_0xfa12('0x46'),db[_0xfa12('0x30')]['fn']('IF',db[_0xfa12('0x30')][_0xfa12('0x47')]('`scheduledat`\x20>=\x20'+util['format'](_0xfa12('0x48'),moment()[_0xfa12('0x49')]('YYYY-MM-DD\x20HH:mm:ss'))+_0xfa12('0x4a')))),_0xfa12('0x4b')]]})[_0xfa12('0xe')](function(_0x4f31c7){logger[_0xfa12('0xf')](_0xfa12('0x45'),_0x111ee0);logger[_0xfa12('0x11')](_0xfa12('0x45'),_0x111ee0,JSON[_0xfa12('0x13')](_0x4f31c7));_0x5e36c2(_0x4f31c7);})['catch'](function(_0x210c29){logger[_0xfa12('0x14')](_0xfa12('0x45'),_0x210c29[_0xfa12('0x15')],_0x111ee0);_0x3650a7(_0x4ee212[_0xfa12('0x14')](0x1f4,_0x210c29[_0xfa12('0x15')]));});});};exports[_0xfa12('0x4c')]=function(_0xb4be0e){var _0x204814=this;return new Promise(function(_0x209224,_0x48e4d6){return db[_0xfa12('0x2e')][_0xfa12('0x2f')]()['then'](function(_0x1e4746){return db[_0xfa12('0x30')][_0xfa12('0x31')](function(_0x1360c7){return db[_0xfa12('0x24')]['findAll']({'where':_0xb4be0e[_0xfa12('0x1a')]?_0xb4be0e[_0xfa12('0x1a')]['where']||null:null,'attributes':_0xb4be0e['options']?_0xb4be0e[_0xfa12('0x1a')][_0xfa12('0x1d')]||null:null,'limit':0x1,'order':_0xb4be0e['options']?_0xb4be0e[_0xfa12('0x1a')][_0xfa12('0x32')]||null:null,'group':db[_0xfa12('0x24')][_0xfa12('0x3b')],'transaction':_0x1360c7,'lock':_0x1360c7[_0xfa12('0x33')][_0xfa12('0x34')],'include':_0xb4be0e[_0xfa12('0x1a')]?_0xb4be0e['options'][_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0xb4be0e[_0xfa12('0x1a')][_0xfa12('0x1f')],function(_0x1fb01a){return{'model':db[_0x1fb01a[_0xfa12('0x21')]],'as':_0x1fb01a['as'],'attributes':_0x1fb01a[_0xfa12('0x1d')],'include':_0x1fb01a[_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0x1fb01a[_0xfa12('0x1f')],function(_0x1e104c){return{'model':db[_0x1e104c[_0xfa12('0x21')]],'as':_0x1e104c['as'],'attributes':_0x1e104c[_0xfa12('0x1d')],'include':_0x1e104c[_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0x1e104c[_0xfa12('0x1f')],function(_0x269e4a){return{'model':db[_0x269e4a[_0xfa12('0x21')]],'as':_0x269e4a['as'],'attributes':_0x269e4a[_0xfa12('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfa12('0xe')](function(_0x4e32e6){var _0x202317=[];for(var _0x2f9625=0x0;_0x2f9625<_0x4e32e6[_0xfa12('0x3a')];_0x2f9625+=0x1){_0x202317[_0xfa12('0x3d')](_0x4e32e6[_0x2f9625][_0xfa12('0x2a')](_0xb4be0e[_0xfa12('0x28')],{'transaction':_0x1360c7}));}return BPromise[_0xfa12('0x3e')](_0x202317);});})[_0xfa12('0xe')](function(_0x1f85fb){logger[_0xfa12('0xf')](_0xfa12('0x4c'),_0xb4be0e);logger['debug']('GetContactRecallMe',_0xb4be0e,JSON['stringify'](_0x1f85fb));_0x209224(_0x1f85fb);})[_0xfa12('0x18')](function(_0x7953d){logger[_0xfa12('0x14')](_0xfa12('0x4c'),_0x7953d[_0xfa12('0x15')],_0xb4be0e);_0x48e4d6(_0x204814[_0xfa12('0x14')](0x1f4,_0x7953d[_0xfa12('0x15')]));});});});};exports['GetCmHopperPreview']=function(_0x17bba7){var _0x221e28=this;return new Promise(function(_0x5e1a6c,_0x37abeb){db[_0xfa12('0x2e')][_0xfa12('0x2f')]()[_0xfa12('0xe')](function(_0x2897d6){return db[_0xfa12('0x24')][_0xfa12('0x19')]({'raw':_0x17bba7[_0xfa12('0x1a')]?_0x17bba7[_0xfa12('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x17bba7[_0xfa12('0x1a')]?_0x17bba7[_0xfa12('0x1a')][_0xfa12('0x1c')]||null:null,'attributes':_0x17bba7[_0xfa12('0x1a')]?_0x17bba7[_0xfa12('0x1a')][_0xfa12('0x1d')]||null:null,'limit':_0x17bba7[_0xfa12('0x1a')]?_0x17bba7[_0xfa12('0x1a')][_0xfa12('0x1e')]||null:null,'include':_0x17bba7[_0xfa12('0x1a')]?_0x17bba7[_0xfa12('0x1a')][_0xfa12('0x1f')]?_[_0xfa12('0x20')](_0x17bba7[_0xfa12('0x1a')]['include'],function(_0x1984e3){return{'model':db[_0x1984e3['model']],'as':_0x1984e3['as'],'attributes':_0x1984e3['as']===_0xfa12('0x35')?_[_0xfa12('0x36')](_0x2897d6):_0x1984e3[_0xfa12('0x1d')],'include':_0x1984e3['include']?_[_0xfa12('0x20')](_0x1984e3[_0xfa12('0x1f')],function(_0x1203b5){return{'model':db[_0x1203b5[_0xfa12('0x21')]],'as':_0x1203b5['as'],'attributes':_0x1203b5['attributes'],'include':_0x1203b5['include']?_[_0xfa12('0x20')](_0x1203b5['include'],function(_0x55c3c4){return{'model':db[_0x55c3c4[_0xfa12('0x21')]],'as':_0x55c3c4['as'],'attributes':_0x55c3c4[_0xfa12('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfa12('0xe')](function(_0x262dce){logger[_0xfa12('0xf')]('GetCmHopper',_0x17bba7);logger['debug']('GetCmHopper',_0x17bba7,JSON[_0xfa12('0x13')](_0x262dce));_0x5e1a6c(_0x262dce);})[_0xfa12('0x18')](function(_0x6fbb1e){logger[_0xfa12('0x14')](_0xfa12('0x22'),_0x6fbb1e['message'],_0x17bba7);_0x37abeb(_0x221e28[_0xfa12('0x14')](0x1f4,_0x6fbb1e['message']));});});});};exports['GetContactByPhone']=function(_0x1d44be){var _0x3e0bf2=this;return new Promise(function(_0x4821cb,_0x18cc0d){return db[_0xfa12('0x2e')][_0xfa12('0x4d')]({'raw':!![],'where':{'phone':_0x1d44be[_0xfa12('0x1a')][_0xfa12('0x1c')][_0xfa12('0x4e')]},'attributes':['id',_0xfa12('0x4f')],'order':[['id',_0xfa12('0x50')]]})[_0xfa12('0xe')](function(_0x251860){logger[_0xfa12('0xf')]('getContactByPhone',_0x1d44be);logger[_0xfa12('0x11')]('getContactByPhone',_0x1d44be,JSON[_0xfa12('0x13')](_0x251860));_0x4821cb(_0x251860);})['catch'](function(_0x13fb30){logger['error'](_0xfa12('0x51'),_0x13fb30[_0xfa12('0x15')],_0x1d44be);_0x18cc0d(_0x3e0bf2[_0xfa12('0x14')](0x1f4,_0x13fb30[_0xfa12('0x15')]));});});};exports[_0xfa12('0x52')]=function(_0x14b20b){var _0xc1f405=this;return new Promise(function(_0x312edb,_0x4467c4){return db[_0xfa12('0x30')]['transaction'](function(_0x1c1df2){return db[_0xfa12('0x24')][_0xfa12('0x2a')]({'active':![]},{'where':{},'transaction':_0x1c1df2})[_0xfa12('0xe')](function(_0x43c089){logger[_0xfa12('0xf')](_0xfa12('0x52'),_0x14b20b);logger[_0xfa12('0x11')](_0xfa12('0x52'),_0x14b20b,JSON['stringify'](_0x43c089));_0x312edb(_0x43c089);})[_0xfa12('0x18')](function(_0x47d37d){logger[_0xfa12('0x14')]('ResetActiveCalls',_0x47d37d['message'],_0x14b20b);_0x4467c4(_0xc1f405[_0xfa12('0x14')](0x1f4,_0x47d37d[_0xfa12('0x15')]));});});});};exports[_0xfa12('0x53')]=function(_0x22b017){var _0x2a99c0=this;var _0x32c6e2=_0x22b017[_0xfa12('0x28')][_0xfa12('0x1c')][_0xfa12('0x54')];var _0x5a98a4=_0x22b017[_0xfa12('0x28')][_0xfa12('0x1c')][_0xfa12('0x55')];return new Promise(function(_0x14f6b3,_0x423b1c){return db[_0xfa12('0x24')][_0xfa12('0x19')]({'where':{'voiceQueueId':_0x32c6e2,'recallme':0x1,'active':0x0,'recallmeNotifiedDate':{'$eq':null},'scheduledat':{'$lte':db['sequelize'][_0xfa12('0x47')](_0xfa12('0x56')+_0x5a98a4+'\x20MINUTE')}},'include':[{'model':db[_0xfa12('0x2e')],'as':_0xfa12('0x35')},{'model':db[_0xfa12('0x57')],'as':_0xfa12('0x37'),'attributes':['id',_0xfa12('0x38'),'voicePause']},{'model':db['CmList'],'as':_0xfa12('0x58')}]})[_0xfa12('0xe')](function(_0x73e2ef){return db[_0xfa12('0x30')][_0xfa12('0x31')](function(_0x5ed6d9){return db[_0xfa12('0x24')][_0xfa12('0x2a')]({'recallmeNotifiedDate':new Date()},{'where':{'voiceQueueId':_0x32c6e2,'recallme':0x1,'active':0x0,'recallmeNotifiedDate':{'$eq':null},'scheduledat':{'$lte':db[_0xfa12('0x30')]['literal'](_0xfa12('0x56')+_0x5a98a4+_0xfa12('0x59'))}},'transaction':_0x5ed6d9})['then'](function(_0x4af5a7){_0x14f6b3(_0x73e2ef);})['catch'](function(_0x15215c){logger[_0xfa12('0x14')](_0xfa12('0x53'),_0x15215c[_0xfa12('0x15')],_0x22b017);_0x423b1c(validateExpressRequest);});});})[_0xfa12('0x18')](function(_0x569fc1){logger[_0xfa12('0x14')](_0xfa12('0x53'),_0x569fc1[_0xfa12('0x15')],_0x22b017);_0x423b1c(_0x2a99c0[_0xfa12('0x14')](0x1f4,_0x569fc1['message']));});});};