bcc5953109de604da5251b22cc37da99cc0c512f
[motion2.git] / server / api / voicePrefix / voicePrefix.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 _0xc6cb=['defaults','redis','localhost','socket.io-emitter','./voicePrefix.socket','register','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','VoicePrefixes','sendStatus','error','name','send','index','map','fieldName','type','key','model','keys','query','intersection','attributes','fields','length','order','sort','where','filters','merge','VIRTUAL','filter','options','VoicePrefix','includeAll','include','findAll','rows','show','params','find','catch','describe','create','sequelize','VoiceExtension','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','context','from-sip','exten','app','system','description','Voice\x20Prefix\x20Extension','priority','appdata','NoOp','Voice\x20Prefix','VoiceExtensionId','bulkCreate','Extensions\x20creation\x20failed','prefix','push','Set','PREFIX-CALLERIDALL=','callerIdAll','No\x20callerid\x20available','goto','charAt','system-','addAgents','body','omit','spread','ids','emit','removeAgents','isArray','userVoicePrefix:remove','getAgents','findOne','User','rawAttributes','pick','hasOwnProperty','nolimit','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb'];(function(_0x4398a2,_0x432a25){var _0x239463=function(_0x5e9ec8){while(--_0x5e9ec8){_0x4398a2['push'](_0x4398a2['shift']());}};_0x239463(++_0x432a25);}(_0xc6cb,0x162));var _0xbc6c=function(_0x59b565,_0x1fbcee){_0x59b565=_0x59b565-0x0;var _0x32aea8=_0xc6cb[_0x59b565];return _0x32aea8;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xbc6c('0x0'));var rimraf=require(_0xbc6c('0x1'));var zipdir=require(_0xbc6c('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xbc6c('0x3'));var BPromise=require(_0xbc6c('0x4'));var Mustache=require(_0xbc6c('0x5'));var util=require(_0xbc6c('0x6'));var path=require(_0xbc6c('0x7'));var sox=require(_0xbc6c('0x8'));var csv=require('to-csv');var ejs=require(_0xbc6c('0x9'));var fs=require('fs');var _=require(_0xbc6c('0xa'));var squel=require(_0xbc6c('0xb'));var crypto=require(_0xbc6c('0xc'));var jsforce=require(_0xbc6c('0xd'));var deskjs=require(_0xbc6c('0xe'));var toCsv=require('to-csv');var querystring=require(_0xbc6c('0xf'));var Papa=require('papaparse');var Redis=require(_0xbc6c('0x10'));var authService=require(_0xbc6c('0x11'));var qs=require(_0xbc6c('0x12'));var as=require(_0xbc6c('0x13'));var hardwareService=require(_0xbc6c('0x14'));var logger=require(_0xbc6c('0x15'))('api');var utils=require(_0xbc6c('0x16'));var config=require('../../config/environment');var db=require(_0xbc6c('0x17'))['db'];config['redis']=_[_0xbc6c('0x18')](config[_0xbc6c('0x19')],{'host':_0xbc6c('0x1a'),'port':0x18eb});var socket=require(_0xbc6c('0x1b'))(new Redis(config['redis']));require(_0xbc6c('0x1c'))[_0xbc6c('0x1d')](socket);function respondWithStatusCode(_0x57eb0d,_0x15a06f){_0x15a06f=_0x15a06f||0xcc;return function(_0x2a3d7d){if(_0x2a3d7d){return _0x57eb0d['sendStatus'](_0x15a06f);}return _0x57eb0d[_0xbc6c('0x1e')](_0x15a06f)[_0xbc6c('0x1f')]();};}function respondWithResult(_0x57c819,_0x2b585d){_0x2b585d=_0x2b585d||0xc8;return function(_0xfa2e69){if(_0xfa2e69){return _0x57c819['status'](_0x2b585d)[_0xbc6c('0x20')](_0xfa2e69);}};}function respondWithFilteredResult(_0x4ab816,_0x839c09){return function(_0x4ebe37){if(_0x4ebe37){var _0x39e200=_0x4ebe37[_0xbc6c('0x21')],_0x2baf03=_0x839c09[_0xbc6c('0x22')],_0x367cf5=_0x839c09[_0xbc6c('0x22')]+_0x839c09[_0xbc6c('0x23')],_0x282436;if(_0x367cf5>=_0x39e200){_0x367cf5=_0x39e200;_0x282436=0xc8;}else{_0x282436=0xce;}_0x4ab816['status'](_0x282436);return _0x4ab816[_0xbc6c('0x24')](_0xbc6c('0x25'),_0x2baf03+'-'+_0x367cf5+'/'+_0x39e200)[_0xbc6c('0x20')](_0x4ebe37);}return null;};}function patchUpdates(_0x56af9d){return function(_0x1b33bb){try{jsonpatch[_0xbc6c('0x26')](_0x1b33bb,_0x56af9d,!![]);}catch(_0x118ec9){return BPromise[_0xbc6c('0x27')](_0x118ec9);}return _0x1b33bb[_0xbc6c('0x28')]();};}function saveUpdates(_0x5c3078,_0x48dc1d){return function(_0x36060f){if(_0x36060f){return _0x36060f[_0xbc6c('0x29')](_0x5c3078)[_0xbc6c('0x2a')](function(_0x3d9514){return _0x3d9514;});}return null;};}function removeEntity(_0x14f3f1,_0x41db5b){return function(_0xb63826){if(_0xb63826){return _0xb63826[_0xbc6c('0x2b')]()['then'](function(){var _0x4c00ac=_0xb63826[_0xbc6c('0x2c')]({'plain':!![]});var _0x127577=_0xbc6c('0x2d');return db['UserProfileResource'][_0xbc6c('0x2b')]({'where':{'type':_0x127577,'resourceId':_0x4c00ac['id']}})[_0xbc6c('0x2a')](function(){return _0xb63826;});})['then'](function(){_0x14f3f1[_0xbc6c('0x1e')](0xcc)[_0xbc6c('0x1f')]();});}};}function handleEntityNotFound(_0x535804,_0x2ca85d){return function(_0x37f81c){if(!_0x37f81c){_0x535804[_0xbc6c('0x2e')](0x194);}return _0x37f81c;};}function handleError(_0x376eab,_0x339e90){_0x339e90=_0x339e90||0x1f4;return function(_0x21e3fd){logger[_0xbc6c('0x2f')](_0x21e3fd['stack']);if(_0x21e3fd[_0xbc6c('0x30')]){delete _0x21e3fd['name'];}_0x376eab[_0xbc6c('0x1e')](_0x339e90)[_0xbc6c('0x31')](_0x21e3fd);};}exports[_0xbc6c('0x32')]=function(_0x5ade0d,_0x337f78){var _0x22aefb={},_0x3676a4={},_0x5a822c={'count':0x0,'rows':[]};var _0x3f580d=_[_0xbc6c('0x33')](db['VoicePrefix']['rawAttributes'],function(_0x4a0b77){return{'name':_0x4a0b77[_0xbc6c('0x34')],'type':_0x4a0b77[_0xbc6c('0x35')][_0xbc6c('0x36')]};});_0x3676a4[_0xbc6c('0x37')]=_[_0xbc6c('0x33')](_0x3f580d,'name');_0x3676a4['query']=_[_0xbc6c('0x38')](_0x5ade0d[_0xbc6c('0x39')]);_0x3676a4['filters']=_[_0xbc6c('0x3a')](_0x3676a4[_0xbc6c('0x37')],_0x3676a4['query']);_0x22aefb[_0xbc6c('0x3b')]=_[_0xbc6c('0x3a')](_0x3676a4['model'],qs[_0xbc6c('0x3c')](_0x5ade0d[_0xbc6c('0x39')][_0xbc6c('0x3c')]));_0x22aefb[_0xbc6c('0x3b')]=_0x22aefb[_0xbc6c('0x3b')][_0xbc6c('0x3d')]?_0x22aefb[_0xbc6c('0x3b')]:_0x3676a4['model'];if(!_0x5ade0d[_0xbc6c('0x39')]['hasOwnProperty']('nolimit')){_0x22aefb[_0xbc6c('0x23')]=qs[_0xbc6c('0x23')](_0x5ade0d['query']['limit']);_0x22aefb[_0xbc6c('0x22')]=qs[_0xbc6c('0x22')](_0x5ade0d['query'][_0xbc6c('0x22')]);}_0x22aefb[_0xbc6c('0x3e')]=qs[_0xbc6c('0x3f')](_0x5ade0d[_0xbc6c('0x39')]['sort']);_0x22aefb[_0xbc6c('0x40')]=qs['filters'](_['pick'](_0x5ade0d[_0xbc6c('0x39')],_0x3676a4[_0xbc6c('0x41')]),_0x3f580d);if(_0x5ade0d[_0xbc6c('0x39')]['filter']){_0x22aefb[_0xbc6c('0x40')]=_[_0xbc6c('0x42')](_0x22aefb['where'],{'$or':_[_0xbc6c('0x33')](_0x3f580d,function(_0x3535ac){if(_0x3535ac['type']!==_0xbc6c('0x43')){var _0x44f775={};_0x44f775[_0x3535ac[_0xbc6c('0x30')]]={'$like':'%'+_0x5ade0d['query'][_0xbc6c('0x44')]+'%'};return _0x44f775;}})});}_0x22aefb=_[_0xbc6c('0x42')]({},_0x22aefb,_0x5ade0d[_0xbc6c('0x45')]);var _0x4c32d8={'where':_0x22aefb[_0xbc6c('0x40')]};return db[_0xbc6c('0x46')][_0xbc6c('0x21')](_0x4c32d8)[_0xbc6c('0x2a')](function(_0x24c5c7){_0x5a822c[_0xbc6c('0x21')]=_0x24c5c7;if(_0x5ade0d[_0xbc6c('0x39')][_0xbc6c('0x47')]){_0x22aefb[_0xbc6c('0x48')]=[{'all':!![]}];}return db['VoicePrefix'][_0xbc6c('0x49')](_0x22aefb);})['then'](function(_0xb2319d){_0x5a822c[_0xbc6c('0x4a')]=_0xb2319d;return _0x5a822c;})[_0xbc6c('0x2a')](respondWithFilteredResult(_0x337f78,_0x22aefb))['catch'](handleError(_0x337f78,null));};exports[_0xbc6c('0x4b')]=function(_0x193ef2,_0x2f6663){var _0x5a4a9a={'raw':![],'where':{'id':_0x193ef2[_0xbc6c('0x4c')]['id']}},_0x22d5cf={};_0x22d5cf[_0xbc6c('0x37')]=_[_0xbc6c('0x38')](db[_0xbc6c('0x46')]['rawAttributes']);_0x22d5cf[_0xbc6c('0x39')]=_[_0xbc6c('0x38')](_0x193ef2[_0xbc6c('0x39')]);_0x22d5cf[_0xbc6c('0x41')]=_[_0xbc6c('0x3a')](_0x22d5cf[_0xbc6c('0x37')],_0x22d5cf[_0xbc6c('0x39')]);_0x5a4a9a[_0xbc6c('0x3b')]=_[_0xbc6c('0x3a')](_0x22d5cf[_0xbc6c('0x37')],qs[_0xbc6c('0x3c')](_0x193ef2[_0xbc6c('0x39')]['fields']));_0x5a4a9a[_0xbc6c('0x3b')]=_0x5a4a9a[_0xbc6c('0x3b')]['length']?_0x5a4a9a[_0xbc6c('0x3b')]:_0x22d5cf[_0xbc6c('0x37')];if(_0x193ef2[_0xbc6c('0x39')]['includeAll']){_0x5a4a9a['include']=[{'all':!![]}];}_0x5a4a9a=_[_0xbc6c('0x42')]({},_0x5a4a9a,_0x193ef2[_0xbc6c('0x45')]);return db[_0xbc6c('0x46')][_0xbc6c('0x4d')](_0x5a4a9a)[_0xbc6c('0x2a')](handleEntityNotFound(_0x2f6663,null))[_0xbc6c('0x2a')](respondWithResult(_0x2f6663,null))[_0xbc6c('0x4e')](handleError(_0x2f6663,null));};exports['destroy']=function(_0x3467fd,_0x2a67ac){return db['VoicePrefix']['find']({'where':{'id':_0x3467fd[_0xbc6c('0x4c')]['id']}})[_0xbc6c('0x2a')](handleEntityNotFound(_0x2a67ac,null))['then'](removeEntity(_0x2a67ac,null))[_0xbc6c('0x4e')](handleError(_0x2a67ac,null));};exports[_0xbc6c('0x4f')]=function(_0x353647,_0xf45a4a){return db[_0xbc6c('0x46')][_0xbc6c('0x4f')]()[_0xbc6c('0x2a')](respondWithResult(_0xf45a4a,null))['catch'](handleError(_0xf45a4a,null));};exports[_0xbc6c('0x50')]=function(_0x1cfeb9,_0x4000c5){var _0x54c6d7;return db[_0xbc6c('0x51')]['transaction'](function(_0xd892a5){return db[_0xbc6c('0x46')][_0xbc6c('0x50')](_0x1cfeb9['body'],{'transaction':_0xd892a5})[_0xbc6c('0x2a')](function(_0x39932a){_0x54c6d7=_0x39932a[_0xbc6c('0x2c')]({'plain':!![]});return db[_0xbc6c('0x52')][_0xbc6c('0x4d')]({'where':{'id':_0x54c6d7['VoiceExtensionId']},'raw':!![]})[_0xbc6c('0x2a')](function(_0x56496b){return createVoicePrefixExtensions(_0x54c6d7,_0x56496b,_0xd892a5);});});})['then'](function(){var _0x3e16ee=_0x1cfeb9['user']['get']({'plain':!![]});if(!_0x3e16ee)throw new Error(_0xbc6c('0x53'));if(_0x3e16ee['role']===_0xbc6c('0x54')){var _0x87cc36=_0x54c6d7;return db[_0xbc6c('0x55')][_0xbc6c('0x4d')]({'where':{'name':_0xbc6c('0x2d'),'userProfileId':_0x3e16ee['userProfileId']},'raw':!![]})[_0xbc6c('0x2a')](function(_0x101d42){if(_0x101d42&&_0x101d42[_0xbc6c('0x56')]===0x0){return db['UserProfileResource'][_0xbc6c('0x50')]({'name':_0x87cc36[_0xbc6c('0x30')],'resourceId':_0x87cc36['id'],'type':_0x101d42[_0xbc6c('0x30')],'sectionId':_0x101d42['id']},{})['then'](function(){return _0x54c6d7;});}else{return _0x54c6d7;}})[_0xbc6c('0x4e')](function(_0x1cbf0c){logger[_0xbc6c('0x2f')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1cbf0c);throw _0x1cbf0c;});}return _0x54c6d7;})[_0xbc6c('0x2a')](respondWithResult(_0x4000c5,null))[_0xbc6c('0x4e')](handleError(_0x4000c5,null));};function Extension(_0x58c763,_0x1eb879,_0x5aa9ad,_0x2ae6ae){this[_0xbc6c('0x57')]=_0xbc6c('0x58');this[_0xbc6c('0x59')]=_0x58c763;this[_0xbc6c('0x5a')]=_0x5aa9ad;this['type']=_0xbc6c('0x5b');this[_0xbc6c('0x5c')]=_0xbc6c('0x5d');this[_0xbc6c('0x5e')]=_0x1eb879;this[_0xbc6c('0x5f')]=_0x2ae6ae;}function createVoicePrefixExtensions(_0x23f97d,_0x3b39f4,_0x4ebf52){return new BPromise(function(_0x37e7e0,_0x1b6326){var _0x228abf=new Extension(formatPrefixName(_0x23f97d['prefix']),0x1,_0xbc6c('0x60'),_0xbc6c('0x61'));_0x228abf['VoicePrefixId']=_0x23f97d['id'];return db['VoiceExtension']['create'](_0x228abf,{'transaction':_0x4ebf52})[_0xbc6c('0x2a')](function(_0x5e081d){var _0x3178db=_0x5e081d['get']({'plain':!![]});var _0x3ce2c1=_[_0xbc6c('0x33')](addVoicePrefixExtensions(_0x23f97d,_0x3b39f4),function(_0x41bca2){_0x41bca2[_0xbc6c('0x62')]=_0x3178db['id'];_0x41bca2['VoicePrefixId']=_0x23f97d['id'];return _0x41bca2;});return db[_0xbc6c('0x52')][_0xbc6c('0x63')](_0x3ce2c1,{'transaction':_0x4ebf52})[_0xbc6c('0x2a')](function(_0x1c0e24){if(!_0x1c0e24){return _0x1b6326(_0xbc6c('0x64'));}else{return _0x37e7e0(_0x1c0e24);}})[_0xbc6c('0x4e')](function(_0x53d12c){return _0x1b6326(_0x53d12c);});});;});};function addVoicePrefixExtensions(_0x41a343,_0x4f02e4){var _0x5da86c=[];var _0x5278f5=formatPrefixName(_0x41a343[_0xbc6c('0x65')]);_0x5da86c[_0xbc6c('0x66')](new Extension(_0x5278f5,0x2,_0xbc6c('0x67'),'CDR(prefix)='+_0x41a343[_0xbc6c('0x30')]));if(_0x41a343['callerIdAll']){_0x5da86c[_0xbc6c('0x66')](new Extension(_0x5278f5,0x3,_0xbc6c('0x67'),_0xbc6c('0x68')+_0x41a343[_0xbc6c('0x69')]));}else{_0x5da86c['push'](new Extension(_0x5278f5,0x3,_0xbc6c('0x60'),_0xbc6c('0x6a')));}_0x5da86c[_0xbc6c('0x66')](new Extension(_0x5278f5,0x4,_0xbc6c('0x6b'),_0x4f02e4['context']+','+'${EXTEN:'+(0x8+_0x41a343[_0xbc6c('0x30')][_0xbc6c('0x3d')])+'}'+','+0x1));return _0x5da86c;}function formatPrefixName(_0x2cb1ed){var _0x4222d9='_';for(var _0x2e945c=0x0;_0x2e945c<_0x2cb1ed['length'];_0x2e945c++){if(_0x2cb1ed['charAt'](_0x2e945c)=='-'){_0x4222d9+=_0x2cb1ed[_0xbc6c('0x6c')](_0x2e945c);}else{_0x4222d9+='['+_0x2cb1ed[_0xbc6c('0x6c')](_0x2e945c)+']';}}_0x4222d9+='.';return _0x4222d9;}exports[_0xbc6c('0x29')]=function(_0x10af72,_0xe6c250,_0x4172ee){var _0x453d6a=_0x10af72['body'];_0x453d6a[_0xbc6c('0x65')]=_0xbc6c('0x6d')+_0x453d6a[_0xbc6c('0x30')]+'-';return db['sequelize']['transaction'](function(_0x462e17){return db[_0xbc6c('0x46')]['update'](_0x453d6a,{'where':{'id':_0x453d6a['id']},'transaction':_0x462e17})[_0xbc6c('0x2a')](function(){return db['VoiceExtension'][_0xbc6c('0x2b')]({'where':{'VoicePrefixId':_0x453d6a['id']},'transaction':_0x462e17})[_0xbc6c('0x2a')](function(){return db['VoiceExtension'][_0xbc6c('0x4d')]({'where':{'id':_0x453d6a[_0xbc6c('0x62')]},'raw':!![]})[_0xbc6c('0x2a')](function(_0xa61931){return createVoicePrefixExtensions(_0x453d6a,_0xa61931,_0x462e17);});});});})[_0xbc6c('0x2a')](function(){return db[_0xbc6c('0x46')]['findById'](_0x453d6a['id']);})[_0xbc6c('0x2a')](respondWithResult(_0xe6c250,null))[_0xbc6c('0x4e')](handleError(_0xe6c250,null));};exports[_0xbc6c('0x6e')]=function(_0x263f26,_0x5de3cd,_0x2432f8){return db[_0xbc6c('0x46')][_0xbc6c('0x4d')]({'where':{'id':_0x263f26[_0xbc6c('0x4c')]['id']}})['then'](handleEntityNotFound(_0x5de3cd,null))[_0xbc6c('0x2a')](function(_0x5f17bb){if(_0x5f17bb){return _0x5f17bb[_0xbc6c('0x6e')](_0x263f26[_0xbc6c('0x6f')]['ids'],_[_0xbc6c('0x70')](_0x263f26[_0xbc6c('0x6f')],['ids','id'])||{})[_0xbc6c('0x71')](function(_0xc3b9bd){for(var _0x1eba31=0x0;_0x1eba31<_0x263f26[_0xbc6c('0x6f')][_0xbc6c('0x72')][_0xbc6c('0x3d')];_0x1eba31+=0x1){socket[_0xbc6c('0x73')]('userVoicePrefix:save',{'UserId':_0x263f26[_0xbc6c('0x6f')][_0xbc6c('0x72')][_0x1eba31],'VoicePrefixId':_0x263f26[_0xbc6c('0x4c')]['id']});}return _0xc3b9bd;});}})[_0xbc6c('0x2a')](respondWithResult(_0x5de3cd,null))['catch'](handleError(_0x5de3cd,null));};exports[_0xbc6c('0x74')]=function(_0x499285,_0x44d283,_0x71354d){return db['VoicePrefix'][_0xbc6c('0x4d')]({'where':{'id':_0x499285['params']['id']}})[_0xbc6c('0x2a')](handleEntityNotFound(_0x44d283,null))[_0xbc6c('0x2a')](function(_0x5b8aaa){if(_0x5b8aaa){return _0x5b8aaa[_0xbc6c('0x74')](_0x499285[_0xbc6c('0x39')][_0xbc6c('0x72')])[_0xbc6c('0x2a')](function(){if(_[_0xbc6c('0x75')](_0x499285[_0xbc6c('0x39')][_0xbc6c('0x72')])){for(var _0x3690da=0x0;_0x3690da<_0x499285['query'][_0xbc6c('0x72')][_0xbc6c('0x3d')];_0x3690da+=0x1){socket[_0xbc6c('0x73')](_0xbc6c('0x76'),{'UserId':Number(_0x499285[_0xbc6c('0x39')][_0xbc6c('0x72')][_0x3690da]),'VoicePrefixId':Number(_0x499285[_0xbc6c('0x4c')]['id'])});}}else{socket[_0xbc6c('0x73')](_0xbc6c('0x76'),{'UserId':Number(_0x499285[_0xbc6c('0x39')]['ids']),'VoicePrefixId':Number(_0x499285[_0xbc6c('0x4c')]['id'])});}});}})[_0xbc6c('0x2a')](respondWithStatusCode(_0x44d283,null))[_0xbc6c('0x4e')](handleError(_0x44d283,null));};exports[_0xbc6c('0x77')]=function(_0x13432f,_0x1d6151,_0x17c61f){var _0x1a08e8={};var _0x213656={};var _0x3c61a2;var _0x36a41c;return db[_0xbc6c('0x46')][_0xbc6c('0x78')]({'where':{'id':_0x13432f[_0xbc6c('0x4c')]['id']}})[_0xbc6c('0x2a')](handleEntityNotFound(_0x1d6151,null))['then'](function(_0x455b57){if(_0x455b57){_0x3c61a2=_0x455b57;_0x213656['model']=_[_0xbc6c('0x38')](db[_0xbc6c('0x79')][_0xbc6c('0x7a')]);_0x213656[_0xbc6c('0x39')]=_[_0xbc6c('0x38')](_0x13432f['query']);_0x213656[_0xbc6c('0x41')]=_['intersection'](_0x213656[_0xbc6c('0x37')],_0x213656[_0xbc6c('0x39')]);_0x1a08e8['attributes']=_[_0xbc6c('0x3a')](_0x213656[_0xbc6c('0x37')],qs[_0xbc6c('0x3c')](_0x13432f[_0xbc6c('0x39')][_0xbc6c('0x3c')]));_0x1a08e8[_0xbc6c('0x3b')]=_0x1a08e8[_0xbc6c('0x3b')][_0xbc6c('0x3d')]?_0x1a08e8[_0xbc6c('0x3b')]:_0x213656[_0xbc6c('0x37')];_0x1a08e8[_0xbc6c('0x3e')]=qs[_0xbc6c('0x3f')](_0x13432f[_0xbc6c('0x39')][_0xbc6c('0x3f')]);_0x1a08e8[_0xbc6c('0x40')]=qs[_0xbc6c('0x41')](_[_0xbc6c('0x7b')](_0x13432f[_0xbc6c('0x39')],_0x213656[_0xbc6c('0x41')]));if(_0x13432f[_0xbc6c('0x39')][_0xbc6c('0x44')]){_0x1a08e8[_0xbc6c('0x40')]=_[_0xbc6c('0x42')](_0x1a08e8[_0xbc6c('0x40')],{'$or':_[_0xbc6c('0x33')](_0x1a08e8[_0xbc6c('0x3b')],function(_0x5222c1){var _0x11e576={};_0x11e576[_0x5222c1]={'$like':'%'+_0x13432f[_0xbc6c('0x39')]['filter']+'%'};return _0x11e576;})});}_0x1a08e8=_[_0xbc6c('0x42')]({},_0x1a08e8,_0x13432f[_0xbc6c('0x45')]);return _0x3c61a2[_0xbc6c('0x77')](_0x1a08e8);}})[_0xbc6c('0x2a')](function(_0x4b9464){if(_0x4b9464){_0x36a41c=_0x4b9464[_0xbc6c('0x3d')];if(!_0x13432f[_0xbc6c('0x39')][_0xbc6c('0x7c')](_0xbc6c('0x7d'))){_0x1a08e8[_0xbc6c('0x23')]=qs[_0xbc6c('0x23')](_0x13432f['query'][_0xbc6c('0x23')]);_0x1a08e8[_0xbc6c('0x22')]=qs['offset'](_0x13432f[_0xbc6c('0x39')][_0xbc6c('0x22')]);}return _0x3c61a2[_0xbc6c('0x77')](_0x1a08e8);}})[_0xbc6c('0x2a')](function(_0x19198c){if(_0x19198c){return _0x19198c?{'count':_0x36a41c,'rows':_0x19198c}:null;}})[_0xbc6c('0x2a')](respondWithResult(_0x1d6151,null))[_0xbc6c('0x4e')](handleError(_0x1d6151,null));};