Built motion from commit (unavailable).|2.4.3
[motion2.git] / server / api / chatInternalMessage / chatInternalMessage.controller.js
index 900aa7c..67278af 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x75f6=['role','userpic','internal','online','lastLoginAt','showWebBar','VoiceQueue','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','Agents','autoAssociation','UserProfileResource','isEmpty','resourceId','push','messages','createdAt','FromId','ToId','read','-createdAt','all','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','path','sox','to-csv','ejs','squel','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./chatInternalMessage.socket','register','sendStatus','status','end','count','offset','limit','set','apply','reject','update','then','error','stack','name','send','index','ChatInternalMessage','rawAttributes','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','sort','where','pick','filters','filter','map','type','VIRTUAL','field','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','destroy','describe','get','lastMessageAt','format','lastMessage','getUsers','User','agent','user','fullname'];(function(_0x3726b3,_0x1d9f2e){var _0x3d040f=function(_0x1ba1d1){while(--_0x1ba1d1){_0x3726b3['push'](_0x3726b3['shift']());}};_0x3d040f(++_0x1d9f2e);}(_0x75f6,0xe8));var _0x675f=function(_0x1db399,_0x39fafe){_0x1db399=_0x1db399-0x0;var _0x543a57=_0x75f6[_0x1db399];return _0x543a57;};'use strict';var pdf=require(_0x675f('0x0'));var emlformat=require(_0x675f('0x1'));var rimraf=require(_0x675f('0x2'));var zipdir=require(_0x675f('0x3'));var jsonpatch=require(_0x675f('0x4'));var rp=require(_0x675f('0x5'));var moment=require('moment');var BPromise=require(_0x675f('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0x675f('0x7'));var sox=require(_0x675f('0x8'));var csv=require(_0x675f('0x9'));var ejs=require(_0x675f('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x675f('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x675f('0xc'));var toCsv=require(_0x675f('0x9'));var querystring=require(_0x675f('0xd'));var Papa=require(_0x675f('0xe'));var Redis=require(_0x675f('0xf'));var authService=require(_0x675f('0x10'));var qs=require('../../components/parsers/qs');var hardwareService=require(_0x675f('0x11'));var logger=require('../../config/logger')('api');var utils=require(_0x675f('0x12'));var config=require(_0x675f('0x13'));var db=require(_0x675f('0x14'))['db'];config[_0x675f('0x15')]=_[_0x675f('0x16')](config[_0x675f('0x15')],{'host':'localhost','port':0x18eb});var socket=require(_0x675f('0x17'))(new Redis(config[_0x675f('0x15')]));require(_0x675f('0x18'))[_0x675f('0x19')](socket);function respondWithStatusCode(_0x23fa9f,_0x422401){_0x422401=_0x422401||0xcc;return function(_0x38c46b){if(_0x38c46b){return _0x23fa9f[_0x675f('0x1a')](_0x422401);}return _0x23fa9f[_0x675f('0x1b')](_0x422401)[_0x675f('0x1c')]();};}function respondWithResult(_0x58dd1e,_0x1ac567){_0x1ac567=_0x1ac567||0xc8;return function(_0x3140dd){if(_0x3140dd){return _0x58dd1e[_0x675f('0x1b')](_0x1ac567)['json'](_0x3140dd);}};}function respondWithFilteredResult(_0x25d334,_0x1b2a13){return function(_0x5ee11d){if(_0x5ee11d){var _0x404e10=_0x5ee11d[_0x675f('0x1d')],_0x41a1ad=_0x1b2a13['offset'],_0x4b4d8a=_0x1b2a13[_0x675f('0x1e')]+_0x1b2a13[_0x675f('0x1f')],_0x2210f2;if(_0x4b4d8a>=_0x404e10){_0x4b4d8a=_0x404e10;_0x2210f2=0xc8;}else{_0x2210f2=0xce;}_0x25d334['status'](_0x2210f2);return _0x25d334[_0x675f('0x20')]('Content-Range',_0x41a1ad+'-'+_0x4b4d8a+'/'+_0x404e10)['json'](_0x5ee11d);}return null;};}function patchUpdates(_0x2c6597){return function(_0x3cfe9b){try{jsonpatch[_0x675f('0x21')](_0x3cfe9b,_0x2c6597,!![]);}catch(_0x458921){return BPromise[_0x675f('0x22')](_0x458921);}return _0x3cfe9b['save']();};}function saveUpdates(_0x2dcbb2,_0x420579){return function(_0x2e13ab){if(_0x2e13ab){return _0x2e13ab[_0x675f('0x23')](_0x2dcbb2)[_0x675f('0x24')](function(_0x460c7c){return _0x460c7c;});}return null;};}function removeEntity(_0x53bf2f,_0x3b2a4d){return function(_0x1d2566){if(_0x1d2566){return _0x1d2566['destroy']()['then'](function(){_0x53bf2f['status'](0xcc)[_0x675f('0x1c')]();});}};}function handleEntityNotFound(_0x5616c8,_0x2b1fd9){return function(_0x32aa1c){if(!_0x32aa1c){_0x5616c8[_0x675f('0x1a')](0x194);}return _0x32aa1c;};}function handleError(_0x5c656d,_0x1fa3a0){_0x1fa3a0=_0x1fa3a0||0x1f4;return function(_0x4bd691){logger[_0x675f('0x25')](_0x4bd691[_0x675f('0x26')]);if(_0x4bd691[_0x675f('0x27')]){delete _0x4bd691[_0x675f('0x27')];}_0x5c656d[_0x675f('0x1b')](_0x1fa3a0)[_0x675f('0x28')](_0x4bd691);};}exports[_0x675f('0x29')]=function(_0x52bac5,_0x39aaa){var _0x59a131={},_0x4625e1={},_0x582326={'count':0x0,'rows':[]};var _0x48428e=db[_0x675f('0x2a')][_0x675f('0x2b')];_0x4625e1[_0x675f('0x2c')]=_['keys'](_0x48428e);_0x4625e1[_0x675f('0x2d')]=_[_0x675f('0x2e')](_0x52bac5[_0x675f('0x2d')]);_0x4625e1['filters']=_['intersection'](_0x4625e1['model'],_0x4625e1['query']);_0x59a131[_0x675f('0x2f')]=_[_0x675f('0x30')](_0x4625e1['model'],qs[_0x675f('0x31')](_0x52bac5['query'][_0x675f('0x31')]));_0x59a131[_0x675f('0x2f')]=_0x59a131[_0x675f('0x2f')][_0x675f('0x32')]?_0x59a131[_0x675f('0x2f')]:_0x4625e1['model'];if(!_0x52bac5[_0x675f('0x2d')][_0x675f('0x33')]('nolimit')){_0x59a131[_0x675f('0x1f')]=qs[_0x675f('0x1f')](_0x52bac5['query'][_0x675f('0x1f')]);_0x59a131[_0x675f('0x1e')]=qs[_0x675f('0x1e')](_0x52bac5[_0x675f('0x2d')][_0x675f('0x1e')]);}_0x59a131['order']=qs[_0x675f('0x34')](_0x52bac5[_0x675f('0x2d')][_0x675f('0x34')]);_0x59a131[_0x675f('0x35')]=qs['filters'](_[_0x675f('0x36')](_0x52bac5[_0x675f('0x2d')],_0x4625e1[_0x675f('0x37')]));if(_0x52bac5['query'][_0x675f('0x38')]){_0x59a131[_0x675f('0x35')]=_['merge'](_0x59a131[_0x675f('0x35')],{'$or':_[_0x675f('0x39')](_0x48428e,function(_0x39c551){if(_0x39c551[_0x675f('0x3a')]['key']!==_0x675f('0x3b')){var _0x37266c={};_0x37266c[_0x39c551[_0x675f('0x3c')]]={'$like':'%'+_0x52bac5[_0x675f('0x2d')][_0x675f('0x38')]+'%'};return _0x37266c;}})});}_0x59a131=_['merge']({},_0x59a131,_0x52bac5[_0x675f('0x3d')]);var _0x18bb4a={'where':_0x59a131[_0x675f('0x35')]};return db[_0x675f('0x2a')]['count'](_0x18bb4a)['then'](function(_0x3da5e7){_0x582326[_0x675f('0x1d')]=_0x3da5e7;if(_0x52bac5[_0x675f('0x2d')][_0x675f('0x3e')]){_0x59a131[_0x675f('0x3f')]=[{'all':!![]}];}return db['ChatInternalMessage'][_0x675f('0x40')](_0x59a131);})[_0x675f('0x24')](function(_0x4f4810){_0x582326[_0x675f('0x41')]=_0x4f4810;return _0x582326;})['then'](respondWithFilteredResult(_0x39aaa,_0x59a131))[_0x675f('0x42')](handleError(_0x39aaa,null));};exports[_0x675f('0x43')]=function(_0x3f3324,_0x599f51){var _0x3bb91e={'raw':!![],'where':{'id':_0x3f3324[_0x675f('0x44')]['id']}},_0x2136b6={};_0x2136b6[_0x675f('0x2c')]=_[_0x675f('0x2e')](db[_0x675f('0x2a')][_0x675f('0x2b')]);_0x2136b6[_0x675f('0x2d')]=_[_0x675f('0x2e')](_0x3f3324[_0x675f('0x2d')]);_0x2136b6[_0x675f('0x37')]=_[_0x675f('0x30')](_0x2136b6[_0x675f('0x2c')],_0x2136b6[_0x675f('0x2d')]);_0x3bb91e['attributes']=_[_0x675f('0x30')](_0x2136b6['model'],qs[_0x675f('0x31')](_0x3f3324[_0x675f('0x2d')]['fields']));_0x3bb91e[_0x675f('0x2f')]=_0x3bb91e['attributes'][_0x675f('0x32')]?_0x3bb91e[_0x675f('0x2f')]:_0x2136b6['model'];if(_0x3f3324['query']['includeAll']){_0x3bb91e['include']=[{'all':!![]}];}_0x3bb91e=_['merge']({},_0x3bb91e,_0x3f3324[_0x675f('0x3d')]);return db[_0x675f('0x2a')][_0x675f('0x45')](_0x3bb91e)[_0x675f('0x24')](handleEntityNotFound(_0x599f51,null))[_0x675f('0x24')](respondWithResult(_0x599f51,null))[_0x675f('0x42')](handleError(_0x599f51,null));};exports['create']=function(_0x1270fe,_0x1f6c18){return db[_0x675f('0x2a')][_0x675f('0x46')](_0x1270fe[_0x675f('0x47')],{})[_0x675f('0x24')](respondWithResult(_0x1f6c18,0xc9))[_0x675f('0x42')](handleError(_0x1f6c18,null));};exports[_0x675f('0x23')]=function(_0x9d121,_0x12066a){if(_0x9d121[_0x675f('0x47')]['id']){delete _0x9d121[_0x675f('0x47')]['id'];}return db[_0x675f('0x2a')][_0x675f('0x45')]({'where':{'id':_0x9d121[_0x675f('0x44')]['id']}})[_0x675f('0x24')](handleEntityNotFound(_0x12066a,null))[_0x675f('0x24')](saveUpdates(_0x9d121[_0x675f('0x47')],null))[_0x675f('0x24')](respondWithResult(_0x12066a,null))[_0x675f('0x42')](handleError(_0x12066a,null));};exports[_0x675f('0x48')]=function(_0x3cb936,_0x63ff42){return db['ChatInternalMessage'][_0x675f('0x45')]({'where':{'id':_0x3cb936['params']['id']}})['then'](handleEntityNotFound(_0x63ff42,null))[_0x675f('0x24')](removeEntity(_0x63ff42,null))[_0x675f('0x42')](handleError(_0x63ff42,null));};exports['describe']=function(_0x73b150,_0xb77dc2){return db[_0x675f('0x2a')][_0x675f('0x49')]()['then'](respondWithResult(_0xb77dc2,null))[_0x675f('0x42')](handleError(_0xb77dc2,null));};function wrapUser(_0x39c541){return function(_0x370e0b){var _0x475eb4=_0x39c541[_0x675f('0x4a')]({'plain':!![]});_0x475eb4['messages']=[];if(_0x370e0b){_0x475eb4[_0x675f('0x4b')]=_0x370e0b['createdAt'];_0x475eb4['lastMessage']=_0x370e0b;}else{_0x475eb4['lastMessageAt']=moment(0x0)[_0x675f('0x4c')]('YYYY-MM-DD\x20HH:mm:ss');_0x475eb4[_0x675f('0x4d')]={};}return _0x475eb4;};}exports[_0x675f('0x4e')]=function(_0x44e496,_0x13782e,_0x216124){var _0x6db852=[];return db[_0x675f('0x4f')][_0x675f('0x40')]({'where':{'role':[_0x675f('0x50'),'admin',_0x675f('0x51')]},'attributes':['id',_0x675f('0x52'),_0x675f('0x27'),_0x675f('0x53'),_0x675f('0x54'),_0x675f('0x55'),_0x675f('0x56'),_0x675f('0x57'),'allowmessenger',_0x675f('0x58')],'order':qs[_0x675f('0x34')]('-online'),'include':[{'model':db[_0x675f('0x59')],'as':'VoiceQueues','attributes':['id',_0x675f('0x27'),_0x675f('0x3a')],'through':{'attributes':[]}}]})[_0x675f('0x24')](function(_0x113f76){if(_0x113f76){var _0x3beab5=_0x44e496[_0x675f('0x51')]['get']({'plain':!![]});if(!_0x3beab5)throw new Error(_0x675f('0x5a'));if(_0x3beab5[_0x675f('0x53')]===_0x675f('0x51')){return db[_0x675f('0x5b')][_0x675f('0x45')]({'where':{'name':_0x675f('0x5c'),'userProfileId':_0x3beab5['userProfileId']},'raw':!![]})[_0x675f('0x24')](function(_0x2c91c3){if(_0x2c91c3){if(_0x2c91c3[_0x675f('0x5d')]===0x0){return db[_0x675f('0x5e')][_0x675f('0x40')]({'where':{'sectionId':_0x2c91c3['id']},'raw':!![]})[_0x675f('0x24')](function(_0xd097fc){var _0x2c3d8d=[];if(_[_0x675f('0x5f')](_0xd097fc)){_0x2c3d8d=_[_0x675f('0x38')](_0x113f76,function(_0x22f52a){if(_0x22f52a[_0x675f('0x53')]!==_0x675f('0x50')){return _0x22f52a;}});return _0x2c3d8d;}else{for(var _0x22b08d=0x0;_0x22b08d<_0x113f76[_0x675f('0x32')];_0x22b08d++){var _0x39341d=_0x113f76[_0x22b08d];if(_0x39341d[_0x675f('0x53')]===_0x675f('0x50')){var _0x262d30=_['find'](_0xd097fc,function(_0x229e31){return _0x229e31[_0x675f('0x60')]===_0x39341d['id'];});if(_0x262d30)_0x2c3d8d[_0x675f('0x61')](_0x39341d);}else{_0x2c3d8d[_0x675f('0x61')](_0x39341d);}}return _0x2c3d8d;}});}else{return _0x113f76;}}else{var _0x247617=_['filter'](_0x113f76,function(_0x22cffe){if(_0x22cffe[_0x675f('0x53')]!=='agent'){return _0x22cffe;}});return _0x247617;}});}else{return _0x113f76;}}})['then'](function(_0x36f03c){var _0x1cc0b7=[];if(_0x36f03c){_0x6db852=_0x36f03c;for(var _0x31767b=0x0;_0x31767b<_0x36f03c[_0x675f('0x32')];_0x31767b+=0x1){_0x6db852[_0x31767b][_0x675f('0x62')]=[];_0x1cc0b7[_0x675f('0x61')](db[_0x675f('0x2a')]['find']({'where':{'FromId':[_0x44e496[_0x675f('0x51')]['id'],_0x36f03c[_0x31767b]['id']],'ToId':[_0x44e496[_0x675f('0x51')]['id'],_0x36f03c[_0x31767b]['id']],'ChatGroupId':null},'attributes':['id',_0x675f('0x63'),_0x675f('0x64'),_0x675f('0x65'),_0x675f('0x66'),_0x675f('0x47')],'order':qs['sort'](_0x675f('0x67')),'limit':0x1,'offset':0x0,'raw':!![]})['then'](wrapUser(_0x36f03c[_0x31767b])));}return BPromise[_0x675f('0x68')](_0x1cc0b7);}return[];})[_0x675f('0x24')](function(_0xf5a372){return{'rows':_0xf5a372,'count':_0xf5a372[_0x675f('0x32')]};})[_0x675f('0x24')](respondWithResult(_0x13782e,null))[_0x675f('0x42')](handleError(_0x13782e,null));};
\ No newline at end of file
+var _0xc24f=['push','ToId','read','-createdAt','all','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatInternalMessage.socket','register','sendStatus','status','end','count','offset','set','Content-Range','apply','reject','save','update','then','error','name','send','ChatInternalMessage','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filter','merge','map','type','key','VIRTUAL','field','options','include','findAll','catch','show','params','rawAttributes','includeAll','find','create','body','destroy','describe','lastMessageAt','createdAt','lastMessage','format','getUsers','agent','admin','user','fullname','role','userpic','internal','online','lastLoginAt','allowmessenger','showWebBar','-online','VoiceQueues','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','isEmpty','resourceId'];(function(_0x1fef31,_0x55da45){var _0x31e093=function(_0x342d32){while(--_0x342d32){_0x1fef31['push'](_0x1fef31['shift']());}};_0x31e093(++_0x55da45);}(_0xc24f,0x1b9));var _0xfc24=function(_0x5ade40,_0x3c5392){_0x5ade40=_0x5ade40-0x0;var _0x14f454=_0xc24f[_0x5ade40];return _0x14f454;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xfc24('0x0'));var zipdir=require(_0xfc24('0x1'));var jsonpatch=require(_0xfc24('0x2'));var rp=require(_0xfc24('0x3'));var moment=require(_0xfc24('0x4'));var BPromise=require(_0xfc24('0x5'));var Mustache=require(_0xfc24('0x6'));var util=require(_0xfc24('0x7'));var path=require(_0xfc24('0x8'));var sox=require(_0xfc24('0x9'));var csv=require(_0xfc24('0xa'));var ejs=require(_0xfc24('0xb'));var fs=require('fs');var _=require(_0xfc24('0xc'));var squel=require(_0xfc24('0xd'));var crypto=require(_0xfc24('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xfc24('0xf'));var toCsv=require(_0xfc24('0xa'));var querystring=require(_0xfc24('0x10'));var Papa=require(_0xfc24('0x11'));var Redis=require('ioredis');var authService=require(_0xfc24('0x12'));var qs=require(_0xfc24('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xfc24('0x14'))('api');var utils=require(_0xfc24('0x15'));var config=require(_0xfc24('0x16'));var db=require(_0xfc24('0x17'))['db'];config[_0xfc24('0x18')]=_[_0xfc24('0x19')](config['redis'],{'host':_0xfc24('0x1a'),'port':0x18eb});var socket=require(_0xfc24('0x1b'))(new Redis(config['redis']));require(_0xfc24('0x1c'))[_0xfc24('0x1d')](socket);function respondWithStatusCode(_0x4a1b13,_0x7e63ea){_0x7e63ea=_0x7e63ea||0xcc;return function(_0x42c883){if(_0x42c883){return _0x4a1b13[_0xfc24('0x1e')](_0x7e63ea);}return _0x4a1b13[_0xfc24('0x1f')](_0x7e63ea)[_0xfc24('0x20')]();};}function respondWithResult(_0x548d7e,_0x28387d){_0x28387d=_0x28387d||0xc8;return function(_0x121da1){if(_0x121da1){return _0x548d7e[_0xfc24('0x1f')](_0x28387d)['json'](_0x121da1);}};}function respondWithFilteredResult(_0x57d337,_0x2d00d6){return function(_0x238fe9){if(_0x238fe9){var _0x165d6c=_0x238fe9[_0xfc24('0x21')],_0x1039a2=_0x2d00d6['offset'],_0x314b0a=_0x2d00d6[_0xfc24('0x22')]+_0x2d00d6['limit'],_0x19d92f;if(_0x314b0a>=_0x165d6c){_0x314b0a=_0x165d6c;_0x19d92f=0xc8;}else{_0x19d92f=0xce;}_0x57d337[_0xfc24('0x1f')](_0x19d92f);return _0x57d337[_0xfc24('0x23')](_0xfc24('0x24'),_0x1039a2+'-'+_0x314b0a+'/'+_0x165d6c)['json'](_0x238fe9);}return null;};}function patchUpdates(_0x7edd94){return function(_0x1a8e3a){try{jsonpatch[_0xfc24('0x25')](_0x1a8e3a,_0x7edd94,!![]);}catch(_0x35033f){return BPromise[_0xfc24('0x26')](_0x35033f);}return _0x1a8e3a[_0xfc24('0x27')]();};}function saveUpdates(_0x55258f,_0x3869d6){return function(_0x3dca83){if(_0x3dca83){return _0x3dca83[_0xfc24('0x28')](_0x55258f)[_0xfc24('0x29')](function(_0x2b56bb){return _0x2b56bb;});}return null;};}function removeEntity(_0x14cd23,_0x1cb001){return function(_0x1a6a3f){if(_0x1a6a3f){return _0x1a6a3f['destroy']()[_0xfc24('0x29')](function(){_0x14cd23[_0xfc24('0x1f')](0xcc)[_0xfc24('0x20')]();});}};}function handleEntityNotFound(_0x27bdff,_0x254dae){return function(_0x48252d){if(!_0x48252d){_0x27bdff[_0xfc24('0x1e')](0x194);}return _0x48252d;};}function handleError(_0x332dce,_0xffa31b){_0xffa31b=_0xffa31b||0x1f4;return function(_0x339686){logger[_0xfc24('0x2a')](_0x339686['stack']);if(_0x339686[_0xfc24('0x2b')]){delete _0x339686[_0xfc24('0x2b')];}_0x332dce[_0xfc24('0x1f')](_0xffa31b)[_0xfc24('0x2c')](_0x339686);};}exports['index']=function(_0x44afad,_0x143c3d){var _0x2a2ea3={},_0x559458={},_0x571429={'count':0x0,'rows':[]};var _0x2df7d0=db[_0xfc24('0x2d')]['rawAttributes'];_0x559458[_0xfc24('0x2e')]=_[_0xfc24('0x2f')](_0x2df7d0);_0x559458[_0xfc24('0x30')]=_[_0xfc24('0x2f')](_0x44afad['query']);_0x559458[_0xfc24('0x31')]=_[_0xfc24('0x32')](_0x559458[_0xfc24('0x2e')],_0x559458['query']);_0x2a2ea3[_0xfc24('0x33')]=_['intersection'](_0x559458[_0xfc24('0x2e')],qs[_0xfc24('0x34')](_0x44afad[_0xfc24('0x30')]['fields']));_0x2a2ea3[_0xfc24('0x33')]=_0x2a2ea3['attributes'][_0xfc24('0x35')]?_0x2a2ea3['attributes']:_0x559458['model'];if(!_0x44afad[_0xfc24('0x30')][_0xfc24('0x36')](_0xfc24('0x37'))){_0x2a2ea3['limit']=qs[_0xfc24('0x38')](_0x44afad[_0xfc24('0x30')]['limit']);_0x2a2ea3['offset']=qs['offset'](_0x44afad['query'][_0xfc24('0x22')]);}_0x2a2ea3[_0xfc24('0x39')]=qs[_0xfc24('0x3a')](_0x44afad['query'][_0xfc24('0x3a')]);_0x2a2ea3[_0xfc24('0x3b')]=qs[_0xfc24('0x31')](_['pick'](_0x44afad[_0xfc24('0x30')],_0x559458[_0xfc24('0x31')]));if(_0x44afad['query'][_0xfc24('0x3c')]){_0x2a2ea3[_0xfc24('0x3b')]=_[_0xfc24('0x3d')](_0x2a2ea3[_0xfc24('0x3b')],{'$or':_[_0xfc24('0x3e')](_0x2df7d0,function(_0x3d472a){if(_0x3d472a[_0xfc24('0x3f')][_0xfc24('0x40')]!==_0xfc24('0x41')){var _0x33e929={};_0x33e929[_0x3d472a[_0xfc24('0x42')]]={'$like':'%'+_0x44afad[_0xfc24('0x30')][_0xfc24('0x3c')]+'%'};return _0x33e929;}})});}_0x2a2ea3=_[_0xfc24('0x3d')]({},_0x2a2ea3,_0x44afad[_0xfc24('0x43')]);var _0x12bf0d={'where':_0x2a2ea3[_0xfc24('0x3b')]};return db[_0xfc24('0x2d')]['count'](_0x12bf0d)[_0xfc24('0x29')](function(_0x7c83bd){_0x571429[_0xfc24('0x21')]=_0x7c83bd;if(_0x44afad[_0xfc24('0x30')]['includeAll']){_0x2a2ea3[_0xfc24('0x44')]=[{'all':!![]}];}return db[_0xfc24('0x2d')][_0xfc24('0x45')](_0x2a2ea3);})[_0xfc24('0x29')](function(_0x1a6eef){_0x571429['rows']=_0x1a6eef;return _0x571429;})['then'](respondWithFilteredResult(_0x143c3d,_0x2a2ea3))[_0xfc24('0x46')](handleError(_0x143c3d,null));};exports[_0xfc24('0x47')]=function(_0x577d4f,_0x50a2f1){var _0x2e69d0={'raw':!![],'where':{'id':_0x577d4f[_0xfc24('0x48')]['id']}},_0x211d84={};_0x211d84[_0xfc24('0x2e')]=_['keys'](db['ChatInternalMessage'][_0xfc24('0x49')]);_0x211d84['query']=_['keys'](_0x577d4f[_0xfc24('0x30')]);_0x211d84[_0xfc24('0x31')]=_[_0xfc24('0x32')](_0x211d84[_0xfc24('0x2e')],_0x211d84['query']);_0x2e69d0[_0xfc24('0x33')]=_[_0xfc24('0x32')](_0x211d84[_0xfc24('0x2e')],qs[_0xfc24('0x34')](_0x577d4f['query'][_0xfc24('0x34')]));_0x2e69d0[_0xfc24('0x33')]=_0x2e69d0[_0xfc24('0x33')][_0xfc24('0x35')]?_0x2e69d0[_0xfc24('0x33')]:_0x211d84['model'];if(_0x577d4f[_0xfc24('0x30')][_0xfc24('0x4a')]){_0x2e69d0[_0xfc24('0x44')]=[{'all':!![]}];}_0x2e69d0=_[_0xfc24('0x3d')]({},_0x2e69d0,_0x577d4f['options']);return db[_0xfc24('0x2d')][_0xfc24('0x4b')](_0x2e69d0)['then'](handleEntityNotFound(_0x50a2f1,null))[_0xfc24('0x29')](respondWithResult(_0x50a2f1,null))['catch'](handleError(_0x50a2f1,null));};exports[_0xfc24('0x4c')]=function(_0x3c4668,_0x13fefc){return db[_0xfc24('0x2d')][_0xfc24('0x4c')](_0x3c4668['body'],{})[_0xfc24('0x29')](respondWithResult(_0x13fefc,0xc9))[_0xfc24('0x46')](handleError(_0x13fefc,null));};exports[_0xfc24('0x28')]=function(_0x27d227,_0x31d2c5){if(_0x27d227['body']['id']){delete _0x27d227['body']['id'];}return db['ChatInternalMessage'][_0xfc24('0x4b')]({'where':{'id':_0x27d227[_0xfc24('0x48')]['id']}})['then'](handleEntityNotFound(_0x31d2c5,null))['then'](saveUpdates(_0x27d227[_0xfc24('0x4d')],null))[_0xfc24('0x29')](respondWithResult(_0x31d2c5,null))[_0xfc24('0x46')](handleError(_0x31d2c5,null));};exports[_0xfc24('0x4e')]=function(_0x1c3f3c,_0x3b7d66){return db['ChatInternalMessage'][_0xfc24('0x4b')]({'where':{'id':_0x1c3f3c['params']['id']}})['then'](handleEntityNotFound(_0x3b7d66,null))['then'](removeEntity(_0x3b7d66,null))['catch'](handleError(_0x3b7d66,null));};exports[_0xfc24('0x4f')]=function(_0x4877ec,_0x31ea93){return db[_0xfc24('0x2d')][_0xfc24('0x4f')]()['then'](respondWithResult(_0x31ea93,null))[_0xfc24('0x46')](handleError(_0x31ea93,null));};function wrapUser(_0x57cf87){return function(_0x3eba24){var _0x58c591=_0x57cf87['get']({'plain':!![]});_0x58c591['messages']=[];if(_0x3eba24){_0x58c591[_0xfc24('0x50')]=_0x3eba24[_0xfc24('0x51')];_0x58c591[_0xfc24('0x52')]=_0x3eba24;}else{_0x58c591['lastMessageAt']=moment(0x0)[_0xfc24('0x53')]('YYYY-MM-DD\x20HH:mm:ss');_0x58c591['lastMessage']={};}return _0x58c591;};}exports[_0xfc24('0x54')]=function(_0x4caa23,_0x5707e3,_0x37853c){var _0x24f115=[];return db['User']['findAll']({'where':{'role':[_0xfc24('0x55'),_0xfc24('0x56'),_0xfc24('0x57')]},'attributes':['id',_0xfc24('0x58'),_0xfc24('0x2b'),_0xfc24('0x59'),_0xfc24('0x5a'),_0xfc24('0x5b'),_0xfc24('0x5c'),_0xfc24('0x5d'),_0xfc24('0x5e'),_0xfc24('0x5f')],'order':qs[_0xfc24('0x3a')](_0xfc24('0x60')),'include':[{'model':db['VoiceQueue'],'as':_0xfc24('0x61'),'attributes':['id',_0xfc24('0x2b'),_0xfc24('0x3f')],'through':{'attributes':[]}}]})[_0xfc24('0x29')](function(_0x3d83b1){if(_0x3d83b1){var _0x43b5f4=_0x4caa23['user'][_0xfc24('0x62')]({'plain':!![]});if(!_0x43b5f4)throw new Error(_0xfc24('0x63'));if(_0x43b5f4[_0xfc24('0x59')]===_0xfc24('0x57')){return db['UserProfileSection'][_0xfc24('0x4b')]({'where':{'name':'Agents','userProfileId':_0x43b5f4[_0xfc24('0x64')]},'raw':!![]})['then'](function(_0x7d5e3b){if(_0x7d5e3b){if(_0x7d5e3b[_0xfc24('0x65')]===0x0){return db['UserProfileResource']['findAll']({'where':{'sectionId':_0x7d5e3b['id']},'raw':!![]})[_0xfc24('0x29')](function(_0x4ec112){var _0x50660e=[];if(_[_0xfc24('0x66')](_0x4ec112)){_0x50660e=_[_0xfc24('0x3c')](_0x3d83b1,function(_0x1d7f8b){if(_0x1d7f8b[_0xfc24('0x59')]!=='agent'){return _0x1d7f8b;}});return _0x50660e;}else{for(var _0x39b45f=0x0;_0x39b45f<_0x3d83b1['length'];_0x39b45f++){var _0x576a33=_0x3d83b1[_0x39b45f];if(_0x576a33[_0xfc24('0x59')]===_0xfc24('0x55')){var _0x4cb0ea=_['find'](_0x4ec112,function(_0x2a225d){return _0x2a225d[_0xfc24('0x67')]===_0x576a33['id'];});if(_0x4cb0ea)_0x50660e[_0xfc24('0x68')](_0x576a33);}else{_0x50660e[_0xfc24('0x68')](_0x576a33);}}return _0x50660e;}});}else{return _0x3d83b1;}}else{var _0x26fd7e=_[_0xfc24('0x3c')](_0x3d83b1,function(_0x3df3ff){if(_0x3df3ff[_0xfc24('0x59')]!==_0xfc24('0x55')){return _0x3df3ff;}});return _0x26fd7e;}});}else{return _0x3d83b1;}}})[_0xfc24('0x29')](function(_0x533139){var _0x548b2d=[];if(_0x533139){_0x24f115=_0x533139;for(var _0x395793=0x0;_0x395793<_0x533139[_0xfc24('0x35')];_0x395793+=0x1){_0x24f115[_0x395793]['messages']=[];_0x548b2d['push'](db[_0xfc24('0x2d')][_0xfc24('0x4b')]({'where':{'FromId':[_0x4caa23[_0xfc24('0x57')]['id'],_0x533139[_0x395793]['id']],'ToId':[_0x4caa23[_0xfc24('0x57')]['id'],_0x533139[_0x395793]['id']],'ChatGroupId':null},'attributes':['id',_0xfc24('0x51'),'FromId',_0xfc24('0x69'),_0xfc24('0x6a'),_0xfc24('0x4d')],'order':qs[_0xfc24('0x3a')](_0xfc24('0x6b')),'limit':0x1,'offset':0x0,'raw':!![]})[_0xfc24('0x29')](wrapUser(_0x533139[_0x395793])));}return BPromise[_0xfc24('0x6c')](_0x548b2d);}return[];})[_0xfc24('0x29')](function(_0x16a180){return{'rows':_0x16a180,'count':_0x16a180['length']};})[_0xfc24('0x29')](respondWithResult(_0x5707e3,null))[_0xfc24('0x46')](handleError(_0x5707e3,null));};
\ No newline at end of file