Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.controller.js
index 422292a..86eb7f8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0fc7=['jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','defaults','localhost','status','end','json','count','offset','set','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','send','index','map','ChatInternalMessage','rawAttributes','key','model','keys','query','filters','attributes','intersection','fields','hasOwnProperty','limit','order','sort','where','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','find','create','body','params','describe','get','messages','lastMessageAt','createdAt','format','YYYY-MM-DD\x20HH:mm:ss','agent','admin','user','role','userpic','internal','online','lastLoginAt','showWebBar','-online','VoiceQueue','VoiceQueues','UserProfileSection','Agents','UserProfileResource','isEmpty','length','resourceId','push','FromId','ToId','read','-createdAt','all','html-pdf','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','ejs','squel'];(function(_0x2298d0,_0x266cc7){var _0x2c9172=function(_0x346fbd){while(--_0x346fbd){_0x2298d0['push'](_0x2298d0['shift']());}};_0x2c9172(++_0x266cc7);}(_0x0fc7,0xcb));var _0x70fc=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0fc7[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x70fc('0x0'));var emlformat=require(_0x70fc('0x1'));var rimraf=require(_0x70fc('0x2'));var zipdir=require(_0x70fc('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x70fc('0x4'));var BPromise=require(_0x70fc('0x5'));var Mustache=require(_0x70fc('0x6'));var util=require(_0x70fc('0x7'));var path=require(_0x70fc('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x70fc('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x70fc('0xa'));var crypto=require('crypto');var jsforce=require(_0x70fc('0xb'));var deskjs=require(_0x70fc('0xc'));var toCsv=require(_0x70fc('0xd'));var querystring=require(_0x70fc('0xe'));var Papa=require(_0x70fc('0xf'));var Redis=require(_0x70fc('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x70fc('0x11'));var as=require(_0x70fc('0x12'));var hardwareService=require(_0x70fc('0x13'));var logger=require(_0x70fc('0x14'))(_0x70fc('0x15'));var utils=require(_0x70fc('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x70fc('0x17'));var db=require(_0x70fc('0x18'))['db'];config['redis']=_[_0x70fc('0x19')](config['redis'],{'host':_0x70fc('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./chatInternalMessage.socket')['register'](socket);function respondWithStatusCode(_0x254530,_0x4e73ae){_0x4e73ae=_0x4e73ae||0xcc;return function(_0x410d3a){if(_0x410d3a){return _0x254530['sendStatus'](_0x4e73ae);}return _0x254530[_0x70fc('0x1b')](_0x4e73ae)[_0x70fc('0x1c')]();};}function respondWithResult(_0x200006,_0x3116d0){_0x3116d0=_0x3116d0||0xc8;return function(_0x26114b){if(_0x26114b){return _0x200006[_0x70fc('0x1b')](_0x3116d0)[_0x70fc('0x1d')](_0x26114b);}};}function respondWithFilteredResult(_0x5246ae,_0x5c75a3){return function(_0x271f66){if(_0x271f66){var _0x57a376=_0x271f66[_0x70fc('0x1e')],_0xcfa71f=_0x5c75a3[_0x70fc('0x1f')],_0x4d1250=_0x5c75a3['offset']+_0x5c75a3['limit'],_0x221c83;if(_0x4d1250>=_0x57a376){_0x4d1250=_0x57a376;_0x221c83=0xc8;}else{_0x221c83=0xce;}_0x5246ae[_0x70fc('0x1b')](_0x221c83);return _0x5246ae[_0x70fc('0x20')]('Content-Range',_0xcfa71f+'-'+_0x4d1250+'/'+_0x57a376)[_0x70fc('0x1d')](_0x271f66);}return null;};}function patchUpdates(_0x377ed8){return function(_0x2e02ce){try{jsonpatch[_0x70fc('0x21')](_0x2e02ce,_0x377ed8,!![]);}catch(_0x57a60b){return BPromise[_0x70fc('0x22')](_0x57a60b);}return _0x2e02ce[_0x70fc('0x23')]();};}function saveUpdates(_0x1ace98,_0x52e069){return function(_0x445a95){if(_0x445a95){return _0x445a95[_0x70fc('0x24')](_0x1ace98)[_0x70fc('0x25')](function(_0x4213dd){return _0x4213dd;});}return null;};}function removeEntity(_0x45b741,_0x5a504c){return function(_0x176941){if(_0x176941){return _0x176941[_0x70fc('0x26')]()[_0x70fc('0x25')](function(){_0x45b741['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x281de8,_0x51edfb){return function(_0x2ed489){if(!_0x2ed489){_0x281de8[_0x70fc('0x27')](0x194);}return _0x2ed489;};}function handleError(_0x570297,_0x4fc663){_0x4fc663=_0x4fc663||0x1f4;return function(_0x7bdede){logger[_0x70fc('0x28')](_0x7bdede[_0x70fc('0x29')]);if(_0x7bdede[_0x70fc('0x2a')]){delete _0x7bdede[_0x70fc('0x2a')];}_0x570297['status'](_0x4fc663)[_0x70fc('0x2b')](_0x7bdede);};}exports[_0x70fc('0x2c')]=function(_0x1e31e8,_0x5621af){var _0x585f14={},_0x49c87d={},_0x25ec0f={'count':0x0,'rows':[]};var _0x710311=_[_0x70fc('0x2d')](db[_0x70fc('0x2e')][_0x70fc('0x2f')],function(_0x4d2022){return{'name':_0x4d2022['fieldName'],'type':_0x4d2022['type'][_0x70fc('0x30')]};});_0x49c87d[_0x70fc('0x31')]=_[_0x70fc('0x2d')](_0x710311,_0x70fc('0x2a'));_0x49c87d['query']=_[_0x70fc('0x32')](_0x1e31e8[_0x70fc('0x33')]);_0x49c87d[_0x70fc('0x34')]=_['intersection'](_0x49c87d[_0x70fc('0x31')],_0x49c87d['query']);_0x585f14[_0x70fc('0x35')]=_[_0x70fc('0x36')](_0x49c87d[_0x70fc('0x31')],qs['fields'](_0x1e31e8['query'][_0x70fc('0x37')]));_0x585f14[_0x70fc('0x35')]=_0x585f14[_0x70fc('0x35')]['length']?_0x585f14[_0x70fc('0x35')]:_0x49c87d[_0x70fc('0x31')];if(!_0x1e31e8[_0x70fc('0x33')][_0x70fc('0x38')]('nolimit')){_0x585f14[_0x70fc('0x39')]=qs[_0x70fc('0x39')](_0x1e31e8[_0x70fc('0x33')]['limit']);_0x585f14['offset']=qs[_0x70fc('0x1f')](_0x1e31e8['query']['offset']);}_0x585f14[_0x70fc('0x3a')]=qs[_0x70fc('0x3b')](_0x1e31e8[_0x70fc('0x33')][_0x70fc('0x3b')]);_0x585f14[_0x70fc('0x3c')]=qs['filters'](_['pick'](_0x1e31e8[_0x70fc('0x33')],_0x49c87d[_0x70fc('0x34')]),_0x710311);if(_0x1e31e8[_0x70fc('0x33')][_0x70fc('0x3d')]){_0x585f14['where']=_[_0x70fc('0x3e')](_0x585f14['where'],{'$or':_[_0x70fc('0x2d')](_0x710311,function(_0x34e323){if(_0x34e323[_0x70fc('0x3f')]!==_0x70fc('0x40')){var _0x181d24={};_0x181d24[_0x34e323[_0x70fc('0x2a')]]={'$like':'%'+_0x1e31e8['query'][_0x70fc('0x3d')]+'%'};return _0x181d24;}})});}_0x585f14=_['merge']({},_0x585f14,_0x1e31e8[_0x70fc('0x41')]);var _0x3c0f52={'where':_0x585f14[_0x70fc('0x3c')]};return db['ChatInternalMessage'][_0x70fc('0x1e')](_0x3c0f52)[_0x70fc('0x25')](function(_0x4dc0b2){_0x25ec0f[_0x70fc('0x1e')]=_0x4dc0b2;if(_0x1e31e8['query'][_0x70fc('0x42')]){_0x585f14[_0x70fc('0x43')]=[{'all':!![]}];}return db['ChatInternalMessage'][_0x70fc('0x44')](_0x585f14);})[_0x70fc('0x25')](function(_0x34758b){_0x25ec0f[_0x70fc('0x45')]=_0x34758b;return _0x25ec0f;})[_0x70fc('0x25')](respondWithFilteredResult(_0x5621af,_0x585f14))[_0x70fc('0x46')](handleError(_0x5621af,null));};exports[_0x70fc('0x47')]=function(_0x2e0cfe,_0x584cff){var _0x417d58={'raw':!![],'where':{'id':_0x2e0cfe['params']['id']}},_0x496e94={};_0x496e94[_0x70fc('0x31')]=_[_0x70fc('0x32')](db['ChatInternalMessage']['rawAttributes']);_0x496e94['query']=_[_0x70fc('0x32')](_0x2e0cfe[_0x70fc('0x33')]);_0x496e94[_0x70fc('0x34')]=_[_0x70fc('0x36')](_0x496e94['model'],_0x496e94[_0x70fc('0x33')]);_0x417d58[_0x70fc('0x35')]=_[_0x70fc('0x36')](_0x496e94['model'],qs[_0x70fc('0x37')](_0x2e0cfe[_0x70fc('0x33')][_0x70fc('0x37')]));_0x417d58[_0x70fc('0x35')]=_0x417d58[_0x70fc('0x35')]['length']?_0x417d58['attributes']:_0x496e94[_0x70fc('0x31')];if(_0x2e0cfe[_0x70fc('0x33')][_0x70fc('0x42')]){_0x417d58[_0x70fc('0x43')]=[{'all':!![]}];}_0x417d58=_[_0x70fc('0x3e')]({},_0x417d58,_0x2e0cfe['options']);return db['ChatInternalMessage'][_0x70fc('0x48')](_0x417d58)['then'](handleEntityNotFound(_0x584cff,null))['then'](respondWithResult(_0x584cff,null))[_0x70fc('0x46')](handleError(_0x584cff,null));};exports[_0x70fc('0x49')]=function(_0x47f817,_0x34a669){return db[_0x70fc('0x2e')][_0x70fc('0x49')](_0x47f817['body'],{})[_0x70fc('0x25')](respondWithResult(_0x34a669,0xc9))[_0x70fc('0x46')](handleError(_0x34a669,null));};exports['update']=function(_0x59ee68,_0x381ce9){if(_0x59ee68[_0x70fc('0x4a')]['id']){delete _0x59ee68[_0x70fc('0x4a')]['id'];}return db['ChatInternalMessage']['find']({'where':{'id':_0x59ee68[_0x70fc('0x4b')]['id']}})['then'](handleEntityNotFound(_0x381ce9,null))[_0x70fc('0x25')](saveUpdates(_0x59ee68[_0x70fc('0x4a')],null))['then'](respondWithResult(_0x381ce9,null))[_0x70fc('0x46')](handleError(_0x381ce9,null));};exports[_0x70fc('0x26')]=function(_0xedf3a2,_0x332fec){return db[_0x70fc('0x2e')][_0x70fc('0x48')]({'where':{'id':_0xedf3a2[_0x70fc('0x4b')]['id']}})['then'](handleEntityNotFound(_0x332fec,null))[_0x70fc('0x25')](removeEntity(_0x332fec,null))[_0x70fc('0x46')](handleError(_0x332fec,null));};exports[_0x70fc('0x4c')]=function(_0x53b869,_0x1b4e8f){return db['ChatInternalMessage'][_0x70fc('0x4c')]()['then'](respondWithResult(_0x1b4e8f,null))[_0x70fc('0x46')](handleError(_0x1b4e8f,null));};function wrapUser(_0xbe64f){return function(_0x4e6805){var _0x3cb504=_0xbe64f[_0x70fc('0x4d')]({'plain':!![]});_0x3cb504[_0x70fc('0x4e')]=[];if(_0x4e6805){_0x3cb504[_0x70fc('0x4f')]=_0x4e6805[_0x70fc('0x50')];_0x3cb504['lastMessage']=_0x4e6805;}else{_0x3cb504['lastMessageAt']=moment(0x0)[_0x70fc('0x51')](_0x70fc('0x52'));_0x3cb504['lastMessage']={};}return _0x3cb504;};}exports['getUsers']=function(_0x5912ac,_0x580b91,_0x471975){var _0x53b8e9=[];return db['User'][_0x70fc('0x44')]({'where':{'role':[_0x70fc('0x53'),_0x70fc('0x54'),_0x70fc('0x55')]},'attributes':['id','fullname',_0x70fc('0x2a'),_0x70fc('0x56'),_0x70fc('0x57'),_0x70fc('0x58'),_0x70fc('0x59'),_0x70fc('0x5a'),'allowmessenger',_0x70fc('0x5b')],'order':qs[_0x70fc('0x3b')](_0x70fc('0x5c')),'include':[{'model':db[_0x70fc('0x5d')],'as':_0x70fc('0x5e'),'attributes':['id',_0x70fc('0x2a'),_0x70fc('0x3f')],'through':{'attributes':[]}}]})['then'](function(_0x1d7a76){if(_0x1d7a76){var _0x3b1b02=_0x5912ac[_0x70fc('0x55')][_0x70fc('0x4d')]({'plain':!![]});if(!_0x3b1b02)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3b1b02[_0x70fc('0x56')]===_0x70fc('0x55')){return db[_0x70fc('0x5f')][_0x70fc('0x48')]({'where':{'name':_0x70fc('0x60'),'userProfileId':_0x3b1b02['userProfileId']},'raw':!![]})[_0x70fc('0x25')](function(_0x4921e6){if(_0x4921e6){if(_0x4921e6['autoAssociation']===0x0){return db[_0x70fc('0x61')][_0x70fc('0x44')]({'where':{'sectionId':_0x4921e6['id']},'raw':!![]})['then'](function(_0x346d74){var _0x5d082c=[];if(_[_0x70fc('0x62')](_0x346d74)){_0x5d082c=_['filter'](_0x1d7a76,function(_0x575c73){if(_0x575c73[_0x70fc('0x56')]!==_0x70fc('0x53')){return _0x575c73;}});return _0x5d082c;}else{for(var _0x393f3e=0x0;_0x393f3e<_0x1d7a76[_0x70fc('0x63')];_0x393f3e++){var _0x5c9e4d=_0x1d7a76[_0x393f3e];if(_0x5c9e4d[_0x70fc('0x56')]===_0x70fc('0x53')){var _0xe055a7=_[_0x70fc('0x48')](_0x346d74,function(_0x50b551){return _0x50b551[_0x70fc('0x64')]===_0x5c9e4d['id'];});if(_0xe055a7)_0x5d082c['push'](_0x5c9e4d);}else{_0x5d082c['push'](_0x5c9e4d);}}return _0x5d082c;}});}else{return _0x1d7a76;}}else{var _0x168fae=_[_0x70fc('0x3d')](_0x1d7a76,function(_0xf7afc9){if(_0xf7afc9[_0x70fc('0x56')]!=='agent'){return _0xf7afc9;}});return _0x168fae;}});}else{return _0x1d7a76;}}})['then'](function(_0x582581){var _0x5d8fe4=[];if(_0x582581){_0x53b8e9=_0x582581;for(var _0x5a2332=0x0;_0x5a2332<_0x582581[_0x70fc('0x63')];_0x5a2332+=0x1){_0x53b8e9[_0x5a2332][_0x70fc('0x4e')]=[];_0x5d8fe4[_0x70fc('0x65')](db[_0x70fc('0x2e')][_0x70fc('0x48')]({'where':{'FromId':[_0x5912ac[_0x70fc('0x55')]['id'],_0x582581[_0x5a2332]['id']],'ToId':[_0x5912ac['user']['id'],_0x582581[_0x5a2332]['id']],'ChatGroupId':null},'attributes':['id',_0x70fc('0x50'),_0x70fc('0x66'),_0x70fc('0x67'),_0x70fc('0x68'),_0x70fc('0x4a')],'order':qs[_0x70fc('0x3b')](_0x70fc('0x69')),'limit':0x1,'offset':0x0,'raw':!![]})[_0x70fc('0x25')](wrapUser(_0x582581[_0x5a2332])));}return BPromise[_0x70fc('0x6a')](_0x5d8fe4);}return[];})[_0x70fc('0x25')](function(_0x43e8e3){return{'rows':_0x43e8e3,'count':_0x43e8e3[_0x70fc('0x63')]};})['then'](respondWithResult(_0x580b91,null))[_0x70fc('0x46')](handleError(_0x580b91,null));};
\ No newline at end of file
+var _0xf41a=['type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','merge','filter','includeAll','findAll','rows','catch','show','params','include','options','body','find','destroy','describe','get','messages','lastMessageAt','lastMessage','format','getUsers','User','admin','role','userpic','showWebBar','-online','VoiceQueues','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','isEmpty','agent','resourceId','push','createdAt','FromId','ToId','read','all','eml-format','rimraf','fast-json-patch','mustache','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','redis','localhost','socket.io-emitter','./chatInternalMessage.socket','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','then','sendStatus','stack','name','send','map','ChatInternalMessage','rawAttributes','fieldName'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xf41a,0x1dd));var _0xaf41=function(_0x21f588,_0x3f63ae){_0x21f588=_0x21f588-0x0;var _0x3b28cb=_0xf41a[_0x21f588];return _0x3b28cb;};'use strict';var emlformat=require(_0xaf41('0x0'));var rimraf=require(_0xaf41('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xaf41('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xaf41('0x3'));var util=require('util');var path=require(_0xaf41('0x4'));var sox=require('sox');var csv=require(_0xaf41('0x5'));var ejs=require(_0xaf41('0x6'));var fs=require('fs');var fs_extra=require(_0xaf41('0x7'));var _=require('lodash');var squel=require(_0xaf41('0x8'));var crypto=require(_0xaf41('0x9'));var jsforce=require(_0xaf41('0xa'));var deskjs=require(_0xaf41('0xb'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xaf41('0xc'));var Redis=require(_0xaf41('0xd'));var authService=require(_0xaf41('0xe'));var qs=require(_0xaf41('0xf'));var as=require(_0xaf41('0x10'));var hardwareService=require(_0xaf41('0x11'));var logger=require(_0xaf41('0x12'))('api');var utils=require(_0xaf41('0x13'));var config=require(_0xaf41('0x14'));var licenseUtil=require(_0xaf41('0x15'));var db=require('../../mysqldb')['db'];config[_0xaf41('0x16')]=_['defaults'](config['redis'],{'host':_0xaf41('0x17'),'port':0x18eb});var socket=require(_0xaf41('0x18'))(new Redis(config[_0xaf41('0x16')]));require(_0xaf41('0x19'))['register'](socket);function respondWithStatusCode(_0x2fdcf2,_0x37a6ae){_0x37a6ae=_0x37a6ae||0xcc;return function(_0x1cdaec){if(_0x1cdaec){return _0x2fdcf2['sendStatus'](_0x37a6ae);}return _0x2fdcf2[_0xaf41('0x1a')](_0x37a6ae)[_0xaf41('0x1b')]();};}function respondWithResult(_0x47873e,_0x1ed489){_0x1ed489=_0x1ed489||0xc8;return function(_0x346aa6){if(_0x346aa6){return _0x47873e[_0xaf41('0x1a')](_0x1ed489)['json'](_0x346aa6);}};}function respondWithFilteredResult(_0x35d58d,_0x18c259){return function(_0x35ec23){if(_0x35ec23){var _0x2cc149=typeof _0x18c259[_0xaf41('0x1c')]===_0xaf41('0x1d')&&typeof _0x18c259[_0xaf41('0x1e')]===_0xaf41('0x1d');var _0x156ab5=_0x35ec23[_0xaf41('0x1f')];var _0x45c80b=_0x2cc149?0x0:_0x18c259[_0xaf41('0x1c')];var _0x1b5a1f=_0x2cc149?_0x35ec23[_0xaf41('0x1f')]:_0x18c259[_0xaf41('0x1c')]+_0x18c259[_0xaf41('0x1e')];var _0x5abeeb;if(_0x1b5a1f>=_0x156ab5){_0x1b5a1f=_0x156ab5;_0x5abeeb=0xc8;}else{_0x5abeeb=0xce;}_0x35d58d['status'](_0x5abeeb);return _0x35d58d[_0xaf41('0x20')](_0xaf41('0x21'),_0x45c80b+'-'+_0x1b5a1f+'/'+_0x156ab5)[_0xaf41('0x22')](_0x35ec23);}return null;};}function patchUpdates(_0xae1b00){return function(_0x3f6d03){try{jsonpatch[_0xaf41('0x23')](_0x3f6d03,_0xae1b00,!![]);}catch(_0x26abc7){return BPromise[_0xaf41('0x24')](_0x26abc7);}return _0x3f6d03[_0xaf41('0x25')]();};}function saveUpdates(_0xd5c6b8,_0x454489){return function(_0x20cf87){if(_0x20cf87){return _0x20cf87[_0xaf41('0x26')](_0xd5c6b8)[_0xaf41('0x27')](function(_0x29828a){return _0x29828a;});}return null;};}function removeEntity(_0x953b9f,_0x5533e4){return function(_0x3ed706){if(_0x3ed706){return _0x3ed706['destroy']()[_0xaf41('0x27')](function(){_0x953b9f[_0xaf41('0x1a')](0xcc)[_0xaf41('0x1b')]();});}};}function handleEntityNotFound(_0x334051,_0x260677){return function(_0x3d5031){if(!_0x3d5031){_0x334051[_0xaf41('0x28')](0x194);}return _0x3d5031;};}function handleError(_0x5de024,_0x31d48e){_0x31d48e=_0x31d48e||0x1f4;return function(_0x3a630f){logger['error'](_0x3a630f[_0xaf41('0x29')]);if(_0x3a630f[_0xaf41('0x2a')]){delete _0x3a630f[_0xaf41('0x2a')];}_0x5de024[_0xaf41('0x1a')](_0x31d48e)[_0xaf41('0x2b')](_0x3a630f);};}exports['index']=function(_0x3a4e3b,_0x482009){var _0x229f71={},_0x5fea95={},_0x342f48={'count':0x0,'rows':[]};var _0x248ec0=_[_0xaf41('0x2c')](db[_0xaf41('0x2d')][_0xaf41('0x2e')],function(_0x5d719f){return{'name':_0x5d719f[_0xaf41('0x2f')],'type':_0x5d719f[_0xaf41('0x30')][_0xaf41('0x31')]};});_0x5fea95[_0xaf41('0x32')]=_[_0xaf41('0x2c')](_0x248ec0,_0xaf41('0x2a'));_0x5fea95[_0xaf41('0x33')]=_[_0xaf41('0x34')](_0x3a4e3b[_0xaf41('0x33')]);_0x5fea95[_0xaf41('0x35')]=_['intersection'](_0x5fea95[_0xaf41('0x32')],_0x5fea95[_0xaf41('0x33')]);_0x229f71['attributes']=_[_0xaf41('0x36')](_0x5fea95[_0xaf41('0x32')],qs[_0xaf41('0x37')](_0x3a4e3b[_0xaf41('0x33')]['fields']));_0x229f71['attributes']=_0x229f71[_0xaf41('0x38')][_0xaf41('0x39')]?_0x229f71[_0xaf41('0x38')]:_0x5fea95['model'];if(!_0x3a4e3b[_0xaf41('0x33')][_0xaf41('0x3a')]('nolimit')){_0x229f71[_0xaf41('0x1e')]=qs[_0xaf41('0x1e')](_0x3a4e3b[_0xaf41('0x33')]['limit']);_0x229f71[_0xaf41('0x1c')]=qs[_0xaf41('0x1c')](_0x3a4e3b[_0xaf41('0x33')][_0xaf41('0x1c')]);}_0x229f71[_0xaf41('0x3b')]=qs[_0xaf41('0x3c')](_0x3a4e3b['query'][_0xaf41('0x3c')]);_0x229f71[_0xaf41('0x3d')]=qs[_0xaf41('0x35')](_[_0xaf41('0x3e')](_0x3a4e3b[_0xaf41('0x33')],_0x5fea95[_0xaf41('0x35')]),_0x248ec0);if(_0x3a4e3b[_0xaf41('0x33')]['filter']){_0x229f71[_0xaf41('0x3d')]=_[_0xaf41('0x3f')](_0x229f71[_0xaf41('0x3d')],{'$or':_[_0xaf41('0x2c')](_0x248ec0,function(_0x4aeb38){if(_0x4aeb38[_0xaf41('0x30')]!=='VIRTUAL'){var _0x4afa79={};_0x4afa79[_0x4aeb38['name']]={'$like':'%'+_0x3a4e3b[_0xaf41('0x33')][_0xaf41('0x40')]+'%'};return _0x4afa79;}})});}_0x229f71=_['merge']({},_0x229f71,_0x3a4e3b['options']);var _0x2d53fb={'where':_0x229f71[_0xaf41('0x3d')]};return db[_0xaf41('0x2d')]['count'](_0x2d53fb)[_0xaf41('0x27')](function(_0x51bbad){_0x342f48[_0xaf41('0x1f')]=_0x51bbad;if(_0x3a4e3b[_0xaf41('0x33')][_0xaf41('0x41')]){_0x229f71['include']=[{'all':!![]}];}return db[_0xaf41('0x2d')][_0xaf41('0x42')](_0x229f71);})['then'](function(_0x21d432){_0x342f48[_0xaf41('0x43')]=_0x21d432;return _0x342f48;})[_0xaf41('0x27')](respondWithFilteredResult(_0x482009,_0x229f71))[_0xaf41('0x44')](handleError(_0x482009,null));};exports[_0xaf41('0x45')]=function(_0x312523,_0x735f01){var _0x1af06e={'raw':!![],'where':{'id':_0x312523[_0xaf41('0x46')]['id']}},_0x3323b2={};_0x3323b2['model']=_[_0xaf41('0x34')](db[_0xaf41('0x2d')][_0xaf41('0x2e')]);_0x3323b2[_0xaf41('0x33')]=_[_0xaf41('0x34')](_0x312523[_0xaf41('0x33')]);_0x3323b2[_0xaf41('0x35')]=_[_0xaf41('0x36')](_0x3323b2[_0xaf41('0x32')],_0x3323b2[_0xaf41('0x33')]);_0x1af06e[_0xaf41('0x38')]=_[_0xaf41('0x36')](_0x3323b2[_0xaf41('0x32')],qs[_0xaf41('0x37')](_0x312523[_0xaf41('0x33')][_0xaf41('0x37')]));_0x1af06e[_0xaf41('0x38')]=_0x1af06e[_0xaf41('0x38')][_0xaf41('0x39')]?_0x1af06e['attributes']:_0x3323b2[_0xaf41('0x32')];if(_0x312523[_0xaf41('0x33')][_0xaf41('0x41')]){_0x1af06e[_0xaf41('0x47')]=[{'all':!![]}];}_0x1af06e=_[_0xaf41('0x3f')]({},_0x1af06e,_0x312523[_0xaf41('0x48')]);return db[_0xaf41('0x2d')]['find'](_0x1af06e)[_0xaf41('0x27')](handleEntityNotFound(_0x735f01,null))['then'](respondWithResult(_0x735f01,null))[_0xaf41('0x44')](handleError(_0x735f01,null));};exports['create']=function(_0x4c807a,_0x1c6655){return db[_0xaf41('0x2d')]['create'](_0x4c807a['body'],{})[_0xaf41('0x27')](respondWithResult(_0x1c6655,0xc9))[_0xaf41('0x44')](handleError(_0x1c6655,null));};exports['update']=function(_0x192f37,_0x2f2f8a){if(_0x192f37[_0xaf41('0x49')]['id']){delete _0x192f37[_0xaf41('0x49')]['id'];}return db[_0xaf41('0x2d')][_0xaf41('0x4a')]({'where':{'id':_0x192f37[_0xaf41('0x46')]['id']}})[_0xaf41('0x27')](handleEntityNotFound(_0x2f2f8a,null))['then'](saveUpdates(_0x192f37['body'],null))[_0xaf41('0x27')](respondWithResult(_0x2f2f8a,null))[_0xaf41('0x44')](handleError(_0x2f2f8a,null));};exports[_0xaf41('0x4b')]=function(_0x2af88d,_0x3d5cc5){return db[_0xaf41('0x2d')][_0xaf41('0x4a')]({'where':{'id':_0x2af88d[_0xaf41('0x46')]['id']}})['then'](handleEntityNotFound(_0x3d5cc5,null))[_0xaf41('0x27')](removeEntity(_0x3d5cc5,null))[_0xaf41('0x44')](handleError(_0x3d5cc5,null));};exports[_0xaf41('0x4c')]=function(_0x2902eb,_0x6f715b){return db[_0xaf41('0x2d')][_0xaf41('0x4c')]()['then'](respondWithResult(_0x6f715b,null))['catch'](handleError(_0x6f715b,null));};function wrapUser(_0x22c493){return function(_0x2e323b){var _0x5f3c6c=_0x22c493[_0xaf41('0x4d')]({'plain':!![]});_0x5f3c6c[_0xaf41('0x4e')]=[];if(_0x2e323b){_0x5f3c6c[_0xaf41('0x4f')]=_0x2e323b['createdAt'];_0x5f3c6c[_0xaf41('0x50')]=_0x2e323b;}else{_0x5f3c6c[_0xaf41('0x4f')]=moment(0x0)[_0xaf41('0x51')]('YYYY-MM-DD\x20HH:mm:ss');_0x5f3c6c[_0xaf41('0x50')]={};}return _0x5f3c6c;};}exports[_0xaf41('0x52')]=function(_0x4dfa0b,_0x274d86,_0xf423b3){var _0x5ca2cc=[];return db[_0xaf41('0x53')]['findAll']({'where':{'role':['agent',_0xaf41('0x54'),'user']},'attributes':['id','fullname',_0xaf41('0x2a'),_0xaf41('0x55'),_0xaf41('0x56'),'internal','online','lastLoginAt','allowmessenger',_0xaf41('0x57')],'order':qs[_0xaf41('0x3c')](_0xaf41('0x58')),'include':[{'model':db['VoiceQueue'],'as':_0xaf41('0x59'),'attributes':['id','name',_0xaf41('0x30')],'through':{'attributes':[]}}]})[_0xaf41('0x27')](function(_0x2cc6f4){if(_0x2cc6f4){var _0x4aa3bb=_0x4dfa0b['user'][_0xaf41('0x4d')]({'plain':!![]});if(!_0x4aa3bb)throw new Error(_0xaf41('0x5a'));if(_0x4aa3bb[_0xaf41('0x55')]===_0xaf41('0x5b')){return db[_0xaf41('0x5c')][_0xaf41('0x4a')]({'where':{'name':'Agents','userProfileId':_0x4aa3bb[_0xaf41('0x5d')]},'raw':!![]})[_0xaf41('0x27')](function(_0x50bf17){if(_0x50bf17){if(_0x50bf17[_0xaf41('0x5e')]===0x0){return db[_0xaf41('0x5f')]['findAll']({'where':{'sectionId':_0x50bf17['id']},'raw':!![]})[_0xaf41('0x27')](function(_0x5200e6){var _0x2dafb3=[];if(_[_0xaf41('0x60')](_0x5200e6)){_0x2dafb3=_[_0xaf41('0x40')](_0x2cc6f4,function(_0x219145){if(_0x219145[_0xaf41('0x55')]!==_0xaf41('0x61')){return _0x219145;}});return _0x2dafb3;}else{for(var _0xd3c2ad=0x0;_0xd3c2ad<_0x2cc6f4[_0xaf41('0x39')];_0xd3c2ad++){var _0x8093ae=_0x2cc6f4[_0xd3c2ad];if(_0x8093ae['role']===_0xaf41('0x61')){var _0x49fa94=_['find'](_0x5200e6,function(_0x596b70){return _0x596b70[_0xaf41('0x62')]===_0x8093ae['id'];});if(_0x49fa94)_0x2dafb3['push'](_0x8093ae);}else{_0x2dafb3[_0xaf41('0x63')](_0x8093ae);}}return _0x2dafb3;}});}else{return _0x2cc6f4;}}else{var _0x4a9f55=_[_0xaf41('0x40')](_0x2cc6f4,function(_0x19b474){if(_0x19b474['role']!=='agent'){return _0x19b474;}});return _0x4a9f55;}});}else{return _0x2cc6f4;}}})[_0xaf41('0x27')](function(_0x283341){var _0x3429cd=[];if(_0x283341){_0x5ca2cc=_0x283341;for(var _0x48e115=0x0;_0x48e115<_0x283341['length'];_0x48e115+=0x1){_0x5ca2cc[_0x48e115][_0xaf41('0x4e')]=[];_0x3429cd['push'](db[_0xaf41('0x2d')][_0xaf41('0x4a')]({'where':{'FromId':[_0x4dfa0b[_0xaf41('0x5b')]['id'],_0x283341[_0x48e115]['id']],'ToId':[_0x4dfa0b[_0xaf41('0x5b')]['id'],_0x283341[_0x48e115]['id']],'ChatGroupId':null},'attributes':['id',_0xaf41('0x64'),_0xaf41('0x65'),_0xaf41('0x66'),_0xaf41('0x67'),_0xaf41('0x49')],'order':qs[_0xaf41('0x3c')]('-createdAt'),'limit':0x1,'offset':0x0,'raw':!![]})['then'](wrapUser(_0x283341[_0x48e115])));}return BPromise[_0xaf41('0x68')](_0x3429cd);}return[];})['then'](function(_0x5b2f2c){return{'rows':_0x5b2f2c,'count':_0x5b2f2c[_0xaf41('0x39')]};})[_0xaf41('0x27')](respondWithResult(_0x274d86,null))[_0xaf41('0x44')](handleError(_0x274d86,null));};
\ No newline at end of file