Built motion from commit 26159a51.|2.5.44
[motion2.git] / server / api / intZendeskConfiguration / intZendeskConfiguration.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 _0xe921=['lodash','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','Content-Range','apply','reject','save','update','then','destroy','name','send','index','ZendeskConfiguration','type','key','model','map','filters','intersection','query','attributes','fields','length','nolimit','sort','where','pick','filter','merge','options','includeAll','findAll','rows','catch','params','keys','rawAttributes','include','find','create','body','getFields','findOne','ZendeskField','order','hasOwnProperty','getSubjects','getDescriptions','getTags','Tag','setTags','ids','eml-format','rimraf','moment','mustache','util','path','sox','to-csv'];(function(_0x25cd2c,_0x57498e){var _0x1e364c=function(_0x35ac2e){while(--_0x35ac2e){_0x25cd2c['push'](_0x25cd2c['shift']());}};_0x1e364c(++_0x57498e);}(_0xe921,0x90));var _0x1e92=function(_0x47454a,_0x23d2ce){_0x47454a=_0x47454a-0x0;var _0x33bf6e=_0xe921[_0x47454a];return _0x33bf6e;};'use strict';var emlformat=require(_0x1e92('0x0'));var rimraf=require(_0x1e92('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x1e92('0x2'));var BPromise=require('bluebird');var Mustache=require(_0x1e92('0x3'));var util=require(_0x1e92('0x4'));var path=require(_0x1e92('0x5'));var sox=require(_0x1e92('0x6'));var csv=require(_0x1e92('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x1e92('0x8'));var squel=require('squel');var crypto=require(_0x1e92('0x9'));var jsforce=require('jsforce');var deskjs=require(_0x1e92('0xa'));var toCsv=require(_0x1e92('0x7'));var querystring=require(_0x1e92('0xb'));var Papa=require('papaparse');var Redis=require(_0x1e92('0xc'));var authService=require(_0x1e92('0xd'));var qs=require(_0x1e92('0xe'));var as=require(_0x1e92('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x1e92('0x10'));var config=require('../../config/environment');var licenseUtil=require(_0x1e92('0x11'));var db=require(_0x1e92('0x12'))['db'];function respondWithStatusCode(_0x366a9a,_0x1d8535){_0x1d8535=_0x1d8535||0xcc;return function(_0x382a9a){if(_0x382a9a){return _0x366a9a[_0x1e92('0x13')](_0x1d8535);}return _0x366a9a[_0x1e92('0x14')](_0x1d8535)[_0x1e92('0x15')]();};}function respondWithResult(_0x14b944,_0x4ad0d5){_0x4ad0d5=_0x4ad0d5||0xc8;return function(_0x2fe40f){if(_0x2fe40f){return _0x14b944[_0x1e92('0x14')](_0x4ad0d5)[_0x1e92('0x16')](_0x2fe40f);}};}function respondWithFilteredResult(_0x35bc2f,_0xc130f4){return function(_0x960a36){if(_0x960a36){var _0x5b1b81=typeof _0xc130f4[_0x1e92('0x17')]==='undefined'&&typeof _0xc130f4[_0x1e92('0x18')]==='undefined';var _0x46a8ca=_0x960a36['count'];var _0x221aa5=_0x5b1b81?0x0:_0xc130f4['offset'];var _0x1dc38b=_0x5b1b81?_0x960a36[_0x1e92('0x19')]:_0xc130f4['offset']+_0xc130f4[_0x1e92('0x18')];var _0x81d3d1;if(_0x1dc38b>=_0x46a8ca){_0x1dc38b=_0x46a8ca;_0x81d3d1=0xc8;}else{_0x81d3d1=0xce;}_0x35bc2f[_0x1e92('0x14')](_0x81d3d1);return _0x35bc2f['set'](_0x1e92('0x1a'),_0x221aa5+'-'+_0x1dc38b+'/'+_0x46a8ca)['json'](_0x960a36);}return null;};}function patchUpdates(_0x3cab5e){return function(_0x5d0d05){try{jsonpatch[_0x1e92('0x1b')](_0x5d0d05,_0x3cab5e,!![]);}catch(_0x208f35){return BPromise[_0x1e92('0x1c')](_0x208f35);}return _0x5d0d05[_0x1e92('0x1d')]();};}function saveUpdates(_0x35b24c,_0x2376bc){return function(_0x1b5eb5){if(_0x1b5eb5){return _0x1b5eb5[_0x1e92('0x1e')](_0x35b24c)[_0x1e92('0x1f')](function(_0x36c104){return _0x36c104;});}return null;};}function removeEntity(_0x43dd65,_0x10022d){return function(_0xfe0ca8){if(_0xfe0ca8){return _0xfe0ca8[_0x1e92('0x20')]()['then'](function(){_0x43dd65[_0x1e92('0x14')](0xcc)['end']();});}};}function handleEntityNotFound(_0xe94081,_0x4d3b95){return function(_0x1900bc){if(!_0x1900bc){_0xe94081[_0x1e92('0x13')](0x194);}return _0x1900bc;};}function handleError(_0x570214,_0x4c39cb){_0x4c39cb=_0x4c39cb||0x1f4;return function(_0x45afab){logger['error'](_0x45afab['stack']);if(_0x45afab[_0x1e92('0x21')]){delete _0x45afab['name'];}_0x570214[_0x1e92('0x14')](_0x4c39cb)[_0x1e92('0x22')](_0x45afab);};}exports[_0x1e92('0x23')]=function(_0xa88d8f,_0x27666d){var _0x42a4b4={},_0x137233={},_0x47a60e={'count':0x0,'rows':[]};var _0x588412=_['map'](db[_0x1e92('0x24')]['rawAttributes'],function(_0x53c1f6){return{'name':_0x53c1f6['fieldName'],'type':_0x53c1f6[_0x1e92('0x25')][_0x1e92('0x26')]};});_0x137233[_0x1e92('0x27')]=_[_0x1e92('0x28')](_0x588412,_0x1e92('0x21'));_0x137233['query']=_['keys'](_0xa88d8f['query']);_0x137233[_0x1e92('0x29')]=_[_0x1e92('0x2a')](_0x137233['model'],_0x137233[_0x1e92('0x2b')]);_0x42a4b4[_0x1e92('0x2c')]=_[_0x1e92('0x2a')](_0x137233['model'],qs[_0x1e92('0x2d')](_0xa88d8f[_0x1e92('0x2b')][_0x1e92('0x2d')]));_0x42a4b4[_0x1e92('0x2c')]=_0x42a4b4['attributes'][_0x1e92('0x2e')]?_0x42a4b4[_0x1e92('0x2c')]:_0x137233['model'];if(!_0xa88d8f[_0x1e92('0x2b')]['hasOwnProperty'](_0x1e92('0x2f'))){_0x42a4b4['limit']=qs[_0x1e92('0x18')](_0xa88d8f['query'][_0x1e92('0x18')]);_0x42a4b4[_0x1e92('0x17')]=qs[_0x1e92('0x17')](_0xa88d8f[_0x1e92('0x2b')][_0x1e92('0x17')]);}_0x42a4b4['order']=qs['sort'](_0xa88d8f[_0x1e92('0x2b')][_0x1e92('0x30')]);_0x42a4b4[_0x1e92('0x31')]=qs[_0x1e92('0x29')](_[_0x1e92('0x32')](_0xa88d8f['query'],_0x137233[_0x1e92('0x29')]),_0x588412);if(_0xa88d8f[_0x1e92('0x2b')][_0x1e92('0x33')]){_0x42a4b4[_0x1e92('0x31')]=_[_0x1e92('0x34')](_0x42a4b4[_0x1e92('0x31')],{'$or':_[_0x1e92('0x28')](_0x588412,function(_0xe1e590){if(_0xe1e590['type']!=='VIRTUAL'){var _0x20389e={};_0x20389e[_0xe1e590[_0x1e92('0x21')]]={'$like':'%'+_0xa88d8f[_0x1e92('0x2b')][_0x1e92('0x33')]+'%'};return _0x20389e;}})});}_0x42a4b4=_[_0x1e92('0x34')]({},_0x42a4b4,_0xa88d8f[_0x1e92('0x35')]);var _0x4d6689={'where':_0x42a4b4[_0x1e92('0x31')]};return db[_0x1e92('0x24')]['count'](_0x4d6689)[_0x1e92('0x1f')](function(_0x37089a){_0x47a60e[_0x1e92('0x19')]=_0x37089a;if(_0xa88d8f[_0x1e92('0x2b')][_0x1e92('0x36')]){_0x42a4b4['include']=[{'all':!![]}];}return db[_0x1e92('0x24')][_0x1e92('0x37')](_0x42a4b4);})['then'](function(_0x2312e3){_0x47a60e[_0x1e92('0x38')]=_0x2312e3;return _0x47a60e;})['then'](respondWithFilteredResult(_0x27666d,_0x42a4b4))[_0x1e92('0x39')](handleError(_0x27666d,null));};exports['show']=function(_0x191383,_0x2fe5fb){var _0x4a75ef={'raw':![],'where':{'id':_0x191383[_0x1e92('0x3a')]['id']}},_0x33e0a4={};_0x33e0a4['model']=_[_0x1e92('0x3b')](db['ZendeskConfiguration'][_0x1e92('0x3c')]);_0x33e0a4[_0x1e92('0x2b')]=_[_0x1e92('0x3b')](_0x191383[_0x1e92('0x2b')]);_0x33e0a4[_0x1e92('0x29')]=_['intersection'](_0x33e0a4['model'],_0x33e0a4['query']);_0x4a75ef[_0x1e92('0x2c')]=_[_0x1e92('0x2a')](_0x33e0a4[_0x1e92('0x27')],qs[_0x1e92('0x2d')](_0x191383[_0x1e92('0x2b')][_0x1e92('0x2d')]));_0x4a75ef[_0x1e92('0x2c')]=_0x4a75ef['attributes'][_0x1e92('0x2e')]?_0x4a75ef[_0x1e92('0x2c')]:_0x33e0a4[_0x1e92('0x27')];if(_0x191383['query'][_0x1e92('0x36')]){_0x4a75ef[_0x1e92('0x3d')]=[{'all':!![]}];}_0x4a75ef=_[_0x1e92('0x34')]({},_0x4a75ef,_0x191383['options']);return db[_0x1e92('0x24')][_0x1e92('0x3e')](_0x4a75ef)[_0x1e92('0x1f')](handleEntityNotFound(_0x2fe5fb,null))[_0x1e92('0x1f')](respondWithResult(_0x2fe5fb,null))['catch'](handleError(_0x2fe5fb,null));};exports[_0x1e92('0x3f')]=function(_0x5505b3,_0x597b3a){return db[_0x1e92('0x24')][_0x1e92('0x3f')](_0x5505b3['body'],{})['then'](respondWithResult(_0x597b3a,0xc9))[_0x1e92('0x39')](handleError(_0x597b3a,null));};exports[_0x1e92('0x1e')]=function(_0x480666,_0x5a1353){if(_0x480666[_0x1e92('0x40')]['id']){delete _0x480666['body']['id'];}return db['ZendeskConfiguration'][_0x1e92('0x3e')]({'where':{'id':_0x480666[_0x1e92('0x3a')]['id']}})[_0x1e92('0x1f')](handleEntityNotFound(_0x5a1353,null))[_0x1e92('0x1f')](saveUpdates(_0x480666[_0x1e92('0x40')],null))['then'](respondWithResult(_0x5a1353,null))[_0x1e92('0x39')](handleError(_0x5a1353,null));};exports['destroy']=function(_0x5c788f,_0x4d5b3a){return db[_0x1e92('0x24')]['find']({'where':{'id':_0x5c788f[_0x1e92('0x3a')]['id']}})[_0x1e92('0x1f')](handleEntityNotFound(_0x4d5b3a,null))[_0x1e92('0x1f')](removeEntity(_0x4d5b3a,null))[_0x1e92('0x39')](handleError(_0x4d5b3a,null));};exports[_0x1e92('0x41')]=function(_0x7c9716,_0x45c3a2,_0x355f10){var _0x38367c={};var _0x1f2e68={};var _0x48dca0;var _0x1cdf2e;return db[_0x1e92('0x24')][_0x1e92('0x42')]({'where':{'id':_0x7c9716[_0x1e92('0x3a')]['id']}})[_0x1e92('0x1f')](handleEntityNotFound(_0x45c3a2,null))[_0x1e92('0x1f')](function(_0x2fd284){if(_0x2fd284){_0x48dca0=_0x2fd284;_0x1f2e68[_0x1e92('0x27')]=_[_0x1e92('0x3b')](db[_0x1e92('0x43')][_0x1e92('0x3c')]);_0x1f2e68[_0x1e92('0x2b')]=_[_0x1e92('0x3b')](_0x7c9716[_0x1e92('0x2b')]);_0x1f2e68[_0x1e92('0x29')]=_['intersection'](_0x1f2e68[_0x1e92('0x27')],_0x1f2e68[_0x1e92('0x2b')]);_0x38367c[_0x1e92('0x2c')]=_[_0x1e92('0x2a')](_0x1f2e68[_0x1e92('0x27')],qs[_0x1e92('0x2d')](_0x7c9716[_0x1e92('0x2b')][_0x1e92('0x2d')]));_0x38367c[_0x1e92('0x2c')]=_0x38367c[_0x1e92('0x2c')][_0x1e92('0x2e')]?_0x38367c[_0x1e92('0x2c')]:_0x1f2e68['model'];_0x38367c[_0x1e92('0x44')]=qs[_0x1e92('0x30')](_0x7c9716[_0x1e92('0x2b')]['sort']);_0x38367c[_0x1e92('0x31')]=qs[_0x1e92('0x29')](_[_0x1e92('0x32')](_0x7c9716['query'],_0x1f2e68[_0x1e92('0x29')]));if(_0x7c9716[_0x1e92('0x2b')][_0x1e92('0x33')]){_0x38367c['where']=_[_0x1e92('0x34')](_0x38367c[_0x1e92('0x31')],{'$or':_['map'](_0x38367c[_0x1e92('0x2c')],function(_0x3ec580){var _0x55ad8b={};_0x55ad8b[_0x3ec580]={'$like':'%'+_0x7c9716[_0x1e92('0x2b')][_0x1e92('0x33')]+'%'};return _0x55ad8b;})});}_0x38367c=_[_0x1e92('0x34')]({},_0x38367c,_0x7c9716['options']);return _0x48dca0[_0x1e92('0x41')](_0x38367c);}})['then'](function(_0x3e8b7d){if(_0x3e8b7d){_0x1cdf2e=_0x3e8b7d[_0x1e92('0x2e')];if(!_0x7c9716[_0x1e92('0x2b')][_0x1e92('0x45')](_0x1e92('0x2f'))){_0x38367c['limit']=qs[_0x1e92('0x18')](_0x7c9716[_0x1e92('0x2b')][_0x1e92('0x18')]);_0x38367c[_0x1e92('0x17')]=qs['offset'](_0x7c9716[_0x1e92('0x2b')][_0x1e92('0x17')]);}return _0x48dca0['getFields'](_0x38367c);}})[_0x1e92('0x1f')](function(_0x3b85d8){if(_0x3b85d8){return _0x3b85d8?{'count':_0x1cdf2e,'rows':_0x3b85d8}:null;}})['then'](respondWithResult(_0x45c3a2,null))[_0x1e92('0x39')](handleError(_0x45c3a2,null));};exports[_0x1e92('0x46')]=function(_0x1779f9,_0x561f3e,_0x78d5a9){var _0x496ca3={};var _0x15a3de={};var _0x56b8bc;var _0x5034c0;return db['ZendeskConfiguration']['findOne']({'where':{'id':_0x1779f9[_0x1e92('0x3a')]['id']}})['then'](handleEntityNotFound(_0x561f3e,null))['then'](function(_0x2f22bb){if(_0x2f22bb){_0x56b8bc=_0x2f22bb;_0x15a3de[_0x1e92('0x27')]=_[_0x1e92('0x3b')](db['ZendeskField'][_0x1e92('0x3c')]);_0x15a3de['query']=_[_0x1e92('0x3b')](_0x1779f9[_0x1e92('0x2b')]);_0x15a3de[_0x1e92('0x29')]=_['intersection'](_0x15a3de[_0x1e92('0x27')],_0x15a3de['query']);_0x496ca3['attributes']=_[_0x1e92('0x2a')](_0x15a3de['model'],qs[_0x1e92('0x2d')](_0x1779f9[_0x1e92('0x2b')]['fields']));_0x496ca3[_0x1e92('0x2c')]=_0x496ca3[_0x1e92('0x2c')][_0x1e92('0x2e')]?_0x496ca3[_0x1e92('0x2c')]:_0x15a3de['model'];_0x496ca3['order']=qs[_0x1e92('0x30')](_0x1779f9[_0x1e92('0x2b')][_0x1e92('0x30')]);_0x496ca3[_0x1e92('0x31')]=qs['filters'](_[_0x1e92('0x32')](_0x1779f9[_0x1e92('0x2b')],_0x15a3de['filters']));if(_0x1779f9[_0x1e92('0x2b')][_0x1e92('0x33')]){_0x496ca3[_0x1e92('0x31')]=_['merge'](_0x496ca3[_0x1e92('0x31')],{'$or':_[_0x1e92('0x28')](_0x496ca3[_0x1e92('0x2c')],function(_0x46f7df){var _0x4b9f23={};_0x4b9f23[_0x46f7df]={'$like':'%'+_0x1779f9[_0x1e92('0x2b')][_0x1e92('0x33')]+'%'};return _0x4b9f23;})});}_0x496ca3=_['merge']({},_0x496ca3,_0x1779f9[_0x1e92('0x35')]);return _0x56b8bc[_0x1e92('0x46')](_0x496ca3);}})[_0x1e92('0x1f')](function(_0x5618c0){if(_0x5618c0){_0x5034c0=_0x5618c0[_0x1e92('0x2e')];if(!_0x1779f9[_0x1e92('0x2b')][_0x1e92('0x45')](_0x1e92('0x2f'))){_0x496ca3[_0x1e92('0x18')]=qs[_0x1e92('0x18')](_0x1779f9[_0x1e92('0x2b')][_0x1e92('0x18')]);_0x496ca3[_0x1e92('0x17')]=qs[_0x1e92('0x17')](_0x1779f9['query'][_0x1e92('0x17')]);}return _0x56b8bc[_0x1e92('0x46')](_0x496ca3);}})['then'](function(_0x188df4){if(_0x188df4){return _0x188df4?{'count':_0x5034c0,'rows':_0x188df4}:null;}})[_0x1e92('0x1f')](respondWithResult(_0x561f3e,null))['catch'](handleError(_0x561f3e,null));};exports[_0x1e92('0x47')]=function(_0x52a3a3,_0x51b0ab,_0x274ba3){var _0x1bb8ff={};var _0x2fb687={};var _0x1251d7;var _0x7dd188;return db[_0x1e92('0x24')][_0x1e92('0x42')]({'where':{'id':_0x52a3a3[_0x1e92('0x3a')]['id']}})[_0x1e92('0x1f')](handleEntityNotFound(_0x51b0ab,null))[_0x1e92('0x1f')](function(_0x60f29){if(_0x60f29){_0x1251d7=_0x60f29;_0x2fb687[_0x1e92('0x27')]=_[_0x1e92('0x3b')](db[_0x1e92('0x43')][_0x1e92('0x3c')]);_0x2fb687[_0x1e92('0x2b')]=_[_0x1e92('0x3b')](_0x52a3a3[_0x1e92('0x2b')]);_0x2fb687[_0x1e92('0x29')]=_[_0x1e92('0x2a')](_0x2fb687[_0x1e92('0x27')],_0x2fb687[_0x1e92('0x2b')]);_0x1bb8ff[_0x1e92('0x2c')]=_[_0x1e92('0x2a')](_0x2fb687[_0x1e92('0x27')],qs[_0x1e92('0x2d')](_0x52a3a3[_0x1e92('0x2b')][_0x1e92('0x2d')]));_0x1bb8ff['attributes']=_0x1bb8ff[_0x1e92('0x2c')][_0x1e92('0x2e')]?_0x1bb8ff[_0x1e92('0x2c')]:_0x2fb687['model'];_0x1bb8ff['order']=qs['sort'](_0x52a3a3[_0x1e92('0x2b')][_0x1e92('0x30')]);_0x1bb8ff[_0x1e92('0x31')]=qs['filters'](_[_0x1e92('0x32')](_0x52a3a3[_0x1e92('0x2b')],_0x2fb687[_0x1e92('0x29')]));if(_0x52a3a3[_0x1e92('0x2b')][_0x1e92('0x33')]){_0x1bb8ff[_0x1e92('0x31')]=_[_0x1e92('0x34')](_0x1bb8ff[_0x1e92('0x31')],{'$or':_[_0x1e92('0x28')](_0x1bb8ff[_0x1e92('0x2c')],function(_0x16b921){var _0x5dece1={};_0x5dece1[_0x16b921]={'$like':'%'+_0x52a3a3[_0x1e92('0x2b')][_0x1e92('0x33')]+'%'};return _0x5dece1;})});}_0x1bb8ff=_[_0x1e92('0x34')]({},_0x1bb8ff,_0x52a3a3['options']);return _0x1251d7[_0x1e92('0x47')](_0x1bb8ff);}})[_0x1e92('0x1f')](function(_0x3eadb4){if(_0x3eadb4){_0x7dd188=_0x3eadb4[_0x1e92('0x2e')];if(!_0x52a3a3[_0x1e92('0x2b')]['hasOwnProperty'](_0x1e92('0x2f'))){_0x1bb8ff['limit']=qs[_0x1e92('0x18')](_0x52a3a3[_0x1e92('0x2b')]['limit']);_0x1bb8ff[_0x1e92('0x17')]=qs[_0x1e92('0x17')](_0x52a3a3[_0x1e92('0x2b')][_0x1e92('0x17')]);}return _0x1251d7['getDescriptions'](_0x1bb8ff);}})[_0x1e92('0x1f')](function(_0x28bdb1){if(_0x28bdb1){return _0x28bdb1?{'count':_0x7dd188,'rows':_0x28bdb1}:null;}})[_0x1e92('0x1f')](respondWithResult(_0x51b0ab,null))[_0x1e92('0x39')](handleError(_0x51b0ab,null));};exports[_0x1e92('0x48')]=function(_0xb3ec4f,_0x11760b,_0x463cab){var _0x2119f8={};var _0x5411a0={};var _0x7db254;var _0x2a7a7b;return db[_0x1e92('0x24')]['findOne']({'where':{'id':_0xb3ec4f[_0x1e92('0x3a')]['id']}})['then'](handleEntityNotFound(_0x11760b,null))[_0x1e92('0x1f')](function(_0x5b1cba){if(_0x5b1cba){_0x7db254=_0x5b1cba;_0x5411a0[_0x1e92('0x27')]=_[_0x1e92('0x3b')](db[_0x1e92('0x49')][_0x1e92('0x3c')]);_0x5411a0[_0x1e92('0x2b')]=_[_0x1e92('0x3b')](_0xb3ec4f[_0x1e92('0x2b')]);_0x5411a0[_0x1e92('0x29')]=_['intersection'](_0x5411a0['model'],_0x5411a0[_0x1e92('0x2b')]);_0x2119f8[_0x1e92('0x2c')]=_[_0x1e92('0x2a')](_0x5411a0[_0x1e92('0x27')],qs[_0x1e92('0x2d')](_0xb3ec4f[_0x1e92('0x2b')][_0x1e92('0x2d')]));_0x2119f8[_0x1e92('0x2c')]=_0x2119f8[_0x1e92('0x2c')][_0x1e92('0x2e')]?_0x2119f8['attributes']:_0x5411a0[_0x1e92('0x27')];_0x2119f8[_0x1e92('0x44')]=qs['sort'](_0xb3ec4f[_0x1e92('0x2b')][_0x1e92('0x30')]);_0x2119f8['where']=qs[_0x1e92('0x29')](_['pick'](_0xb3ec4f[_0x1e92('0x2b')],_0x5411a0[_0x1e92('0x29')]));if(_0xb3ec4f[_0x1e92('0x2b')]['filter']){_0x2119f8[_0x1e92('0x31')]=_[_0x1e92('0x34')](_0x2119f8[_0x1e92('0x31')],{'$or':_[_0x1e92('0x28')](_0x2119f8['attributes'],function(_0x2108de){var _0x171480={};_0x171480[_0x2108de]={'$like':'%'+_0xb3ec4f['query'][_0x1e92('0x33')]+'%'};return _0x171480;})});}_0x2119f8=_[_0x1e92('0x34')]({},_0x2119f8,_0xb3ec4f[_0x1e92('0x35')]);return _0x7db254[_0x1e92('0x48')](_0x2119f8);}})[_0x1e92('0x1f')](function(_0x1bd5ea){if(_0x1bd5ea){_0x2a7a7b=_0x1bd5ea[_0x1e92('0x2e')];if(!_0xb3ec4f['query'][_0x1e92('0x45')](_0x1e92('0x2f'))){_0x2119f8[_0x1e92('0x18')]=qs[_0x1e92('0x18')](_0xb3ec4f[_0x1e92('0x2b')]['limit']);_0x2119f8[_0x1e92('0x17')]=qs[_0x1e92('0x17')](_0xb3ec4f[_0x1e92('0x2b')][_0x1e92('0x17')]);}return _0x7db254[_0x1e92('0x48')](_0x2119f8);}})['then'](function(_0x4aab65){if(_0x4aab65){return _0x4aab65?{'count':_0x2a7a7b,'rows':_0x4aab65}:null;}})['then'](respondWithResult(_0x11760b,null))[_0x1e92('0x39')](handleError(_0x11760b,null));};exports[_0x1e92('0x4a')]=function(_0x24089a,_0x42b5d5,_0x3a9428){if(_0x24089a[_0x1e92('0x40')]['id']){delete _0x24089a[_0x1e92('0x40')]['id'];}return db[_0x1e92('0x24')][_0x1e92('0x42')]({'where':{'id':_0x24089a[_0x1e92('0x3a')]['id']}})['then'](handleEntityNotFound(_0x42b5d5,null))['then'](function(_0x4550f5){if(_0x4550f5){return _0x4550f5[_0x1e92('0x4a')](_0x24089a['body'][_0x1e92('0x4b')]||[]);}return null;})[_0x1e92('0x1f')](respondWithResult(_0x42b5d5,null))[_0x1e92('0x39')](handleError(_0x42b5d5,null));};