Built motion from commit 25580385.|2.6.2
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.controller.js
index e54dff1..fd91366 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4ca3=['rawAttributes','type','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','filters','find','create','body','describe','get','createdAt','lastMessage','User','agent','user','fullname','userpic','internal','allowmessenger','showWebBar','VoiceQueue','VoiceQueues','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','Agents','userProfileId','UserProfileResource','resourceId','push','FromId','read','-createdAt','all','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','path','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./chatInternalMessage.socket','register','sendStatus','status','json','count','offset','limit','save','destroy','then','end','error','stack','name','send','index','map','ChatInternalMessage'];(function(_0x1e91eb,_0x5829a3){var _0x2af75a=function(_0x1815d1){while(--_0x1815d1){_0x1e91eb['push'](_0x1e91eb['shift']());}};_0x2af75a(++_0x5829a3);}(_0x4ca3,0x9f));var _0x34ca=function(_0x1849bf,_0x91a62b){_0x1849bf=_0x1849bf-0x0;var _0x94fbe0=_0x4ca3[_0x1849bf];return _0x94fbe0;};'use strict';var pdf=require(_0x34ca('0x0'));var emlformat=require(_0x34ca('0x1'));var rimraf=require(_0x34ca('0x2'));var zipdir=require(_0x34ca('0x3'));var jsonpatch=require(_0x34ca('0x4'));var rp=require(_0x34ca('0x5'));var moment=require(_0x34ca('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x34ca('0x7'));var util=require('util');var path=require(_0x34ca('0x8'));var sox=require('sox');var csv=require(_0x34ca('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x34ca('0xa'));var squel=require('squel');var crypto=require(_0x34ca('0xb'));var jsforce=require(_0x34ca('0xc'));var deskjs=require(_0x34ca('0xd'));var toCsv=require(_0x34ca('0x9'));var querystring=require(_0x34ca('0xe'));var Papa=require(_0x34ca('0xf'));var Redis=require(_0x34ca('0x10'));var authService=require(_0x34ca('0x11'));var qs=require(_0x34ca('0x12'));var as=require(_0x34ca('0x13'));var hardwareService=require(_0x34ca('0x14'));var logger=require(_0x34ca('0x15'))(_0x34ca('0x16'));var utils=require('../../config/utils');var config=require(_0x34ca('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x34ca('0x18'))['db'];config[_0x34ca('0x19')]=_[_0x34ca('0x1a')](config[_0x34ca('0x19')],{'host':_0x34ca('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x34ca('0x19')]));require(_0x34ca('0x1c'))[_0x34ca('0x1d')](socket);function respondWithStatusCode(_0x612acd,_0x3ded0f){_0x3ded0f=_0x3ded0f||0xcc;return function(_0x2c8238){if(_0x2c8238){return _0x612acd[_0x34ca('0x1e')](_0x3ded0f);}return _0x612acd['status'](_0x3ded0f)['end']();};}function respondWithResult(_0x527a1c,_0xe18555){_0xe18555=_0xe18555||0xc8;return function(_0x552ad9){if(_0x552ad9){return _0x527a1c[_0x34ca('0x1f')](_0xe18555)[_0x34ca('0x20')](_0x552ad9);}};}function respondWithFilteredResult(_0x4d94eb,_0x31d9b0){return function(_0x3da5a0){if(_0x3da5a0){var _0x5df665=_0x3da5a0[_0x34ca('0x21')],_0x3fba14=_0x31d9b0[_0x34ca('0x22')],_0x280664=_0x31d9b0[_0x34ca('0x22')]+_0x31d9b0[_0x34ca('0x23')],_0x45f747;if(_0x280664>=_0x5df665){_0x280664=_0x5df665;_0x45f747=0xc8;}else{_0x45f747=0xce;}_0x4d94eb[_0x34ca('0x1f')](_0x45f747);return _0x4d94eb['set']('Content-Range',_0x3fba14+'-'+_0x280664+'/'+_0x5df665)[_0x34ca('0x20')](_0x3da5a0);}return null;};}function patchUpdates(_0x3d2920){return function(_0x50e991){try{jsonpatch['apply'](_0x50e991,_0x3d2920,!![]);}catch(_0x127b3d){return BPromise['reject'](_0x127b3d);}return _0x50e991[_0x34ca('0x24')]();};}function saveUpdates(_0x531001,_0x3e6c0f){return function(_0x4028d8){if(_0x4028d8){return _0x4028d8['update'](_0x531001)['then'](function(_0x200ab7){return _0x200ab7;});}return null;};}function removeEntity(_0x15c32e,_0x458cec){return function(_0xcede8a){if(_0xcede8a){return _0xcede8a[_0x34ca('0x25')]()[_0x34ca('0x26')](function(){_0x15c32e[_0x34ca('0x1f')](0xcc)[_0x34ca('0x27')]();});}};}function handleEntityNotFound(_0x239983,_0x2f61f6){return function(_0x89bc2f){if(!_0x89bc2f){_0x239983['sendStatus'](0x194);}return _0x89bc2f;};}function handleError(_0x76d9f0,_0x537c01){_0x537c01=_0x537c01||0x1f4;return function(_0x59e321){logger[_0x34ca('0x28')](_0x59e321[_0x34ca('0x29')]);if(_0x59e321[_0x34ca('0x2a')]){delete _0x59e321['name'];}_0x76d9f0['status'](_0x537c01)[_0x34ca('0x2b')](_0x59e321);};}exports[_0x34ca('0x2c')]=function(_0x152bd9,_0x446748){var _0x45eef8={},_0x3bd449={},_0x2102d0={'count':0x0,'rows':[]};var _0x50f887=_[_0x34ca('0x2d')](db[_0x34ca('0x2e')][_0x34ca('0x2f')],function(_0x1b2f72){return{'name':_0x1b2f72['fieldName'],'type':_0x1b2f72[_0x34ca('0x30')]['key']};});_0x3bd449['model']=_[_0x34ca('0x2d')](_0x50f887,'name');_0x3bd449[_0x34ca('0x31')]=_[_0x34ca('0x32')](_0x152bd9['query']);_0x3bd449['filters']=_[_0x34ca('0x33')](_0x3bd449[_0x34ca('0x34')],_0x3bd449[_0x34ca('0x31')]);_0x45eef8[_0x34ca('0x35')]=_[_0x34ca('0x33')](_0x3bd449['model'],qs[_0x34ca('0x36')](_0x152bd9[_0x34ca('0x31')]['fields']));_0x45eef8[_0x34ca('0x35')]=_0x45eef8[_0x34ca('0x35')][_0x34ca('0x37')]?_0x45eef8[_0x34ca('0x35')]:_0x3bd449[_0x34ca('0x34')];if(!_0x152bd9[_0x34ca('0x31')][_0x34ca('0x38')](_0x34ca('0x39'))){_0x45eef8[_0x34ca('0x23')]=qs[_0x34ca('0x23')](_0x152bd9['query'][_0x34ca('0x23')]);_0x45eef8[_0x34ca('0x22')]=qs[_0x34ca('0x22')](_0x152bd9[_0x34ca('0x31')]['offset']);}_0x45eef8[_0x34ca('0x3a')]=qs[_0x34ca('0x3b')](_0x152bd9[_0x34ca('0x31')][_0x34ca('0x3b')]);_0x45eef8[_0x34ca('0x3c')]=qs['filters'](_[_0x34ca('0x3d')](_0x152bd9[_0x34ca('0x31')],_0x3bd449['filters']),_0x50f887);if(_0x152bd9[_0x34ca('0x31')][_0x34ca('0x3e')]){_0x45eef8[_0x34ca('0x3c')]=_[_0x34ca('0x3f')](_0x45eef8[_0x34ca('0x3c')],{'$or':_[_0x34ca('0x2d')](_0x50f887,function(_0x112e50){if(_0x112e50[_0x34ca('0x30')]!==_0x34ca('0x40')){var _0x13bf3a={};_0x13bf3a[_0x112e50['name']]={'$like':'%'+_0x152bd9[_0x34ca('0x31')][_0x34ca('0x3e')]+'%'};return _0x13bf3a;}})});}_0x45eef8=_[_0x34ca('0x3f')]({},_0x45eef8,_0x152bd9[_0x34ca('0x41')]);var _0x19874f={'where':_0x45eef8[_0x34ca('0x3c')]};return db[_0x34ca('0x2e')]['count'](_0x19874f)[_0x34ca('0x26')](function(_0x4548f9){_0x2102d0['count']=_0x4548f9;if(_0x152bd9[_0x34ca('0x31')][_0x34ca('0x42')]){_0x45eef8[_0x34ca('0x43')]=[{'all':!![]}];}return db[_0x34ca('0x2e')][_0x34ca('0x44')](_0x45eef8);})[_0x34ca('0x26')](function(_0x381fb8){_0x2102d0[_0x34ca('0x45')]=_0x381fb8;return _0x2102d0;})[_0x34ca('0x26')](respondWithFilteredResult(_0x446748,_0x45eef8))[_0x34ca('0x46')](handleError(_0x446748,null));};exports[_0x34ca('0x47')]=function(_0x4ecddd,_0x310d35){var _0x3596c0={'raw':!![],'where':{'id':_0x4ecddd[_0x34ca('0x48')]['id']}},_0x2b5981={};_0x2b5981['model']=_[_0x34ca('0x32')](db[_0x34ca('0x2e')][_0x34ca('0x2f')]);_0x2b5981['query']=_[_0x34ca('0x32')](_0x4ecddd[_0x34ca('0x31')]);_0x2b5981[_0x34ca('0x49')]=_[_0x34ca('0x33')](_0x2b5981[_0x34ca('0x34')],_0x2b5981[_0x34ca('0x31')]);_0x3596c0[_0x34ca('0x35')]=_[_0x34ca('0x33')](_0x2b5981[_0x34ca('0x34')],qs[_0x34ca('0x36')](_0x4ecddd[_0x34ca('0x31')][_0x34ca('0x36')]));_0x3596c0[_0x34ca('0x35')]=_0x3596c0[_0x34ca('0x35')]['length']?_0x3596c0[_0x34ca('0x35')]:_0x2b5981['model'];if(_0x4ecddd['query'][_0x34ca('0x42')]){_0x3596c0[_0x34ca('0x43')]=[{'all':!![]}];}_0x3596c0=_[_0x34ca('0x3f')]({},_0x3596c0,_0x4ecddd[_0x34ca('0x41')]);return db[_0x34ca('0x2e')][_0x34ca('0x4a')](_0x3596c0)[_0x34ca('0x26')](handleEntityNotFound(_0x310d35,null))[_0x34ca('0x26')](respondWithResult(_0x310d35,null))['catch'](handleError(_0x310d35,null));};exports[_0x34ca('0x4b')]=function(_0x4287f9,_0xc831f5){return db[_0x34ca('0x2e')][_0x34ca('0x4b')](_0x4287f9['body'],{})[_0x34ca('0x26')](respondWithResult(_0xc831f5,0xc9))['catch'](handleError(_0xc831f5,null));};exports['update']=function(_0x433883,_0x5d73f2){if(_0x433883[_0x34ca('0x4c')]['id']){delete _0x433883[_0x34ca('0x4c')]['id'];}return db[_0x34ca('0x2e')][_0x34ca('0x4a')]({'where':{'id':_0x433883[_0x34ca('0x48')]['id']}})[_0x34ca('0x26')](handleEntityNotFound(_0x5d73f2,null))[_0x34ca('0x26')](saveUpdates(_0x433883['body'],null))['then'](respondWithResult(_0x5d73f2,null))['catch'](handleError(_0x5d73f2,null));};exports['destroy']=function(_0x1cba49,_0x1550f0){return db['ChatInternalMessage'][_0x34ca('0x4a')]({'where':{'id':_0x1cba49[_0x34ca('0x48')]['id']}})['then'](handleEntityNotFound(_0x1550f0,null))[_0x34ca('0x26')](removeEntity(_0x1550f0,null))[_0x34ca('0x46')](handleError(_0x1550f0,null));};exports[_0x34ca('0x4d')]=function(_0x3505bb,_0x49ed0){return db[_0x34ca('0x2e')][_0x34ca('0x4d')]()[_0x34ca('0x26')](respondWithResult(_0x49ed0,null))[_0x34ca('0x46')](handleError(_0x49ed0,null));};function wrapUser(_0x360272){return function(_0x32c0d5){var _0x164d56=_0x360272[_0x34ca('0x4e')]({'plain':!![]});_0x164d56['messages']=[];if(_0x32c0d5){_0x164d56['lastMessageAt']=_0x32c0d5[_0x34ca('0x4f')];_0x164d56[_0x34ca('0x50')]=_0x32c0d5;}else{_0x164d56['lastMessageAt']=moment(0x0)['format']('YYYY-MM-DD\x20HH:mm:ss');_0x164d56[_0x34ca('0x50')]={};}return _0x164d56;};}exports['getUsers']=function(_0x403add,_0x4da05f,_0x1003c5){var _0x47075a=[];return db[_0x34ca('0x51')]['findAll']({'where':{'role':[_0x34ca('0x52'),'admin',_0x34ca('0x53')]},'attributes':['id',_0x34ca('0x54'),_0x34ca('0x2a'),'role',_0x34ca('0x55'),_0x34ca('0x56'),'online','lastLoginAt',_0x34ca('0x57'),_0x34ca('0x58')],'order':qs['sort']('-online'),'include':[{'model':db[_0x34ca('0x59')],'as':_0x34ca('0x5a'),'attributes':['id','name',_0x34ca('0x30')],'through':{'attributes':[]}}]})['then'](function(_0x5e4455){if(_0x5e4455){var _0x395815=_0x403add['user'][_0x34ca('0x4e')]({'plain':!![]});if(!_0x395815)throw new Error(_0x34ca('0x5b'));if(_0x395815[_0x34ca('0x5c')]===_0x34ca('0x53')){return db[_0x34ca('0x5d')]['find']({'where':{'name':_0x34ca('0x5e'),'userProfileId':_0x395815[_0x34ca('0x5f')]},'raw':!![]})[_0x34ca('0x26')](function(_0x2a829c){if(_0x2a829c){if(_0x2a829c['autoAssociation']===0x0){return db[_0x34ca('0x60')][_0x34ca('0x44')]({'where':{'sectionId':_0x2a829c['id']},'raw':!![]})[_0x34ca('0x26')](function(_0x37af71){var _0x381297=[];if(_['isEmpty'](_0x37af71)){_0x381297=_[_0x34ca('0x3e')](_0x5e4455,function(_0x51f01b){if(_0x51f01b[_0x34ca('0x5c')]!=='agent'){return _0x51f01b;}});return _0x381297;}else{for(var _0x1906cf=0x0;_0x1906cf<_0x5e4455['length'];_0x1906cf++){var _0x1f437d=_0x5e4455[_0x1906cf];if(_0x1f437d['role']===_0x34ca('0x52')){var _0x470b1c=_[_0x34ca('0x4a')](_0x37af71,function(_0x55b7ad){return _0x55b7ad[_0x34ca('0x61')]===_0x1f437d['id'];});if(_0x470b1c)_0x381297[_0x34ca('0x62')](_0x1f437d);}else{_0x381297['push'](_0x1f437d);}}return _0x381297;}});}else{return _0x5e4455;}}else{var _0x51dfb4=_[_0x34ca('0x3e')](_0x5e4455,function(_0x4b6607){if(_0x4b6607[_0x34ca('0x5c')]!==_0x34ca('0x52')){return _0x4b6607;}});return _0x51dfb4;}});}else{return _0x5e4455;}}})['then'](function(_0x476322){var _0x2d1c92=[];if(_0x476322){_0x47075a=_0x476322;for(var _0x36d49d=0x0;_0x36d49d<_0x476322[_0x34ca('0x37')];_0x36d49d+=0x1){_0x47075a[_0x36d49d]['messages']=[];_0x2d1c92[_0x34ca('0x62')](db[_0x34ca('0x2e')][_0x34ca('0x4a')]({'where':{'FromId':[_0x403add['user']['id'],_0x476322[_0x36d49d]['id']],'ToId':[_0x403add[_0x34ca('0x53')]['id'],_0x476322[_0x36d49d]['id']],'ChatGroupId':null},'attributes':['id',_0x34ca('0x4f'),_0x34ca('0x63'),'ToId',_0x34ca('0x64'),'body'],'order':qs['sort'](_0x34ca('0x65')),'limit':0x1,'offset':0x0,'raw':!![]})[_0x34ca('0x26')](wrapUser(_0x476322[_0x36d49d])));}return BPromise[_0x34ca('0x66')](_0x2d1c92);}return[];})[_0x34ca('0x26')](function(_0x4f44a1){return{'rows':_0x4f44a1,'count':_0x4f44a1[_0x34ca('0x37')]};})[_0x34ca('0x26')](respondWithResult(_0x4da05f,null))[_0x34ca('0x46')](handleError(_0x4da05f,null));};
\ No newline at end of file
+var _0x0da9=['-online','VoiceQueues','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','isEmpty','resourceId','push','messages','FromId','-createdAt','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','./chatInternalMessage.socket','register','status','end','offset','undefined','count','set','Content-Range','apply','reject','update','then','destroy','sendStatus','error','stack','name','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','length','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','catch','params','ChatInternalMessage','find','create','body','describe','get','createdAt','lastMessage','lastMessageAt','YYYY-MM-DD\x20HH:mm:ss','getUsers','User','findAll','agent','admin','fullname','userpic','internal','lastLoginAt','allowmessenger','showWebBar'];(function(_0x233e8a,_0x3b4adf){var _0x49bedf=function(_0x152c8d){while(--_0x152c8d){_0x233e8a['push'](_0x233e8a['shift']());}};_0x49bedf(++_0x3b4adf);}(_0x0da9,0xe9));var _0x90da=function(_0x397c8d,_0xf0a1a4){_0x397c8d=_0x397c8d-0x0;var _0x1c5b0a=_0x0da9[_0x397c8d];return _0x1c5b0a;};'use strict';var emlformat=require(_0x90da('0x0'));var rimraf=require(_0x90da('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x90da('0x2'));var rp=require(_0x90da('0x3'));var moment=require(_0x90da('0x4'));var BPromise=require(_0x90da('0x5'));var Mustache=require(_0x90da('0x6'));var util=require(_0x90da('0x7'));var path=require('path');var sox=require(_0x90da('0x8'));var csv=require('to-csv');var ejs=require(_0x90da('0x9'));var fs=require('fs');var fs_extra=require(_0x90da('0xa'));var _=require(_0x90da('0xb'));var squel=require(_0x90da('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x90da('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x90da('0xe'));var Redis=require(_0x90da('0xf'));var authService=require(_0x90da('0x10'));var qs=require(_0x90da('0x11'));var as=require(_0x90da('0x12'));var hardwareService=require(_0x90da('0x13'));var logger=require(_0x90da('0x14'))(_0x90da('0x15'));var utils=require(_0x90da('0x16'));var config=require(_0x90da('0x17'));var licenseUtil=require(_0x90da('0x18'));var db=require(_0x90da('0x19'))['db'];config['redis']=_[_0x90da('0x1a')](config[_0x90da('0x1b')],{'host':_0x90da('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x90da('0x1d'))[_0x90da('0x1e')](socket);function respondWithStatusCode(_0x4b5094,_0xa8c434){_0xa8c434=_0xa8c434||0xcc;return function(_0x2b70ae){if(_0x2b70ae){return _0x4b5094['sendStatus'](_0xa8c434);}return _0x4b5094[_0x90da('0x1f')](_0xa8c434)[_0x90da('0x20')]();};}function respondWithResult(_0x34f775,_0x9f75c6){_0x9f75c6=_0x9f75c6||0xc8;return function(_0x5399f0){if(_0x5399f0){return _0x34f775[_0x90da('0x1f')](_0x9f75c6)['json'](_0x5399f0);}};}function respondWithFilteredResult(_0x14f2a7,_0x1e5591){return function(_0x4cbf21){if(_0x4cbf21){var _0x5dc625=typeof _0x1e5591[_0x90da('0x21')]===_0x90da('0x22')&&typeof _0x1e5591['limit']===_0x90da('0x22');var _0x58d8f7=_0x4cbf21['count'];var _0x4d85e2=_0x5dc625?0x0:_0x1e5591[_0x90da('0x21')];var _0x2edf2b=_0x5dc625?_0x4cbf21[_0x90da('0x23')]:_0x1e5591[_0x90da('0x21')]+_0x1e5591['limit'];var _0x268ba7;if(_0x2edf2b>=_0x58d8f7){_0x2edf2b=_0x58d8f7;_0x268ba7=0xc8;}else{_0x268ba7=0xce;}_0x14f2a7[_0x90da('0x1f')](_0x268ba7);return _0x14f2a7[_0x90da('0x24')](_0x90da('0x25'),_0x4d85e2+'-'+_0x2edf2b+'/'+_0x58d8f7)['json'](_0x4cbf21);}return null;};}function patchUpdates(_0x4899c0){return function(_0x539205){try{jsonpatch[_0x90da('0x26')](_0x539205,_0x4899c0,!![]);}catch(_0x5412e6){return BPromise[_0x90da('0x27')](_0x5412e6);}return _0x539205['save']();};}function saveUpdates(_0x4fd5d9,_0x739a00){return function(_0x5f1a55){if(_0x5f1a55){return _0x5f1a55[_0x90da('0x28')](_0x4fd5d9)[_0x90da('0x29')](function(_0x2811b6){return _0x2811b6;});}return null;};}function removeEntity(_0x8f8ba5,_0x5b0eda){return function(_0x3398c5){if(_0x3398c5){return _0x3398c5[_0x90da('0x2a')]()[_0x90da('0x29')](function(){_0x8f8ba5['status'](0xcc)[_0x90da('0x20')]();});}};}function handleEntityNotFound(_0x3dc663,_0x1efcca){return function(_0x403d21){if(!_0x403d21){_0x3dc663[_0x90da('0x2b')](0x194);}return _0x403d21;};}function handleError(_0x4a8129,_0x32ad86){_0x32ad86=_0x32ad86||0x1f4;return function(_0x3d6246){logger[_0x90da('0x2c')](_0x3d6246[_0x90da('0x2d')]);if(_0x3d6246[_0x90da('0x2e')]){delete _0x3d6246[_0x90da('0x2e')];}_0x4a8129[_0x90da('0x1f')](_0x32ad86)['send'](_0x3d6246);};}exports['index']=function(_0x52243b,_0x50bc9b){var _0x5c253c={},_0x5544d2={},_0x54b06f={'count':0x0,'rows':[]};var _0x45b25d=_['map'](db['ChatInternalMessage'][_0x90da('0x2f')],function(_0x10ddbf){return{'name':_0x10ddbf[_0x90da('0x30')],'type':_0x10ddbf[_0x90da('0x31')][_0x90da('0x32')]};});_0x5544d2[_0x90da('0x33')]=_[_0x90da('0x34')](_0x45b25d,_0x90da('0x2e'));_0x5544d2[_0x90da('0x35')]=_[_0x90da('0x36')](_0x52243b[_0x90da('0x35')]);_0x5544d2[_0x90da('0x37')]=_[_0x90da('0x38')](_0x5544d2[_0x90da('0x33')],_0x5544d2[_0x90da('0x35')]);_0x5c253c[_0x90da('0x39')]=_[_0x90da('0x38')](_0x5544d2[_0x90da('0x33')],qs[_0x90da('0x3a')](_0x52243b['query']['fields']));_0x5c253c[_0x90da('0x39')]=_0x5c253c[_0x90da('0x39')][_0x90da('0x3b')]?_0x5c253c[_0x90da('0x39')]:_0x5544d2[_0x90da('0x33')];if(!_0x52243b['query']['hasOwnProperty']('nolimit')){_0x5c253c[_0x90da('0x3c')]=qs[_0x90da('0x3c')](_0x52243b[_0x90da('0x35')]['limit']);_0x5c253c[_0x90da('0x21')]=qs[_0x90da('0x21')](_0x52243b[_0x90da('0x35')][_0x90da('0x21')]);}_0x5c253c[_0x90da('0x3d')]=qs[_0x90da('0x3e')](_0x52243b['query'][_0x90da('0x3e')]);_0x5c253c[_0x90da('0x3f')]=qs['filters'](_[_0x90da('0x40')](_0x52243b['query'],_0x5544d2[_0x90da('0x37')]),_0x45b25d);if(_0x52243b[_0x90da('0x35')][_0x90da('0x41')]){_0x5c253c[_0x90da('0x3f')]=_[_0x90da('0x42')](_0x5c253c['where'],{'$or':_[_0x90da('0x34')](_0x45b25d,function(_0xff7f71){if(_0xff7f71[_0x90da('0x31')]!==_0x90da('0x43')){var _0x1b1df1={};_0x1b1df1[_0xff7f71[_0x90da('0x2e')]]={'$like':'%'+_0x52243b['query']['filter']+'%'};return _0x1b1df1;}})});}_0x5c253c=_[_0x90da('0x42')]({},_0x5c253c,_0x52243b[_0x90da('0x44')]);var _0x36ac7a={'where':_0x5c253c['where']};return db['ChatInternalMessage']['count'](_0x36ac7a)[_0x90da('0x29')](function(_0x56f489){_0x54b06f['count']=_0x56f489;if(_0x52243b[_0x90da('0x35')]['includeAll']){_0x5c253c[_0x90da('0x45')]=[{'all':!![]}];}return db['ChatInternalMessage']['findAll'](_0x5c253c);})['then'](function(_0x407c00){_0x54b06f[_0x90da('0x46')]=_0x407c00;return _0x54b06f;})['then'](respondWithFilteredResult(_0x50bc9b,_0x5c253c))[_0x90da('0x47')](handleError(_0x50bc9b,null));};exports['show']=function(_0x106a17,_0x3f42f2){var _0xca5f95={'raw':!![],'where':{'id':_0x106a17[_0x90da('0x48')]['id']}},_0x5997e2={};_0x5997e2[_0x90da('0x33')]=_[_0x90da('0x36')](db[_0x90da('0x49')]['rawAttributes']);_0x5997e2[_0x90da('0x35')]=_[_0x90da('0x36')](_0x106a17[_0x90da('0x35')]);_0x5997e2[_0x90da('0x37')]=_[_0x90da('0x38')](_0x5997e2['model'],_0x5997e2[_0x90da('0x35')]);_0xca5f95[_0x90da('0x39')]=_[_0x90da('0x38')](_0x5997e2[_0x90da('0x33')],qs['fields'](_0x106a17[_0x90da('0x35')]['fields']));_0xca5f95['attributes']=_0xca5f95[_0x90da('0x39')]['length']?_0xca5f95['attributes']:_0x5997e2[_0x90da('0x33')];if(_0x106a17[_0x90da('0x35')]['includeAll']){_0xca5f95[_0x90da('0x45')]=[{'all':!![]}];}_0xca5f95=_[_0x90da('0x42')]({},_0xca5f95,_0x106a17['options']);return db[_0x90da('0x49')][_0x90da('0x4a')](_0xca5f95)['then'](handleEntityNotFound(_0x3f42f2,null))['then'](respondWithResult(_0x3f42f2,null))['catch'](handleError(_0x3f42f2,null));};exports[_0x90da('0x4b')]=function(_0x2cb53b,_0xdffe3d){return db[_0x90da('0x49')]['create'](_0x2cb53b[_0x90da('0x4c')],{})[_0x90da('0x29')](respondWithResult(_0xdffe3d,0xc9))[_0x90da('0x47')](handleError(_0xdffe3d,null));};exports[_0x90da('0x28')]=function(_0x178924,_0x363fa2){if(_0x178924[_0x90da('0x4c')]['id']){delete _0x178924[_0x90da('0x4c')]['id'];}return db[_0x90da('0x49')]['find']({'where':{'id':_0x178924[_0x90da('0x48')]['id']}})['then'](handleEntityNotFound(_0x363fa2,null))[_0x90da('0x29')](saveUpdates(_0x178924[_0x90da('0x4c')],null))[_0x90da('0x29')](respondWithResult(_0x363fa2,null))[_0x90da('0x47')](handleError(_0x363fa2,null));};exports[_0x90da('0x2a')]=function(_0x174095,_0x474540){return db[_0x90da('0x49')]['find']({'where':{'id':_0x174095[_0x90da('0x48')]['id']}})['then'](handleEntityNotFound(_0x474540,null))[_0x90da('0x29')](removeEntity(_0x474540,null))[_0x90da('0x47')](handleError(_0x474540,null));};exports[_0x90da('0x4d')]=function(_0x58475f,_0x42473d){return db[_0x90da('0x49')][_0x90da('0x4d')]()[_0x90da('0x29')](respondWithResult(_0x42473d,null))[_0x90da('0x47')](handleError(_0x42473d,null));};function wrapUser(_0x4ee34d){return function(_0xf3dde9){var _0xf4e2c6=_0x4ee34d[_0x90da('0x4e')]({'plain':!![]});_0xf4e2c6['messages']=[];if(_0xf3dde9){_0xf4e2c6['lastMessageAt']=_0xf3dde9[_0x90da('0x4f')];_0xf4e2c6[_0x90da('0x50')]=_0xf3dde9;}else{_0xf4e2c6[_0x90da('0x51')]=moment(0x0)['format'](_0x90da('0x52'));_0xf4e2c6['lastMessage']={};}return _0xf4e2c6;};}exports[_0x90da('0x53')]=function(_0x9df4db,_0x59d28c,_0x4672d1){var _0x2b8378=[];return db[_0x90da('0x54')][_0x90da('0x55')]({'where':{'role':[_0x90da('0x56'),_0x90da('0x57'),'user']},'attributes':['id',_0x90da('0x58'),_0x90da('0x2e'),'role',_0x90da('0x59'),_0x90da('0x5a'),'online',_0x90da('0x5b'),_0x90da('0x5c'),_0x90da('0x5d')],'order':qs['sort'](_0x90da('0x5e')),'include':[{'model':db['VoiceQueue'],'as':_0x90da('0x5f'),'attributes':['id','name','type'],'through':{'attributes':[]}}]})[_0x90da('0x29')](function(_0x5e48da){if(_0x5e48da){var _0x5602ff=_0x9df4db[_0x90da('0x60')][_0x90da('0x4e')]({'plain':!![]});if(!_0x5602ff)throw new Error(_0x90da('0x61'));if(_0x5602ff[_0x90da('0x62')]===_0x90da('0x60')){return db[_0x90da('0x63')][_0x90da('0x4a')]({'where':{'name':'Agents','userProfileId':_0x5602ff[_0x90da('0x64')]},'raw':!![]})[_0x90da('0x29')](function(_0x648933){if(_0x648933){if(_0x648933[_0x90da('0x65')]===0x0){return db[_0x90da('0x66')][_0x90da('0x55')]({'where':{'sectionId':_0x648933['id']},'raw':!![]})[_0x90da('0x29')](function(_0x1ddd39){var _0x768493=[];if(_[_0x90da('0x67')](_0x1ddd39)){_0x768493=_[_0x90da('0x41')](_0x5e48da,function(_0xbc65b){if(_0xbc65b[_0x90da('0x62')]!==_0x90da('0x56')){return _0xbc65b;}});return _0x768493;}else{for(var _0x229998=0x0;_0x229998<_0x5e48da[_0x90da('0x3b')];_0x229998++){var _0x464f92=_0x5e48da[_0x229998];if(_0x464f92[_0x90da('0x62')]===_0x90da('0x56')){var _0x26e850=_[_0x90da('0x4a')](_0x1ddd39,function(_0xae2fdf){return _0xae2fdf[_0x90da('0x68')]===_0x464f92['id'];});if(_0x26e850)_0x768493[_0x90da('0x69')](_0x464f92);}else{_0x768493[_0x90da('0x69')](_0x464f92);}}return _0x768493;}});}else{return _0x5e48da;}}else{var _0x3e86a4=_[_0x90da('0x41')](_0x5e48da,function(_0x319589){if(_0x319589[_0x90da('0x62')]!==_0x90da('0x56')){return _0x319589;}});return _0x3e86a4;}});}else{return _0x5e48da;}}})[_0x90da('0x29')](function(_0x10ca34){var _0x2ee9c4=[];if(_0x10ca34){_0x2b8378=_0x10ca34;for(var _0x5b9997=0x0;_0x5b9997<_0x10ca34[_0x90da('0x3b')];_0x5b9997+=0x1){_0x2b8378[_0x5b9997][_0x90da('0x6a')]=[];_0x2ee9c4['push'](db[_0x90da('0x49')][_0x90da('0x4a')]({'where':{'FromId':[_0x9df4db['user']['id'],_0x10ca34[_0x5b9997]['id']],'ToId':[_0x9df4db['user']['id'],_0x10ca34[_0x5b9997]['id']],'ChatGroupId':null},'attributes':['id',_0x90da('0x4f'),_0x90da('0x6b'),'ToId','read',_0x90da('0x4c')],'order':qs[_0x90da('0x3e')](_0x90da('0x6c')),'limit':0x1,'offset':0x0,'raw':!![]})[_0x90da('0x29')](wrapUser(_0x10ca34[_0x5b9997])));}return BPromise['all'](_0x2ee9c4);}return[];})[_0x90da('0x29')](function(_0x295e8a){return{'rows':_0x295e8a,'count':_0x295e8a['length']};})[_0x90da('0x29')](respondWithResult(_0x59d28c,null))[_0x90da('0x47')](handleError(_0x59d28c,null));};
\ No newline at end of file