Built motion from commit (unavailable).|2.4.17
[motion2.git] / server / api / chatGroup / chatGroup.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 _0x6c1d=['request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','redis','localhost','socket.io-emitter','./chatGroup.socket','jayson/promise','client','http','Sequelize','ValidationError','request','info','debug','ChatGroup,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','ChatGroup,\x20%s,\x20%s','message','result','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','update','then','destroy','end','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','ChatGroup','includeAll','include','findAll','rows','show','find','create','body','params','describe','getUnread','ChatInternalMessage','toInteger','addMembers','ids','getMembers','findOne','User','removeMembers','ChatGroupId','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch'];(function(_0x166742,_0x55520c){var _0xb7814a=function(_0x18feaf){while(--_0x18feaf){_0x166742['push'](_0x166742['shift']());}};_0xb7814a(++_0x55520c);}(_0x6c1d,0x1bb));var _0xd6c1=function(_0xe9b84,_0x27fb00){_0xe9b84=_0xe9b84-0x0;var _0x1fcdae=_0x6c1d[_0xe9b84];return _0x1fcdae;};'use strict';var pdf=require(_0xd6c1('0x0'));var emlformat=require(_0xd6c1('0x1'));var rimraf=require(_0xd6c1('0x2'));var zipdir=require(_0xd6c1('0x3'));var jsonpatch=require(_0xd6c1('0x4'));var rp=require(_0xd6c1('0x5'));var moment=require('moment');var BPromise=require(_0xd6c1('0x6'));var Mustache=require(_0xd6c1('0x7'));var util=require(_0xd6c1('0x8'));var path=require(_0xd6c1('0x9'));var sox=require(_0xd6c1('0xa'));var csv=require(_0xd6c1('0xb'));var ejs=require(_0xd6c1('0xc'));var fs=require('fs');var _=require('lodash');var squel=require(_0xd6c1('0xd'));var crypto=require('crypto');var jsforce=require(_0xd6c1('0xe'));var deskjs=require(_0xd6c1('0xf'));var toCsv=require(_0xd6c1('0xb'));var querystring=require('querystring');var Papa=require(_0xd6c1('0x10'));var Redis=require(_0xd6c1('0x11'));var authService=require(_0xd6c1('0x12'));var qs=require(_0xd6c1('0x13'));var as=require(_0xd6c1('0x14'));var hardwareService=require(_0xd6c1('0x15'));var logger=require(_0xd6c1('0x16'))('api');var utils=require(_0xd6c1('0x17'));var config=require(_0xd6c1('0x18'));var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0xd6c1('0x19')],{'host':_0xd6c1('0x1a'),'port':0x18eb});var socket=require(_0xd6c1('0x1b'))(new Redis(config[_0xd6c1('0x19')]));require(_0xd6c1('0x1c'))['register'](socket);var jayson=require(_0xd6c1('0x1d'));var client=jayson[_0xd6c1('0x1e')][_0xd6c1('0x1f')]({'port':0x232a});function checkPasswordPattern(_0x18361b,_0xa84c4,_0x539264){if(_0x539264){var _0x56d764=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x56d764['test'](_0xa84c4)){return _0x18361b;}else{throw new db[(_0xd6c1('0x20'))][(_0xd6c1('0x21'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x18361b;}}function respondWithRpcPromise(_0x43bac0,_0x94aa6d,_0x1d374f,_0x2d0613){return new BPromise(function(_0x91b23,_0x4732cc){var _0x2381b6=_0x2d0613||client;return _0x2381b6[_0xd6c1('0x22')](_0x43bac0,_0x1d374f)['then'](function(_0x32c6ea){logger[_0xd6c1('0x23')]('ChatGroup,\x20%s,\x20%s',_0x94aa6d,'request\x20sent');logger[_0xd6c1('0x24')](_0xd6c1('0x25'),_0x94aa6d,_0xd6c1('0x26'),JSON[_0xd6c1('0x27')](_0x32c6ea));if(_0x32c6ea[_0xd6c1('0x28')]){if(_0x32c6ea['error'][_0xd6c1('0x29')]===0x1f4){logger[_0xd6c1('0x28')](_0xd6c1('0x2a'),_0x94aa6d,_0x32c6ea[_0xd6c1('0x28')]['message']);return _0x4732cc(_0x32c6ea[_0xd6c1('0x28')][_0xd6c1('0x2b')]);}logger[_0xd6c1('0x28')]('ChatGroup,\x20%s,\x20%s',_0x94aa6d,_0x32c6ea[_0xd6c1('0x28')]['message']);return _0x91b23(_0x32c6ea[_0xd6c1('0x28')][_0xd6c1('0x2b')]);}else{logger[_0xd6c1('0x23')]('ChatGroup,\x20%s,\x20%s',_0x94aa6d,_0xd6c1('0x26'));_0x91b23(_0x32c6ea[_0xd6c1('0x2c')][_0xd6c1('0x2b')]);}})[_0xd6c1('0x2d')](function(_0x379b10){logger['error']('ChatGroup,\x20%s,\x20%s',_0x94aa6d,_0x379b10);_0x4732cc(_0x379b10);});});}function respondWithStatusCode(_0x563ea7,_0x47ec8b){_0x47ec8b=_0x47ec8b||0xcc;return function(_0x1f2276){if(_0x1f2276){return _0x563ea7[_0xd6c1('0x2e')](_0x47ec8b);}return _0x563ea7[_0xd6c1('0x2f')](_0x47ec8b)['end']();};}function respondWithResult(_0x2f375b,_0x19a0be){_0x19a0be=_0x19a0be||0xc8;return function(_0x35e501){if(_0x35e501){return _0x2f375b['status'](_0x19a0be)[_0xd6c1('0x30')](_0x35e501);}};}function respondWithFilteredResult(_0x5df25d,_0x1ea56e){return function(_0x5d750a){if(_0x5d750a){var _0x20b64b=_0x5d750a[_0xd6c1('0x31')],_0x4f0ba0=_0x1ea56e['offset'],_0x1b6bed=_0x1ea56e[_0xd6c1('0x32')]+_0x1ea56e[_0xd6c1('0x33')],_0x47d703;if(_0x1b6bed>=_0x20b64b){_0x1b6bed=_0x20b64b;_0x47d703=0xc8;}else{_0x47d703=0xce;}_0x5df25d['status'](_0x47d703);return _0x5df25d[_0xd6c1('0x34')](_0xd6c1('0x35'),_0x4f0ba0+'-'+_0x1b6bed+'/'+_0x20b64b)['json'](_0x5d750a);}return null;};}function patchUpdates(_0x53f335){return function(_0x50b874){try{jsonpatch[_0xd6c1('0x36')](_0x50b874,_0x53f335,!![]);}catch(_0x2b4b42){return BPromise[_0xd6c1('0x37')](_0x2b4b42);}return _0x50b874['save']();};}function saveUpdates(_0x35badb,_0x55177a){return function(_0x281971){if(_0x281971){return _0x281971[_0xd6c1('0x38')](_0x35badb)[_0xd6c1('0x39')](function(_0x2e8e47){return _0x2e8e47;});}return null;};}function removeEntity(_0x19a375,_0x195201){return function(_0x217cee){if(_0x217cee){return _0x217cee[_0xd6c1('0x3a')]()[_0xd6c1('0x39')](function(){_0x19a375[_0xd6c1('0x2f')](0xcc)[_0xd6c1('0x3b')]();});}};}function handleEntityNotFound(_0x17df28,_0x550b1b){return function(_0x4a1486){if(!_0x4a1486){_0x17df28[_0xd6c1('0x2e')](0x194);}return _0x4a1486;};}function handleError(_0x2e2f6c,_0x349998){_0x349998=_0x349998||0x1f4;return function(_0x41d125){logger[_0xd6c1('0x28')](_0x41d125[_0xd6c1('0x3c')]);if(_0x41d125['name']){delete _0x41d125[_0xd6c1('0x3d')];}_0x2e2f6c[_0xd6c1('0x2f')](_0x349998)[_0xd6c1('0x3e')](_0x41d125);};}exports['index']=function(_0x24086f,_0x5e5b7c){var _0x34e574={},_0x4ca570={},_0x11565e={'count':0x0,'rows':[]};var _0x25a785=_[_0xd6c1('0x3f')](db['ChatGroup'][_0xd6c1('0x40')],function(_0x36b6d0){return{'name':_0x36b6d0[_0xd6c1('0x41')],'type':_0x36b6d0[_0xd6c1('0x42')][_0xd6c1('0x43')]};});_0x4ca570[_0xd6c1('0x44')]=_[_0xd6c1('0x3f')](_0x25a785,_0xd6c1('0x3d'));_0x4ca570[_0xd6c1('0x45')]=_[_0xd6c1('0x46')](_0x24086f[_0xd6c1('0x45')]);_0x4ca570[_0xd6c1('0x47')]=_[_0xd6c1('0x48')](_0x4ca570[_0xd6c1('0x44')],_0x4ca570[_0xd6c1('0x45')]);_0x34e574[_0xd6c1('0x49')]=_[_0xd6c1('0x48')](_0x4ca570[_0xd6c1('0x44')],qs['fields'](_0x24086f[_0xd6c1('0x45')][_0xd6c1('0x4a')]));_0x34e574[_0xd6c1('0x49')]=_0x34e574[_0xd6c1('0x49')][_0xd6c1('0x4b')]?_0x34e574['attributes']:_0x4ca570['model'];if(!_0x24086f[_0xd6c1('0x45')][_0xd6c1('0x4c')](_0xd6c1('0x4d'))){_0x34e574[_0xd6c1('0x33')]=qs[_0xd6c1('0x33')](_0x24086f[_0xd6c1('0x45')][_0xd6c1('0x33')]);_0x34e574[_0xd6c1('0x32')]=qs[_0xd6c1('0x32')](_0x24086f['query']['offset']);}_0x34e574[_0xd6c1('0x4e')]=qs[_0xd6c1('0x4f')](_0x24086f['query'][_0xd6c1('0x4f')]);_0x34e574[_0xd6c1('0x50')]=qs['filters'](_[_0xd6c1('0x51')](_0x24086f[_0xd6c1('0x45')],_0x4ca570[_0xd6c1('0x47')]));if(_0x24086f['query'][_0xd6c1('0x52')]){_0x34e574[_0xd6c1('0x50')]=_[_0xd6c1('0x53')](_0x34e574['where'],{'$or':_['map'](_0x25a785,function(_0x93bdd8){if(_0x93bdd8['type']!==_0xd6c1('0x54')){var _0x480850={};_0x480850[_0x93bdd8[_0xd6c1('0x3d')]]={'$like':'%'+_0x24086f[_0xd6c1('0x45')][_0xd6c1('0x52')]+'%'};return _0x480850;}})});}_0x34e574=_['merge']({},_0x34e574,_0x24086f[_0xd6c1('0x55')]);var _0xbb8aad={'where':_0x34e574['where']};return db[_0xd6c1('0x56')][_0xd6c1('0x31')](_0xbb8aad)[_0xd6c1('0x39')](function(_0x545b64){_0x11565e[_0xd6c1('0x31')]=_0x545b64;if(_0x24086f[_0xd6c1('0x45')][_0xd6c1('0x57')]){_0x34e574[_0xd6c1('0x58')]=[{'all':!![]}];}return db[_0xd6c1('0x56')][_0xd6c1('0x59')](_0x34e574);})[_0xd6c1('0x39')](function(_0x2aadc1){_0x11565e[_0xd6c1('0x5a')]=_0x2aadc1;return _0x11565e;})[_0xd6c1('0x39')](respondWithFilteredResult(_0x5e5b7c,_0x34e574))[_0xd6c1('0x2d')](handleError(_0x5e5b7c,null));};exports[_0xd6c1('0x5b')]=function(_0x3707f0,_0x1b0cbe){var _0x169f47={'raw':!![],'where':{'id':_0x3707f0['params']['id']}},_0x169b9a={};_0x169b9a[_0xd6c1('0x44')]=_['keys'](db[_0xd6c1('0x56')][_0xd6c1('0x40')]);_0x169b9a[_0xd6c1('0x45')]=_[_0xd6c1('0x46')](_0x3707f0[_0xd6c1('0x45')]);_0x169b9a[_0xd6c1('0x47')]=_['intersection'](_0x169b9a[_0xd6c1('0x44')],_0x169b9a['query']);_0x169f47[_0xd6c1('0x49')]=_[_0xd6c1('0x48')](_0x169b9a[_0xd6c1('0x44')],qs[_0xd6c1('0x4a')](_0x3707f0[_0xd6c1('0x45')][_0xd6c1('0x4a')]));_0x169f47['attributes']=_0x169f47[_0xd6c1('0x49')][_0xd6c1('0x4b')]?_0x169f47[_0xd6c1('0x49')]:_0x169b9a[_0xd6c1('0x44')];if(_0x3707f0[_0xd6c1('0x45')][_0xd6c1('0x57')]){_0x169f47[_0xd6c1('0x58')]=[{'all':!![]}];}_0x169f47=_[_0xd6c1('0x53')]({},_0x169f47,_0x3707f0[_0xd6c1('0x55')]);return db[_0xd6c1('0x56')][_0xd6c1('0x5c')](_0x169f47)[_0xd6c1('0x39')](handleEntityNotFound(_0x1b0cbe,null))[_0xd6c1('0x39')](respondWithResult(_0x1b0cbe,null))[_0xd6c1('0x2d')](handleError(_0x1b0cbe,null));};exports[_0xd6c1('0x5d')]=function(_0xe34518,_0xc88804){return db[_0xd6c1('0x56')]['create'](_0xe34518[_0xd6c1('0x5e')],{})['then'](respondWithResult(_0xc88804,0xc9))[_0xd6c1('0x2d')](handleError(_0xc88804,null));};exports[_0xd6c1('0x38')]=function(_0x230d83,_0x43c439){if(_0x230d83[_0xd6c1('0x5e')]['id']){delete _0x230d83[_0xd6c1('0x5e')]['id'];}return db[_0xd6c1('0x56')][_0xd6c1('0x5c')]({'where':{'id':_0x230d83[_0xd6c1('0x5f')]['id']}})[_0xd6c1('0x39')](handleEntityNotFound(_0x43c439,null))[_0xd6c1('0x39')](saveUpdates(_0x230d83[_0xd6c1('0x5e')],null))['then'](respondWithResult(_0x43c439,null))[_0xd6c1('0x2d')](handleError(_0x43c439,null));};exports[_0xd6c1('0x3a')]=function(_0x474306,_0x15fa48){return db[_0xd6c1('0x56')][_0xd6c1('0x5c')]({'where':{'id':_0x474306[_0xd6c1('0x5f')]['id']}})['then'](handleEntityNotFound(_0x15fa48,null))[_0xd6c1('0x39')](removeEntity(_0x15fa48,null))[_0xd6c1('0x2d')](handleError(_0x15fa48,null));};exports[_0xd6c1('0x60')]=function(_0x148d99,_0x243119){return db[_0xd6c1('0x56')][_0xd6c1('0x60')]()[_0xd6c1('0x39')](respondWithResult(_0x243119,null))['catch'](handleError(_0x243119,null));};exports[_0xd6c1('0x61')]=function(_0x10da6a,_0x3c0b2b,_0xf5837a){return db[_0xd6c1('0x62')]['count']({'where':{'ChatGroupId':_0x10da6a[_0xd6c1('0x5f')]['id'],'ToId':_0x10da6a['user']['id'],'read':![]}})[_0xd6c1('0x39')](function(_0x2ea9ff){return{'id':_[_0xd6c1('0x63')](_0x10da6a[_0xd6c1('0x5f')]['id']),'count':_0x2ea9ff};})[_0xd6c1('0x39')](respondWithResult(_0x3c0b2b,null))[_0xd6c1('0x2d')](handleError(_0x3c0b2b,null));};exports[_0xd6c1('0x64')]=function(_0x332a28,_0x262006,_0x47a4aa){return db[_0xd6c1('0x56')]['find']({'where':{'id':_0x332a28[_0xd6c1('0x5f')]['id']}})[_0xd6c1('0x39')](handleEntityNotFound(_0x262006,null))['then'](function(_0x1f37cc){if(_0x1f37cc){return _0x1f37cc[_0xd6c1('0x64')](_0x332a28['body']['ids'],_['omit'](_0x332a28[_0xd6c1('0x5e')],[_0xd6c1('0x65'),'id'])||{});}})[_0xd6c1('0x39')](respondWithResult(_0x262006,null))[_0xd6c1('0x2d')](handleError(_0x262006,null));};exports[_0xd6c1('0x66')]=function(_0x7a2a74,_0x3f4ced,_0x172636){var _0x23ffea={};var _0x2dd452={};var _0x4f6be7;var _0x45915e;return db['ChatGroup'][_0xd6c1('0x67')]({'where':{'id':_0x7a2a74[_0xd6c1('0x5f')]['id']}})[_0xd6c1('0x39')](handleEntityNotFound(_0x3f4ced,null))[_0xd6c1('0x39')](function(_0x108627){if(_0x108627){_0x4f6be7=_0x108627;_0x2dd452['model']=_[_0xd6c1('0x46')](db[_0xd6c1('0x68')][_0xd6c1('0x40')]);_0x2dd452[_0xd6c1('0x45')]=_[_0xd6c1('0x46')](_0x7a2a74[_0xd6c1('0x45')]);_0x2dd452['filters']=_['intersection'](_0x2dd452[_0xd6c1('0x44')],_0x2dd452[_0xd6c1('0x45')]);_0x23ffea[_0xd6c1('0x49')]=_[_0xd6c1('0x48')](_0x2dd452[_0xd6c1('0x44')],qs[_0xd6c1('0x4a')](_0x7a2a74[_0xd6c1('0x45')][_0xd6c1('0x4a')]));_0x23ffea['attributes']=_0x23ffea['attributes']['length']?_0x23ffea[_0xd6c1('0x49')]:_0x2dd452[_0xd6c1('0x44')];_0x23ffea['order']=qs[_0xd6c1('0x4f')](_0x7a2a74[_0xd6c1('0x45')]['sort']);_0x23ffea[_0xd6c1('0x50')]=qs[_0xd6c1('0x47')](_[_0xd6c1('0x51')](_0x7a2a74[_0xd6c1('0x45')],_0x2dd452[_0xd6c1('0x47')]));if(_0x7a2a74[_0xd6c1('0x45')][_0xd6c1('0x52')]){_0x23ffea[_0xd6c1('0x50')]=_[_0xd6c1('0x53')](_0x23ffea['where'],{'$or':_['map'](_0x23ffea[_0xd6c1('0x49')],function(_0x32c41c){var _0x5b4de6={};_0x5b4de6[_0x32c41c]={'$like':'%'+_0x7a2a74['query'][_0xd6c1('0x52')]+'%'};return _0x5b4de6;})});}_0x23ffea=_['merge']({},_0x23ffea,_0x7a2a74['options']);return _0x4f6be7['getMembers'](_0x23ffea);}})[_0xd6c1('0x39')](function(_0x481bc1){if(_0x481bc1){_0x45915e=_0x481bc1[_0xd6c1('0x4b')];if(!_0x7a2a74[_0xd6c1('0x45')]['hasOwnProperty'](_0xd6c1('0x4d'))){_0x23ffea['limit']=qs[_0xd6c1('0x33')](_0x7a2a74[_0xd6c1('0x45')][_0xd6c1('0x33')]);_0x23ffea['offset']=qs['offset'](_0x7a2a74[_0xd6c1('0x45')]['offset']);}return _0x4f6be7['getMembers'](_0x23ffea);}})[_0xd6c1('0x39')](function(_0x30b9bd){if(_0x30b9bd){return _0x30b9bd?{'count':_0x45915e,'rows':_0x30b9bd}:null;}})['then'](respondWithResult(_0x3f4ced,null))['catch'](handleError(_0x3f4ced,null));};exports['removeMembers']=function(_0x163a58,_0x19adb0,_0xdfd080){return db[_0xd6c1('0x56')][_0xd6c1('0x5c')]({'where':{'id':_0x163a58['params']['id']}})[_0xd6c1('0x39')](handleEntityNotFound(_0x19adb0,null))[_0xd6c1('0x39')](function(_0x2ad3ac){if(_0x2ad3ac){return _0x2ad3ac[_0xd6c1('0x69')](_0x163a58[_0xd6c1('0x45')][_0xd6c1('0x65')]);}})[_0xd6c1('0x39')](respondWithStatusCode(_0x19adb0,null))[_0xd6c1('0x2d')](handleError(_0x19adb0,null));};exports['addMessage']=function(_0x4e97cc,_0x582254,_0x457297){if(_0x4e97cc['body']['id']){delete _0x4e97cc['body']['id'];}return db[_0xd6c1('0x56')]['find']({'where':{'id':_0x4e97cc['params']['id']}})[_0xd6c1('0x39')](handleEntityNotFound(_0x582254,null))[_0xd6c1('0x39')](function(_0x41f610){if(_0x41f610){_0x4e97cc[_0xd6c1('0x5e')][_0xd6c1('0x6a')]=_0x41f610['id'];return db['ChatInternalMessage'][_0xd6c1('0x5d')](_0x4e97cc[_0xd6c1('0x5e')]);}})[_0xd6c1('0x39')](respondWithResult(_0x582254,null))[_0xd6c1('0x2d')](handleError(_0x582254,null));};exports[_0xd6c1('0x6b')]=function(_0x1433fe,_0x2e0e4f,_0x52d9db){var _0x3a8669={};var _0x35d9c2={};var _0x389899;var _0x398ed8;return db[_0xd6c1('0x56')][_0xd6c1('0x67')]({'where':{'id':_0x1433fe['params']['id']}})[_0xd6c1('0x39')](handleEntityNotFound(_0x2e0e4f,null))[_0xd6c1('0x39')](function(_0x52cb4b){if(_0x52cb4b){_0x389899=_0x52cb4b;_0x35d9c2['model']=_['keys'](db[_0xd6c1('0x62')]['rawAttributes']);_0x35d9c2[_0xd6c1('0x45')]=_[_0xd6c1('0x46')](_0x1433fe[_0xd6c1('0x45')]);_0x35d9c2[_0xd6c1('0x47')]=_[_0xd6c1('0x48')](_0x35d9c2['model'],_0x35d9c2[_0xd6c1('0x45')]);_0x3a8669['attributes']=_[_0xd6c1('0x48')](_0x35d9c2['model'],qs[_0xd6c1('0x4a')](_0x1433fe[_0xd6c1('0x45')][_0xd6c1('0x4a')]));_0x3a8669[_0xd6c1('0x49')]=_0x3a8669[_0xd6c1('0x49')][_0xd6c1('0x4b')]?_0x3a8669[_0xd6c1('0x49')]:_0x35d9c2[_0xd6c1('0x44')];_0x3a8669[_0xd6c1('0x4e')]=qs[_0xd6c1('0x4f')](_0x1433fe[_0xd6c1('0x45')]['sort']);_0x3a8669['where']=qs[_0xd6c1('0x47')](_[_0xd6c1('0x51')](_0x1433fe[_0xd6c1('0x45')],_0x35d9c2['filters']));if(_0x1433fe[_0xd6c1('0x45')][_0xd6c1('0x52')]){_0x3a8669['where']=_[_0xd6c1('0x53')](_0x3a8669[_0xd6c1('0x50')],{'$or':_[_0xd6c1('0x3f')](_0x3a8669[_0xd6c1('0x49')],function(_0x105db0){var _0x4e20a6={};_0x4e20a6[_0x105db0]={'$like':'%'+_0x1433fe[_0xd6c1('0x45')]['filter']+'%'};return _0x4e20a6;})});}if(_0x1433fe['query'][_0xd6c1('0x6c')]){var _0x26e62c=_0x1433fe[_0xd6c1('0x45')][_0xd6c1('0x6c')][_0xd6c1('0x6d')](',');var _0xa7f3cd={};_0xa7f3cd[_0x26e62c[0x0]]={'$gte':moment(_0x26e62c[0x1])[_0xd6c1('0x6e')](_0xd6c1('0x6f'))};_0x3a8669['where']=_[_0xd6c1('0x53')](_0x3a8669[_0xd6c1('0x50')],_0xa7f3cd);}_0x3a8669=_[_0xd6c1('0x53')]({},_0x3a8669,_0x1433fe[_0xd6c1('0x55')]);return _0x389899[_0xd6c1('0x6b')](_0x3a8669);}})[_0xd6c1('0x39')](function(_0x526aa4){if(_0x526aa4){_0x398ed8=_0x526aa4[_0xd6c1('0x4b')];if(!_0x1433fe[_0xd6c1('0x45')][_0xd6c1('0x4c')]('nolimit')){_0x3a8669[_0xd6c1('0x33')]=qs[_0xd6c1('0x33')](_0x1433fe['query'][_0xd6c1('0x33')]);_0x3a8669['offset']=qs[_0xd6c1('0x32')](_0x1433fe[_0xd6c1('0x45')]['offset']);}return _0x389899[_0xd6c1('0x6b')](_0x3a8669);}})[_0xd6c1('0x39')](function(_0xf4cc16){if(_0xf4cc16){return _0xf4cc16?{'count':_0x398ed8,'rows':_0xf4cc16}:null;}})[_0xd6c1('0x39')](respondWithResult(_0x2e0e4f,null))[_0xd6c1('0x2d')](handleError(_0x2e0e4f,null));};