Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.controller.js
index 6817ce4..e54dff1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6659=['find','create','body','params','get','messages','lastMessageAt','createdAt','lastMessage','format','YYYY-MM-DD\x20HH:mm:ss','agent','user','fullname','role','userpic','internal','online','lastLoginAt','allowmessenger','showWebBar','-online','VoiceQueue','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','Agents','userProfileId','autoAssociation','UserProfileResource','length','push','FromId','ToId','read','all','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./chatInternalMessage.socket','register','sendStatus','status','end','count','offset','limit','Content-Range','json','apply','reject','save','update','then','destroy','error','name','send','index','map','rawAttributes','fieldName','model','query','filters','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','ChatInternalMessage','includeAll','include','findAll','rows','catch','keys'];(function(_0x32b0b2,_0x4f3f45){var _0x5b595e=function(_0x5e6952){while(--_0x5e6952){_0x32b0b2['push'](_0x32b0b2['shift']());}};_0x5b595e(++_0x4f3f45);}(_0x6659,0x176));var _0x9665=function(_0x132ca3,_0x4be008){_0x132ca3=_0x132ca3-0x0;var _0x3e2ee0=_0x6659[_0x132ca3];return _0x3e2ee0;};'use strict';var pdf=require(_0x9665('0x0'));var emlformat=require(_0x9665('0x1'));var rimraf=require(_0x9665('0x2'));var zipdir=require(_0x9665('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9665('0x4'));var moment=require(_0x9665('0x5'));var BPromise=require(_0x9665('0x6'));var Mustache=require(_0x9665('0x7'));var util=require(_0x9665('0x8'));var path=require(_0x9665('0x9'));var sox=require(_0x9665('0xa'));var csv=require(_0x9665('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x9665('0xc'));var squel=require(_0x9665('0xd'));var crypto=require(_0x9665('0xe'));var jsforce=require(_0x9665('0xf'));var deskjs=require(_0x9665('0x10'));var toCsv=require('to-csv');var querystring=require(_0x9665('0x11'));var Papa=require(_0x9665('0x12'));var Redis=require(_0x9665('0x13'));var authService=require('../../components/auth/service');var qs=require(_0x9665('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9665('0x15'));var logger=require(_0x9665('0x16'))(_0x9665('0x17'));var utils=require(_0x9665('0x18'));var config=require(_0x9665('0x19'));var licenseUtil=require(_0x9665('0x1a'));var db=require(_0x9665('0x1b'))['db'];config[_0x9665('0x1c')]=_[_0x9665('0x1d')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x9665('0x1e'))(new Redis(config['redis']));require(_0x9665('0x1f'))[_0x9665('0x20')](socket);function respondWithStatusCode(_0x50fe25,_0x314b67){_0x314b67=_0x314b67||0xcc;return function(_0xd93bc1){if(_0xd93bc1){return _0x50fe25[_0x9665('0x21')](_0x314b67);}return _0x50fe25[_0x9665('0x22')](_0x314b67)[_0x9665('0x23')]();};}function respondWithResult(_0xdb5d65,_0x73cd12){_0x73cd12=_0x73cd12||0xc8;return function(_0x362ed4){if(_0x362ed4){return _0xdb5d65['status'](_0x73cd12)['json'](_0x362ed4);}};}function respondWithFilteredResult(_0x26125b,_0x23b0b0){return function(_0x15f797){if(_0x15f797){var _0x364a03=_0x15f797[_0x9665('0x24')],_0x2b59d7=_0x23b0b0[_0x9665('0x25')],_0x200ea5=_0x23b0b0['offset']+_0x23b0b0[_0x9665('0x26')],_0x5ea7a1;if(_0x200ea5>=_0x364a03){_0x200ea5=_0x364a03;_0x5ea7a1=0xc8;}else{_0x5ea7a1=0xce;}_0x26125b[_0x9665('0x22')](_0x5ea7a1);return _0x26125b['set'](_0x9665('0x27'),_0x2b59d7+'-'+_0x200ea5+'/'+_0x364a03)[_0x9665('0x28')](_0x15f797);}return null;};}function patchUpdates(_0x4672a2){return function(_0x17a0bb){try{jsonpatch[_0x9665('0x29')](_0x17a0bb,_0x4672a2,!![]);}catch(_0x38b564){return BPromise[_0x9665('0x2a')](_0x38b564);}return _0x17a0bb[_0x9665('0x2b')]();};}function saveUpdates(_0xd6857c,_0x29c7d0){return function(_0x267e88){if(_0x267e88){return _0x267e88[_0x9665('0x2c')](_0xd6857c)[_0x9665('0x2d')](function(_0x3190d4){return _0x3190d4;});}return null;};}function removeEntity(_0x5c0fbf,_0x2d15b7){return function(_0x2366ee){if(_0x2366ee){return _0x2366ee[_0x9665('0x2e')]()[_0x9665('0x2d')](function(){_0x5c0fbf[_0x9665('0x22')](0xcc)[_0x9665('0x23')]();});}};}function handleEntityNotFound(_0x545500,_0x6c68bd){return function(_0x57b67f){if(!_0x57b67f){_0x545500['sendStatus'](0x194);}return _0x57b67f;};}function handleError(_0x251cb0,_0x4427df){_0x4427df=_0x4427df||0x1f4;return function(_0x36f637){logger[_0x9665('0x2f')](_0x36f637['stack']);if(_0x36f637[_0x9665('0x30')]){delete _0x36f637['name'];}_0x251cb0['status'](_0x4427df)[_0x9665('0x31')](_0x36f637);};}exports[_0x9665('0x32')]=function(_0x54c0f5,_0x3aa324){var _0x4208b5={},_0x16637f={},_0x336c32={'count':0x0,'rows':[]};var _0x7efa76=_[_0x9665('0x33')](db['ChatInternalMessage'][_0x9665('0x34')],function(_0x493544){return{'name':_0x493544[_0x9665('0x35')],'type':_0x493544['type']['key']};});_0x16637f[_0x9665('0x36')]=_[_0x9665('0x33')](_0x7efa76,_0x9665('0x30'));_0x16637f[_0x9665('0x37')]=_['keys'](_0x54c0f5[_0x9665('0x37')]);_0x16637f[_0x9665('0x38')]=_['intersection'](_0x16637f['model'],_0x16637f[_0x9665('0x37')]);_0x4208b5[_0x9665('0x39')]=_[_0x9665('0x3a')](_0x16637f['model'],qs[_0x9665('0x3b')](_0x54c0f5['query'][_0x9665('0x3b')]));_0x4208b5[_0x9665('0x39')]=_0x4208b5[_0x9665('0x39')]['length']?_0x4208b5['attributes']:_0x16637f[_0x9665('0x36')];if(!_0x54c0f5[_0x9665('0x37')][_0x9665('0x3c')](_0x9665('0x3d'))){_0x4208b5[_0x9665('0x26')]=qs['limit'](_0x54c0f5[_0x9665('0x37')][_0x9665('0x26')]);_0x4208b5[_0x9665('0x25')]=qs[_0x9665('0x25')](_0x54c0f5[_0x9665('0x37')][_0x9665('0x25')]);}_0x4208b5[_0x9665('0x3e')]=qs[_0x9665('0x3f')](_0x54c0f5['query'][_0x9665('0x3f')]);_0x4208b5[_0x9665('0x40')]=qs[_0x9665('0x38')](_[_0x9665('0x41')](_0x54c0f5[_0x9665('0x37')],_0x16637f[_0x9665('0x38')]),_0x7efa76);if(_0x54c0f5[_0x9665('0x37')][_0x9665('0x42')]){_0x4208b5[_0x9665('0x40')]=_[_0x9665('0x43')](_0x4208b5[_0x9665('0x40')],{'$or':_[_0x9665('0x33')](_0x7efa76,function(_0x54a57){if(_0x54a57[_0x9665('0x44')]!==_0x9665('0x45')){var _0x35771d={};_0x35771d[_0x54a57['name']]={'$like':'%'+_0x54c0f5[_0x9665('0x37')][_0x9665('0x42')]+'%'};return _0x35771d;}})});}_0x4208b5=_[_0x9665('0x43')]({},_0x4208b5,_0x54c0f5[_0x9665('0x46')]);var _0x493c0e={'where':_0x4208b5[_0x9665('0x40')]};return db[_0x9665('0x47')]['count'](_0x493c0e)[_0x9665('0x2d')](function(_0x570f5c){_0x336c32[_0x9665('0x24')]=_0x570f5c;if(_0x54c0f5[_0x9665('0x37')][_0x9665('0x48')]){_0x4208b5[_0x9665('0x49')]=[{'all':!![]}];}return db[_0x9665('0x47')][_0x9665('0x4a')](_0x4208b5);})['then'](function(_0x234610){_0x336c32[_0x9665('0x4b')]=_0x234610;return _0x336c32;})[_0x9665('0x2d')](respondWithFilteredResult(_0x3aa324,_0x4208b5))[_0x9665('0x4c')](handleError(_0x3aa324,null));};exports['show']=function(_0x3d2d67,_0x12d574){var _0x590fd4={'raw':!![],'where':{'id':_0x3d2d67['params']['id']}},_0x4ec039={};_0x4ec039['model']=_[_0x9665('0x4d')](db['ChatInternalMessage'][_0x9665('0x34')]);_0x4ec039[_0x9665('0x37')]=_[_0x9665('0x4d')](_0x3d2d67['query']);_0x4ec039['filters']=_[_0x9665('0x3a')](_0x4ec039['model'],_0x4ec039[_0x9665('0x37')]);_0x590fd4[_0x9665('0x39')]=_[_0x9665('0x3a')](_0x4ec039[_0x9665('0x36')],qs[_0x9665('0x3b')](_0x3d2d67[_0x9665('0x37')][_0x9665('0x3b')]));_0x590fd4[_0x9665('0x39')]=_0x590fd4[_0x9665('0x39')]['length']?_0x590fd4[_0x9665('0x39')]:_0x4ec039[_0x9665('0x36')];if(_0x3d2d67['query'][_0x9665('0x48')]){_0x590fd4['include']=[{'all':!![]}];}_0x590fd4=_[_0x9665('0x43')]({},_0x590fd4,_0x3d2d67[_0x9665('0x46')]);return db['ChatInternalMessage'][_0x9665('0x4e')](_0x590fd4)[_0x9665('0x2d')](handleEntityNotFound(_0x12d574,null))[_0x9665('0x2d')](respondWithResult(_0x12d574,null))[_0x9665('0x4c')](handleError(_0x12d574,null));};exports[_0x9665('0x4f')]=function(_0x2d3f1b,_0x4d9360){return db[_0x9665('0x47')][_0x9665('0x4f')](_0x2d3f1b['body'],{})[_0x9665('0x2d')](respondWithResult(_0x4d9360,0xc9))[_0x9665('0x4c')](handleError(_0x4d9360,null));};exports[_0x9665('0x2c')]=function(_0x3a22c7,_0x179280){if(_0x3a22c7[_0x9665('0x50')]['id']){delete _0x3a22c7['body']['id'];}return db[_0x9665('0x47')][_0x9665('0x4e')]({'where':{'id':_0x3a22c7[_0x9665('0x51')]['id']}})['then'](handleEntityNotFound(_0x179280,null))['then'](saveUpdates(_0x3a22c7[_0x9665('0x50')],null))[_0x9665('0x2d')](respondWithResult(_0x179280,null))[_0x9665('0x4c')](handleError(_0x179280,null));};exports[_0x9665('0x2e')]=function(_0x5e91aa,_0x27612a){return db[_0x9665('0x47')][_0x9665('0x4e')]({'where':{'id':_0x5e91aa[_0x9665('0x51')]['id']}})['then'](handleEntityNotFound(_0x27612a,null))[_0x9665('0x2d')](removeEntity(_0x27612a,null))['catch'](handleError(_0x27612a,null));};exports['describe']=function(_0x245b93,_0x4c5e41){return db[_0x9665('0x47')]['describe']()[_0x9665('0x2d')](respondWithResult(_0x4c5e41,null))[_0x9665('0x4c')](handleError(_0x4c5e41,null));};function wrapUser(_0x16825e){return function(_0x10d33b){var _0x2fdd32=_0x16825e[_0x9665('0x52')]({'plain':!![]});_0x2fdd32[_0x9665('0x53')]=[];if(_0x10d33b){_0x2fdd32[_0x9665('0x54')]=_0x10d33b[_0x9665('0x55')];_0x2fdd32[_0x9665('0x56')]=_0x10d33b;}else{_0x2fdd32[_0x9665('0x54')]=moment(0x0)[_0x9665('0x57')](_0x9665('0x58'));_0x2fdd32[_0x9665('0x56')]={};}return _0x2fdd32;};}exports['getUsers']=function(_0x32ed5e,_0x5f119c,_0x56124b){var _0x4a180b=[];return db['User'][_0x9665('0x4a')]({'where':{'role':[_0x9665('0x59'),'admin',_0x9665('0x5a')]},'attributes':['id',_0x9665('0x5b'),_0x9665('0x30'),_0x9665('0x5c'),_0x9665('0x5d'),_0x9665('0x5e'),_0x9665('0x5f'),_0x9665('0x60'),_0x9665('0x61'),_0x9665('0x62')],'order':qs[_0x9665('0x3f')](_0x9665('0x63')),'include':[{'model':db[_0x9665('0x64')],'as':'VoiceQueues','attributes':['id','name',_0x9665('0x44')],'through':{'attributes':[]}}]})['then'](function(_0x3dcbfc){if(_0x3dcbfc){var _0x1c73b0=_0x32ed5e[_0x9665('0x5a')][_0x9665('0x52')]({'plain':!![]});if(!_0x1c73b0)throw new Error(_0x9665('0x65'));if(_0x1c73b0['role']==='user'){return db[_0x9665('0x66')][_0x9665('0x4e')]({'where':{'name':_0x9665('0x67'),'userProfileId':_0x1c73b0[_0x9665('0x68')]},'raw':!![]})[_0x9665('0x2d')](function(_0x52333c){if(_0x52333c){if(_0x52333c[_0x9665('0x69')]===0x0){return db[_0x9665('0x6a')]['findAll']({'where':{'sectionId':_0x52333c['id']},'raw':!![]})['then'](function(_0x404889){var _0x358a89=[];if(_['isEmpty'](_0x404889)){_0x358a89=_['filter'](_0x3dcbfc,function(_0x1eef79){if(_0x1eef79[_0x9665('0x5c')]!==_0x9665('0x59')){return _0x1eef79;}});return _0x358a89;}else{for(var _0x4d6f4e=0x0;_0x4d6f4e<_0x3dcbfc[_0x9665('0x6b')];_0x4d6f4e++){var _0x40cf59=_0x3dcbfc[_0x4d6f4e];if(_0x40cf59['role']==='agent'){var _0x5be196=_[_0x9665('0x4e')](_0x404889,function(_0x43b8df){return _0x43b8df['resourceId']===_0x40cf59['id'];});if(_0x5be196)_0x358a89['push'](_0x40cf59);}else{_0x358a89[_0x9665('0x6c')](_0x40cf59);}}return _0x358a89;}});}else{return _0x3dcbfc;}}else{var _0x5b4892=_[_0x9665('0x42')](_0x3dcbfc,function(_0x55f4a4){if(_0x55f4a4[_0x9665('0x5c')]!==_0x9665('0x59')){return _0x55f4a4;}});return _0x5b4892;}});}else{return _0x3dcbfc;}}})[_0x9665('0x2d')](function(_0x2e2eb7){var _0x33876e=[];if(_0x2e2eb7){_0x4a180b=_0x2e2eb7;for(var _0x440e39=0x0;_0x440e39<_0x2e2eb7[_0x9665('0x6b')];_0x440e39+=0x1){_0x4a180b[_0x440e39][_0x9665('0x53')]=[];_0x33876e[_0x9665('0x6c')](db[_0x9665('0x47')][_0x9665('0x4e')]({'where':{'FromId':[_0x32ed5e[_0x9665('0x5a')]['id'],_0x2e2eb7[_0x440e39]['id']],'ToId':[_0x32ed5e['user']['id'],_0x2e2eb7[_0x440e39]['id']],'ChatGroupId':null},'attributes':['id',_0x9665('0x55'),_0x9665('0x6d'),_0x9665('0x6e'),_0x9665('0x6f'),_0x9665('0x50')],'order':qs['sort']('-createdAt'),'limit':0x1,'offset':0x0,'raw':!![]})[_0x9665('0x2d')](wrapUser(_0x2e2eb7[_0x440e39])));}return BPromise[_0x9665('0x70')](_0x33876e);}return[];})[_0x9665('0x2d')](function(_0x1e36e0){return{'rows':_0x1e36e0,'count':_0x1e36e0[_0x9665('0x6b')]};})[_0x9665('0x2d')](respondWithResult(_0x5f119c,null))[_0x9665('0x4c')](handleError(_0x5f119c,null));};
\ No newline at end of file
+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