Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.controller.js
index 620fc25..9c981bf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x94f4=['index','ChatInternalMessage','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','nolimit','order','sort','where','filter','merge','options','includeAll','include','findAll','rows','catch','show','params','length','find','update','body','describe','get','messages','lastMessageAt','YYYY-MM-DD\x20HH:mm:ss','lastMessage','getUsers','User','agent','user','role','internal','lastLoginAt','allowmessenger','showWebBar','-online','VoiceQueue','VoiceQueues','Unable\x20to\x20retrieve\x20the\x20current\x20user','Agents','userProfileId','autoAssociation','UserProfileResource','push','createdAt','FromId','ToId','read','-createdAt','all','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','end','json','offset','limit','set','reject','then','destroy','error','name','send'];(function(_0x2ec688,_0x436cd5){var _0x1f9b88=function(_0x1e578e){while(--_0x1e578e){_0x2ec688['push'](_0x2ec688['shift']());}};_0x1f9b88(++_0x436cd5);}(_0x94f4,0x1e6));var _0x494f=function(_0x1da586,_0x476132){_0x1da586=_0x1da586-0x0;var _0x362c81=_0x94f4[_0x1da586];return _0x362c81;};'use strict';var pdf=require(_0x494f('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x494f('0x1'));var zipdir=require(_0x494f('0x2'));var jsonpatch=require(_0x494f('0x3'));var rp=require(_0x494f('0x4'));var moment=require(_0x494f('0x5'));var BPromise=require(_0x494f('0x6'));var Mustache=require(_0x494f('0x7'));var util=require(_0x494f('0x8'));var path=require(_0x494f('0x9'));var sox=require(_0x494f('0xa'));var csv=require(_0x494f('0xb'));var ejs=require(_0x494f('0xc'));var fs=require('fs');var _=require(_0x494f('0xd'));var squel=require(_0x494f('0xe'));var crypto=require(_0x494f('0xf'));var jsforce=require(_0x494f('0x10'));var deskjs=require(_0x494f('0x11'));var toCsv=require(_0x494f('0xb'));var querystring=require(_0x494f('0x12'));var Papa=require('papaparse');var Redis=require(_0x494f('0x13'));var authService=require(_0x494f('0x14'));var qs=require('../../components/parsers/qs');var as=require(_0x494f('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x494f('0x16'))(_0x494f('0x17'));var utils=require(_0x494f('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x494f('0x19'));var db=require(_0x494f('0x1a'))['db'];config[_0x494f('0x1b')]=_[_0x494f('0x1c')](config[_0x494f('0x1b')],{'host':_0x494f('0x1d'),'port':0x18eb});var socket=require(_0x494f('0x1e'))(new Redis(config[_0x494f('0x1b')]));require('./chatInternalMessage.socket')['register'](socket);function respondWithStatusCode(_0x3c4a34,_0x421680){_0x421680=_0x421680||0xcc;return function(_0x4ae1c9){if(_0x4ae1c9){return _0x3c4a34[_0x494f('0x1f')](_0x421680);}return _0x3c4a34[_0x494f('0x20')](_0x421680)[_0x494f('0x21')]();};}function respondWithResult(_0x2cca65,_0x4689ef){_0x4689ef=_0x4689ef||0xc8;return function(_0x12c154){if(_0x12c154){return _0x2cca65[_0x494f('0x20')](_0x4689ef)[_0x494f('0x22')](_0x12c154);}};}function respondWithFilteredResult(_0x5f0a23,_0x213086){return function(_0x293d32){if(_0x293d32){var _0x4d3b83=_0x293d32['count'],_0x75197f=_0x213086[_0x494f('0x23')],_0x12440e=_0x213086[_0x494f('0x23')]+_0x213086[_0x494f('0x24')],_0x5b2c6d;if(_0x12440e>=_0x4d3b83){_0x12440e=_0x4d3b83;_0x5b2c6d=0xc8;}else{_0x5b2c6d=0xce;}_0x5f0a23['status'](_0x5b2c6d);return _0x5f0a23[_0x494f('0x25')]('Content-Range',_0x75197f+'-'+_0x12440e+'/'+_0x4d3b83)[_0x494f('0x22')](_0x293d32);}return null;};}function patchUpdates(_0x6bcf45){return function(_0x106c73){try{jsonpatch['apply'](_0x106c73,_0x6bcf45,!![]);}catch(_0x20f642){return BPromise[_0x494f('0x26')](_0x20f642);}return _0x106c73['save']();};}function saveUpdates(_0x553e27,_0x4617d9){return function(_0x469b75){if(_0x469b75){return _0x469b75['update'](_0x553e27)[_0x494f('0x27')](function(_0x5f33f6){return _0x5f33f6;});}return null;};}function removeEntity(_0x24916f,_0x1edd84){return function(_0x594d51){if(_0x594d51){return _0x594d51[_0x494f('0x28')]()[_0x494f('0x27')](function(){_0x24916f['status'](0xcc)[_0x494f('0x21')]();});}};}function handleEntityNotFound(_0xb8226a,_0x4e91de){return function(_0x30dcd3){if(!_0x30dcd3){_0xb8226a[_0x494f('0x1f')](0x194);}return _0x30dcd3;};}function handleError(_0x125fcb,_0x56d370){_0x56d370=_0x56d370||0x1f4;return function(_0x4fe049){logger[_0x494f('0x29')](_0x4fe049['stack']);if(_0x4fe049[_0x494f('0x2a')]){delete _0x4fe049[_0x494f('0x2a')];}_0x125fcb['status'](_0x56d370)[_0x494f('0x2b')](_0x4fe049);};}exports[_0x494f('0x2c')]=function(_0x1aeb4e,_0x574c59){var _0x259112={},_0x24e6ba={},_0x1b1d21={'count':0x0,'rows':[]};var _0x3b3d9e=_['map'](db[_0x494f('0x2d')][_0x494f('0x2e')],function(_0x362187){return{'name':_0x362187[_0x494f('0x2f')],'type':_0x362187[_0x494f('0x30')][_0x494f('0x31')]};});_0x24e6ba[_0x494f('0x32')]=_[_0x494f('0x33')](_0x3b3d9e,_0x494f('0x2a'));_0x24e6ba[_0x494f('0x34')]=_[_0x494f('0x35')](_0x1aeb4e[_0x494f('0x34')]);_0x24e6ba[_0x494f('0x36')]=_[_0x494f('0x37')](_0x24e6ba[_0x494f('0x32')],_0x24e6ba[_0x494f('0x34')]);_0x259112[_0x494f('0x38')]=_[_0x494f('0x37')](_0x24e6ba['model'],qs[_0x494f('0x39')](_0x1aeb4e[_0x494f('0x34')][_0x494f('0x39')]));_0x259112[_0x494f('0x38')]=_0x259112[_0x494f('0x38')]['length']?_0x259112['attributes']:_0x24e6ba[_0x494f('0x32')];if(!_0x1aeb4e['query']['hasOwnProperty'](_0x494f('0x3a'))){_0x259112[_0x494f('0x24')]=qs['limit'](_0x1aeb4e[_0x494f('0x34')][_0x494f('0x24')]);_0x259112[_0x494f('0x23')]=qs[_0x494f('0x23')](_0x1aeb4e[_0x494f('0x34')]['offset']);}_0x259112[_0x494f('0x3b')]=qs[_0x494f('0x3c')](_0x1aeb4e[_0x494f('0x34')][_0x494f('0x3c')]);_0x259112[_0x494f('0x3d')]=qs[_0x494f('0x36')](_['pick'](_0x1aeb4e[_0x494f('0x34')],_0x24e6ba['filters']),_0x3b3d9e);if(_0x1aeb4e[_0x494f('0x34')][_0x494f('0x3e')]){_0x259112['where']=_[_0x494f('0x3f')](_0x259112[_0x494f('0x3d')],{'$or':_[_0x494f('0x33')](_0x3b3d9e,function(_0x114957){if(_0x114957[_0x494f('0x30')]!=='VIRTUAL'){var _0x5d13e9={};_0x5d13e9[_0x114957[_0x494f('0x2a')]]={'$like':'%'+_0x1aeb4e[_0x494f('0x34')]['filter']+'%'};return _0x5d13e9;}})});}_0x259112=_[_0x494f('0x3f')]({},_0x259112,_0x1aeb4e[_0x494f('0x40')]);var _0x1ec3ab={'where':_0x259112[_0x494f('0x3d')]};return db['ChatInternalMessage']['count'](_0x1ec3ab)[_0x494f('0x27')](function(_0x16cbbf){_0x1b1d21['count']=_0x16cbbf;if(_0x1aeb4e[_0x494f('0x34')][_0x494f('0x41')]){_0x259112[_0x494f('0x42')]=[{'all':!![]}];}return db[_0x494f('0x2d')][_0x494f('0x43')](_0x259112);})[_0x494f('0x27')](function(_0x1e3aae){_0x1b1d21[_0x494f('0x44')]=_0x1e3aae;return _0x1b1d21;})['then'](respondWithFilteredResult(_0x574c59,_0x259112))[_0x494f('0x45')](handleError(_0x574c59,null));};exports[_0x494f('0x46')]=function(_0x4145e2,_0x2aa595){var _0x5c1310={'raw':!![],'where':{'id':_0x4145e2[_0x494f('0x47')]['id']}},_0x5ebeda={};_0x5ebeda[_0x494f('0x32')]=_[_0x494f('0x35')](db[_0x494f('0x2d')][_0x494f('0x2e')]);_0x5ebeda[_0x494f('0x34')]=_['keys'](_0x4145e2['query']);_0x5ebeda[_0x494f('0x36')]=_[_0x494f('0x37')](_0x5ebeda['model'],_0x5ebeda[_0x494f('0x34')]);_0x5c1310[_0x494f('0x38')]=_[_0x494f('0x37')](_0x5ebeda[_0x494f('0x32')],qs[_0x494f('0x39')](_0x4145e2[_0x494f('0x34')][_0x494f('0x39')]));_0x5c1310[_0x494f('0x38')]=_0x5c1310[_0x494f('0x38')][_0x494f('0x48')]?_0x5c1310[_0x494f('0x38')]:_0x5ebeda[_0x494f('0x32')];if(_0x4145e2[_0x494f('0x34')][_0x494f('0x41')]){_0x5c1310[_0x494f('0x42')]=[{'all':!![]}];}_0x5c1310=_[_0x494f('0x3f')]({},_0x5c1310,_0x4145e2[_0x494f('0x40')]);return db[_0x494f('0x2d')][_0x494f('0x49')](_0x5c1310)[_0x494f('0x27')](handleEntityNotFound(_0x2aa595,null))[_0x494f('0x27')](respondWithResult(_0x2aa595,null))[_0x494f('0x45')](handleError(_0x2aa595,null));};exports['create']=function(_0x337bf2,_0x2e7d27){return db[_0x494f('0x2d')]['create'](_0x337bf2['body'],{})[_0x494f('0x27')](respondWithResult(_0x2e7d27,0xc9))[_0x494f('0x45')](handleError(_0x2e7d27,null));};exports[_0x494f('0x4a')]=function(_0x27c432,_0x2e50b3){if(_0x27c432['body']['id']){delete _0x27c432[_0x494f('0x4b')]['id'];}return db[_0x494f('0x2d')][_0x494f('0x49')]({'where':{'id':_0x27c432['params']['id']}})[_0x494f('0x27')](handleEntityNotFound(_0x2e50b3,null))[_0x494f('0x27')](saveUpdates(_0x27c432['body'],null))[_0x494f('0x27')](respondWithResult(_0x2e50b3,null))[_0x494f('0x45')](handleError(_0x2e50b3,null));};exports[_0x494f('0x28')]=function(_0x10d3cc,_0x4f12f8){return db['ChatInternalMessage'][_0x494f('0x49')]({'where':{'id':_0x10d3cc['params']['id']}})[_0x494f('0x27')](handleEntityNotFound(_0x4f12f8,null))[_0x494f('0x27')](removeEntity(_0x4f12f8,null))[_0x494f('0x45')](handleError(_0x4f12f8,null));};exports[_0x494f('0x4c')]=function(_0x5a22db,_0x30f922){return db[_0x494f('0x2d')][_0x494f('0x4c')]()[_0x494f('0x27')](respondWithResult(_0x30f922,null))[_0x494f('0x45')](handleError(_0x30f922,null));};function wrapUser(_0x5d75c6){return function(_0x162278){var _0x2f4a0d=_0x5d75c6[_0x494f('0x4d')]({'plain':!![]});_0x2f4a0d[_0x494f('0x4e')]=[];if(_0x162278){_0x2f4a0d[_0x494f('0x4f')]=_0x162278['createdAt'];_0x2f4a0d['lastMessage']=_0x162278;}else{_0x2f4a0d[_0x494f('0x4f')]=moment(0x0)['format'](_0x494f('0x50'));_0x2f4a0d[_0x494f('0x51')]={};}return _0x2f4a0d;};}exports[_0x494f('0x52')]=function(_0xe01b26,_0x1db2a6,_0xb93fb3){var _0x153d54=[];return db[_0x494f('0x53')][_0x494f('0x43')]({'where':{'role':[_0x494f('0x54'),'admin',_0x494f('0x55')]},'attributes':['id','fullname',_0x494f('0x2a'),_0x494f('0x56'),'userpic',_0x494f('0x57'),'online',_0x494f('0x58'),_0x494f('0x59'),_0x494f('0x5a')],'order':qs[_0x494f('0x3c')](_0x494f('0x5b')),'include':[{'model':db[_0x494f('0x5c')],'as':_0x494f('0x5d'),'attributes':['id',_0x494f('0x2a'),_0x494f('0x30')],'through':{'attributes':[]}}]})[_0x494f('0x27')](function(_0x55ce9e){if(_0x55ce9e){var _0x5ace64=_0xe01b26[_0x494f('0x55')][_0x494f('0x4d')]({'plain':!![]});if(!_0x5ace64)throw new Error(_0x494f('0x5e'));if(_0x5ace64['role']===_0x494f('0x55')){return db['UserProfileSection'][_0x494f('0x49')]({'where':{'name':_0x494f('0x5f'),'userProfileId':_0x5ace64[_0x494f('0x60')]},'raw':!![]})[_0x494f('0x27')](function(_0x1d04f9){if(_0x1d04f9){if(_0x1d04f9[_0x494f('0x61')]===0x0){return db[_0x494f('0x62')]['findAll']({'where':{'sectionId':_0x1d04f9['id']},'raw':!![]})[_0x494f('0x27')](function(_0x2bce12){var _0x17e2eb=[];if(_['isEmpty'](_0x2bce12)){_0x17e2eb=_[_0x494f('0x3e')](_0x55ce9e,function(_0x229cc9){if(_0x229cc9[_0x494f('0x56')]!==_0x494f('0x54')){return _0x229cc9;}});return _0x17e2eb;}else{for(var _0x52978c=0x0;_0x52978c<_0x55ce9e[_0x494f('0x48')];_0x52978c++){var _0x460011=_0x55ce9e[_0x52978c];if(_0x460011[_0x494f('0x56')]==='agent'){var _0x4a6092=_[_0x494f('0x49')](_0x2bce12,function(_0x58d325){return _0x58d325['resourceId']===_0x460011['id'];});if(_0x4a6092)_0x17e2eb[_0x494f('0x63')](_0x460011);}else{_0x17e2eb[_0x494f('0x63')](_0x460011);}}return _0x17e2eb;}});}else{return _0x55ce9e;}}else{var _0x3cb7e2=_[_0x494f('0x3e')](_0x55ce9e,function(_0x5c0fdf){if(_0x5c0fdf[_0x494f('0x56')]!=='agent'){return _0x5c0fdf;}});return _0x3cb7e2;}});}else{return _0x55ce9e;}}})['then'](function(_0x1f1356){var _0x5e2b71=[];if(_0x1f1356){_0x153d54=_0x1f1356;for(var _0x47010b=0x0;_0x47010b<_0x1f1356[_0x494f('0x48')];_0x47010b+=0x1){_0x153d54[_0x47010b][_0x494f('0x4e')]=[];_0x5e2b71[_0x494f('0x63')](db['ChatInternalMessage']['find']({'where':{'FromId':[_0xe01b26[_0x494f('0x55')]['id'],_0x1f1356[_0x47010b]['id']],'ToId':[_0xe01b26[_0x494f('0x55')]['id'],_0x1f1356[_0x47010b]['id']],'ChatGroupId':null},'attributes':['id',_0x494f('0x64'),_0x494f('0x65'),_0x494f('0x66'),_0x494f('0x67'),_0x494f('0x4b')],'order':qs[_0x494f('0x3c')](_0x494f('0x68')),'limit':0x1,'offset':0x0,'raw':!![]})['then'](wrapUser(_0x1f1356[_0x47010b])));}return BPromise[_0x494f('0x69')](_0x5e2b71);}return[];})[_0x494f('0x27')](function(_0x4c92f5){return{'rows':_0x4c92f5,'count':_0x4c92f5['length']};})[_0x494f('0x27')](respondWithResult(_0x1db2a6,null))[_0x494f('0x45')](handleError(_0x1db2a6,null));};
\ No newline at end of file
+var _0x8fab=['attributes','length','nolimit','order','sort','pick','filter','map','VIRTUAL','merge','options','include','findAll','then','rows','catch','show','params','keys','includeAll','find','create','body','describe','messages','lastMessageAt','createdAt','lastMessage','format','YYYY-MM-DD\x20HH:mm:ss','getUsers','User','agent','admin','fullname','role','internal','online','lastLoginAt','allowmessenger','showWebBar','-online','VoiceQueue','VoiceQueues','get','user','UserProfileSection','Agents','userProfileId','autoAssociation','UserProfileResource','isEmpty','push','FromId','ToId','all','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','end','status','json','count','offset','limit','set','Content-Range','save','update','destroy','stack','name','ChatInternalMessage','rawAttributes','fieldName','type','model','query','filters','intersection','fields'];(function(_0x462f0e,_0x1d1cfd){var _0x5d8632=function(_0x1dcda6){while(--_0x1dcda6){_0x462f0e['push'](_0x462f0e['shift']());}};_0x5d8632(++_0x1d1cfd);}(_0x8fab,0x112));var _0xb8fa=function(_0x3c47ce,_0x4e53b0){_0x3c47ce=_0x3c47ce-0x0;var _0x4528a9=_0x8fab[_0x3c47ce];return _0x4528a9;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xb8fa('0x0'));var rimraf=require(_0xb8fa('0x1'));var zipdir=require(_0xb8fa('0x2'));var jsonpatch=require(_0xb8fa('0x3'));var rp=require(_0xb8fa('0x4'));var moment=require(_0xb8fa('0x5'));var BPromise=require(_0xb8fa('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0xb8fa('0x7'));var sox=require(_0xb8fa('0x8'));var csv=require(_0xb8fa('0x9'));var ejs=require(_0xb8fa('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0xb8fa('0xb'));var crypto=require(_0xb8fa('0xc'));var jsforce=require(_0xb8fa('0xd'));var deskjs=require(_0xb8fa('0xe'));var toCsv=require(_0xb8fa('0x9'));var querystring=require(_0xb8fa('0xf'));var Papa=require(_0xb8fa('0x10'));var Redis=require(_0xb8fa('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xb8fa('0x12'));var as=require(_0xb8fa('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xb8fa('0x14'))(_0xb8fa('0x15'));var utils=require(_0xb8fa('0x16'));var config=require(_0xb8fa('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xb8fa('0x18'))['db'];config[_0xb8fa('0x19')]=_[_0xb8fa('0x1a')](config[_0xb8fa('0x19')],{'host':_0xb8fa('0x1b'),'port':0x18eb});var socket=require(_0xb8fa('0x1c'))(new Redis(config['redis']));require('./chatInternalMessage.socket')[_0xb8fa('0x1d')](socket);function respondWithStatusCode(_0x3f62db,_0x4548a0){_0x4548a0=_0x4548a0||0xcc;return function(_0x1f00fb){if(_0x1f00fb){return _0x3f62db[_0xb8fa('0x1e')](_0x4548a0);}return _0x3f62db['status'](_0x4548a0)[_0xb8fa('0x1f')]();};}function respondWithResult(_0x10568d,_0x213b0d){_0x213b0d=_0x213b0d||0xc8;return function(_0x41e0eb){if(_0x41e0eb){return _0x10568d[_0xb8fa('0x20')](_0x213b0d)[_0xb8fa('0x21')](_0x41e0eb);}};}function respondWithFilteredResult(_0x3406a5,_0x41babe){return function(_0x2f8c25){if(_0x2f8c25){var _0x486e01=_0x2f8c25[_0xb8fa('0x22')],_0x1ceb9d=_0x41babe[_0xb8fa('0x23')],_0x55ba9e=_0x41babe[_0xb8fa('0x23')]+_0x41babe[_0xb8fa('0x24')],_0x4983ae;if(_0x55ba9e>=_0x486e01){_0x55ba9e=_0x486e01;_0x4983ae=0xc8;}else{_0x4983ae=0xce;}_0x3406a5[_0xb8fa('0x20')](_0x4983ae);return _0x3406a5[_0xb8fa('0x25')](_0xb8fa('0x26'),_0x1ceb9d+'-'+_0x55ba9e+'/'+_0x486e01)[_0xb8fa('0x21')](_0x2f8c25);}return null;};}function patchUpdates(_0xa873fb){return function(_0x183ba3){try{jsonpatch['apply'](_0x183ba3,_0xa873fb,!![]);}catch(_0x59b6fd){return BPromise['reject'](_0x59b6fd);}return _0x183ba3[_0xb8fa('0x27')]();};}function saveUpdates(_0x22377a,_0x5ed8bd){return function(_0x263407){if(_0x263407){return _0x263407[_0xb8fa('0x28')](_0x22377a)['then'](function(_0x108ab7){return _0x108ab7;});}return null;};}function removeEntity(_0x29e1eb,_0x5e1d28){return function(_0x38f327){if(_0x38f327){return _0x38f327[_0xb8fa('0x29')]()['then'](function(){_0x29e1eb[_0xb8fa('0x20')](0xcc)[_0xb8fa('0x1f')]();});}};}function handleEntityNotFound(_0x116118,_0x26ae14){return function(_0x3074af){if(!_0x3074af){_0x116118[_0xb8fa('0x1e')](0x194);}return _0x3074af;};}function handleError(_0x4b8514,_0x46369d){_0x46369d=_0x46369d||0x1f4;return function(_0x11cee2){logger['error'](_0x11cee2[_0xb8fa('0x2a')]);if(_0x11cee2[_0xb8fa('0x2b')]){delete _0x11cee2[_0xb8fa('0x2b')];}_0x4b8514[_0xb8fa('0x20')](_0x46369d)['send'](_0x11cee2);};}exports['index']=function(_0x24c639,_0x42cbcf){var _0x53cb0c={},_0x4a3817={},_0x5f505b={'count':0x0,'rows':[]};var _0x15c5f2=_['map'](db[_0xb8fa('0x2c')][_0xb8fa('0x2d')],function(_0x464072){return{'name':_0x464072[_0xb8fa('0x2e')],'type':_0x464072[_0xb8fa('0x2f')]['key']};});_0x4a3817[_0xb8fa('0x30')]=_['map'](_0x15c5f2,'name');_0x4a3817[_0xb8fa('0x31')]=_['keys'](_0x24c639[_0xb8fa('0x31')]);_0x4a3817[_0xb8fa('0x32')]=_[_0xb8fa('0x33')](_0x4a3817[_0xb8fa('0x30')],_0x4a3817[_0xb8fa('0x31')]);_0x53cb0c['attributes']=_[_0xb8fa('0x33')](_0x4a3817[_0xb8fa('0x30')],qs['fields'](_0x24c639[_0xb8fa('0x31')][_0xb8fa('0x34')]));_0x53cb0c[_0xb8fa('0x35')]=_0x53cb0c['attributes'][_0xb8fa('0x36')]?_0x53cb0c[_0xb8fa('0x35')]:_0x4a3817[_0xb8fa('0x30')];if(!_0x24c639[_0xb8fa('0x31')]['hasOwnProperty'](_0xb8fa('0x37'))){_0x53cb0c[_0xb8fa('0x24')]=qs[_0xb8fa('0x24')](_0x24c639['query'][_0xb8fa('0x24')]);_0x53cb0c[_0xb8fa('0x23')]=qs[_0xb8fa('0x23')](_0x24c639[_0xb8fa('0x31')][_0xb8fa('0x23')]);}_0x53cb0c[_0xb8fa('0x38')]=qs[_0xb8fa('0x39')](_0x24c639['query'][_0xb8fa('0x39')]);_0x53cb0c['where']=qs[_0xb8fa('0x32')](_[_0xb8fa('0x3a')](_0x24c639[_0xb8fa('0x31')],_0x4a3817[_0xb8fa('0x32')]),_0x15c5f2);if(_0x24c639[_0xb8fa('0x31')][_0xb8fa('0x3b')]){_0x53cb0c['where']=_['merge'](_0x53cb0c['where'],{'$or':_[_0xb8fa('0x3c')](_0x15c5f2,function(_0x18215d){if(_0x18215d[_0xb8fa('0x2f')]!==_0xb8fa('0x3d')){var _0x242f08={};_0x242f08[_0x18215d[_0xb8fa('0x2b')]]={'$like':'%'+_0x24c639['query'][_0xb8fa('0x3b')]+'%'};return _0x242f08;}})});}_0x53cb0c=_[_0xb8fa('0x3e')]({},_0x53cb0c,_0x24c639[_0xb8fa('0x3f')]);var _0x17a9ac={'where':_0x53cb0c['where']};return db[_0xb8fa('0x2c')][_0xb8fa('0x22')](_0x17a9ac)['then'](function(_0x197fa5){_0x5f505b['count']=_0x197fa5;if(_0x24c639[_0xb8fa('0x31')]['includeAll']){_0x53cb0c[_0xb8fa('0x40')]=[{'all':!![]}];}return db[_0xb8fa('0x2c')][_0xb8fa('0x41')](_0x53cb0c);})[_0xb8fa('0x42')](function(_0x40bf48){_0x5f505b[_0xb8fa('0x43')]=_0x40bf48;return _0x5f505b;})[_0xb8fa('0x42')](respondWithFilteredResult(_0x42cbcf,_0x53cb0c))[_0xb8fa('0x44')](handleError(_0x42cbcf,null));};exports[_0xb8fa('0x45')]=function(_0x604b16,_0x1f652a){var _0x3af31e={'raw':!![],'where':{'id':_0x604b16[_0xb8fa('0x46')]['id']}},_0x51388f={};_0x51388f['model']=_[_0xb8fa('0x47')](db['ChatInternalMessage'][_0xb8fa('0x2d')]);_0x51388f[_0xb8fa('0x31')]=_[_0xb8fa('0x47')](_0x604b16[_0xb8fa('0x31')]);_0x51388f[_0xb8fa('0x32')]=_[_0xb8fa('0x33')](_0x51388f[_0xb8fa('0x30')],_0x51388f[_0xb8fa('0x31')]);_0x3af31e[_0xb8fa('0x35')]=_[_0xb8fa('0x33')](_0x51388f['model'],qs[_0xb8fa('0x34')](_0x604b16[_0xb8fa('0x31')]['fields']));_0x3af31e['attributes']=_0x3af31e[_0xb8fa('0x35')][_0xb8fa('0x36')]?_0x3af31e[_0xb8fa('0x35')]:_0x51388f['model'];if(_0x604b16[_0xb8fa('0x31')][_0xb8fa('0x48')]){_0x3af31e[_0xb8fa('0x40')]=[{'all':!![]}];}_0x3af31e=_['merge']({},_0x3af31e,_0x604b16[_0xb8fa('0x3f')]);return db[_0xb8fa('0x2c')][_0xb8fa('0x49')](_0x3af31e)[_0xb8fa('0x42')](handleEntityNotFound(_0x1f652a,null))[_0xb8fa('0x42')](respondWithResult(_0x1f652a,null))[_0xb8fa('0x44')](handleError(_0x1f652a,null));};exports['create']=function(_0x5e2549,_0x4b4e73){return db[_0xb8fa('0x2c')][_0xb8fa('0x4a')](_0x5e2549[_0xb8fa('0x4b')],{})[_0xb8fa('0x42')](respondWithResult(_0x4b4e73,0xc9))[_0xb8fa('0x44')](handleError(_0x4b4e73,null));};exports[_0xb8fa('0x28')]=function(_0x46766a,_0x4050f7){if(_0x46766a[_0xb8fa('0x4b')]['id']){delete _0x46766a[_0xb8fa('0x4b')]['id'];}return db[_0xb8fa('0x2c')][_0xb8fa('0x49')]({'where':{'id':_0x46766a[_0xb8fa('0x46')]['id']}})[_0xb8fa('0x42')](handleEntityNotFound(_0x4050f7,null))['then'](saveUpdates(_0x46766a[_0xb8fa('0x4b')],null))[_0xb8fa('0x42')](respondWithResult(_0x4050f7,null))[_0xb8fa('0x44')](handleError(_0x4050f7,null));};exports[_0xb8fa('0x29')]=function(_0x39eace,_0x13bc9c){return db[_0xb8fa('0x2c')][_0xb8fa('0x49')]({'where':{'id':_0x39eace[_0xb8fa('0x46')]['id']}})['then'](handleEntityNotFound(_0x13bc9c,null))[_0xb8fa('0x42')](removeEntity(_0x13bc9c,null))[_0xb8fa('0x44')](handleError(_0x13bc9c,null));};exports[_0xb8fa('0x4c')]=function(_0x56e6da,_0x2a88cc){return db[_0xb8fa('0x2c')][_0xb8fa('0x4c')]()[_0xb8fa('0x42')](respondWithResult(_0x2a88cc,null))[_0xb8fa('0x44')](handleError(_0x2a88cc,null));};function wrapUser(_0x17c66c){return function(_0x2220c5){var _0x535404=_0x17c66c['get']({'plain':!![]});_0x535404[_0xb8fa('0x4d')]=[];if(_0x2220c5){_0x535404[_0xb8fa('0x4e')]=_0x2220c5[_0xb8fa('0x4f')];_0x535404[_0xb8fa('0x50')]=_0x2220c5;}else{_0x535404[_0xb8fa('0x4e')]=moment(0x0)[_0xb8fa('0x51')](_0xb8fa('0x52'));_0x535404[_0xb8fa('0x50')]={};}return _0x535404;};}exports[_0xb8fa('0x53')]=function(_0x3be035,_0x44e096,_0x1ba588){var _0x29b5ba=[];return db[_0xb8fa('0x54')][_0xb8fa('0x41')]({'where':{'role':[_0xb8fa('0x55'),_0xb8fa('0x56'),'user']},'attributes':['id',_0xb8fa('0x57'),_0xb8fa('0x2b'),_0xb8fa('0x58'),'userpic',_0xb8fa('0x59'),_0xb8fa('0x5a'),_0xb8fa('0x5b'),_0xb8fa('0x5c'),_0xb8fa('0x5d')],'order':qs[_0xb8fa('0x39')](_0xb8fa('0x5e')),'include':[{'model':db[_0xb8fa('0x5f')],'as':_0xb8fa('0x60'),'attributes':['id',_0xb8fa('0x2b'),_0xb8fa('0x2f')],'through':{'attributes':[]}}]})[_0xb8fa('0x42')](function(_0x54b55a){if(_0x54b55a){var _0x55e268=_0x3be035['user'][_0xb8fa('0x61')]({'plain':!![]});if(!_0x55e268)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x55e268[_0xb8fa('0x58')]===_0xb8fa('0x62')){return db[_0xb8fa('0x63')]['find']({'where':{'name':_0xb8fa('0x64'),'userProfileId':_0x55e268[_0xb8fa('0x65')]},'raw':!![]})[_0xb8fa('0x42')](function(_0x4754bd){if(_0x4754bd){if(_0x4754bd[_0xb8fa('0x66')]===0x0){return db[_0xb8fa('0x67')][_0xb8fa('0x41')]({'where':{'sectionId':_0x4754bd['id']},'raw':!![]})['then'](function(_0x5c2ebf){var _0x2a5502=[];if(_[_0xb8fa('0x68')](_0x5c2ebf)){_0x2a5502=_[_0xb8fa('0x3b')](_0x54b55a,function(_0xe5c16e){if(_0xe5c16e[_0xb8fa('0x58')]!=='agent'){return _0xe5c16e;}});return _0x2a5502;}else{for(var _0x51d825=0x0;_0x51d825<_0x54b55a['length'];_0x51d825++){var _0x7183c3=_0x54b55a[_0x51d825];if(_0x7183c3[_0xb8fa('0x58')]===_0xb8fa('0x55')){var _0x1bac61=_[_0xb8fa('0x49')](_0x5c2ebf,function(_0x3c0878){return _0x3c0878['resourceId']===_0x7183c3['id'];});if(_0x1bac61)_0x2a5502[_0xb8fa('0x69')](_0x7183c3);}else{_0x2a5502[_0xb8fa('0x69')](_0x7183c3);}}return _0x2a5502;}});}else{return _0x54b55a;}}else{var _0x1c41f0=_['filter'](_0x54b55a,function(_0x638921){if(_0x638921[_0xb8fa('0x58')]!==_0xb8fa('0x55')){return _0x638921;}});return _0x1c41f0;}});}else{return _0x54b55a;}}})['then'](function(_0x2487b4){var _0x58364c=[];if(_0x2487b4){_0x29b5ba=_0x2487b4;for(var _0xe71332=0x0;_0xe71332<_0x2487b4[_0xb8fa('0x36')];_0xe71332+=0x1){_0x29b5ba[_0xe71332]['messages']=[];_0x58364c[_0xb8fa('0x69')](db[_0xb8fa('0x2c')][_0xb8fa('0x49')]({'where':{'FromId':[_0x3be035[_0xb8fa('0x62')]['id'],_0x2487b4[_0xe71332]['id']],'ToId':[_0x3be035['user']['id'],_0x2487b4[_0xe71332]['id']],'ChatGroupId':null},'attributes':['id',_0xb8fa('0x4f'),_0xb8fa('0x6a'),_0xb8fa('0x6b'),'read','body'],'order':qs[_0xb8fa('0x39')]('-createdAt'),'limit':0x1,'offset':0x0,'raw':!![]})[_0xb8fa('0x42')](wrapUser(_0x2487b4[_0xe71332])));}return BPromise[_0xb8fa('0x6c')](_0x58364c);}return[];})[_0xb8fa('0x42')](function(_0x3b009b){return{'rows':_0x3b009b,'count':_0x3b009b[_0xb8fa('0x36')]};})[_0xb8fa('0x42')](respondWithResult(_0x44e096,null))[_0xb8fa('0x44')](handleError(_0x44e096,null));};
\ No newline at end of file