Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index 5d21fae..0ca2821 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x029f=['limit','count','set','save','update','then','destroy','error','stack','name','send','index','rawAttributes','fieldName','type','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filters','pick','filter','merge','options','ChatGroup','includeAll','include','findAll','catch','show','params','find','create','body','describe','getUnread','ChatInternalMessage','user','toInteger','addMembers','ids','omit','getMembers','findOne','nolimit','removeMembers','addMessage','ChatGroupId','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatGroup.socket','register','sendStatus','status','end','json','offset','undefined'];(function(_0x49ec29,_0xe947b0){var _0x53082b=function(_0x436a82){while(--_0x436a82){_0x49ec29['push'](_0x49ec29['shift']());}};_0x53082b(++_0xe947b0);}(_0x029f,0x166));var _0xf029=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x029f[_0x3947c9];return _0x2e7871;};'use strict';var emlformat=require(_0xf029('0x0'));var rimraf=require(_0xf029('0x1'));var zipdir=require(_0xf029('0x2'));var jsonpatch=require(_0xf029('0x3'));var rp=require(_0xf029('0x4'));var moment=require(_0xf029('0x5'));var BPromise=require(_0xf029('0x6'));var Mustache=require(_0xf029('0x7'));var util=require(_0xf029('0x8'));var path=require(_0xf029('0x9'));var sox=require('sox');var csv=require(_0xf029('0xa'));var ejs=require(_0xf029('0xb'));var fs=require('fs');var fs_extra=require(_0xf029('0xc'));var _=require(_0xf029('0xd'));var squel=require(_0xf029('0xe'));var crypto=require(_0xf029('0xf'));var jsforce=require(_0xf029('0x10'));var deskjs=require('desk.js');var toCsv=require(_0xf029('0xa'));var querystring=require('querystring');var Papa=require(_0xf029('0x11'));var Redis=require(_0xf029('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xf029('0x13'));var as=require(_0xf029('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xf029('0x15'));var utils=require(_0xf029('0x16'));var config=require(_0xf029('0x17'));var licenseUtil=require(_0xf029('0x18'));var db=require(_0xf029('0x19'))['db'];config['redis']=_[_0xf029('0x1a')](config[_0xf029('0x1b')],{'host':_0xf029('0x1c'),'port':0x18eb});var socket=require(_0xf029('0x1d'))(new Redis(config['redis']));require(_0xf029('0x1e'))[_0xf029('0x1f')](socket);function respondWithStatusCode(_0xb6060e,_0x557b4a){_0x557b4a=_0x557b4a||0xcc;return function(_0x43733f){if(_0x43733f){return _0xb6060e[_0xf029('0x20')](_0x557b4a);}return _0xb6060e[_0xf029('0x21')](_0x557b4a)[_0xf029('0x22')]();};}function respondWithResult(_0xcc1c3f,_0x3cf2e5){_0x3cf2e5=_0x3cf2e5||0xc8;return function(_0xa1a8a9){if(_0xa1a8a9){return _0xcc1c3f[_0xf029('0x21')](_0x3cf2e5)[_0xf029('0x23')](_0xa1a8a9);}};}function respondWithFilteredResult(_0x1baf85,_0x3de867){return function(_0x57bf93){if(_0x57bf93){var _0x1b5aee=typeof _0x3de867[_0xf029('0x24')]===_0xf029('0x25')&&typeof _0x3de867[_0xf029('0x26')]===_0xf029('0x25');var _0x4c4c07=_0x57bf93[_0xf029('0x27')];var _0x2e55e3=_0x1b5aee?0x0:_0x3de867[_0xf029('0x24')];var _0x28725b=_0x1b5aee?_0x57bf93[_0xf029('0x27')]:_0x3de867[_0xf029('0x24')]+_0x3de867['limit'];var _0x2f1c19;if(_0x28725b>=_0x4c4c07){_0x28725b=_0x4c4c07;_0x2f1c19=0xc8;}else{_0x2f1c19=0xce;}_0x1baf85[_0xf029('0x21')](_0x2f1c19);return _0x1baf85[_0xf029('0x28')]('Content-Range',_0x2e55e3+'-'+_0x28725b+'/'+_0x4c4c07)[_0xf029('0x23')](_0x57bf93);}return null;};}function patchUpdates(_0x2d6ba4){return function(_0xe10735){try{jsonpatch['apply'](_0xe10735,_0x2d6ba4,!![]);}catch(_0x1834d0){return BPromise['reject'](_0x1834d0);}return _0xe10735[_0xf029('0x29')]();};}function saveUpdates(_0x4d8fbb,_0x69b3eb){return function(_0x20d057){if(_0x20d057){return _0x20d057[_0xf029('0x2a')](_0x4d8fbb)[_0xf029('0x2b')](function(_0x1828b8){return _0x1828b8;});}return null;};}function removeEntity(_0x48f631,_0x22b24b){return function(_0x1554e1){if(_0x1554e1){return _0x1554e1[_0xf029('0x2c')]()[_0xf029('0x2b')](function(){_0x48f631[_0xf029('0x21')](0xcc)[_0xf029('0x22')]();});}};}function handleEntityNotFound(_0xcfb184,_0x14a031){return function(_0xf7d402){if(!_0xf7d402){_0xcfb184['sendStatus'](0x194);}return _0xf7d402;};}function handleError(_0x2be9e6,_0x193de4){_0x193de4=_0x193de4||0x1f4;return function(_0x267a91){logger[_0xf029('0x2d')](_0x267a91[_0xf029('0x2e')]);if(_0x267a91[_0xf029('0x2f')]){delete _0x267a91[_0xf029('0x2f')];}_0x2be9e6[_0xf029('0x21')](_0x193de4)[_0xf029('0x30')](_0x267a91);};}exports[_0xf029('0x31')]=function(_0x3e749b,_0x35b23d){var _0x27f013={},_0x4acad7={},_0x5194cd={'count':0x0,'rows':[]};var _0x5e403a=_['map'](db['ChatGroup'][_0xf029('0x32')],function(_0x32f3c8){return{'name':_0x32f3c8[_0xf029('0x33')],'type':_0x32f3c8[_0xf029('0x34')]['key']};});_0x4acad7[_0xf029('0x35')]=_[_0xf029('0x36')](_0x5e403a,_0xf029('0x2f'));_0x4acad7[_0xf029('0x37')]=_[_0xf029('0x38')](_0x3e749b[_0xf029('0x37')]);_0x4acad7['filters']=_[_0xf029('0x39')](_0x4acad7[_0xf029('0x35')],_0x4acad7['query']);_0x27f013[_0xf029('0x3a')]=_['intersection'](_0x4acad7[_0xf029('0x35')],qs[_0xf029('0x3b')](_0x3e749b[_0xf029('0x37')]['fields']));_0x27f013['attributes']=_0x27f013['attributes'][_0xf029('0x3c')]?_0x27f013[_0xf029('0x3a')]:_0x4acad7['model'];if(!_0x3e749b['query'][_0xf029('0x3d')]('nolimit')){_0x27f013[_0xf029('0x26')]=qs['limit'](_0x3e749b[_0xf029('0x37')][_0xf029('0x26')]);_0x27f013[_0xf029('0x24')]=qs[_0xf029('0x24')](_0x3e749b[_0xf029('0x37')]['offset']);}_0x27f013[_0xf029('0x3e')]=qs[_0xf029('0x3f')](_0x3e749b['query'][_0xf029('0x3f')]);_0x27f013[_0xf029('0x40')]=qs[_0xf029('0x41')](_[_0xf029('0x42')](_0x3e749b[_0xf029('0x37')],_0x4acad7['filters']),_0x5e403a);if(_0x3e749b[_0xf029('0x37')][_0xf029('0x43')]){_0x27f013[_0xf029('0x40')]=_[_0xf029('0x44')](_0x27f013[_0xf029('0x40')],{'$or':_['map'](_0x5e403a,function(_0x165efb){if(_0x165efb[_0xf029('0x34')]!=='VIRTUAL'){var _0x1e57d9={};_0x1e57d9[_0x165efb[_0xf029('0x2f')]]={'$like':'%'+_0x3e749b[_0xf029('0x37')][_0xf029('0x43')]+'%'};return _0x1e57d9;}})});}_0x27f013=_[_0xf029('0x44')]({},_0x27f013,_0x3e749b[_0xf029('0x45')]);var _0x1ed6a5={'where':_0x27f013[_0xf029('0x40')]};return db[_0xf029('0x46')]['count'](_0x1ed6a5)[_0xf029('0x2b')](function(_0x140f6f){_0x5194cd[_0xf029('0x27')]=_0x140f6f;if(_0x3e749b['query'][_0xf029('0x47')]){_0x27f013[_0xf029('0x48')]=[{'all':!![]}];}return db[_0xf029('0x46')][_0xf029('0x49')](_0x27f013);})['then'](function(_0x39dfc9){_0x5194cd['rows']=_0x39dfc9;return _0x5194cd;})[_0xf029('0x2b')](respondWithFilteredResult(_0x35b23d,_0x27f013))[_0xf029('0x4a')](handleError(_0x35b23d,null));};exports[_0xf029('0x4b')]=function(_0x237fd7,_0x2fb77a){var _0x1e2071={'raw':!![],'where':{'id':_0x237fd7[_0xf029('0x4c')]['id']}},_0x2f3c89={};_0x2f3c89[_0xf029('0x35')]=_[_0xf029('0x38')](db[_0xf029('0x46')]['rawAttributes']);_0x2f3c89[_0xf029('0x37')]=_[_0xf029('0x38')](_0x237fd7['query']);_0x2f3c89['filters']=_[_0xf029('0x39')](_0x2f3c89[_0xf029('0x35')],_0x2f3c89[_0xf029('0x37')]);_0x1e2071[_0xf029('0x3a')]=_[_0xf029('0x39')](_0x2f3c89['model'],qs['fields'](_0x237fd7[_0xf029('0x37')][_0xf029('0x3b')]));_0x1e2071[_0xf029('0x3a')]=_0x1e2071[_0xf029('0x3a')][_0xf029('0x3c')]?_0x1e2071['attributes']:_0x2f3c89['model'];if(_0x237fd7[_0xf029('0x37')][_0xf029('0x47')]){_0x1e2071[_0xf029('0x48')]=[{'all':!![]}];}_0x1e2071=_[_0xf029('0x44')]({},_0x1e2071,_0x237fd7[_0xf029('0x45')]);return db[_0xf029('0x46')][_0xf029('0x4d')](_0x1e2071)[_0xf029('0x2b')](handleEntityNotFound(_0x2fb77a,null))[_0xf029('0x2b')](respondWithResult(_0x2fb77a,null))[_0xf029('0x4a')](handleError(_0x2fb77a,null));};exports['create']=function(_0x54dbd5,_0xbb1d10){return db[_0xf029('0x46')][_0xf029('0x4e')](_0x54dbd5[_0xf029('0x4f')],{})[_0xf029('0x2b')](respondWithResult(_0xbb1d10,0xc9))[_0xf029('0x4a')](handleError(_0xbb1d10,null));};exports[_0xf029('0x2a')]=function(_0x5f1da2,_0x12cf10){if(_0x5f1da2[_0xf029('0x4f')]['id']){delete _0x5f1da2[_0xf029('0x4f')]['id'];}return db[_0xf029('0x46')][_0xf029('0x4d')]({'where':{'id':_0x5f1da2[_0xf029('0x4c')]['id']}})[_0xf029('0x2b')](handleEntityNotFound(_0x12cf10,null))[_0xf029('0x2b')](saveUpdates(_0x5f1da2['body'],null))[_0xf029('0x2b')](respondWithResult(_0x12cf10,null))[_0xf029('0x4a')](handleError(_0x12cf10,null));};exports[_0xf029('0x2c')]=function(_0x574970,_0x3391c4){return db[_0xf029('0x46')][_0xf029('0x4d')]({'where':{'id':_0x574970[_0xf029('0x4c')]['id']}})['then'](handleEntityNotFound(_0x3391c4,null))[_0xf029('0x2b')](removeEntity(_0x3391c4,null))[_0xf029('0x4a')](handleError(_0x3391c4,null));};exports[_0xf029('0x50')]=function(_0x2fc1b8,_0x210272){return db['ChatGroup'][_0xf029('0x50')]()[_0xf029('0x2b')](respondWithResult(_0x210272,null))[_0xf029('0x4a')](handleError(_0x210272,null));};exports[_0xf029('0x51')]=function(_0x1c11c5,_0x1107f6,_0x116c68){return db[_0xf029('0x52')][_0xf029('0x27')]({'where':{'ChatGroupId':_0x1c11c5[_0xf029('0x4c')]['id'],'ToId':_0x1c11c5[_0xf029('0x53')]['id'],'read':![]}})[_0xf029('0x2b')](function(_0x32661f){return{'id':_[_0xf029('0x54')](_0x1c11c5[_0xf029('0x4c')]['id']),'count':_0x32661f};})['then'](respondWithResult(_0x1107f6,null))[_0xf029('0x4a')](handleError(_0x1107f6,null));};exports['addMembers']=function(_0x2087c4,_0x34caee,_0x456453){return db[_0xf029('0x46')][_0xf029('0x4d')]({'where':{'id':_0x2087c4[_0xf029('0x4c')]['id']}})[_0xf029('0x2b')](handleEntityNotFound(_0x34caee,null))[_0xf029('0x2b')](function(_0x5257f1){if(_0x5257f1){return _0x5257f1[_0xf029('0x55')](_0x2087c4[_0xf029('0x4f')][_0xf029('0x56')],_[_0xf029('0x57')](_0x2087c4[_0xf029('0x4f')],[_0xf029('0x56'),'id'])||{});}})[_0xf029('0x2b')](respondWithResult(_0x34caee,null))[_0xf029('0x4a')](handleError(_0x34caee,null));};exports[_0xf029('0x58')]=function(_0x104f23,_0x3e87fc,_0x10b344){var _0x577e2f={};var _0x7e5219={};var _0x59cd1b;var _0x591e90;return db[_0xf029('0x46')][_0xf029('0x59')]({'where':{'id':_0x104f23[_0xf029('0x4c')]['id']}})[_0xf029('0x2b')](handleEntityNotFound(_0x3e87fc,null))[_0xf029('0x2b')](function(_0x518b30){if(_0x518b30){_0x59cd1b=_0x518b30;_0x7e5219['model']=_['keys'](db['User'][_0xf029('0x32')]);_0x7e5219[_0xf029('0x37')]=_[_0xf029('0x38')](_0x104f23['query']);_0x7e5219['filters']=_[_0xf029('0x39')](_0x7e5219['model'],_0x7e5219['query']);_0x577e2f['attributes']=_['intersection'](_0x7e5219[_0xf029('0x35')],qs[_0xf029('0x3b')](_0x104f23[_0xf029('0x37')]['fields']));_0x577e2f[_0xf029('0x3a')]=_0x577e2f[_0xf029('0x3a')][_0xf029('0x3c')]?_0x577e2f[_0xf029('0x3a')]:_0x7e5219['model'];_0x577e2f[_0xf029('0x3e')]=qs[_0xf029('0x3f')](_0x104f23[_0xf029('0x37')][_0xf029('0x3f')]);_0x577e2f['where']=qs['filters'](_[_0xf029('0x42')](_0x104f23[_0xf029('0x37')],_0x7e5219['filters']));if(_0x104f23[_0xf029('0x37')][_0xf029('0x43')]){_0x577e2f[_0xf029('0x40')]=_[_0xf029('0x44')](_0x577e2f['where'],{'$or':_[_0xf029('0x36')](_0x577e2f['attributes'],function(_0x477153){var _0x45a3cb={};_0x45a3cb[_0x477153]={'$like':'%'+_0x104f23[_0xf029('0x37')]['filter']+'%'};return _0x45a3cb;})});}_0x577e2f=_[_0xf029('0x44')]({},_0x577e2f,_0x104f23[_0xf029('0x45')]);return _0x59cd1b[_0xf029('0x58')](_0x577e2f);}})['then'](function(_0x3b00ab){if(_0x3b00ab){_0x591e90=_0x3b00ab[_0xf029('0x3c')];if(!_0x104f23['query'][_0xf029('0x3d')](_0xf029('0x5a'))){_0x577e2f[_0xf029('0x26')]=qs['limit'](_0x104f23[_0xf029('0x37')][_0xf029('0x26')]);_0x577e2f['offset']=qs[_0xf029('0x24')](_0x104f23['query']['offset']);}return _0x59cd1b['getMembers'](_0x577e2f);}})[_0xf029('0x2b')](function(_0x2ef91f){if(_0x2ef91f){return _0x2ef91f?{'count':_0x591e90,'rows':_0x2ef91f}:null;}})[_0xf029('0x2b')](respondWithResult(_0x3e87fc,null))[_0xf029('0x4a')](handleError(_0x3e87fc,null));};exports[_0xf029('0x5b')]=function(_0x565358,_0x57b2d2,_0x1f8f15){return db['ChatGroup'][_0xf029('0x4d')]({'where':{'id':_0x565358[_0xf029('0x4c')]['id']}})['then'](handleEntityNotFound(_0x57b2d2,null))['then'](function(_0x4f7cd5){if(_0x4f7cd5){return _0x4f7cd5[_0xf029('0x5b')](_0x565358['query'][_0xf029('0x56')]);}})['then'](respondWithStatusCode(_0x57b2d2,null))[_0xf029('0x4a')](handleError(_0x57b2d2,null));};exports[_0xf029('0x5c')]=function(_0x2b7849,_0x44cd7c,_0x518ae1){if(_0x2b7849[_0xf029('0x4f')]['id']){delete _0x2b7849[_0xf029('0x4f')]['id'];}return db['ChatGroup'][_0xf029('0x4d')]({'where':{'id':_0x2b7849[_0xf029('0x4c')]['id']}})[_0xf029('0x2b')](handleEntityNotFound(_0x44cd7c,null))[_0xf029('0x2b')](function(_0xcd3bfd){if(_0xcd3bfd){_0x2b7849['body'][_0xf029('0x5d')]=_0xcd3bfd['id'];return db[_0xf029('0x52')][_0xf029('0x4e')](_0x2b7849[_0xf029('0x4f')]);}})[_0xf029('0x2b')](respondWithResult(_0x44cd7c,null))[_0xf029('0x4a')](handleError(_0x44cd7c,null));};exports[_0xf029('0x5e')]=function(_0xf9540e,_0x4cd17e,_0x1b1e3a){var _0x3bce3c={};var _0x283f61={};var _0x36f02c;var _0x15d8cd;return db[_0xf029('0x46')]['findOne']({'where':{'id':_0xf9540e['params']['id']}})[_0xf029('0x2b')](handleEntityNotFound(_0x4cd17e,null))[_0xf029('0x2b')](function(_0x9c88cf){if(_0x9c88cf){_0x36f02c=_0x9c88cf;_0x283f61[_0xf029('0x35')]=_[_0xf029('0x38')](db[_0xf029('0x52')][_0xf029('0x32')]);_0x283f61[_0xf029('0x37')]=_[_0xf029('0x38')](_0xf9540e['query']);_0x283f61[_0xf029('0x41')]=_[_0xf029('0x39')](_0x283f61[_0xf029('0x35')],_0x283f61[_0xf029('0x37')]);_0x3bce3c[_0xf029('0x3a')]=_[_0xf029('0x39')](_0x283f61[_0xf029('0x35')],qs['fields'](_0xf9540e[_0xf029('0x37')]['fields']));_0x3bce3c['attributes']=_0x3bce3c[_0xf029('0x3a')]['length']?_0x3bce3c['attributes']:_0x283f61['model'];_0x3bce3c['order']=qs['sort'](_0xf9540e[_0xf029('0x37')]['sort']);_0x3bce3c['where']=qs[_0xf029('0x41')](_['pick'](_0xf9540e['query'],_0x283f61[_0xf029('0x41')]));if(_0xf9540e[_0xf029('0x37')][_0xf029('0x43')]){_0x3bce3c[_0xf029('0x40')]=_[_0xf029('0x44')](_0x3bce3c[_0xf029('0x40')],{'$or':_[_0xf029('0x36')](_0x3bce3c[_0xf029('0x3a')],function(_0xb93701){var _0x66b990={};_0x66b990[_0xb93701]={'$like':'%'+_0xf9540e[_0xf029('0x37')][_0xf029('0x43')]+'%'};return _0x66b990;})});}if(_0xf9540e[_0xf029('0x37')][_0xf029('0x5f')]){var _0x8a19af=_0xf9540e[_0xf029('0x37')]['$gte'][_0xf029('0x60')](',');var _0x4c889a={};_0x4c889a[_0x8a19af[0x0]]={'$gte':moment(_0x8a19af[0x1])[_0xf029('0x61')](_0xf029('0x62'))};_0x3bce3c[_0xf029('0x40')]=_[_0xf029('0x44')](_0x3bce3c['where'],_0x4c889a);}_0x3bce3c=_[_0xf029('0x44')]({},_0x3bce3c,_0xf9540e[_0xf029('0x45')]);return _0x36f02c[_0xf029('0x5e')](_0x3bce3c);}})[_0xf029('0x2b')](function(_0x4defa8){if(_0x4defa8){_0x15d8cd=_0x4defa8['length'];if(!_0xf9540e[_0xf029('0x37')][_0xf029('0x3d')](_0xf029('0x5a'))){_0x3bce3c['limit']=qs[_0xf029('0x26')](_0xf9540e[_0xf029('0x37')][_0xf029('0x26')]);_0x3bce3c['offset']=qs[_0xf029('0x24')](_0xf9540e['query'][_0xf029('0x24')]);}return _0x36f02c['getMessages'](_0x3bce3c);}})[_0xf029('0x2b')](function(_0x4e014a){if(_0x4e014a){return _0x4e014a?{'count':_0x15d8cd,'rows':_0x4e014a}:null;}})[_0xf029('0x2b')](respondWithResult(_0x4cd17e,null))['catch'](handleError(_0x4cd17e,null));};
\ No newline at end of file
+var _0x6082=['body','update','describe','getUnread','ChatInternalMessage','user','toInteger','addMembers','getMembers','findOne','removeMembers','addMessage','ChatGroupId','getMessages','format','YYYY-MM-DD\x20HH:mm:ss','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','save','then','destroy','error','name','send','map','ChatGroup','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','options','includeAll','findAll','catch','show','params','include','find','create'];(function(_0x6b14c8,_0x3be7c2){var _0x51b553=function(_0x483dd){while(--_0x483dd){_0x6b14c8['push'](_0x6b14c8['shift']());}};_0x51b553(++_0x3be7c2);}(_0x6082,0x124));var _0x2608=function(_0x5202e8,_0x176362){_0x5202e8=_0x5202e8-0x0;var _0x290bff=_0x6082[_0x5202e8];return _0x290bff;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x2608('0x0'));var zipdir=require(_0x2608('0x1'));var jsonpatch=require(_0x2608('0x2'));var rp=require(_0x2608('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x2608('0x4'));var util=require(_0x2608('0x5'));var path=require(_0x2608('0x6'));var sox=require('sox');var csv=require(_0x2608('0x7'));var ejs=require(_0x2608('0x8'));var fs=require('fs');var fs_extra=require(_0x2608('0x9'));var _=require(_0x2608('0xa'));var squel=require(_0x2608('0xb'));var crypto=require(_0x2608('0xc'));var jsforce=require(_0x2608('0xd'));var deskjs=require(_0x2608('0xe'));var toCsv=require('to-csv');var querystring=require(_0x2608('0xf'));var Papa=require(_0x2608('0x10'));var Redis=require(_0x2608('0x11'));var authService=require(_0x2608('0x12'));var qs=require(_0x2608('0x13'));var as=require(_0x2608('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x2608('0x15'));var utils=require(_0x2608('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x2608('0x17'))['db'];config[_0x2608('0x18')]=_[_0x2608('0x19')](config[_0x2608('0x18')],{'host':_0x2608('0x1a'),'port':0x18eb});var socket=require(_0x2608('0x1b'))(new Redis(config['redis']));require('./chatGroup.socket')[_0x2608('0x1c')](socket);function respondWithStatusCode(_0x3b5eb6,_0x33aa67){_0x33aa67=_0x33aa67||0xcc;return function(_0x461c74){if(_0x461c74){return _0x3b5eb6[_0x2608('0x1d')](_0x33aa67);}return _0x3b5eb6[_0x2608('0x1e')](_0x33aa67)[_0x2608('0x1f')]();};}function respondWithResult(_0x3a1fae,_0x9cc8a1){_0x9cc8a1=_0x9cc8a1||0xc8;return function(_0x27fab8){if(_0x27fab8){return _0x3a1fae['status'](_0x9cc8a1)[_0x2608('0x20')](_0x27fab8);}};}function respondWithFilteredResult(_0x25db8a,_0x921df5){return function(_0x5badf1){if(_0x5badf1){var _0x311143=typeof _0x921df5[_0x2608('0x21')]===_0x2608('0x22')&&typeof _0x921df5[_0x2608('0x23')]===_0x2608('0x22');var _0x25bd68=_0x5badf1['count'];var _0x436e16=_0x311143?0x0:_0x921df5[_0x2608('0x21')];var _0x6b92dc=_0x311143?_0x5badf1[_0x2608('0x24')]:_0x921df5['offset']+_0x921df5['limit'];var _0x3cc4e5;if(_0x6b92dc>=_0x25bd68){_0x6b92dc=_0x25bd68;_0x3cc4e5=0xc8;}else{_0x3cc4e5=0xce;}_0x25db8a['status'](_0x3cc4e5);return _0x25db8a[_0x2608('0x25')](_0x2608('0x26'),_0x436e16+'-'+_0x6b92dc+'/'+_0x25bd68)[_0x2608('0x20')](_0x5badf1);}return null;};}function patchUpdates(_0x4399b0){return function(_0x46bbed){try{jsonpatch['apply'](_0x46bbed,_0x4399b0,!![]);}catch(_0x25f0b2){return BPromise['reject'](_0x25f0b2);}return _0x46bbed[_0x2608('0x27')]();};}function saveUpdates(_0x4c315f,_0x39c823){return function(_0x3e313c){if(_0x3e313c){return _0x3e313c['update'](_0x4c315f)[_0x2608('0x28')](function(_0x28dcd7){return _0x28dcd7;});}return null;};}function removeEntity(_0x4e459d,_0x1e3f25){return function(_0x92cab2){if(_0x92cab2){return _0x92cab2[_0x2608('0x29')]()['then'](function(){_0x4e459d['status'](0xcc)[_0x2608('0x1f')]();});}};}function handleEntityNotFound(_0x27dd94,_0x559497){return function(_0x225bc4){if(!_0x225bc4){_0x27dd94[_0x2608('0x1d')](0x194);}return _0x225bc4;};}function handleError(_0x123305,_0x1c8a42){_0x1c8a42=_0x1c8a42||0x1f4;return function(_0x3942ad){logger[_0x2608('0x2a')](_0x3942ad['stack']);if(_0x3942ad[_0x2608('0x2b')]){delete _0x3942ad['name'];}_0x123305[_0x2608('0x1e')](_0x1c8a42)[_0x2608('0x2c')](_0x3942ad);};}exports['index']=function(_0x3d7802,_0x5bebc6){var _0x5f2a21={},_0x70690f={},_0x4ea49e={'count':0x0,'rows':[]};var _0xdafefa=_[_0x2608('0x2d')](db[_0x2608('0x2e')][_0x2608('0x2f')],function(_0x29f413){return{'name':_0x29f413[_0x2608('0x30')],'type':_0x29f413['type'][_0x2608('0x31')]};});_0x70690f[_0x2608('0x32')]=_[_0x2608('0x2d')](_0xdafefa,'name');_0x70690f[_0x2608('0x33')]=_[_0x2608('0x34')](_0x3d7802[_0x2608('0x33')]);_0x70690f[_0x2608('0x35')]=_['intersection'](_0x70690f[_0x2608('0x32')],_0x70690f[_0x2608('0x33')]);_0x5f2a21[_0x2608('0x36')]=_[_0x2608('0x37')](_0x70690f[_0x2608('0x32')],qs[_0x2608('0x38')](_0x3d7802[_0x2608('0x33')][_0x2608('0x38')]));_0x5f2a21[_0x2608('0x36')]=_0x5f2a21[_0x2608('0x36')][_0x2608('0x39')]?_0x5f2a21['attributes']:_0x70690f[_0x2608('0x32')];if(!_0x3d7802[_0x2608('0x33')][_0x2608('0x3a')](_0x2608('0x3b'))){_0x5f2a21[_0x2608('0x23')]=qs['limit'](_0x3d7802[_0x2608('0x33')]['limit']);_0x5f2a21[_0x2608('0x21')]=qs[_0x2608('0x21')](_0x3d7802[_0x2608('0x33')][_0x2608('0x21')]);}_0x5f2a21[_0x2608('0x3c')]=qs[_0x2608('0x3d')](_0x3d7802[_0x2608('0x33')][_0x2608('0x3d')]);_0x5f2a21[_0x2608('0x3e')]=qs['filters'](_[_0x2608('0x3f')](_0x3d7802['query'],_0x70690f['filters']),_0xdafefa);if(_0x3d7802[_0x2608('0x33')][_0x2608('0x40')]){_0x5f2a21[_0x2608('0x3e')]=_[_0x2608('0x41')](_0x5f2a21[_0x2608('0x3e')],{'$or':_[_0x2608('0x2d')](_0xdafefa,function(_0x40549e){if(_0x40549e[_0x2608('0x42')]!=='VIRTUAL'){var _0xbcc4e9={};_0xbcc4e9[_0x40549e['name']]={'$like':'%'+_0x3d7802['query'][_0x2608('0x40')]+'%'};return _0xbcc4e9;}})});}_0x5f2a21=_[_0x2608('0x41')]({},_0x5f2a21,_0x3d7802[_0x2608('0x43')]);var _0x1223c5={'where':_0x5f2a21[_0x2608('0x3e')]};return db[_0x2608('0x2e')][_0x2608('0x24')](_0x1223c5)[_0x2608('0x28')](function(_0x3e4a63){_0x4ea49e['count']=_0x3e4a63;if(_0x3d7802[_0x2608('0x33')][_0x2608('0x44')]){_0x5f2a21['include']=[{'all':!![]}];}return db['ChatGroup'][_0x2608('0x45')](_0x5f2a21);})[_0x2608('0x28')](function(_0x39247f){_0x4ea49e['rows']=_0x39247f;return _0x4ea49e;})[_0x2608('0x28')](respondWithFilteredResult(_0x5bebc6,_0x5f2a21))[_0x2608('0x46')](handleError(_0x5bebc6,null));};exports[_0x2608('0x47')]=function(_0x17c509,_0x283c12){var _0x5c1fc2={'raw':!![],'where':{'id':_0x17c509[_0x2608('0x48')]['id']}},_0xc5064a={};_0xc5064a['model']=_[_0x2608('0x34')](db[_0x2608('0x2e')][_0x2608('0x2f')]);_0xc5064a[_0x2608('0x33')]=_['keys'](_0x17c509[_0x2608('0x33')]);_0xc5064a['filters']=_[_0x2608('0x37')](_0xc5064a[_0x2608('0x32')],_0xc5064a[_0x2608('0x33')]);_0x5c1fc2[_0x2608('0x36')]=_[_0x2608('0x37')](_0xc5064a[_0x2608('0x32')],qs[_0x2608('0x38')](_0x17c509[_0x2608('0x33')]['fields']));_0x5c1fc2['attributes']=_0x5c1fc2['attributes'][_0x2608('0x39')]?_0x5c1fc2[_0x2608('0x36')]:_0xc5064a[_0x2608('0x32')];if(_0x17c509[_0x2608('0x33')][_0x2608('0x44')]){_0x5c1fc2[_0x2608('0x49')]=[{'all':!![]}];}_0x5c1fc2=_['merge']({},_0x5c1fc2,_0x17c509['options']);return db['ChatGroup'][_0x2608('0x4a')](_0x5c1fc2)[_0x2608('0x28')](handleEntityNotFound(_0x283c12,null))[_0x2608('0x28')](respondWithResult(_0x283c12,null))[_0x2608('0x46')](handleError(_0x283c12,null));};exports[_0x2608('0x4b')]=function(_0x35b97e,_0x31f089){return db[_0x2608('0x2e')]['create'](_0x35b97e[_0x2608('0x4c')],{})[_0x2608('0x28')](respondWithResult(_0x31f089,0xc9))[_0x2608('0x46')](handleError(_0x31f089,null));};exports[_0x2608('0x4d')]=function(_0x3dac59,_0x44a2ab){if(_0x3dac59[_0x2608('0x4c')]['id']){delete _0x3dac59[_0x2608('0x4c')]['id'];}return db[_0x2608('0x2e')][_0x2608('0x4a')]({'where':{'id':_0x3dac59[_0x2608('0x48')]['id']}})[_0x2608('0x28')](handleEntityNotFound(_0x44a2ab,null))[_0x2608('0x28')](saveUpdates(_0x3dac59[_0x2608('0x4c')],null))['then'](respondWithResult(_0x44a2ab,null))['catch'](handleError(_0x44a2ab,null));};exports[_0x2608('0x29')]=function(_0x148e87,_0x1744fa){return db[_0x2608('0x2e')][_0x2608('0x4a')]({'where':{'id':_0x148e87[_0x2608('0x48')]['id']}})[_0x2608('0x28')](handleEntityNotFound(_0x1744fa,null))['then'](removeEntity(_0x1744fa,null))['catch'](handleError(_0x1744fa,null));};exports['describe']=function(_0x590911,_0x4bdaeb){return db[_0x2608('0x2e')][_0x2608('0x4e')]()['then'](respondWithResult(_0x4bdaeb,null))[_0x2608('0x46')](handleError(_0x4bdaeb,null));};exports[_0x2608('0x4f')]=function(_0x20025c,_0x3f9de1,_0x36cb3c){return db[_0x2608('0x50')]['count']({'where':{'ChatGroupId':_0x20025c[_0x2608('0x48')]['id'],'ToId':_0x20025c[_0x2608('0x51')]['id'],'read':![]}})[_0x2608('0x28')](function(_0x4a7d5e){return{'id':_[_0x2608('0x52')](_0x20025c[_0x2608('0x48')]['id']),'count':_0x4a7d5e};})['then'](respondWithResult(_0x3f9de1,null))['catch'](handleError(_0x3f9de1,null));};exports[_0x2608('0x53')]=function(_0x44fb75,_0x367f96,_0x59db46){return db[_0x2608('0x2e')][_0x2608('0x4a')]({'where':{'id':_0x44fb75[_0x2608('0x48')]['id']}})[_0x2608('0x28')](handleEntityNotFound(_0x367f96,null))[_0x2608('0x28')](function(_0x1b5178){if(_0x1b5178){return _0x1b5178['addMembers'](_0x44fb75[_0x2608('0x4c')]['ids'],_['omit'](_0x44fb75[_0x2608('0x4c')],['ids','id'])||{});}})[_0x2608('0x28')](respondWithResult(_0x367f96,null))[_0x2608('0x46')](handleError(_0x367f96,null));};exports[_0x2608('0x54')]=function(_0x3b6a40,_0x5dd9ce,_0x440d53){var _0x4ab768={};var _0x1df361={};var _0x567684;var _0xffc7c5;return db[_0x2608('0x2e')][_0x2608('0x55')]({'where':{'id':_0x3b6a40[_0x2608('0x48')]['id']}})[_0x2608('0x28')](handleEntityNotFound(_0x5dd9ce,null))[_0x2608('0x28')](function(_0x5a05f1){if(_0x5a05f1){_0x567684=_0x5a05f1;_0x1df361['model']=_['keys'](db['User'][_0x2608('0x2f')]);_0x1df361[_0x2608('0x33')]=_['keys'](_0x3b6a40[_0x2608('0x33')]);_0x1df361[_0x2608('0x35')]=_[_0x2608('0x37')](_0x1df361[_0x2608('0x32')],_0x1df361[_0x2608('0x33')]);_0x4ab768['attributes']=_[_0x2608('0x37')](_0x1df361[_0x2608('0x32')],qs[_0x2608('0x38')](_0x3b6a40['query'][_0x2608('0x38')]));_0x4ab768['attributes']=_0x4ab768[_0x2608('0x36')]['length']?_0x4ab768['attributes']:_0x1df361[_0x2608('0x32')];_0x4ab768[_0x2608('0x3c')]=qs['sort'](_0x3b6a40[_0x2608('0x33')][_0x2608('0x3d')]);_0x4ab768['where']=qs[_0x2608('0x35')](_['pick'](_0x3b6a40[_0x2608('0x33')],_0x1df361['filters']));if(_0x3b6a40['query'][_0x2608('0x40')]){_0x4ab768['where']=_[_0x2608('0x41')](_0x4ab768[_0x2608('0x3e')],{'$or':_[_0x2608('0x2d')](_0x4ab768['attributes'],function(_0x4c7f71){var _0x465039={};_0x465039[_0x4c7f71]={'$like':'%'+_0x3b6a40[_0x2608('0x33')]['filter']+'%'};return _0x465039;})});}_0x4ab768=_[_0x2608('0x41')]({},_0x4ab768,_0x3b6a40[_0x2608('0x43')]);return _0x567684[_0x2608('0x54')](_0x4ab768);}})['then'](function(_0x3a32da){if(_0x3a32da){_0xffc7c5=_0x3a32da[_0x2608('0x39')];if(!_0x3b6a40['query']['hasOwnProperty'](_0x2608('0x3b'))){_0x4ab768['limit']=qs[_0x2608('0x23')](_0x3b6a40[_0x2608('0x33')][_0x2608('0x23')]);_0x4ab768[_0x2608('0x21')]=qs[_0x2608('0x21')](_0x3b6a40[_0x2608('0x33')][_0x2608('0x21')]);}return _0x567684[_0x2608('0x54')](_0x4ab768);}})[_0x2608('0x28')](function(_0x219e52){if(_0x219e52){return _0x219e52?{'count':_0xffc7c5,'rows':_0x219e52}:null;}})['then'](respondWithResult(_0x5dd9ce,null))['catch'](handleError(_0x5dd9ce,null));};exports[_0x2608('0x56')]=function(_0x570d8b,_0x1212ce,_0x48c5fb){return db[_0x2608('0x2e')]['find']({'where':{'id':_0x570d8b[_0x2608('0x48')]['id']}})[_0x2608('0x28')](handleEntityNotFound(_0x1212ce,null))[_0x2608('0x28')](function(_0x4dac97){if(_0x4dac97){return _0x4dac97[_0x2608('0x56')](_0x570d8b[_0x2608('0x33')]['ids']);}})[_0x2608('0x28')](respondWithStatusCode(_0x1212ce,null))['catch'](handleError(_0x1212ce,null));};exports[_0x2608('0x57')]=function(_0x4681f0,_0x122a42,_0x218230){if(_0x4681f0['body']['id']){delete _0x4681f0[_0x2608('0x4c')]['id'];}return db[_0x2608('0x2e')][_0x2608('0x4a')]({'where':{'id':_0x4681f0['params']['id']}})['then'](handleEntityNotFound(_0x122a42,null))['then'](function(_0x345fd2){if(_0x345fd2){_0x4681f0[_0x2608('0x4c')][_0x2608('0x58')]=_0x345fd2['id'];return db['ChatInternalMessage'][_0x2608('0x4b')](_0x4681f0[_0x2608('0x4c')]);}})[_0x2608('0x28')](respondWithResult(_0x122a42,null))[_0x2608('0x46')](handleError(_0x122a42,null));};exports[_0x2608('0x59')]=function(_0x1bd1fd,_0x1e9d95,_0x70445d){var _0x3a74e0={};var _0x4db469={};var _0x356c23;var _0x52b4f9;return db[_0x2608('0x2e')][_0x2608('0x55')]({'where':{'id':_0x1bd1fd[_0x2608('0x48')]['id']}})[_0x2608('0x28')](handleEntityNotFound(_0x1e9d95,null))[_0x2608('0x28')](function(_0x27de4d){if(_0x27de4d){_0x356c23=_0x27de4d;_0x4db469[_0x2608('0x32')]=_[_0x2608('0x34')](db[_0x2608('0x50')][_0x2608('0x2f')]);_0x4db469[_0x2608('0x33')]=_[_0x2608('0x34')](_0x1bd1fd[_0x2608('0x33')]);_0x4db469[_0x2608('0x35')]=_[_0x2608('0x37')](_0x4db469[_0x2608('0x32')],_0x4db469[_0x2608('0x33')]);_0x3a74e0[_0x2608('0x36')]=_['intersection'](_0x4db469[_0x2608('0x32')],qs['fields'](_0x1bd1fd[_0x2608('0x33')][_0x2608('0x38')]));_0x3a74e0[_0x2608('0x36')]=_0x3a74e0[_0x2608('0x36')][_0x2608('0x39')]?_0x3a74e0[_0x2608('0x36')]:_0x4db469[_0x2608('0x32')];_0x3a74e0[_0x2608('0x3c')]=qs[_0x2608('0x3d')](_0x1bd1fd[_0x2608('0x33')][_0x2608('0x3d')]);_0x3a74e0[_0x2608('0x3e')]=qs[_0x2608('0x35')](_['pick'](_0x1bd1fd[_0x2608('0x33')],_0x4db469['filters']));if(_0x1bd1fd['query'][_0x2608('0x40')]){_0x3a74e0[_0x2608('0x3e')]=_[_0x2608('0x41')](_0x3a74e0['where'],{'$or':_[_0x2608('0x2d')](_0x3a74e0[_0x2608('0x36')],function(_0x2d12bd){var _0x26967f={};_0x26967f[_0x2d12bd]={'$like':'%'+_0x1bd1fd['query'][_0x2608('0x40')]+'%'};return _0x26967f;})});}if(_0x1bd1fd[_0x2608('0x33')]['$gte']){var _0x1323f1=_0x1bd1fd['query']['$gte']['split'](',');var _0x495480={};_0x495480[_0x1323f1[0x0]]={'$gte':moment(_0x1323f1[0x1])[_0x2608('0x5a')](_0x2608('0x5b'))};_0x3a74e0[_0x2608('0x3e')]=_[_0x2608('0x41')](_0x3a74e0[_0x2608('0x3e')],_0x495480);}_0x3a74e0=_[_0x2608('0x41')]({},_0x3a74e0,_0x1bd1fd[_0x2608('0x43')]);return _0x356c23[_0x2608('0x59')](_0x3a74e0);}})[_0x2608('0x28')](function(_0x8a1568){if(_0x8a1568){_0x52b4f9=_0x8a1568[_0x2608('0x39')];if(!_0x1bd1fd[_0x2608('0x33')][_0x2608('0x3a')]('nolimit')){_0x3a74e0['limit']=qs[_0x2608('0x23')](_0x1bd1fd[_0x2608('0x33')][_0x2608('0x23')]);_0x3a74e0[_0x2608('0x21')]=qs[_0x2608('0x21')](_0x1bd1fd[_0x2608('0x33')]['offset']);}return _0x356c23['getMessages'](_0x3a74e0);}})['then'](function(_0x1cd938){if(_0x1cd938){return _0x1cd938?{'count':_0x52b4f9,'rows':_0x1cd938}:null;}})[_0x2608('0x28')](respondWithResult(_0x1e9d95,null))[_0x2608('0x46')](handleError(_0x1e9d95,null));};
\ No newline at end of file