ab35c1db19f3dad45da14949d6bac15a1b3eb39f
[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 _0xf6c5=['name','send','index','map','ChatGroup','fieldName','type','key','query','keys','intersection','model','fields','length','attributes','nolimit','limit','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','find','create','body','update','describe','getUnread','toInteger','addMembers','ids','omit','User','getMembers','removeMembers','addMessage','getMessages','findOne','ChatInternalMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','hasOwnProperty','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatGroup.socket','register','client','http','then','info','request\x20sent','debug','ChatGroup,\x20%s,\x20%s,\x20%s','error','ChatGroup,\x20%s,\x20%s','message','result','sendStatus','status','end','json','count','offset','set','reject','save','destroy','stack'];(function(_0x4e96d8,_0x20304f){var _0x5cb02d=function(_0x423404){while(--_0x423404){_0x4e96d8['push'](_0x4e96d8['shift']());}};_0x5cb02d(++_0x20304f);}(_0xf6c5,0x1f0));var _0x5f6c=function(_0x453583,_0x5ca1e8){_0x453583=_0x453583-0x0;var _0x3e9101=_0xf6c5[_0x453583];return _0x3e9101;};'use strict';var emlformat=require(_0x5f6c('0x0'));var rimraf=require(_0x5f6c('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x5f6c('0x2'));var moment=require(_0x5f6c('0x3'));var BPromise=require(_0x5f6c('0x4'));var Mustache=require(_0x5f6c('0x5'));var util=require(_0x5f6c('0x6'));var path=require(_0x5f6c('0x7'));var sox=require('sox');var csv=require(_0x5f6c('0x8'));var ejs=require(_0x5f6c('0x9'));var fs=require('fs');var fs_extra=require(_0x5f6c('0xa'));var _=require('lodash');var squel=require(_0x5f6c('0xb'));var crypto=require(_0x5f6c('0xc'));var jsforce=require(_0x5f6c('0xd'));var deskjs=require(_0x5f6c('0xe'));var toCsv=require(_0x5f6c('0x8'));var querystring=require(_0x5f6c('0xf'));var Papa=require(_0x5f6c('0x10'));var Redis=require('ioredis');var authService=require(_0x5f6c('0x11'));var qs=require(_0x5f6c('0x12'));var as=require(_0x5f6c('0x13'));var hardwareService=require(_0x5f6c('0x14'));var logger=require(_0x5f6c('0x15'))(_0x5f6c('0x16'));var utils=require('../../config/utils');var config=require(_0x5f6c('0x17'));var licenseUtil=require(_0x5f6c('0x18'));var db=require(_0x5f6c('0x19'))['db'];config['redis']=_[_0x5f6c('0x1a')](config[_0x5f6c('0x1b')],{'host':_0x5f6c('0x1c'),'port':0x18eb});var socket=require(_0x5f6c('0x1d'))(new Redis(config['redis']));require(_0x5f6c('0x1e'))[_0x5f6c('0x1f')](socket);var jayson=require('jayson/promise');var client=jayson[_0x5f6c('0x20')][_0x5f6c('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x52e04e,_0x240b2c,_0x4cf80d,_0x129776){return new BPromise(function(_0xddbf5b,_0x2354c2){var _0x42c15d=_0x129776||client;return _0x42c15d['request'](_0x52e04e,_0x4cf80d)[_0x5f6c('0x22')](function(_0x1cad11){logger[_0x5f6c('0x23')]('ChatGroup,\x20%s,\x20%s',_0x240b2c,_0x5f6c('0x24'));logger[_0x5f6c('0x25')](_0x5f6c('0x26'),_0x240b2c,_0x5f6c('0x24'),JSON['stringify'](_0x1cad11));if(_0x1cad11['error']){if(_0x1cad11[_0x5f6c('0x27')]['code']===0x1f4){logger['error'](_0x5f6c('0x28'),_0x240b2c,_0x1cad11[_0x5f6c('0x27')]['message']);return _0x2354c2(_0x1cad11[_0x5f6c('0x27')][_0x5f6c('0x29')]);}logger[_0x5f6c('0x27')](_0x5f6c('0x28'),_0x240b2c,_0x1cad11[_0x5f6c('0x27')]['message']);return _0xddbf5b(_0x1cad11[_0x5f6c('0x27')][_0x5f6c('0x29')]);}else{logger[_0x5f6c('0x23')](_0x5f6c('0x28'),_0x240b2c,_0x5f6c('0x24'));_0xddbf5b(_0x1cad11[_0x5f6c('0x2a')][_0x5f6c('0x29')]);}})['catch'](function(_0x407d3a){logger[_0x5f6c('0x27')](_0x5f6c('0x28'),_0x240b2c,_0x407d3a);_0x2354c2(_0x407d3a);});});}function respondWithStatusCode(_0x22bded,_0x4ea3ee){_0x4ea3ee=_0x4ea3ee||0xcc;return function(_0x4b6d60){if(_0x4b6d60){return _0x22bded[_0x5f6c('0x2b')](_0x4ea3ee);}return _0x22bded[_0x5f6c('0x2c')](_0x4ea3ee)[_0x5f6c('0x2d')]();};}function respondWithResult(_0xbcdf54,_0xba838c){_0xba838c=_0xba838c||0xc8;return function(_0x4f23fa){if(_0x4f23fa){return _0xbcdf54[_0x5f6c('0x2c')](_0xba838c)[_0x5f6c('0x2e')](_0x4f23fa);}};}function respondWithFilteredResult(_0x3b542f,_0x931eff){return function(_0x5a2ca9){if(_0x5a2ca9){var _0x2bea3d=_0x5a2ca9[_0x5f6c('0x2f')],_0x576615=_0x931eff[_0x5f6c('0x30')],_0x4fb94a=_0x931eff['offset']+_0x931eff['limit'],_0x3265b9;if(_0x4fb94a>=_0x2bea3d){_0x4fb94a=_0x2bea3d;_0x3265b9=0xc8;}else{_0x3265b9=0xce;}_0x3b542f[_0x5f6c('0x2c')](_0x3265b9);return _0x3b542f[_0x5f6c('0x31')]('Content-Range',_0x576615+'-'+_0x4fb94a+'/'+_0x2bea3d)['json'](_0x5a2ca9);}return null;};}function patchUpdates(_0x48d006){return function(_0x2131e9){try{jsonpatch['apply'](_0x2131e9,_0x48d006,!![]);}catch(_0x47dfed){return BPromise[_0x5f6c('0x32')](_0x47dfed);}return _0x2131e9[_0x5f6c('0x33')]();};}function saveUpdates(_0x3722ac,_0x5efa37){return function(_0x45f5ca){if(_0x45f5ca){return _0x45f5ca['update'](_0x3722ac)['then'](function(_0x5a4261){return _0x5a4261;});}return null;};}function removeEntity(_0x34cdca,_0x178069){return function(_0x290ae0){if(_0x290ae0){return _0x290ae0[_0x5f6c('0x34')]()[_0x5f6c('0x22')](function(){_0x34cdca[_0x5f6c('0x2c')](0xcc)[_0x5f6c('0x2d')]();});}};}function handleEntityNotFound(_0x27effd,_0x2e31b9){return function(_0x492ba0){if(!_0x492ba0){_0x27effd[_0x5f6c('0x2b')](0x194);}return _0x492ba0;};}function handleError(_0x5b6ace,_0xf93f56){_0xf93f56=_0xf93f56||0x1f4;return function(_0x4d118a){logger[_0x5f6c('0x27')](_0x4d118a[_0x5f6c('0x35')]);if(_0x4d118a[_0x5f6c('0x36')]){delete _0x4d118a['name'];}_0x5b6ace[_0x5f6c('0x2c')](_0xf93f56)[_0x5f6c('0x37')](_0x4d118a);};}exports[_0x5f6c('0x38')]=function(_0x8c10ab,_0x3cf139){var _0x178a78={},_0x135abf={},_0x5b1972={'count':0x0,'rows':[]};var _0x116079=_[_0x5f6c('0x39')](db[_0x5f6c('0x3a')]['rawAttributes'],function(_0x4c32c2){return{'name':_0x4c32c2[_0x5f6c('0x3b')],'type':_0x4c32c2[_0x5f6c('0x3c')][_0x5f6c('0x3d')]};});_0x135abf['model']=_['map'](_0x116079,_0x5f6c('0x36'));_0x135abf[_0x5f6c('0x3e')]=_[_0x5f6c('0x3f')](_0x8c10ab[_0x5f6c('0x3e')]);_0x135abf['filters']=_[_0x5f6c('0x40')](_0x135abf[_0x5f6c('0x41')],_0x135abf[_0x5f6c('0x3e')]);_0x178a78['attributes']=_[_0x5f6c('0x40')](_0x135abf[_0x5f6c('0x41')],qs[_0x5f6c('0x42')](_0x8c10ab[_0x5f6c('0x3e')]['fields']));_0x178a78['attributes']=_0x178a78['attributes'][_0x5f6c('0x43')]?_0x178a78[_0x5f6c('0x44')]:_0x135abf[_0x5f6c('0x41')];if(!_0x8c10ab[_0x5f6c('0x3e')]['hasOwnProperty'](_0x5f6c('0x45'))){_0x178a78[_0x5f6c('0x46')]=qs['limit'](_0x8c10ab[_0x5f6c('0x3e')][_0x5f6c('0x46')]);_0x178a78['offset']=qs['offset'](_0x8c10ab[_0x5f6c('0x3e')][_0x5f6c('0x30')]);}_0x178a78[_0x5f6c('0x47')]=qs[_0x5f6c('0x48')](_0x8c10ab[_0x5f6c('0x3e')]['sort']);_0x178a78[_0x5f6c('0x49')]=qs[_0x5f6c('0x4a')](_[_0x5f6c('0x4b')](_0x8c10ab['query'],_0x135abf[_0x5f6c('0x4a')]),_0x116079);if(_0x8c10ab[_0x5f6c('0x3e')][_0x5f6c('0x4c')]){_0x178a78[_0x5f6c('0x49')]=_['merge'](_0x178a78[_0x5f6c('0x49')],{'$or':_['map'](_0x116079,function(_0x49faea){if(_0x49faea[_0x5f6c('0x3c')]!==_0x5f6c('0x4d')){var _0x4d0885={};_0x4d0885[_0x49faea[_0x5f6c('0x36')]]={'$like':'%'+_0x8c10ab[_0x5f6c('0x3e')][_0x5f6c('0x4c')]+'%'};return _0x4d0885;}})});}_0x178a78=_[_0x5f6c('0x4e')]({},_0x178a78,_0x8c10ab[_0x5f6c('0x4f')]);var _0x29e316={'where':_0x178a78['where']};return db[_0x5f6c('0x3a')][_0x5f6c('0x2f')](_0x29e316)[_0x5f6c('0x22')](function(_0x3151ef){_0x5b1972[_0x5f6c('0x2f')]=_0x3151ef;if(_0x8c10ab[_0x5f6c('0x3e')][_0x5f6c('0x50')]){_0x178a78[_0x5f6c('0x51')]=[{'all':!![]}];}return db[_0x5f6c('0x3a')][_0x5f6c('0x52')](_0x178a78);})[_0x5f6c('0x22')](function(_0x58f51f){_0x5b1972[_0x5f6c('0x53')]=_0x58f51f;return _0x5b1972;})['then'](respondWithFilteredResult(_0x3cf139,_0x178a78))[_0x5f6c('0x54')](handleError(_0x3cf139,null));};exports[_0x5f6c('0x55')]=function(_0x10f09a,_0x39977a){var _0x4ce221={'raw':!![],'where':{'id':_0x10f09a[_0x5f6c('0x56')]['id']}},_0x5c1b5e={};_0x5c1b5e[_0x5f6c('0x41')]=_['keys'](db[_0x5f6c('0x3a')][_0x5f6c('0x57')]);_0x5c1b5e[_0x5f6c('0x3e')]=_[_0x5f6c('0x3f')](_0x10f09a[_0x5f6c('0x3e')]);_0x5c1b5e[_0x5f6c('0x4a')]=_[_0x5f6c('0x40')](_0x5c1b5e[_0x5f6c('0x41')],_0x5c1b5e['query']);_0x4ce221[_0x5f6c('0x44')]=_[_0x5f6c('0x40')](_0x5c1b5e['model'],qs[_0x5f6c('0x42')](_0x10f09a[_0x5f6c('0x3e')][_0x5f6c('0x42')]));_0x4ce221[_0x5f6c('0x44')]=_0x4ce221[_0x5f6c('0x44')][_0x5f6c('0x43')]?_0x4ce221[_0x5f6c('0x44')]:_0x5c1b5e[_0x5f6c('0x41')];if(_0x10f09a[_0x5f6c('0x3e')][_0x5f6c('0x50')]){_0x4ce221[_0x5f6c('0x51')]=[{'all':!![]}];}_0x4ce221=_[_0x5f6c('0x4e')]({},_0x4ce221,_0x10f09a[_0x5f6c('0x4f')]);return db[_0x5f6c('0x3a')][_0x5f6c('0x58')](_0x4ce221)['then'](handleEntityNotFound(_0x39977a,null))[_0x5f6c('0x22')](respondWithResult(_0x39977a,null))['catch'](handleError(_0x39977a,null));};exports[_0x5f6c('0x59')]=function(_0x87ee1b,_0x57f6e9){return db['ChatGroup'][_0x5f6c('0x59')](_0x87ee1b[_0x5f6c('0x5a')],{})[_0x5f6c('0x22')](respondWithResult(_0x57f6e9,0xc9))[_0x5f6c('0x54')](handleError(_0x57f6e9,null));};exports[_0x5f6c('0x5b')]=function(_0x4cfa80,_0x88116c){if(_0x4cfa80[_0x5f6c('0x5a')]['id']){delete _0x4cfa80['body']['id'];}return db[_0x5f6c('0x3a')][_0x5f6c('0x58')]({'where':{'id':_0x4cfa80[_0x5f6c('0x56')]['id']}})[_0x5f6c('0x22')](handleEntityNotFound(_0x88116c,null))[_0x5f6c('0x22')](saveUpdates(_0x4cfa80[_0x5f6c('0x5a')],null))[_0x5f6c('0x22')](respondWithResult(_0x88116c,null))['catch'](handleError(_0x88116c,null));};exports['destroy']=function(_0x358f73,_0x5118f5){return db[_0x5f6c('0x3a')]['find']({'where':{'id':_0x358f73[_0x5f6c('0x56')]['id']}})[_0x5f6c('0x22')](handleEntityNotFound(_0x5118f5,null))[_0x5f6c('0x22')](removeEntity(_0x5118f5,null))['catch'](handleError(_0x5118f5,null));};exports[_0x5f6c('0x5c')]=function(_0x4e167c,_0x1ddcc9){return db['ChatGroup'][_0x5f6c('0x5c')]()[_0x5f6c('0x22')](respondWithResult(_0x1ddcc9,null))[_0x5f6c('0x54')](handleError(_0x1ddcc9,null));};exports[_0x5f6c('0x5d')]=function(_0x1d2546,_0x2dc3aa,_0x56c311){return db['ChatInternalMessage'][_0x5f6c('0x2f')]({'where':{'ChatGroupId':_0x1d2546[_0x5f6c('0x56')]['id'],'ToId':_0x1d2546['user']['id'],'read':![]}})[_0x5f6c('0x22')](function(_0x2e0643){return{'id':_[_0x5f6c('0x5e')](_0x1d2546[_0x5f6c('0x56')]['id']),'count':_0x2e0643};})[_0x5f6c('0x22')](respondWithResult(_0x2dc3aa,null))[_0x5f6c('0x54')](handleError(_0x2dc3aa,null));};exports[_0x5f6c('0x5f')]=function(_0x4d0497,_0x9b80ab,_0x2ce471){return db['ChatGroup'][_0x5f6c('0x58')]({'where':{'id':_0x4d0497['params']['id']}})[_0x5f6c('0x22')](handleEntityNotFound(_0x9b80ab,null))[_0x5f6c('0x22')](function(_0x5b8949){if(_0x5b8949){return _0x5b8949[_0x5f6c('0x5f')](_0x4d0497[_0x5f6c('0x5a')][_0x5f6c('0x60')],_[_0x5f6c('0x61')](_0x4d0497[_0x5f6c('0x5a')],[_0x5f6c('0x60'),'id'])||{});}})[_0x5f6c('0x22')](respondWithResult(_0x9b80ab,null))[_0x5f6c('0x54')](handleError(_0x9b80ab,null));};exports['getMembers']=function(_0x501078,_0x4f7cdf,_0x5c0662){var _0xb4d3ce={};var _0x4887cf={};var _0x249645;var _0x7fb047;return db['ChatGroup']['findOne']({'where':{'id':_0x501078['params']['id']}})[_0x5f6c('0x22')](handleEntityNotFound(_0x4f7cdf,null))[_0x5f6c('0x22')](function(_0x2732fd){if(_0x2732fd){_0x249645=_0x2732fd;_0x4887cf[_0x5f6c('0x41')]=_[_0x5f6c('0x3f')](db[_0x5f6c('0x62')][_0x5f6c('0x57')]);_0x4887cf['query']=_[_0x5f6c('0x3f')](_0x501078[_0x5f6c('0x3e')]);_0x4887cf[_0x5f6c('0x4a')]=_['intersection'](_0x4887cf[_0x5f6c('0x41')],_0x4887cf[_0x5f6c('0x3e')]);_0xb4d3ce[_0x5f6c('0x44')]=_[_0x5f6c('0x40')](_0x4887cf['model'],qs['fields'](_0x501078[_0x5f6c('0x3e')]['fields']));_0xb4d3ce['attributes']=_0xb4d3ce[_0x5f6c('0x44')][_0x5f6c('0x43')]?_0xb4d3ce[_0x5f6c('0x44')]:_0x4887cf[_0x5f6c('0x41')];_0xb4d3ce[_0x5f6c('0x47')]=qs['sort'](_0x501078[_0x5f6c('0x3e')][_0x5f6c('0x48')]);_0xb4d3ce[_0x5f6c('0x49')]=qs[_0x5f6c('0x4a')](_[_0x5f6c('0x4b')](_0x501078[_0x5f6c('0x3e')],_0x4887cf[_0x5f6c('0x4a')]));if(_0x501078['query'][_0x5f6c('0x4c')]){_0xb4d3ce['where']=_[_0x5f6c('0x4e')](_0xb4d3ce[_0x5f6c('0x49')],{'$or':_[_0x5f6c('0x39')](_0xb4d3ce[_0x5f6c('0x44')],function(_0x192dfb){var _0x1dcb24={};_0x1dcb24[_0x192dfb]={'$like':'%'+_0x501078['query'][_0x5f6c('0x4c')]+'%'};return _0x1dcb24;})});}_0xb4d3ce=_[_0x5f6c('0x4e')]({},_0xb4d3ce,_0x501078[_0x5f6c('0x4f')]);return _0x249645[_0x5f6c('0x63')](_0xb4d3ce);}})[_0x5f6c('0x22')](function(_0x2abda8){if(_0x2abda8){_0x7fb047=_0x2abda8[_0x5f6c('0x43')];if(!_0x501078[_0x5f6c('0x3e')]['hasOwnProperty']('nolimit')){_0xb4d3ce[_0x5f6c('0x46')]=qs[_0x5f6c('0x46')](_0x501078[_0x5f6c('0x3e')][_0x5f6c('0x46')]);_0xb4d3ce[_0x5f6c('0x30')]=qs[_0x5f6c('0x30')](_0x501078[_0x5f6c('0x3e')][_0x5f6c('0x30')]);}return _0x249645[_0x5f6c('0x63')](_0xb4d3ce);}})[_0x5f6c('0x22')](function(_0x3f9080){if(_0x3f9080){return _0x3f9080?{'count':_0x7fb047,'rows':_0x3f9080}:null;}})[_0x5f6c('0x22')](respondWithResult(_0x4f7cdf,null))[_0x5f6c('0x54')](handleError(_0x4f7cdf,null));};exports['removeMembers']=function(_0x4bf5e6,_0x38521d,_0xb3f6a6){return db['ChatGroup'][_0x5f6c('0x58')]({'where':{'id':_0x4bf5e6[_0x5f6c('0x56')]['id']}})[_0x5f6c('0x22')](handleEntityNotFound(_0x38521d,null))[_0x5f6c('0x22')](function(_0x268141){if(_0x268141){return _0x268141[_0x5f6c('0x64')](_0x4bf5e6[_0x5f6c('0x3e')]['ids']);}})['then'](respondWithStatusCode(_0x38521d,null))[_0x5f6c('0x54')](handleError(_0x38521d,null));};exports[_0x5f6c('0x65')]=function(_0x5f23eb,_0x1771dd,_0x13d4f4){if(_0x5f23eb['body']['id']){delete _0x5f23eb[_0x5f6c('0x5a')]['id'];}return db[_0x5f6c('0x3a')][_0x5f6c('0x58')]({'where':{'id':_0x5f23eb['params']['id']}})['then'](handleEntityNotFound(_0x1771dd,null))[_0x5f6c('0x22')](function(_0x5df59d){if(_0x5df59d){_0x5f23eb['body']['ChatGroupId']=_0x5df59d['id'];return db['ChatInternalMessage'][_0x5f6c('0x59')](_0x5f23eb[_0x5f6c('0x5a')]);}})[_0x5f6c('0x22')](respondWithResult(_0x1771dd,null))[_0x5f6c('0x54')](handleError(_0x1771dd,null));};exports[_0x5f6c('0x66')]=function(_0xbf55c7,_0x4ca298,_0xbd57e6){var _0xf0c2d4={};var _0x404d82={};var _0x358e17;var _0x4a7263;return db[_0x5f6c('0x3a')][_0x5f6c('0x67')]({'where':{'id':_0xbf55c7[_0x5f6c('0x56')]['id']}})[_0x5f6c('0x22')](handleEntityNotFound(_0x4ca298,null))[_0x5f6c('0x22')](function(_0x385d55){if(_0x385d55){_0x358e17=_0x385d55;_0x404d82['model']=_[_0x5f6c('0x3f')](db[_0x5f6c('0x68')]['rawAttributes']);_0x404d82[_0x5f6c('0x3e')]=_[_0x5f6c('0x3f')](_0xbf55c7['query']);_0x404d82[_0x5f6c('0x4a')]=_[_0x5f6c('0x40')](_0x404d82[_0x5f6c('0x41')],_0x404d82[_0x5f6c('0x3e')]);_0xf0c2d4[_0x5f6c('0x44')]=_[_0x5f6c('0x40')](_0x404d82[_0x5f6c('0x41')],qs[_0x5f6c('0x42')](_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x42')]));_0xf0c2d4['attributes']=_0xf0c2d4[_0x5f6c('0x44')][_0x5f6c('0x43')]?_0xf0c2d4[_0x5f6c('0x44')]:_0x404d82[_0x5f6c('0x41')];_0xf0c2d4['order']=qs[_0x5f6c('0x48')](_0xbf55c7['query']['sort']);_0xf0c2d4[_0x5f6c('0x49')]=qs[_0x5f6c('0x4a')](_[_0x5f6c('0x4b')](_0xbf55c7[_0x5f6c('0x3e')],_0x404d82[_0x5f6c('0x4a')]));if(_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x4c')]){_0xf0c2d4[_0x5f6c('0x49')]=_[_0x5f6c('0x4e')](_0xf0c2d4[_0x5f6c('0x49')],{'$or':_[_0x5f6c('0x39')](_0xf0c2d4[_0x5f6c('0x44')],function(_0x316077){var _0x3a0f7b={};_0x3a0f7b[_0x316077]={'$like':'%'+_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x4c')]+'%'};return _0x3a0f7b;})});}if(_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x69')]){var _0x3a42ca=_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x69')][_0x5f6c('0x6a')](',');var _0x1b4424={};_0x1b4424[_0x3a42ca[0x0]]={'$gte':moment(_0x3a42ca[0x1])[_0x5f6c('0x6b')](_0x5f6c('0x6c'))};_0xf0c2d4['where']=_[_0x5f6c('0x4e')](_0xf0c2d4['where'],_0x1b4424);}_0xf0c2d4=_[_0x5f6c('0x4e')]({},_0xf0c2d4,_0xbf55c7['options']);return _0x358e17[_0x5f6c('0x66')](_0xf0c2d4);}})['then'](function(_0x3e4e3b){if(_0x3e4e3b){_0x4a7263=_0x3e4e3b[_0x5f6c('0x43')];if(!_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x6d')](_0x5f6c('0x45'))){_0xf0c2d4[_0x5f6c('0x46')]=qs[_0x5f6c('0x46')](_0xbf55c7['query']['limit']);_0xf0c2d4[_0x5f6c('0x30')]=qs[_0x5f6c('0x30')](_0xbf55c7[_0x5f6c('0x3e')][_0x5f6c('0x30')]);}return _0x358e17[_0x5f6c('0x66')](_0xf0c2d4);}})['then'](function(_0x5d44cf){if(_0x5d44cf){return _0x5d44cf?{'count':_0x4a7263,'rows':_0x5d44cf}:null;}})['then'](respondWithResult(_0x4ca298,null))[_0x5f6c('0x54')](handleError(_0x4ca298,null));};