Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.controller.js
index 14048f0..fd8c82e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf725=['../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatInternalMessage.socket','register','status','end','json','count','offset','limit','set','apply','reject','update','destroy','then','name','send','ChatInternalMessage','rawAttributes','model','keys','query','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','map','key','VIRTUAL','field','options','includeAll','include','findAll','show','params','find','catch','create','body','describe','lastMessageAt','lastMessage','format','YYYY-MM-DD\x20HH:mm:ss','getUsers','agent','admin','user','role','userpic','internal','online','lastLoginAt','allowmessenger','showWebBar','VoiceQueues','get','UserProfileSection','Agents','userProfileId','autoAssociation','UserProfileResource','resourceId','messages','push','createdAt','FromId','ToId','read','-createdAt','all','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils'];(function(_0x1758e7,_0x514db1){var _0x5f46c0=function(_0x4b15a7){while(--_0x4b15a7){_0x1758e7['push'](_0x1758e7['shift']());}};_0x5f46c0(++_0x514db1);}(_0xf725,0xc1));var _0x5f72=function(_0x14144a,_0x36addb){_0x14144a=_0x14144a-0x0;var _0x49d44a=_0xf725[_0x14144a];return _0x49d44a;};'use strict';var pdf=require(_0x5f72('0x0'));var emlformat=require(_0x5f72('0x1'));var rimraf=require(_0x5f72('0x2'));var zipdir=require(_0x5f72('0x3'));var jsonpatch=require(_0x5f72('0x4'));var rp=require('request-promise');var moment=require(_0x5f72('0x5'));var BPromise=require(_0x5f72('0x6'));var Mustache=require(_0x5f72('0x7'));var util=require(_0x5f72('0x8'));var path=require(_0x5f72('0x9'));var sox=require(_0x5f72('0xa'));var csv=require(_0x5f72('0xb'));var ejs=require(_0x5f72('0xc'));var fs=require('fs');var _=require(_0x5f72('0xd'));var squel=require(_0x5f72('0xe'));var crypto=require('crypto');var jsforce=require(_0x5f72('0xf'));var deskjs=require(_0x5f72('0x10'));var toCsv=require(_0x5f72('0xb'));var querystring=require(_0x5f72('0x11'));var Papa=require(_0x5f72('0x12'));var Redis=require(_0x5f72('0x13'));var authService=require(_0x5f72('0x14'));var qs=require('../../components/parsers/qs');var hardwareService=require(_0x5f72('0x15'));var logger=require(_0x5f72('0x16'))(_0x5f72('0x17'));var utils=require(_0x5f72('0x18'));var config=require('../../config/environment');var db=require(_0x5f72('0x19'))['db'];config[_0x5f72('0x1a')]=_[_0x5f72('0x1b')](config[_0x5f72('0x1a')],{'host':_0x5f72('0x1c'),'port':0x18eb});var socket=require(_0x5f72('0x1d'))(new Redis(config[_0x5f72('0x1a')]));require(_0x5f72('0x1e'))[_0x5f72('0x1f')](socket);function respondWithStatusCode(_0xe200a2,_0x64e1c3){_0x64e1c3=_0x64e1c3||0xcc;return function(_0x4b3d8c){if(_0x4b3d8c){return _0xe200a2['sendStatus'](_0x64e1c3);}return _0xe200a2[_0x5f72('0x20')](_0x64e1c3)[_0x5f72('0x21')]();};}function respondWithResult(_0x4b16f8,_0x24612e){_0x24612e=_0x24612e||0xc8;return function(_0x2fd938){if(_0x2fd938){return _0x4b16f8[_0x5f72('0x20')](_0x24612e)[_0x5f72('0x22')](_0x2fd938);}};}function respondWithFilteredResult(_0x4ff829,_0xc7346a){return function(_0x1f83bb){if(_0x1f83bb){var _0x4c1d3c=_0x1f83bb[_0x5f72('0x23')],_0x271aea=_0xc7346a[_0x5f72('0x24')],_0x27e29f=_0xc7346a['offset']+_0xc7346a[_0x5f72('0x25')],_0x53cf50;if(_0x27e29f>=_0x4c1d3c){_0x27e29f=_0x4c1d3c;_0x53cf50=0xc8;}else{_0x53cf50=0xce;}_0x4ff829[_0x5f72('0x20')](_0x53cf50);return _0x4ff829[_0x5f72('0x26')]('Content-Range',_0x271aea+'-'+_0x27e29f+'/'+_0x4c1d3c)[_0x5f72('0x22')](_0x1f83bb);}return null;};}function patchUpdates(_0x318a3d){return function(_0x49c15b){try{jsonpatch[_0x5f72('0x27')](_0x49c15b,_0x318a3d,!![]);}catch(_0x2a90a8){return BPromise[_0x5f72('0x28')](_0x2a90a8);}return _0x49c15b['save']();};}function saveUpdates(_0x375e7e,_0x1061c1){return function(_0x3ce771){if(_0x3ce771){return _0x3ce771[_0x5f72('0x29')](_0x375e7e)['then'](function(_0x38f5a9){return _0x38f5a9;});}return null;};}function removeEntity(_0x3a20f9,_0x267fa3){return function(_0x428af2){if(_0x428af2){return _0x428af2[_0x5f72('0x2a')]()[_0x5f72('0x2b')](function(){_0x3a20f9['status'](0xcc)[_0x5f72('0x21')]();});}};}function handleEntityNotFound(_0x565a92,_0x1bb121){return function(_0x4bafbd){if(!_0x4bafbd){_0x565a92['sendStatus'](0x194);}return _0x4bafbd;};}function handleError(_0x1bebff,_0x106905){_0x106905=_0x106905||0x1f4;return function(_0x5688b8){logger['error'](_0x5688b8['stack']);if(_0x5688b8[_0x5f72('0x2c')]){delete _0x5688b8[_0x5f72('0x2c')];}_0x1bebff[_0x5f72('0x20')](_0x106905)[_0x5f72('0x2d')](_0x5688b8);};}exports['index']=function(_0x1a03c7,_0x464ced){var _0x7198c={},_0x16e611={},_0x1690c0={'count':0x0,'rows':[]};var _0x535e61=db[_0x5f72('0x2e')][_0x5f72('0x2f')];_0x16e611[_0x5f72('0x30')]=_[_0x5f72('0x31')](_0x535e61);_0x16e611[_0x5f72('0x32')]=_['keys'](_0x1a03c7[_0x5f72('0x32')]);_0x16e611[_0x5f72('0x33')]=_[_0x5f72('0x34')](_0x16e611['model'],_0x16e611[_0x5f72('0x32')]);_0x7198c[_0x5f72('0x35')]=_[_0x5f72('0x34')](_0x16e611[_0x5f72('0x30')],qs['fields'](_0x1a03c7[_0x5f72('0x32')]['fields']));_0x7198c['attributes']=_0x7198c[_0x5f72('0x35')][_0x5f72('0x36')]?_0x7198c[_0x5f72('0x35')]:_0x16e611[_0x5f72('0x30')];if(!_0x1a03c7[_0x5f72('0x32')][_0x5f72('0x37')](_0x5f72('0x38'))){_0x7198c[_0x5f72('0x25')]=qs[_0x5f72('0x25')](_0x1a03c7[_0x5f72('0x32')]['limit']);_0x7198c[_0x5f72('0x24')]=qs['offset'](_0x1a03c7['query'][_0x5f72('0x24')]);}_0x7198c[_0x5f72('0x39')]=qs[_0x5f72('0x3a')](_0x1a03c7[_0x5f72('0x32')][_0x5f72('0x3a')]);_0x7198c['where']=qs[_0x5f72('0x33')](_[_0x5f72('0x3b')](_0x1a03c7[_0x5f72('0x32')],_0x16e611['filters']));if(_0x1a03c7[_0x5f72('0x32')][_0x5f72('0x3c')]){_0x7198c[_0x5f72('0x3d')]=_[_0x5f72('0x3e')](_0x7198c[_0x5f72('0x3d')],{'$or':_[_0x5f72('0x3f')](_0x535e61,function(_0x3db9b2){if(_0x3db9b2['type'][_0x5f72('0x40')]!==_0x5f72('0x41')){var _0x913bb1={};_0x913bb1[_0x3db9b2[_0x5f72('0x42')]]={'$like':'%'+_0x1a03c7[_0x5f72('0x32')]['filter']+'%'};return _0x913bb1;}})});}_0x7198c=_['merge']({},_0x7198c,_0x1a03c7[_0x5f72('0x43')]);var _0x1e1f6d={'where':_0x7198c[_0x5f72('0x3d')]};return db['ChatInternalMessage']['count'](_0x1e1f6d)[_0x5f72('0x2b')](function(_0x456e8e){_0x1690c0[_0x5f72('0x23')]=_0x456e8e;if(_0x1a03c7[_0x5f72('0x32')][_0x5f72('0x44')]){_0x7198c[_0x5f72('0x45')]=[{'all':!![]}];}return db[_0x5f72('0x2e')][_0x5f72('0x46')](_0x7198c);})[_0x5f72('0x2b')](function(_0x1a8907){_0x1690c0['rows']=_0x1a8907;return _0x1690c0;})[_0x5f72('0x2b')](respondWithFilteredResult(_0x464ced,_0x7198c))['catch'](handleError(_0x464ced,null));};exports[_0x5f72('0x47')]=function(_0x1d4236,_0x3db4b3){var _0x17355a={'raw':!![],'where':{'id':_0x1d4236[_0x5f72('0x48')]['id']}},_0x57ff69={};_0x57ff69[_0x5f72('0x30')]=_[_0x5f72('0x31')](db[_0x5f72('0x2e')][_0x5f72('0x2f')]);_0x57ff69['query']=_[_0x5f72('0x31')](_0x1d4236[_0x5f72('0x32')]);_0x57ff69[_0x5f72('0x33')]=_['intersection'](_0x57ff69['model'],_0x57ff69[_0x5f72('0x32')]);_0x17355a[_0x5f72('0x35')]=_[_0x5f72('0x34')](_0x57ff69[_0x5f72('0x30')],qs['fields'](_0x1d4236[_0x5f72('0x32')]['fields']));_0x17355a['attributes']=_0x17355a[_0x5f72('0x35')][_0x5f72('0x36')]?_0x17355a[_0x5f72('0x35')]:_0x57ff69[_0x5f72('0x30')];if(_0x1d4236[_0x5f72('0x32')][_0x5f72('0x44')]){_0x17355a[_0x5f72('0x45')]=[{'all':!![]}];}_0x17355a=_[_0x5f72('0x3e')]({},_0x17355a,_0x1d4236[_0x5f72('0x43')]);return db[_0x5f72('0x2e')][_0x5f72('0x49')](_0x17355a)[_0x5f72('0x2b')](handleEntityNotFound(_0x3db4b3,null))['then'](respondWithResult(_0x3db4b3,null))[_0x5f72('0x4a')](handleError(_0x3db4b3,null));};exports[_0x5f72('0x4b')]=function(_0x20a0d6,_0x23271a){return db[_0x5f72('0x2e')][_0x5f72('0x4b')](_0x20a0d6[_0x5f72('0x4c')],{})[_0x5f72('0x2b')](respondWithResult(_0x23271a,0xc9))[_0x5f72('0x4a')](handleError(_0x23271a,null));};exports['update']=function(_0x342044,_0x4e118e){if(_0x342044['body']['id']){delete _0x342044['body']['id'];}return db[_0x5f72('0x2e')][_0x5f72('0x49')]({'where':{'id':_0x342044[_0x5f72('0x48')]['id']}})[_0x5f72('0x2b')](handleEntityNotFound(_0x4e118e,null))['then'](saveUpdates(_0x342044['body'],null))[_0x5f72('0x2b')](respondWithResult(_0x4e118e,null))['catch'](handleError(_0x4e118e,null));};exports[_0x5f72('0x2a')]=function(_0x491b1f,_0x36fbab){return db[_0x5f72('0x2e')][_0x5f72('0x49')]({'where':{'id':_0x491b1f[_0x5f72('0x48')]['id']}})[_0x5f72('0x2b')](handleEntityNotFound(_0x36fbab,null))[_0x5f72('0x2b')](removeEntity(_0x36fbab,null))[_0x5f72('0x4a')](handleError(_0x36fbab,null));};exports[_0x5f72('0x4d')]=function(_0x225719,_0x468b27){return db[_0x5f72('0x2e')][_0x5f72('0x4d')]()['then'](respondWithResult(_0x468b27,null))[_0x5f72('0x4a')](handleError(_0x468b27,null));};function wrapUser(_0x471a42){return function(_0x5655b5){var _0x415476=_0x471a42['get']({'plain':!![]});_0x415476['messages']=[];if(_0x5655b5){_0x415476[_0x5f72('0x4e')]=_0x5655b5['createdAt'];_0x415476[_0x5f72('0x4f')]=_0x5655b5;}else{_0x415476[_0x5f72('0x4e')]=moment(0x0)[_0x5f72('0x50')](_0x5f72('0x51'));_0x415476[_0x5f72('0x4f')]={};}return _0x415476;};}exports[_0x5f72('0x52')]=function(_0x4749ec,_0x377799,_0x25c5ca){var _0x12104e=[];return db['User']['findAll']({'where':{'role':[_0x5f72('0x53'),_0x5f72('0x54'),_0x5f72('0x55')]},'attributes':['id','fullname','name',_0x5f72('0x56'),_0x5f72('0x57'),_0x5f72('0x58'),_0x5f72('0x59'),_0x5f72('0x5a'),_0x5f72('0x5b'),_0x5f72('0x5c')],'order':qs[_0x5f72('0x3a')]('-online'),'include':[{'model':db['VoiceQueue'],'as':_0x5f72('0x5d'),'attributes':['id',_0x5f72('0x2c'),'type'],'through':{'attributes':[]}}]})['then'](function(_0x33e77a){if(_0x33e77a){var _0x43572e=_0x4749ec[_0x5f72('0x55')][_0x5f72('0x5e')]({'plain':!![]});if(!_0x43572e)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x43572e[_0x5f72('0x56')]===_0x5f72('0x55')){return db[_0x5f72('0x5f')]['find']({'where':{'name':_0x5f72('0x60'),'userProfileId':_0x43572e[_0x5f72('0x61')]},'raw':!![]})[_0x5f72('0x2b')](function(_0x508e7a){if(_0x508e7a){if(_0x508e7a[_0x5f72('0x62')]===0x0){return db[_0x5f72('0x63')]['findAll']({'where':{'sectionId':_0x508e7a['id']},'raw':!![]})[_0x5f72('0x2b')](function(_0x3b6502){var _0x25a0bd=[];if(_['isEmpty'](_0x3b6502)){_0x25a0bd=_[_0x5f72('0x3c')](_0x33e77a,function(_0x101d0c){if(_0x101d0c[_0x5f72('0x56')]!==_0x5f72('0x53')){return _0x101d0c;}});return _0x25a0bd;}else{for(var _0x49af18=0x0;_0x49af18<_0x33e77a['length'];_0x49af18++){var _0x403b72=_0x33e77a[_0x49af18];if(_0x403b72[_0x5f72('0x56')]===_0x5f72('0x53')){var _0x3f9c85=_[_0x5f72('0x49')](_0x3b6502,function(_0x12dd36){return _0x12dd36[_0x5f72('0x64')]===_0x403b72['id'];});if(_0x3f9c85)_0x25a0bd['push'](_0x403b72);}else{_0x25a0bd['push'](_0x403b72);}}return _0x25a0bd;}});}else{return _0x33e77a;}}else{var _0x18f1d4=_[_0x5f72('0x3c')](_0x33e77a,function(_0x3be578){if(_0x3be578[_0x5f72('0x56')]!==_0x5f72('0x53')){return _0x3be578;}});return _0x18f1d4;}});}else{return _0x33e77a;}}})['then'](function(_0x589f5f){var _0x4d4787=[];if(_0x589f5f){_0x12104e=_0x589f5f;for(var _0x3a4ae1=0x0;_0x3a4ae1<_0x589f5f['length'];_0x3a4ae1+=0x1){_0x12104e[_0x3a4ae1][_0x5f72('0x65')]=[];_0x4d4787[_0x5f72('0x66')](db[_0x5f72('0x2e')][_0x5f72('0x49')]({'where':{'FromId':[_0x4749ec[_0x5f72('0x55')]['id'],_0x589f5f[_0x3a4ae1]['id']],'ToId':[_0x4749ec[_0x5f72('0x55')]['id'],_0x589f5f[_0x3a4ae1]['id']],'ChatGroupId':null},'attributes':['id',_0x5f72('0x67'),_0x5f72('0x68'),_0x5f72('0x69'),_0x5f72('0x6a'),_0x5f72('0x4c')],'order':qs[_0x5f72('0x3a')](_0x5f72('0x6b')),'limit':0x1,'offset':0x0,'raw':!![]})[_0x5f72('0x2b')](wrapUser(_0x589f5f[_0x3a4ae1])));}return BPromise[_0x5f72('0x6c')](_0x4d4787);}return[];})['then'](function(_0x25229b){return{'rows':_0x25229b,'count':_0x25229b['length']};})[_0x5f72('0x2b')](respondWithResult(_0x377799,null))[_0x5f72('0x4a')](handleError(_0x377799,null));};
\ No newline at end of file
+var _0x416a=['fullname','role','userpic','online','lastLoginAt','allowmessenger','showWebBar','-online','type','user','Agents','userProfileId','autoAssociation','UserProfileResource','resourceId','push','createdAt','FromId','ToId','read','-createdAt','html-pdf','eml-format','rimraf','zip-dir','request-promise','bluebird','util','path','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','register','end','status','json','count','offset','limit','set','reject','save','update','then','destroy','sendStatus','error','stack','name','send','ChatInternalMessage','model','keys','query','filters','intersection','attributes','fields','length','nolimit','sort','where','pick','filter','key','VIRTUAL','field','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','create','body','describe','get','messages','lastMessageAt','YYYY-MM-DD\x20HH:mm:ss','getUsers','User','agent','admin'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x416a,0x7b));var _0xa416=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x416a[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xa416('0x0'));var emlformat=require(_0xa416('0x1'));var rimraf=require(_0xa416('0x2'));var zipdir=require(_0xa416('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xa416('0x4'));var moment=require('moment');var BPromise=require(_0xa416('0x5'));var Mustache=require('mustache');var util=require(_0xa416('0x6'));var path=require(_0xa416('0x7'));var sox=require('sox');var csv=require(_0xa416('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xa416('0x9'));var squel=require(_0xa416('0xa'));var crypto=require(_0xa416('0xb'));var jsforce=require(_0xa416('0xc'));var deskjs=require(_0xa416('0xd'));var toCsv=require(_0xa416('0x8'));var querystring=require(_0xa416('0xe'));var Papa=require(_0xa416('0xf'));var Redis=require('ioredis');var authService=require(_0xa416('0x10'));var qs=require(_0xa416('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xa416('0x12'))(_0xa416('0x13'));var utils=require(_0xa416('0x14'));var config=require(_0xa416('0x15'));var db=require(_0xa416('0x16'))['db'];config[_0xa416('0x17')]=_['defaults'](config['redis'],{'host':_0xa416('0x18'),'port':0x18eb});var socket=require(_0xa416('0x19'))(new Redis(config[_0xa416('0x17')]));require('./chatInternalMessage.socket')[_0xa416('0x1a')](socket);function respondWithStatusCode(_0x122c4a,_0x55a787){_0x55a787=_0x55a787||0xcc;return function(_0x186dbf){if(_0x186dbf){return _0x122c4a['sendStatus'](_0x55a787);}return _0x122c4a['status'](_0x55a787)[_0xa416('0x1b')]();};}function respondWithResult(_0x372193,_0x100d51){_0x100d51=_0x100d51||0xc8;return function(_0x3f4224){if(_0x3f4224){return _0x372193[_0xa416('0x1c')](_0x100d51)[_0xa416('0x1d')](_0x3f4224);}};}function respondWithFilteredResult(_0x5ccc3f,_0x3e9e2b){return function(_0x13cfda){if(_0x13cfda){var _0x87306f=_0x13cfda[_0xa416('0x1e')],_0x1f8082=_0x3e9e2b[_0xa416('0x1f')],_0x3e9e1d=_0x3e9e2b[_0xa416('0x1f')]+_0x3e9e2b[_0xa416('0x20')],_0x5caf05;if(_0x3e9e1d>=_0x87306f){_0x3e9e1d=_0x87306f;_0x5caf05=0xc8;}else{_0x5caf05=0xce;}_0x5ccc3f['status'](_0x5caf05);return _0x5ccc3f[_0xa416('0x21')]('Content-Range',_0x1f8082+'-'+_0x3e9e1d+'/'+_0x87306f)['json'](_0x13cfda);}return null;};}function patchUpdates(_0x240225){return function(_0x46d89b){try{jsonpatch['apply'](_0x46d89b,_0x240225,!![]);}catch(_0x61edf8){return BPromise[_0xa416('0x22')](_0x61edf8);}return _0x46d89b[_0xa416('0x23')]();};}function saveUpdates(_0xbefc48,_0x427fef){return function(_0x270272){if(_0x270272){return _0x270272[_0xa416('0x24')](_0xbefc48)[_0xa416('0x25')](function(_0x1ea0c3){return _0x1ea0c3;});}return null;};}function removeEntity(_0x58d0ed,_0x1ea95a){return function(_0x169073){if(_0x169073){return _0x169073[_0xa416('0x26')]()['then'](function(){_0x58d0ed[_0xa416('0x1c')](0xcc)[_0xa416('0x1b')]();});}};}function handleEntityNotFound(_0x33cd6a,_0x4e2e3b){return function(_0x57a46b){if(!_0x57a46b){_0x33cd6a[_0xa416('0x27')](0x194);}return _0x57a46b;};}function handleError(_0x2f0c5a,_0x5ef350){_0x5ef350=_0x5ef350||0x1f4;return function(_0x2227c9){logger[_0xa416('0x28')](_0x2227c9[_0xa416('0x29')]);if(_0x2227c9[_0xa416('0x2a')]){delete _0x2227c9[_0xa416('0x2a')];}_0x2f0c5a['status'](_0x5ef350)[_0xa416('0x2b')](_0x2227c9);};}exports['index']=function(_0x3a85cb,_0x8d7994){var _0x35037e={},_0x4588df={},_0x483a8a={'count':0x0,'rows':[]};var _0x516543=db[_0xa416('0x2c')]['rawAttributes'];_0x4588df[_0xa416('0x2d')]=_[_0xa416('0x2e')](_0x516543);_0x4588df[_0xa416('0x2f')]=_[_0xa416('0x2e')](_0x3a85cb[_0xa416('0x2f')]);_0x4588df[_0xa416('0x30')]=_[_0xa416('0x31')](_0x4588df[_0xa416('0x2d')],_0x4588df[_0xa416('0x2f')]);_0x35037e[_0xa416('0x32')]=_[_0xa416('0x31')](_0x4588df[_0xa416('0x2d')],qs[_0xa416('0x33')](_0x3a85cb[_0xa416('0x2f')][_0xa416('0x33')]));_0x35037e[_0xa416('0x32')]=_0x35037e[_0xa416('0x32')][_0xa416('0x34')]?_0x35037e[_0xa416('0x32')]:_0x4588df[_0xa416('0x2d')];if(!_0x3a85cb[_0xa416('0x2f')]['hasOwnProperty'](_0xa416('0x35'))){_0x35037e['limit']=qs[_0xa416('0x20')](_0x3a85cb[_0xa416('0x2f')]['limit']);_0x35037e[_0xa416('0x1f')]=qs['offset'](_0x3a85cb[_0xa416('0x2f')][_0xa416('0x1f')]);}_0x35037e['order']=qs[_0xa416('0x36')](_0x3a85cb['query'][_0xa416('0x36')]);_0x35037e[_0xa416('0x37')]=qs[_0xa416('0x30')](_[_0xa416('0x38')](_0x3a85cb[_0xa416('0x2f')],_0x4588df[_0xa416('0x30')]));if(_0x3a85cb[_0xa416('0x2f')][_0xa416('0x39')]){_0x35037e['where']=_['merge'](_0x35037e[_0xa416('0x37')],{'$or':_['map'](_0x516543,function(_0x2a286f){if(_0x2a286f['type'][_0xa416('0x3a')]!==_0xa416('0x3b')){var _0x366df7={};_0x366df7[_0x2a286f[_0xa416('0x3c')]]={'$like':'%'+_0x3a85cb[_0xa416('0x2f')][_0xa416('0x39')]+'%'};return _0x366df7;}})});}_0x35037e=_['merge']({},_0x35037e,_0x3a85cb['options']);var _0x38a33d={'where':_0x35037e[_0xa416('0x37')]};return db[_0xa416('0x2c')][_0xa416('0x1e')](_0x38a33d)[_0xa416('0x25')](function(_0x43ff08){_0x483a8a[_0xa416('0x1e')]=_0x43ff08;if(_0x3a85cb[_0xa416('0x2f')][_0xa416('0x3d')]){_0x35037e[_0xa416('0x3e')]=[{'all':!![]}];}return db[_0xa416('0x2c')][_0xa416('0x3f')](_0x35037e);})[_0xa416('0x25')](function(_0x1dacfb){_0x483a8a[_0xa416('0x40')]=_0x1dacfb;return _0x483a8a;})['then'](respondWithFilteredResult(_0x8d7994,_0x35037e))['catch'](handleError(_0x8d7994,null));};exports[_0xa416('0x41')]=function(_0x4296d9,_0xa6446b){var _0xaa83a7={'raw':!![],'where':{'id':_0x4296d9[_0xa416('0x42')]['id']}},_0x25e791={};_0x25e791['model']=_['keys'](db['ChatInternalMessage'][_0xa416('0x43')]);_0x25e791[_0xa416('0x2f')]=_[_0xa416('0x2e')](_0x4296d9['query']);_0x25e791['filters']=_[_0xa416('0x31')](_0x25e791[_0xa416('0x2d')],_0x25e791[_0xa416('0x2f')]);_0xaa83a7[_0xa416('0x32')]=_['intersection'](_0x25e791[_0xa416('0x2d')],qs[_0xa416('0x33')](_0x4296d9[_0xa416('0x2f')][_0xa416('0x33')]));_0xaa83a7[_0xa416('0x32')]=_0xaa83a7[_0xa416('0x32')][_0xa416('0x34')]?_0xaa83a7['attributes']:_0x25e791['model'];if(_0x4296d9[_0xa416('0x2f')][_0xa416('0x3d')]){_0xaa83a7[_0xa416('0x3e')]=[{'all':!![]}];}_0xaa83a7=_['merge']({},_0xaa83a7,_0x4296d9['options']);return db[_0xa416('0x2c')][_0xa416('0x44')](_0xaa83a7)[_0xa416('0x25')](handleEntityNotFound(_0xa6446b,null))[_0xa416('0x25')](respondWithResult(_0xa6446b,null))[_0xa416('0x45')](handleError(_0xa6446b,null));};exports[_0xa416('0x46')]=function(_0x9b778a,_0x86946d){return db['ChatInternalMessage'][_0xa416('0x46')](_0x9b778a[_0xa416('0x47')],{})[_0xa416('0x25')](respondWithResult(_0x86946d,0xc9))[_0xa416('0x45')](handleError(_0x86946d,null));};exports['update']=function(_0x44b499,_0x5f4bb0){if(_0x44b499[_0xa416('0x47')]['id']){delete _0x44b499[_0xa416('0x47')]['id'];}return db[_0xa416('0x2c')]['find']({'where':{'id':_0x44b499[_0xa416('0x42')]['id']}})[_0xa416('0x25')](handleEntityNotFound(_0x5f4bb0,null))[_0xa416('0x25')](saveUpdates(_0x44b499[_0xa416('0x47')],null))[_0xa416('0x25')](respondWithResult(_0x5f4bb0,null))[_0xa416('0x45')](handleError(_0x5f4bb0,null));};exports[_0xa416('0x26')]=function(_0x4f876b,_0x5506a2){return db[_0xa416('0x2c')][_0xa416('0x44')]({'where':{'id':_0x4f876b[_0xa416('0x42')]['id']}})['then'](handleEntityNotFound(_0x5506a2,null))['then'](removeEntity(_0x5506a2,null))[_0xa416('0x45')](handleError(_0x5506a2,null));};exports[_0xa416('0x48')]=function(_0x90370c,_0x2b59c5){return db['ChatInternalMessage']['describe']()[_0xa416('0x25')](respondWithResult(_0x2b59c5,null))[_0xa416('0x45')](handleError(_0x2b59c5,null));};function wrapUser(_0x56ac45){return function(_0x4a520d){var _0x5ceb89=_0x56ac45[_0xa416('0x49')]({'plain':!![]});_0x5ceb89[_0xa416('0x4a')]=[];if(_0x4a520d){_0x5ceb89['lastMessageAt']=_0x4a520d['createdAt'];_0x5ceb89['lastMessage']=_0x4a520d;}else{_0x5ceb89[_0xa416('0x4b')]=moment(0x0)['format'](_0xa416('0x4c'));_0x5ceb89['lastMessage']={};}return _0x5ceb89;};}exports[_0xa416('0x4d')]=function(_0x5e8316,_0x572f30,_0xdfda93){var _0x33e4df=[];return db[_0xa416('0x4e')][_0xa416('0x3f')]({'where':{'role':[_0xa416('0x4f'),_0xa416('0x50'),'user']},'attributes':['id',_0xa416('0x51'),_0xa416('0x2a'),_0xa416('0x52'),_0xa416('0x53'),'internal',_0xa416('0x54'),_0xa416('0x55'),_0xa416('0x56'),_0xa416('0x57')],'order':qs[_0xa416('0x36')](_0xa416('0x58')),'include':[{'model':db['VoiceQueue'],'as':'VoiceQueues','attributes':['id','name',_0xa416('0x59')],'through':{'attributes':[]}}]})[_0xa416('0x25')](function(_0x4d4989){if(_0x4d4989){var _0x5ab394=_0x5e8316['user'][_0xa416('0x49')]({'plain':!![]});if(!_0x5ab394)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5ab394['role']===_0xa416('0x5a')){return db['UserProfileSection'][_0xa416('0x44')]({'where':{'name':_0xa416('0x5b'),'userProfileId':_0x5ab394[_0xa416('0x5c')]},'raw':!![]})[_0xa416('0x25')](function(_0x599bef){if(_0x599bef){if(_0x599bef[_0xa416('0x5d')]===0x0){return db[_0xa416('0x5e')][_0xa416('0x3f')]({'where':{'sectionId':_0x599bef['id']},'raw':!![]})[_0xa416('0x25')](function(_0x27e4ed){var _0x30e668=[];if(_['isEmpty'](_0x27e4ed)){_0x30e668=_[_0xa416('0x39')](_0x4d4989,function(_0x39d2c8){if(_0x39d2c8['role']!==_0xa416('0x4f')){return _0x39d2c8;}});return _0x30e668;}else{for(var _0x366c9f=0x0;_0x366c9f<_0x4d4989[_0xa416('0x34')];_0x366c9f++){var _0x4f77d1=_0x4d4989[_0x366c9f];if(_0x4f77d1[_0xa416('0x52')]===_0xa416('0x4f')){var _0x4e2d4c=_[_0xa416('0x44')](_0x27e4ed,function(_0x2bfc1d){return _0x2bfc1d[_0xa416('0x5f')]===_0x4f77d1['id'];});if(_0x4e2d4c)_0x30e668[_0xa416('0x60')](_0x4f77d1);}else{_0x30e668[_0xa416('0x60')](_0x4f77d1);}}return _0x30e668;}});}else{return _0x4d4989;}}else{var _0x46cebe=_['filter'](_0x4d4989,function(_0x3ac757){if(_0x3ac757[_0xa416('0x52')]!==_0xa416('0x4f')){return _0x3ac757;}});return _0x46cebe;}});}else{return _0x4d4989;}}})[_0xa416('0x25')](function(_0x37f08b){var _0x1abadb=[];if(_0x37f08b){_0x33e4df=_0x37f08b;for(var _0x2191e7=0x0;_0x2191e7<_0x37f08b['length'];_0x2191e7+=0x1){_0x33e4df[_0x2191e7][_0xa416('0x4a')]=[];_0x1abadb[_0xa416('0x60')](db['ChatInternalMessage']['find']({'where':{'FromId':[_0x5e8316[_0xa416('0x5a')]['id'],_0x37f08b[_0x2191e7]['id']],'ToId':[_0x5e8316['user']['id'],_0x37f08b[_0x2191e7]['id']],'ChatGroupId':null},'attributes':['id',_0xa416('0x61'),_0xa416('0x62'),_0xa416('0x63'),_0xa416('0x64'),_0xa416('0x47')],'order':qs[_0xa416('0x36')](_0xa416('0x65')),'limit':0x1,'offset':0x0,'raw':!![]})[_0xa416('0x25')](wrapUser(_0x37f08b[_0x2191e7])));}return BPromise['all'](_0x1abadb);}return[];})['then'](function(_0x3944dc){return{'rows':_0x3944dc,'count':_0x3944dc[_0xa416('0x34')]};})['then'](respondWithResult(_0x572f30,null))[_0xa416('0x45')](handleError(_0x572f30,null));};
\ No newline at end of file