03b9d1180f08a113ada700ff6c48841268614e6c
[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 _0xe3a1=['UPDATE','CmContact','Contact','keys','User','Agent','name','voicePause','push','includes','all','length','GetContactDialer\x20hopperId\x20[%s]\x20-\x20contactId\x20[%s]\x20-\x20active\x20status\x20[%s]','dataValues','MoveContactManagedDialer','CountReScheduled','COUNT','`scheduledat`\x20>=\x20','format','\x20,\x201,\x20null','UserId','GetContactRecallMe','GetCmHopperPreview','GetContactByPhone','findOne','phone','dialTimezone','DESC','getContactByPhone','ResetActiveCalls','CmHopperHandlePreviewRecallNotifications','voiceQueueIds','interval','availableAgentsIds','\x20MINUTE','literal','NOW()','List','../../mysqldb','../../config/logger','rpc','CmHopper','findAll','raw','options','where','limit','include','map','model','attributes','then','GetCmHopper','debug','stringify','catch','message','error','ShowCmHopper','find','info','CreateCmHopper','create','body','UpdateCmHopper','update','UpdateCmHopper\x20hopper\x20options\x20[%s]\x20active\x20status\x20[%s]','active','DestroyCmHopper','destroy','GetContactDialer','describe','sequelize','transaction','order','LOCK'];(function(_0x3b267f,_0x2a7dd9){var _0x4c0cd8=function(_0x5c20c6){while(--_0x5c20c6){_0x3b267f['push'](_0x3b267f['shift']());}};_0x4c0cd8(++_0x2a7dd9);}(_0xe3a1,0x10a));var _0x1e3a=function(_0x20d097,_0x4b5e83){_0x20d097=_0x20d097-0x0;var _0x25b1c9=_0xe3a1[_0x20d097];return _0x25b1c9;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var db=require(_0x1e3a('0x0'))['db'];var logger=require(_0x1e3a('0x1'))(_0x1e3a('0x2'));exports['GetCmHopper']=function(_0x1ecb9f){var _0x4da3f1=this;return new Promise(function(_0x597b91,_0x50e187){return db[_0x1e3a('0x3')][_0x1e3a('0x4')]({'raw':_0x1ecb9f['options']?_0x1ecb9f['options'][_0x1e3a('0x5')]===undefined?!![]:![]:!![],'where':_0x1ecb9f['options']?_0x1ecb9f[_0x1e3a('0x6')][_0x1e3a('0x7')]||null:null,'attributes':_0x1ecb9f[_0x1e3a('0x6')]?_0x1ecb9f[_0x1e3a('0x6')]['attributes']||null:null,'limit':_0x1ecb9f[_0x1e3a('0x6')]?_0x1ecb9f[_0x1e3a('0x6')][_0x1e3a('0x8')]||null:null,'include':_0x1ecb9f[_0x1e3a('0x6')]?_0x1ecb9f[_0x1e3a('0x6')][_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x1ecb9f[_0x1e3a('0x6')][_0x1e3a('0x9')],function(_0x5d826c){return{'model':db[_0x5d826c[_0x1e3a('0xb')]],'as':_0x5d826c['as'],'attributes':_0x5d826c[_0x1e3a('0xc')],'include':_0x5d826c[_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x5d826c[_0x1e3a('0x9')],function(_0x532359){return{'model':db[_0x532359[_0x1e3a('0xb')]],'as':_0x532359['as'],'attributes':_0x532359[_0x1e3a('0xc')],'include':_0x532359['include']?_['map'](_0x532359['include'],function(_0x10ee5a){return{'model':db[_0x10ee5a[_0x1e3a('0xb')]],'as':_0x10ee5a['as'],'attributes':_0x10ee5a[_0x1e3a('0xc')]};}):[]};}):[]};}):[]:[]})[_0x1e3a('0xd')](function(_0x4d855b){logger['info'](_0x1e3a('0xe'),_0x1ecb9f);logger[_0x1e3a('0xf')](_0x1e3a('0xe'),_0x1ecb9f,JSON[_0x1e3a('0x10')](_0x4d855b));_0x597b91(_0x4d855b);})[_0x1e3a('0x11')](function(_0x4f1ecf){logger['error'](_0x1e3a('0xe'),_0x4f1ecf[_0x1e3a('0x12')],_0x1ecb9f);_0x50e187(_0x4da3f1[_0x1e3a('0x13')](0x1f4,_0x4f1ecf[_0x1e3a('0x12')]));});});};exports[_0x1e3a('0x14')]=function(_0x527720){var _0x48bb3d=this;return new Promise(function(_0x3c66b3,_0x7f6ba2){return db[_0x1e3a('0x3')][_0x1e3a('0x15')]({'raw':_0x527720[_0x1e3a('0x6')]?_0x527720['options'][_0x1e3a('0x5')]===undefined?!![]:![]:!![],'where':_0x527720[_0x1e3a('0x6')]?_0x527720[_0x1e3a('0x6')]['where']||null:null,'attributes':_0x527720['options']?_0x527720[_0x1e3a('0x6')][_0x1e3a('0xc')]||null:null,'include':_0x527720['options']?_0x527720['options']['include']?_[_0x1e3a('0xa')](_0x527720[_0x1e3a('0x6')][_0x1e3a('0x9')],function(_0x359e2f){return{'model':db[_0x359e2f[_0x1e3a('0xb')]],'as':_0x359e2f['as'],'attributes':_0x359e2f[_0x1e3a('0xc')],'include':_0x359e2f[_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x359e2f[_0x1e3a('0x9')],function(_0x516041){return{'model':db[_0x516041[_0x1e3a('0xb')]],'as':_0x516041['as'],'attributes':_0x516041[_0x1e3a('0xc')],'include':_0x516041['include']?_['map'](_0x516041['include'],function(_0x3fd379){return{'model':db[_0x3fd379[_0x1e3a('0xb')]],'as':_0x3fd379['as'],'attributes':_0x3fd379[_0x1e3a('0xc')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1c1f7f){logger[_0x1e3a('0x16')]('ShowCmHopper',_0x527720);logger[_0x1e3a('0xf')](_0x1e3a('0x14'),_0x527720,JSON[_0x1e3a('0x10')](_0x1c1f7f));_0x3c66b3(_0x1c1f7f);})[_0x1e3a('0x11')](function(_0x3f6117){logger[_0x1e3a('0x13')](_0x1e3a('0x14'),_0x3f6117['message'],_0x527720);_0x7f6ba2(_0x48bb3d['error'](0x1f4,_0x3f6117[_0x1e3a('0x12')]));});});};exports[_0x1e3a('0x17')]=function(_0x2fda6f){var _0x2eefea=this;return new Promise(function(_0x574dc9,_0x51f668){return db[_0x1e3a('0x3')][_0x1e3a('0x18')](_0x2fda6f[_0x1e3a('0x19')],{'raw':_0x2fda6f[_0x1e3a('0x6')]?_0x2fda6f[_0x1e3a('0x6')][_0x1e3a('0x5')]===undefined?!![]:![]:!![]})['then'](function(_0xd62e19){logger[_0x1e3a('0x16')](_0x1e3a('0x17'),_0x2fda6f);logger[_0x1e3a('0xf')](_0x1e3a('0x17'),_0x2fda6f,JSON[_0x1e3a('0x10')](_0xd62e19));_0x574dc9(_0xd62e19);})[_0x1e3a('0x11')](function(_0x5d5f8e){logger['error'](_0x1e3a('0x17'),_0x5d5f8e[_0x1e3a('0x12')],_0x2fda6f);_0x51f668(_0x2eefea[_0x1e3a('0x13')](0x1f4,_0x5d5f8e[_0x1e3a('0x12')]));});});};exports[_0x1e3a('0x1a')]=function(_0xb4efdb){var _0x6c8acf=this;return new Promise(function(_0x4a2558,_0x491d5c){return db[_0x1e3a('0x3')][_0x1e3a('0x1b')](_0xb4efdb[_0x1e3a('0x19')],{'raw':_0xb4efdb['options']?_0xb4efdb[_0x1e3a('0x6')][_0x1e3a('0x5')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xb4efdb[_0x1e3a('0x6')]?_0xb4efdb[_0x1e3a('0x6')]['where']||null:null,'attributes':_0xb4efdb[_0x1e3a('0x6')]?_0xb4efdb['options'][_0x1e3a('0xc')]||null:null,'limit':_0xb4efdb[_0x1e3a('0x6')]?_0xb4efdb[_0x1e3a('0x6')][_0x1e3a('0x8')]||null:null})[_0x1e3a('0xd')](function(_0x3ef133){logger[_0x1e3a('0x16')]('UpdateCmHopper',_0xb4efdb);logger[_0x1e3a('0x16')](_0x1e3a('0x1c'),JSON[_0x1e3a('0x10')](_0xb4efdb[_0x1e3a('0x6')][_0x1e3a('0x7')]),_0xb4efdb['body'][_0x1e3a('0x1d')]);logger['debug'](_0x1e3a('0x1a'),_0xb4efdb,JSON[_0x1e3a('0x10')](_0x3ef133));_0x4a2558(_0x3ef133);})['catch'](function(_0x94aa47){logger['error'](_0x1e3a('0x1a'),_0x94aa47['message'],_0xb4efdb);_0x491d5c(_0x6c8acf['error'](0x1f4,_0x94aa47[_0x1e3a('0x12')]));});});};exports[_0x1e3a('0x1e')]=function(_0x1f5777){var _0x111068=this;return new Promise(function(_0x3ec917,_0x21744f){return db[_0x1e3a('0x3')][_0x1e3a('0x1f')]({'where':_0x1f5777[_0x1e3a('0x6')]?_0x1f5777[_0x1e3a('0x6')][_0x1e3a('0x7')]||null:null})[_0x1e3a('0xd')](function(_0x999d21){logger[_0x1e3a('0x16')](_0x1e3a('0x1e'),_0x1f5777);logger[_0x1e3a('0xf')](_0x1e3a('0x1e'),_0x1f5777,JSON[_0x1e3a('0x10')](_0x999d21));_0x3ec917(_0x999d21);})[_0x1e3a('0x11')](function(_0x339187){logger['error']('DestroyCmHopper',_0x339187['message'],_0x1f5777);_0x21744f(_0x111068[_0x1e3a('0x13')](0x1f4,_0x339187[_0x1e3a('0x12')]));});});};exports[_0x1e3a('0x20')]=function(_0x4dd904){var _0x58ba1f=this;return new Promise(function(_0x5dfa21,_0x36a1fc){return db['CmContact'][_0x1e3a('0x21')]()['then'](function(_0x4dc79d){return db[_0x1e3a('0x22')][_0x1e3a('0x23')](function(_0x3e199f){return db[_0x1e3a('0x3')][_0x1e3a('0x4')]({'where':_0x4dd904[_0x1e3a('0x6')]?_0x4dd904[_0x1e3a('0x6')][_0x1e3a('0x7')]||null:null,'attributes':_0x4dd904[_0x1e3a('0x6')]?_0x4dd904[_0x1e3a('0x6')]['attributes']||null:null,'limit':_0x4dd904[_0x1e3a('0x6')]?_0x4dd904[_0x1e3a('0x6')][_0x1e3a('0x8')]||null:null,'order':_0x4dd904['options']?_0x4dd904['options'][_0x1e3a('0x24')]||null:null,'transaction':_0x3e199f,'lock':_0x3e199f[_0x1e3a('0x25')][_0x1e3a('0x26')],'include':[{'model':db[_0x1e3a('0x27')],'as':_0x1e3a('0x28'),'attributes':_[_0x1e3a('0x29')](_0x4dc79d)},{'model':db[_0x1e3a('0x2a')],'as':_0x1e3a('0x2b'),'attributes':['id',_0x1e3a('0x2c'),_0x1e3a('0x2d')]}]})[_0x1e3a('0xd')](function(_0x246ed6){var _0x31afe6=[];var _0x3ef67b=[];for(var _0x191fc6=0x0;_0x191fc6<_0x246ed6['length'];_0x191fc6+=0x1){var _0x29db2a=_0x246ed6[_0x191fc6]['UserId'];if(_0x29db2a===null){_0x31afe6[_0x1e3a('0x2e')](_0x246ed6[_0x191fc6][_0x1e3a('0x1b')](_0x4dd904[_0x1e3a('0x19')],{'transaction':_0x3e199f}));}else if(!_0x3ef67b[_0x1e3a('0x2f')](_0x29db2a)){_0x3ef67b[_0x1e3a('0x2e')](_0x29db2a);_0x31afe6['push'](_0x246ed6[_0x191fc6][_0x1e3a('0x1b')](_0x4dd904[_0x1e3a('0x19')],{'transaction':_0x3e199f}));}}return BPromise[_0x1e3a('0x30')](_0x31afe6);});})[_0x1e3a('0xd')](function(_0x5a8fbf){logger['info'](_0x1e3a('0x20'),_0x4dd904);if(_0x5a8fbf[_0x1e3a('0x31')]>0x0){logger[_0x1e3a('0x16')](_0x1e3a('0x32'),_0x5a8fbf[0x0]['dataValues']['id'],_0x5a8fbf[0x0][_0x1e3a('0x33')]['ContactId'],_0x5a8fbf[0x0]['dataValues'][_0x1e3a('0x1d')]);}logger[_0x1e3a('0xf')](_0x1e3a('0x20'),_0x4dd904,JSON[_0x1e3a('0x10')](_0x5a8fbf));_0x5dfa21(_0x5a8fbf);})[_0x1e3a('0x11')](function(_0x5936be){logger['error'](_0x1e3a('0x20'),_0x5936be[_0x1e3a('0x12')],_0x4dd904);_0x36a1fc(_0x58ba1f[_0x1e3a('0x13')](0x1f4,_0x5936be[_0x1e3a('0x12')]));});});});};exports[_0x1e3a('0x34')]=function(_0x55c900){var _0x159a16=this;return new Promise(function(_0x6c9595,_0x190b8d){return db[_0x1e3a('0x22')]['transaction'](function(_0x446bff){return db['CmHopperFinal'][_0x1e3a('0x18')](_0x55c900['body'],{'raw':_0x55c900['options']?_0x55c900['options']['raw']===undefined?!![]:![]:!![],'transaction':_0x446bff})[_0x1e3a('0xd')](function(){logger[_0x1e3a('0x16')]('MoveContactManagedDialer\x20hopper\x20options\x20[%s]\x20active\x20status\x20[%s]',JSON[_0x1e3a('0x10')](_0x55c900['options'][_0x1e3a('0x7')]),_0x55c900[_0x1e3a('0x6')][_0x1e3a('0x7')]['active']);return db['CmHopper'][_0x1e3a('0x1f')]({'where':_0x55c900['options']?_0x55c900[_0x1e3a('0x6')]['where']||null:null,'transaction':_0x446bff});});})['then'](function(_0x1491b8){logger['info'](_0x1e3a('0x34'),_0x55c900);logger[_0x1e3a('0xf')](_0x1e3a('0x34'),_0x55c900,JSON[_0x1e3a('0x10')](_0x1491b8));_0x6c9595(_0x1491b8);})[_0x1e3a('0x11')](function(_0x520ef8){logger['error']('MoveContactManagedDialer',_0x520ef8[_0x1e3a('0x12')],_0x55c900);_0x190b8d(_0x159a16[_0x1e3a('0x13')](0x1f4,_0x520ef8[_0x1e3a('0x12')]));});});};exports[_0x1e3a('0x35')]=function(_0x17d0ce){var _0x270c45=this;return new Promise(function(_0x515ac2,_0x33c312){return db[_0x1e3a('0x3')][_0x1e3a('0x4')]({'raw':_0x17d0ce['options']?_0x17d0ce[_0x1e3a('0x6')][_0x1e3a('0x5')]===undefined?!![]:![]:!![],'where':_0x17d0ce[_0x1e3a('0x6')]?_0x17d0ce[_0x1e3a('0x6')][_0x1e3a('0x7')]||null:null,'attributes':[[db['sequelize']['fn'](_0x1e3a('0x36'),db['sequelize']['fn']('IF',db[_0x1e3a('0x22')]['literal'](_0x1e3a('0x37')+util[_0x1e3a('0x38')]('\x22%s\x22',moment()['format']('YYYY-MM-DD\x20HH:mm:ss'))+_0x1e3a('0x39')))),'contactsRescheduled']]})[_0x1e3a('0xd')](function(_0x1e9e9a){logger[_0x1e3a('0x16')](_0x1e3a('0x35'),_0x17d0ce);logger[_0x1e3a('0xf')](_0x1e3a('0x35'),_0x17d0ce,JSON[_0x1e3a('0x10')](_0x1e9e9a));_0x515ac2(_0x1e9e9a);})[_0x1e3a('0x11')](function(_0x168d5d){logger[_0x1e3a('0x13')]('CountReScheduled',_0x168d5d[_0x1e3a('0x12')],_0x17d0ce);_0x33c312(_0x270c45[_0x1e3a('0x13')](0x1f4,_0x168d5d[_0x1e3a('0x12')]));});});};exports['GetContactRecallMe']=function(_0x28e43c){var _0xdaeba=this;return new Promise(function(_0x1f321f,_0x13d86d){return db[_0x1e3a('0x27')][_0x1e3a('0x21')]()[_0x1e3a('0xd')](function(){return db[_0x1e3a('0x22')][_0x1e3a('0x23')](function(_0x26353d){return db[_0x1e3a('0x3')][_0x1e3a('0x4')]({'where':_0x28e43c[_0x1e3a('0x6')]?_0x28e43c[_0x1e3a('0x6')][_0x1e3a('0x7')]||null:null,'attributes':_0x28e43c['options']?_0x28e43c[_0x1e3a('0x6')]['attributes']||null:null,'limit':0x1,'order':_0x28e43c[_0x1e3a('0x6')]?_0x28e43c[_0x1e3a('0x6')][_0x1e3a('0x24')]||null:null,'group':db[_0x1e3a('0x3')][_0x1e3a('0x3a')],'transaction':_0x26353d,'lock':_0x26353d[_0x1e3a('0x25')][_0x1e3a('0x26')],'include':_0x28e43c[_0x1e3a('0x6')]?_0x28e43c['options']['include']?_['map'](_0x28e43c['options'][_0x1e3a('0x9')],function(_0x276b27){return{'model':db[_0x276b27[_0x1e3a('0xb')]],'as':_0x276b27['as'],'attributes':_0x276b27[_0x1e3a('0xc')],'include':_0x276b27[_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x276b27[_0x1e3a('0x9')],function(_0x26dc62){return{'model':db[_0x26dc62['model']],'as':_0x26dc62['as'],'attributes':_0x26dc62[_0x1e3a('0xc')],'include':_0x26dc62[_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x26dc62[_0x1e3a('0x9')],function(_0x17aaba){return{'model':db[_0x17aaba[_0x1e3a('0xb')]],'as':_0x17aaba['as'],'attributes':_0x17aaba[_0x1e3a('0xc')]};}):[]};}):[]};}):[]:[]})[_0x1e3a('0xd')](function(_0xd949d2){var _0x1c5ccb=[];for(var _0x8cc643=0x0;_0x8cc643<_0xd949d2[_0x1e3a('0x31')];_0x8cc643+=0x1){_0x1c5ccb[_0x1e3a('0x2e')](_0xd949d2[_0x8cc643][_0x1e3a('0x1b')](_0x28e43c[_0x1e3a('0x19')],{'transaction':_0x26353d}));}return BPromise['all'](_0x1c5ccb);});})[_0x1e3a('0xd')](function(_0x8d5cb4){logger[_0x1e3a('0x16')](_0x1e3a('0x3b'),_0x28e43c);logger[_0x1e3a('0xf')]('GetContactRecallMe',_0x28e43c,JSON['stringify'](_0x8d5cb4));_0x1f321f(_0x8d5cb4);})[_0x1e3a('0x11')](function(_0x1b7aca){logger[_0x1e3a('0x13')]('GetContactRecallMe',_0x1b7aca[_0x1e3a('0x12')],_0x28e43c);_0x13d86d(_0xdaeba[_0x1e3a('0x13')](0x1f4,_0x1b7aca[_0x1e3a('0x12')]));});});});};exports[_0x1e3a('0x3c')]=function(_0x560b4e){var _0x115d09=this;return new Promise(function(_0x205a5e,_0x28fa78){db[_0x1e3a('0x27')][_0x1e3a('0x21')]()['then'](function(_0x3a6921){return db[_0x1e3a('0x3')][_0x1e3a('0x4')]({'raw':_0x560b4e[_0x1e3a('0x6')]?_0x560b4e[_0x1e3a('0x6')][_0x1e3a('0x5')]===undefined?!![]:![]:!![],'where':_0x560b4e[_0x1e3a('0x6')]?_0x560b4e[_0x1e3a('0x6')][_0x1e3a('0x7')]||null:null,'attributes':_0x560b4e['options']?_0x560b4e[_0x1e3a('0x6')][_0x1e3a('0xc')]||null:null,'limit':_0x560b4e[_0x1e3a('0x6')]?_0x560b4e[_0x1e3a('0x6')][_0x1e3a('0x8')]||null:null,'include':_0x560b4e[_0x1e3a('0x6')]?_0x560b4e[_0x1e3a('0x6')][_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x560b4e[_0x1e3a('0x6')]['include'],function(_0x100eba){return{'model':db[_0x100eba[_0x1e3a('0xb')]],'as':_0x100eba['as'],'attributes':_0x100eba['as']===_0x1e3a('0x28')?_[_0x1e3a('0x29')](_0x3a6921):_0x100eba[_0x1e3a('0xc')],'include':_0x100eba['include']?_[_0x1e3a('0xa')](_0x100eba[_0x1e3a('0x9')],function(_0x5c8b62){return{'model':db[_0x5c8b62[_0x1e3a('0xb')]],'as':_0x5c8b62['as'],'attributes':_0x5c8b62[_0x1e3a('0xc')],'include':_0x5c8b62[_0x1e3a('0x9')]?_[_0x1e3a('0xa')](_0x5c8b62[_0x1e3a('0x9')],function(_0x5600a0){return{'model':db[_0x5600a0['model']],'as':_0x5600a0['as'],'attributes':_0x5600a0['attributes']};}):[]};}):[]};}):[]:[]})[_0x1e3a('0xd')](function(_0xc19fa8){logger['info'](_0x1e3a('0xe'),_0x560b4e);logger[_0x1e3a('0xf')](_0x1e3a('0xe'),_0x560b4e,JSON['stringify'](_0xc19fa8));_0x205a5e(_0xc19fa8);})[_0x1e3a('0x11')](function(_0x505f8f){logger['error']('GetCmHopper',_0x505f8f[_0x1e3a('0x12')],_0x560b4e);_0x28fa78(_0x115d09['error'](0x1f4,_0x505f8f[_0x1e3a('0x12')]));});});});};exports[_0x1e3a('0x3d')]=function(_0x343155){var _0x17a361=this;return new Promise(function(_0x39a7b1,_0x514b10){return db['CmContact'][_0x1e3a('0x3e')]({'raw':!![],'where':{'phone':_0x343155[_0x1e3a('0x6')][_0x1e3a('0x7')][_0x1e3a('0x3f')]},'attributes':['id',_0x1e3a('0x40')],'order':[['id',_0x1e3a('0x41')]]})[_0x1e3a('0xd')](function(_0x3cd9e0){logger[_0x1e3a('0x16')](_0x1e3a('0x42'),_0x343155);logger[_0x1e3a('0xf')](_0x1e3a('0x42'),_0x343155,JSON['stringify'](_0x3cd9e0));_0x39a7b1(_0x3cd9e0);})['catch'](function(_0x1386a6){logger['error'](_0x1e3a('0x42'),_0x1386a6['message'],_0x343155);_0x514b10(_0x17a361[_0x1e3a('0x13')](0x1f4,_0x1386a6['message']));});});};exports['ResetActiveCalls']=function(_0x3afc9b){var _0x12da19=this;return new Promise(function(_0x4e7b12,_0x257b4f){return db[_0x1e3a('0x22')][_0x1e3a('0x23')](function(_0x363506){var _0x38edd2=_0x3afc9b[_0x1e3a('0x6')]&&_0x3afc9b['options']['where']?_0x3afc9b['options'][_0x1e3a('0x7')]:{};return db['CmHopper'][_0x1e3a('0x1b')](_0x3afc9b[_0x1e3a('0x19')],{'where':_0x38edd2,'transaction':_0x363506})['then'](function(_0x4083c0){logger[_0x1e3a('0x16')](_0x1e3a('0x43'),_0x3afc9b);logger[_0x1e3a('0xf')](_0x1e3a('0x43'),_0x3afc9b,JSON[_0x1e3a('0x10')](_0x4083c0));_0x4e7b12(_0x4083c0);})['catch'](function(_0x22b2e8){logger[_0x1e3a('0x13')]('ResetActiveCalls',_0x22b2e8[_0x1e3a('0x12')],_0x3afc9b);_0x257b4f(_0x12da19[_0x1e3a('0x13')](0x1f4,_0x22b2e8[_0x1e3a('0x12')]));});});});};exports[_0x1e3a('0x44')]=function(_0x4accca){var _0x204e10=this;var _0x355d98=_0x4accca['body']['where'][_0x1e3a('0x45')];var _0x4b3a71=_0x4accca[_0x1e3a('0x19')][_0x1e3a('0x7')][_0x1e3a('0x46')];var _0x5c9b14=_0x4accca[_0x1e3a('0x19')][_0x1e3a('0x7')][_0x1e3a('0x47')];return new Promise(function(_0x1c6a9d,_0x45fe5b){return db['CmHopper']['findAll']({'where':{'voiceQueueId':{'$in':_0x355d98},'recallme':0x1,'active':0x0,'recallmeNotifiedDate':{'$eq':null},'scheduledat':{'$and':{'$lte':db[_0x1e3a('0x22')]['literal']('NOW()\x20+\x20INTERVAL\x20'+_0x4b3a71+_0x1e3a('0x48')),'$gt':db[_0x1e3a('0x22')][_0x1e3a('0x49')](_0x1e3a('0x4a'))}},'UserId':{'$in':_0x5c9b14}},'include':[{'model':db[_0x1e3a('0x27')],'as':'Contact'},{'model':db[_0x1e3a('0x2a')],'as':_0x1e3a('0x2b'),'attributes':['id',_0x1e3a('0x2c'),_0x1e3a('0x2d')]},{'model':db['CmList'],'as':_0x1e3a('0x4b')}]})[_0x1e3a('0xd')](function(_0x1ed6ea){if(_0x1ed6ea['length']>0x0){return db[_0x1e3a('0x22')][_0x1e3a('0x23')](function(_0x189845){return db['CmHopper'][_0x1e3a('0x1b')]({'recallmeNotifiedDate':db[_0x1e3a('0x22')][_0x1e3a('0x49')]('NOW()')},{'where':{'id':{'$in':_[_0x1e3a('0xa')](_0x1ed6ea,'id')}},'transaction':_0x189845})[_0x1e3a('0xd')](function(){_0x1c6a9d(_0x1ed6ea);})[_0x1e3a('0x11')](function(_0xac96ac){logger[_0x1e3a('0x13')](_0x1e3a('0x44'),_0xac96ac['message'],_0x4accca);_0x45fe5b(_0x204e10['error'](0x1f4,_0xac96ac[_0x1e3a('0x12')]));});})[_0x1e3a('0x11')](function(_0x360454){logger[_0x1e3a('0x13')](_0x1e3a('0x44'),_0x360454[_0x1e3a('0x12')],_0x4accca);_0x45fe5b(_0x204e10[_0x1e3a('0x13')](0x1f4,_0x360454[_0x1e3a('0x12')]));});}else{_0x1c6a9d(_0x1ed6ea);}});});};