Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / cmHopperFinal / cmHopperFinal.controller.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 _0xf0f5=['squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','destroy','then','error','stack','send','render','merge','body','contact','agent','interaction','account','index','rawAttributes','key','query','intersection','model','attributes','length','nolimit','order','sort','where','filters','pick','filter','map','type','VIRTUAL','name','CmHopperFinal','include','findAll','rows','params','keys','fields','options','find','catch','describe','uniqueid','countContactsQueueCampaignHopperFinal','COUNT','sequelize','literal','`state`\x20=\x200,\x201,\x20null','noSuchContacts','noAnswerContacts','`state`\x20=\x205,\x201,\x20null','busyContacts','`state`\x20=\x208,\x201,\x20null','congestionContacts','`state`\x20=\x2010\x20,\x201,\x20null','dropContacts','`state`\x20=\x2011\x20,\x201,\x20null','abandonedContacts','`state`\x20=\x2022,\x201,\x20null','reCallContacts','countContactsIvrCampaignHopperFinal','`state`\x20=\x203,\x201,\x20null','VoiceQueue','insert','cm_hopper','fromQuery','phone','ContactId','ListId','VoiceQueueId','createdAt','select','ANY_VALUE(calleridnum)','field','NOW()','scheduledAt','ANY_VALUE(ContactId)','ANY_VALUE(ListId)','from','VoiceQueueId\x20=\x20?','state','toString','calleridnum\x20IS\x20NOT\x20NULL','calleridnum\x20NOT\x20IN\x20(?)','cm_hopper_final','state\x20=\x204','group','moveContactsIvrCampaignHopperFinal','Campaign','into','CampaignId','updatedAt','ANY_VALUE(CampaignId)','CampaignId\x20=\x20?','calleridnum','checkContactHopper','CmHopper','findOne','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash'];(function(_0x579484,_0x836196){var _0x239141=function(_0x32c713){while(--_0x32c713){_0x579484['push'](_0x579484['shift']());}};_0x239141(++_0x836196);}(_0xf0f5,0x191));var _0x5f0f=function(_0x2853ce,_0x23f70e){_0x2853ce=_0x2853ce-0x0;var _0x266a31=_0xf0f5[_0x2853ce];return _0x266a31;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5f0f('0x0'));var zipdir=require(_0x5f0f('0x1'));var jsonpatch=require(_0x5f0f('0x2'));var rp=require(_0x5f0f('0x3'));var moment=require(_0x5f0f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x5f0f('0x5'));var util=require(_0x5f0f('0x6'));var path=require(_0x5f0f('0x7'));var sox=require(_0x5f0f('0x8'));var csv=require(_0x5f0f('0x9'));var ejs=require(_0x5f0f('0xa'));var fs=require('fs');var fs_extra=require(_0x5f0f('0xb'));var _=require(_0x5f0f('0xc'));var squel=require(_0x5f0f('0xd'));var crypto=require(_0x5f0f('0xe'));var jsforce=require(_0x5f0f('0xf'));var deskjs=require(_0x5f0f('0x10'));var toCsv=require(_0x5f0f('0x9'));var querystring=require(_0x5f0f('0x11'));var Papa=require('papaparse');var Redis=require(_0x5f0f('0x12'));var authService=require(_0x5f0f('0x13'));var qs=require(_0x5f0f('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x5f0f('0x15'));var utils=require(_0x5f0f('0x16'));var config=require(_0x5f0f('0x17'));var licenseUtil=require(_0x5f0f('0x18'));var db=require(_0x5f0f('0x19'))['db'];function respondWithStatusCode(_0x4fe42a,_0x44081a){_0x44081a=_0x44081a||0xcc;return function(_0x555b25){if(_0x555b25){return _0x4fe42a[_0x5f0f('0x1a')](_0x44081a);}return _0x4fe42a[_0x5f0f('0x1b')](_0x44081a)[_0x5f0f('0x1c')]();};}function respondWithResult(_0x285769,_0x3c3977){_0x3c3977=_0x3c3977||0xc8;return function(_0x2e536d){if(_0x2e536d){return _0x285769[_0x5f0f('0x1b')](_0x3c3977)[_0x5f0f('0x1d')](_0x2e536d);}};}function respondWithFilteredResult(_0x42b4fd,_0x21c084){return function(_0x93919b){if(_0x93919b){var _0x10e0c4=typeof _0x21c084[_0x5f0f('0x1e')]===_0x5f0f('0x1f')&&typeof _0x21c084['limit']==='undefined';var _0x11aa58=_0x93919b[_0x5f0f('0x20')];var _0x24dda3=_0x10e0c4?0x0:_0x21c084[_0x5f0f('0x1e')];var _0x2846c0=_0x10e0c4?_0x93919b['count']:_0x21c084[_0x5f0f('0x1e')]+_0x21c084[_0x5f0f('0x21')];var _0x478c41;if(_0x2846c0>=_0x11aa58){_0x2846c0=_0x11aa58;_0x478c41=0xc8;}else{_0x478c41=0xce;}_0x42b4fd[_0x5f0f('0x1b')](_0x478c41);return _0x42b4fd[_0x5f0f('0x22')](_0x5f0f('0x23'),_0x24dda3+'-'+_0x2846c0+'/'+_0x11aa58)['json'](_0x93919b);}return null;};}function patchUpdates(_0x4fea2a){return function(_0x34f064){try{jsonpatch[_0x5f0f('0x24')](_0x34f064,_0x4fea2a,!![]);}catch(_0x15e2d8){return BPromise[_0x5f0f('0x25')](_0x15e2d8);}return _0x34f064[_0x5f0f('0x26')]();};}function saveUpdates(_0x530cdb,_0x312edb){return function(_0xa32bd6){if(_0xa32bd6){return _0xa32bd6[_0x5f0f('0x27')](_0x530cdb)['then'](function(_0x333ad6){return _0x333ad6;});}return null;};}function removeEntity(_0x1a40da,_0x1647fe){return function(_0x51872b){if(_0x51872b){return _0x51872b[_0x5f0f('0x28')]()[_0x5f0f('0x29')](function(){_0x1a40da[_0x5f0f('0x1b')](0xcc)[_0x5f0f('0x1c')]();});}};}function handleEntityNotFound(_0xa92154,_0x28c2c9){return function(_0x3d2fcb){if(!_0x3d2fcb){_0xa92154[_0x5f0f('0x1a')](0x194);}return _0x3d2fcb;};}function handleError(_0x235d69,_0x4aca87){_0x4aca87=_0x4aca87||0x1f4;return function(_0x34d9e3){logger[_0x5f0f('0x2a')](_0x34d9e3[_0x5f0f('0x2b')]);if(_0x34d9e3['name']){delete _0x34d9e3['name'];}_0x235d69[_0x5f0f('0x1b')](_0x4aca87)[_0x5f0f('0x2c')](_0x34d9e3);};}function getMustacheRender(_0x4da0f7,_0x486637){return Mustache[_0x5f0f('0x2d')](_0x4da0f7,_[_0x5f0f('0x2e')](_0x486637[_0x5f0f('0x2f')],{'contact':_0x486637[_0x5f0f('0x30')],'message':_0x486637['message'],'agent':_0x486637[_0x5f0f('0x31')],'interaction':_0x486637[_0x5f0f('0x32')],'account':_0x486637[_0x5f0f('0x33')]}))||'';}exports[_0x5f0f('0x34')]=function(_0x4ce9b5,_0x3527cc){var _0x519c90={},_0x4ec22c={},_0x4af07a={'count':0x0,'rows':[]};var _0x2b382a=_['map'](db['CmHopperFinal'][_0x5f0f('0x35')],function(_0x3b156f){return{'name':_0x3b156f['fieldName'],'type':_0x3b156f['type'][_0x5f0f('0x36')]};});_0x4ec22c['model']=_['map'](_0x2b382a,'name');_0x4ec22c[_0x5f0f('0x37')]=_['keys'](_0x4ce9b5[_0x5f0f('0x37')]);_0x4ec22c['filters']=_[_0x5f0f('0x38')](_0x4ec22c[_0x5f0f('0x39')],_0x4ec22c[_0x5f0f('0x37')]);_0x519c90['attributes']=_[_0x5f0f('0x38')](_0x4ec22c[_0x5f0f('0x39')],qs['fields'](_0x4ce9b5['query']['fields']));_0x519c90[_0x5f0f('0x3a')]=_0x519c90['attributes'][_0x5f0f('0x3b')]?_0x519c90['attributes']:_0x4ec22c['model'];if(!_0x4ce9b5[_0x5f0f('0x37')]['hasOwnProperty'](_0x5f0f('0x3c'))){_0x519c90[_0x5f0f('0x21')]=qs['limit'](_0x4ce9b5[_0x5f0f('0x37')][_0x5f0f('0x21')]);_0x519c90[_0x5f0f('0x1e')]=qs[_0x5f0f('0x1e')](_0x4ce9b5['query'][_0x5f0f('0x1e')]);}_0x519c90[_0x5f0f('0x3d')]=qs['sort'](_0x4ce9b5[_0x5f0f('0x37')][_0x5f0f('0x3e')]);_0x519c90[_0x5f0f('0x3f')]=qs[_0x5f0f('0x40')](_[_0x5f0f('0x41')](_0x4ce9b5[_0x5f0f('0x37')],_0x4ec22c[_0x5f0f('0x40')]),_0x2b382a);if(_0x4ce9b5[_0x5f0f('0x37')][_0x5f0f('0x42')]){_0x519c90[_0x5f0f('0x3f')]=_['merge'](_0x519c90[_0x5f0f('0x3f')],{'$or':_[_0x5f0f('0x43')](_0x2b382a,function(_0x1125fd){if(_0x1125fd[_0x5f0f('0x44')]!==_0x5f0f('0x45')){var _0x380b92={};_0x380b92[_0x1125fd[_0x5f0f('0x46')]]={'$like':'%'+_0x4ce9b5[_0x5f0f('0x37')][_0x5f0f('0x42')]+'%'};return _0x380b92;}})});}_0x519c90=_['merge']({},_0x519c90,_0x4ce9b5['options']);var _0x5a4293={'where':_0x519c90['where']};return db[_0x5f0f('0x47')][_0x5f0f('0x20')](_0x5a4293)['then'](function(_0xcf3c4f){_0x4af07a[_0x5f0f('0x20')]=_0xcf3c4f;if(_0x4ce9b5[_0x5f0f('0x37')]['includeAll']){_0x519c90[_0x5f0f('0x48')]=[{'all':!![]}];}return db['CmHopperFinal'][_0x5f0f('0x49')](_0x519c90);})[_0x5f0f('0x29')](function(_0x3aa1b4){_0x4af07a[_0x5f0f('0x4a')]=_0x3aa1b4;return _0x4af07a;})[_0x5f0f('0x29')](respondWithFilteredResult(_0x3527cc,_0x519c90))['catch'](handleError(_0x3527cc,null));};exports['show']=function(_0x1cb317,_0x27a7fc){var _0x59006f={'raw':!![],'where':{'id':_0x1cb317[_0x5f0f('0x4b')]['id']}},_0x293004={};_0x293004[_0x5f0f('0x39')]=_['keys'](db[_0x5f0f('0x47')][_0x5f0f('0x35')]);_0x293004[_0x5f0f('0x37')]=_[_0x5f0f('0x4c')](_0x1cb317[_0x5f0f('0x37')]);_0x293004['filters']=_['intersection'](_0x293004[_0x5f0f('0x39')],_0x293004[_0x5f0f('0x37')]);_0x59006f[_0x5f0f('0x3a')]=_['intersection'](_0x293004[_0x5f0f('0x39')],qs[_0x5f0f('0x4d')](_0x1cb317[_0x5f0f('0x37')][_0x5f0f('0x4d')]));_0x59006f[_0x5f0f('0x3a')]=_0x59006f[_0x5f0f('0x3a')][_0x5f0f('0x3b')]?_0x59006f[_0x5f0f('0x3a')]:_0x293004[_0x5f0f('0x39')];if(_0x1cb317[_0x5f0f('0x37')]['includeAll']){_0x59006f['include']=[{'all':!![]}];}_0x59006f=_[_0x5f0f('0x2e')]({},_0x59006f,_0x1cb317[_0x5f0f('0x4e')]);return db[_0x5f0f('0x47')][_0x5f0f('0x4f')](_0x59006f)['then'](handleEntityNotFound(_0x27a7fc,null))['then'](respondWithResult(_0x27a7fc,null))[_0x5f0f('0x50')](handleError(_0x27a7fc,null));};exports[_0x5f0f('0x51')]=function(_0x8c7c38,_0x27e684){return db[_0x5f0f('0x47')][_0x5f0f('0x51')]()['then'](respondWithResult(_0x27e684,null))[_0x5f0f('0x50')](handleError(_0x27e684,null));};exports[_0x5f0f('0x27')]=function(_0x3d3eb5,_0x159ad5){if(_0x3d3eb5[_0x5f0f('0x2f')][_0x5f0f('0x52')]){delete _0x3d3eb5[_0x5f0f('0x2f')]['uniqueid'];}return db[_0x5f0f('0x47')][_0x5f0f('0x4f')]({'where':{'uniqueid':_0x3d3eb5[_0x5f0f('0x4b')]['id']}})[_0x5f0f('0x29')](handleEntityNotFound(_0x159ad5,null))[_0x5f0f('0x29')](saveUpdates(_0x3d3eb5[_0x5f0f('0x2f')],null))[_0x5f0f('0x29')](respondWithResult(_0x159ad5,null))['catch'](handleError(_0x159ad5,null));};exports[_0x5f0f('0x53')]=function(_0x400252,_0x486ac8,_0x2f27d5){return db['CmHopperFinal'][_0x5f0f('0x49')]({'raw':![],'where':{'VoiceQueueId':_0x400252[_0x5f0f('0x4b')]['id']},'attributes':[[db['sequelize']['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x57')))),_0x5f0f('0x58')],[db[_0x5f0f('0x55')]['fn']('COUNT',db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')]('`state`\x20=\x203,\x201,\x20null'))),_0x5f0f('0x59')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x5a')))),_0x5f0f('0x5b')],[db['sequelize']['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x5c')))),_0x5f0f('0x5d')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x5e')))),_0x5f0f('0x5f')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x60')))),_0x5f0f('0x61')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x62')))),_0x5f0f('0x63')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')]('`state`\x20=\x2019,\x201,\x20null'))),'answeringMachine']]})[_0x5f0f('0x29')](handleEntityNotFound(_0x486ac8,null))[_0x5f0f('0x29')](respondWithResult(_0x486ac8,null))[_0x5f0f('0x50')](handleError(_0x486ac8,null));};exports[_0x5f0f('0x64')]=function(_0x383330,_0xfbba45,_0x16b7b7){return db[_0x5f0f('0x47')][_0x5f0f('0x49')]({'raw':![],'where':{'CampaignId':_0x383330[_0x5f0f('0x4b')]['id']},'attributes':[[db['sequelize']['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')]['literal'](_0x5f0f('0x57')))),_0x5f0f('0x58')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x65')))),_0x5f0f('0x59')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db['sequelize'][_0x5f0f('0x56')]('`state`\x20=\x205,\x201,\x20null'))),_0x5f0f('0x5b')],[db['sequelize']['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x5c')))),_0x5f0f('0x5d')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x5e')))),_0x5f0f('0x5f')],[db['sequelize']['fn']('COUNT',db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x60')))),_0x5f0f('0x61')],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')](_0x5f0f('0x62')))),'reCallContacts'],[db[_0x5f0f('0x55')]['fn'](_0x5f0f('0x54'),db[_0x5f0f('0x55')]['fn']('IF',db[_0x5f0f('0x55')][_0x5f0f('0x56')]('`state`\x20=\x2019,\x201,\x20null'))),'answeringMachine']]})[_0x5f0f('0x29')](handleEntityNotFound(_0xfbba45,null))[_0x5f0f('0x29')](respondWithResult(_0xfbba45,null))[_0x5f0f('0x50')](handleError(_0xfbba45,null));};exports['moveContactsQueueCampaignHopperFinal']=function(_0x442ffc,_0x284526,_0x56b281){return db[_0x5f0f('0x66')][_0x5f0f('0x4f')]({'where':{'id':_0x442ffc[_0x5f0f('0x4b')]['id']}})[_0x5f0f('0x29')](handleEntityNotFound(_0x284526,null))[_0x5f0f('0x29')](function(_0x3c7be7){var _0x368aff;if(_0x3c7be7){_0x368aff=squel[_0x5f0f('0x67')]()['into'](_0x5f0f('0x68'))[_0x5f0f('0x69')]([_0x5f0f('0x6a'),'scheduledAt',_0x5f0f('0x6b'),_0x5f0f('0x6c'),_0x5f0f('0x6d'),_0x5f0f('0x6e'),'updatedAt'],squel[_0x5f0f('0x6f')]()['field'](_0x5f0f('0x70'),_0x5f0f('0x6a'))[_0x5f0f('0x71')](_0x5f0f('0x72'),_0x5f0f('0x73'))[_0x5f0f('0x71')](_0x5f0f('0x74'),'ContactId')[_0x5f0f('0x71')](_0x5f0f('0x75'),_0x5f0f('0x6c'))[_0x5f0f('0x71')]('ANY_VALUE(VoiceQueueId)',_0x5f0f('0x6d'))['field'](_0x5f0f('0x72'),'createdAt')[_0x5f0f('0x71')](_0x5f0f('0x72'),'updatedAt')[_0x5f0f('0x76')]('cm_hopper_final')[_0x5f0f('0x3f')](_0x5f0f('0x77'),_0x442ffc[_0x5f0f('0x4b')]['id']['toString']())[_0x5f0f('0x3f')]('state\x20=\x20?',_0x442ffc[_0x5f0f('0x2f')][_0x5f0f('0x78')][_0x5f0f('0x79')]())[_0x5f0f('0x3f')](_0x5f0f('0x7a'))[_0x5f0f('0x3f')](_0x5f0f('0x7b'),squel[_0x5f0f('0x6f')]()[_0x5f0f('0x71')](_0x5f0f('0x6a'))[_0x5f0f('0x76')](_0x5f0f('0x68'))[_0x5f0f('0x3f')](_0x5f0f('0x77'),_0x442ffc[_0x5f0f('0x4b')]['id']['toString']()))['where'](_0x5f0f('0x7b'),squel['select']()[_0x5f0f('0x71')]('calleridnum')[_0x5f0f('0x76')](_0x5f0f('0x7c'))[_0x5f0f('0x3f')](_0x5f0f('0x77'),_0x442ffc[_0x5f0f('0x4b')]['id'][_0x5f0f('0x79')]())[_0x5f0f('0x3f')](_0x5f0f('0x7d')))[_0x5f0f('0x7e')](_0x5f0f('0x6b')))['toString']();return db['sequelize'][_0x5f0f('0x37')](_0x368aff);}return[];})[_0x5f0f('0x29')](respondWithResult(_0x284526,null))[_0x5f0f('0x50')](handleError(_0x284526,null));};exports[_0x5f0f('0x7f')]=function(_0x36e9eb,_0x50bd26,_0xc53547){return db[_0x5f0f('0x80')][_0x5f0f('0x4f')]({'where':{'id':_0x36e9eb[_0x5f0f('0x4b')]['id']}})[_0x5f0f('0x29')](handleEntityNotFound(_0x50bd26,null))[_0x5f0f('0x29')](function(_0x59728d){var _0x508f41;if(_0x59728d){_0x508f41=squel['insert']()[_0x5f0f('0x81')](_0x5f0f('0x68'))[_0x5f0f('0x69')]([_0x5f0f('0x6a'),_0x5f0f('0x73'),_0x5f0f('0x6b'),_0x5f0f('0x6c'),_0x5f0f('0x82'),_0x5f0f('0x6e'),_0x5f0f('0x83')],squel[_0x5f0f('0x6f')]()['field'](_0x5f0f('0x70'),_0x5f0f('0x6a'))[_0x5f0f('0x71')](_0x5f0f('0x72'),'scheduledAt')[_0x5f0f('0x71')](_0x5f0f('0x74'),'ContactId')[_0x5f0f('0x71')](_0x5f0f('0x75'),'ListId')[_0x5f0f('0x71')](_0x5f0f('0x84'),_0x5f0f('0x82'))[_0x5f0f('0x71')](_0x5f0f('0x72'),_0x5f0f('0x6e'))[_0x5f0f('0x71')]('NOW()',_0x5f0f('0x83'))[_0x5f0f('0x76')]('cm_hopper_final')[_0x5f0f('0x3f')](_0x5f0f('0x85'),_0x36e9eb[_0x5f0f('0x4b')]['id'][_0x5f0f('0x79')]())[_0x5f0f('0x3f')]('state\x20=\x20?',_0x36e9eb[_0x5f0f('0x2f')][_0x5f0f('0x78')]['toString']())['where']('calleridnum\x20IS\x20NOT\x20NULL')[_0x5f0f('0x3f')](_0x5f0f('0x7b'),squel[_0x5f0f('0x6f')]()[_0x5f0f('0x71')](_0x5f0f('0x6a'))[_0x5f0f('0x76')](_0x5f0f('0x68'))['where'](_0x5f0f('0x85'),_0x36e9eb[_0x5f0f('0x4b')]['id'][_0x5f0f('0x79')]()))[_0x5f0f('0x3f')](_0x5f0f('0x7b'),squel[_0x5f0f('0x6f')]()['field'](_0x5f0f('0x86'))[_0x5f0f('0x76')](_0x5f0f('0x7c'))[_0x5f0f('0x3f')](_0x5f0f('0x85'),_0x36e9eb[_0x5f0f('0x4b')]['id']['toString']())[_0x5f0f('0x3f')](_0x5f0f('0x7d')))[_0x5f0f('0x7e')](_0x5f0f('0x6b')))[_0x5f0f('0x79')]();return db[_0x5f0f('0x55')][_0x5f0f('0x37')](_0x508f41);}return[];})[_0x5f0f('0x29')](respondWithResult(_0x50bd26,null))[_0x5f0f('0x50')](handleError(_0x50bd26,null));};exports[_0x5f0f('0x87')]=function(_0x49de21,_0x3dd91b,_0xe72ccd){return db[_0x5f0f('0x88')][_0x5f0f('0x89')]({'where':{'VoiceQueueId':_0x49de21[_0x5f0f('0x2f')]['VoiceQueueId'],'CampaignId':_0x49de21[_0x5f0f('0x2f')][_0x5f0f('0x82')],'ContactId':_0x49de21[_0x5f0f('0x2f')][_0x5f0f('0x6b')]}})['then'](handleEntityNotFound(_0x3dd91b,null))['then'](function(_0x4de847){if(_0x4de847){return _0x4de847;}return null;})[_0x5f0f('0x29')](respondWithResult(_0x3dd91b,null))[_0x5f0f('0x50')](handleError(_0x3dd91b,null));};