Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index 5d21fae..f3b131a 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 _0x0b5c=['rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','fs-extra','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','./chatGroup.socket','register','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','then','destroy','sendStatus','name','send','index','map','ChatGroup','fieldName','type','key','query','model','attributes','intersection','fields','length','nolimit','order','where','filters','filter','VIRTUAL','merge','options','includeAll','findAll','rows','show','keys','rawAttributes','include','catch','create','body','update','find','params','getUnread','user','toInteger','addMembers','ids','omit','User','sort','pick','getMembers','hasOwnProperty','removeMembers','addMessage','ChatGroupId','ChatInternalMessage','getMessages','findOne','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x5b890c,_0x27ac4d){var _0x140fb0=function(_0x2f60c0){while(--_0x2f60c0){_0x5b890c['push'](_0x5b890c['shift']());}};_0x140fb0(++_0x27ac4d);}(_0x0b5c,0x65));var _0xc0b5=function(_0x4a6a4c,_0x5149d1){_0x4a6a4c=_0x4a6a4c-0x0;var _0xdb0e5b=_0x0b5c[_0x4a6a4c];return _0xdb0e5b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xc0b5('0x0'));var zipdir=require(_0xc0b5('0x1'));var jsonpatch=require(_0xc0b5('0x2'));var rp=require(_0xc0b5('0x3'));var moment=require(_0xc0b5('0x4'));var BPromise=require(_0xc0b5('0x5'));var Mustache=require(_0xc0b5('0x6'));var util=require(_0xc0b5('0x7'));var path=require(_0xc0b5('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xc0b5('0x9'));var fs=require('fs');var fs_extra=require(_0xc0b5('0xa'));var _=require(_0xc0b5('0xb'));var squel=require(_0xc0b5('0xc'));var crypto=require(_0xc0b5('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xc0b5('0xe'));var toCsv=require(_0xc0b5('0xf'));var querystring=require(_0xc0b5('0x10'));var Papa=require(_0xc0b5('0x11'));var Redis=require(_0xc0b5('0x12'));var authService=require(_0xc0b5('0x13'));var qs=require(_0xc0b5('0x14'));var as=require(_0xc0b5('0x15'));var hardwareService=require(_0xc0b5('0x16'));var logger=require(_0xc0b5('0x17'))('api');var utils=require('../../config/utils');var config=require(_0xc0b5('0x18'));var licenseUtil=require(_0xc0b5('0x19'));var db=require(_0xc0b5('0x1a'))['db'];config['redis']=_[_0xc0b5('0x1b')](config[_0xc0b5('0x1c')],{'host':'localhost','port':0x18eb});var socket=require(_0xc0b5('0x1d'))(new Redis(config[_0xc0b5('0x1c')]));require(_0xc0b5('0x1e'))[_0xc0b5('0x1f')](socket);function respondWithStatusCode(_0x4be77e,_0x939969){_0x939969=_0x939969||0xcc;return function(_0x3c803a){if(_0x3c803a){return _0x4be77e['sendStatus'](_0x939969);}return _0x4be77e[_0xc0b5('0x20')](_0x939969)[_0xc0b5('0x21')]();};}function respondWithResult(_0x32f17d,_0x3ff214){_0x3ff214=_0x3ff214||0xc8;return function(_0x5bc78b){if(_0x5bc78b){return _0x32f17d[_0xc0b5('0x20')](_0x3ff214)[_0xc0b5('0x22')](_0x5bc78b);}};}function respondWithFilteredResult(_0x1b70c7,_0x433bca){return function(_0x4776a4){if(_0x4776a4){var _0x1eaf8c=typeof _0x433bca[_0xc0b5('0x23')]===_0xc0b5('0x24')&&typeof _0x433bca[_0xc0b5('0x25')]==='undefined';var _0x5222b7=_0x4776a4[_0xc0b5('0x26')];var _0x57af5d=_0x1eaf8c?0x0:_0x433bca[_0xc0b5('0x23')];var _0x20ee3e=_0x1eaf8c?_0x4776a4[_0xc0b5('0x26')]:_0x433bca[_0xc0b5('0x23')]+_0x433bca[_0xc0b5('0x25')];var _0x46e72a;if(_0x20ee3e>=_0x5222b7){_0x20ee3e=_0x5222b7;_0x46e72a=0xc8;}else{_0x46e72a=0xce;}_0x1b70c7[_0xc0b5('0x20')](_0x46e72a);return _0x1b70c7['set'](_0xc0b5('0x27'),_0x57af5d+'-'+_0x20ee3e+'/'+_0x5222b7)[_0xc0b5('0x22')](_0x4776a4);}return null;};}function patchUpdates(_0x383d18){return function(_0x2c6be2){try{jsonpatch[_0xc0b5('0x28')](_0x2c6be2,_0x383d18,!![]);}catch(_0x5b265c){return BPromise[_0xc0b5('0x29')](_0x5b265c);}return _0x2c6be2['save']();};}function saveUpdates(_0x544e57,_0x53a7d6){return function(_0x23eed6){if(_0x23eed6){return _0x23eed6['update'](_0x544e57)[_0xc0b5('0x2a')](function(_0x4732a6){return _0x4732a6;});}return null;};}function removeEntity(_0x283878,_0xf51e2d){return function(_0x587f76){if(_0x587f76){return _0x587f76[_0xc0b5('0x2b')]()['then'](function(){_0x283878['status'](0xcc)[_0xc0b5('0x21')]();});}};}function handleEntityNotFound(_0x15d0a6,_0x2ad4c3){return function(_0x2cd17c){if(!_0x2cd17c){_0x15d0a6[_0xc0b5('0x2c')](0x194);}return _0x2cd17c;};}function handleError(_0x24a365,_0x252745){_0x252745=_0x252745||0x1f4;return function(_0x5a55e2){logger['error'](_0x5a55e2['stack']);if(_0x5a55e2[_0xc0b5('0x2d')]){delete _0x5a55e2[_0xc0b5('0x2d')];}_0x24a365['status'](_0x252745)[_0xc0b5('0x2e')](_0x5a55e2);};}exports[_0xc0b5('0x2f')]=function(_0x17a276,_0x1469ca){var _0x4c51bd={},_0x2e2163={},_0x1e4690={'count':0x0,'rows':[]};var _0x1e1e18=_[_0xc0b5('0x30')](db[_0xc0b5('0x31')]['rawAttributes'],function(_0x49881f){return{'name':_0x49881f[_0xc0b5('0x32')],'type':_0x49881f[_0xc0b5('0x33')][_0xc0b5('0x34')]};});_0x2e2163['model']=_['map'](_0x1e1e18,_0xc0b5('0x2d'));_0x2e2163['query']=_['keys'](_0x17a276[_0xc0b5('0x35')]);_0x2e2163['filters']=_['intersection'](_0x2e2163[_0xc0b5('0x36')],_0x2e2163[_0xc0b5('0x35')]);_0x4c51bd[_0xc0b5('0x37')]=_[_0xc0b5('0x38')](_0x2e2163[_0xc0b5('0x36')],qs[_0xc0b5('0x39')](_0x17a276[_0xc0b5('0x35')][_0xc0b5('0x39')]));_0x4c51bd[_0xc0b5('0x37')]=_0x4c51bd[_0xc0b5('0x37')][_0xc0b5('0x3a')]?_0x4c51bd['attributes']:_0x2e2163[_0xc0b5('0x36')];if(!_0x17a276[_0xc0b5('0x35')]['hasOwnProperty'](_0xc0b5('0x3b'))){_0x4c51bd['limit']=qs[_0xc0b5('0x25')](_0x17a276[_0xc0b5('0x35')][_0xc0b5('0x25')]);_0x4c51bd['offset']=qs['offset'](_0x17a276[_0xc0b5('0x35')][_0xc0b5('0x23')]);}_0x4c51bd[_0xc0b5('0x3c')]=qs['sort'](_0x17a276['query']['sort']);_0x4c51bd[_0xc0b5('0x3d')]=qs[_0xc0b5('0x3e')](_['pick'](_0x17a276[_0xc0b5('0x35')],_0x2e2163[_0xc0b5('0x3e')]),_0x1e1e18);if(_0x17a276[_0xc0b5('0x35')][_0xc0b5('0x3f')]){_0x4c51bd[_0xc0b5('0x3d')]=_['merge'](_0x4c51bd[_0xc0b5('0x3d')],{'$or':_['map'](_0x1e1e18,function(_0x1a8836){if(_0x1a8836[_0xc0b5('0x33')]!==_0xc0b5('0x40')){var _0x1cd40c={};_0x1cd40c[_0x1a8836[_0xc0b5('0x2d')]]={'$like':'%'+_0x17a276[_0xc0b5('0x35')][_0xc0b5('0x3f')]+'%'};return _0x1cd40c;}})});}_0x4c51bd=_[_0xc0b5('0x41')]({},_0x4c51bd,_0x17a276[_0xc0b5('0x42')]);var _0x2cfe0f={'where':_0x4c51bd['where']};return db[_0xc0b5('0x31')][_0xc0b5('0x26')](_0x2cfe0f)[_0xc0b5('0x2a')](function(_0x3fee35){_0x1e4690[_0xc0b5('0x26')]=_0x3fee35;if(_0x17a276[_0xc0b5('0x35')][_0xc0b5('0x43')]){_0x4c51bd['include']=[{'all':!![]}];}return db[_0xc0b5('0x31')][_0xc0b5('0x44')](_0x4c51bd);})[_0xc0b5('0x2a')](function(_0x275b72){_0x1e4690[_0xc0b5('0x45')]=_0x275b72;return _0x1e4690;})[_0xc0b5('0x2a')](respondWithFilteredResult(_0x1469ca,_0x4c51bd))['catch'](handleError(_0x1469ca,null));};exports[_0xc0b5('0x46')]=function(_0x35fa86,_0x15e1cc){var _0x4d8610={'raw':!![],'where':{'id':_0x35fa86['params']['id']}},_0x5883c2={};_0x5883c2[_0xc0b5('0x36')]=_[_0xc0b5('0x47')](db[_0xc0b5('0x31')][_0xc0b5('0x48')]);_0x5883c2[_0xc0b5('0x35')]=_[_0xc0b5('0x47')](_0x35fa86[_0xc0b5('0x35')]);_0x5883c2[_0xc0b5('0x3e')]=_[_0xc0b5('0x38')](_0x5883c2['model'],_0x5883c2[_0xc0b5('0x35')]);_0x4d8610['attributes']=_[_0xc0b5('0x38')](_0x5883c2[_0xc0b5('0x36')],qs[_0xc0b5('0x39')](_0x35fa86[_0xc0b5('0x35')]['fields']));_0x4d8610[_0xc0b5('0x37')]=_0x4d8610[_0xc0b5('0x37')][_0xc0b5('0x3a')]?_0x4d8610['attributes']:_0x5883c2[_0xc0b5('0x36')];if(_0x35fa86[_0xc0b5('0x35')][_0xc0b5('0x43')]){_0x4d8610[_0xc0b5('0x49')]=[{'all':!![]}];}_0x4d8610=_[_0xc0b5('0x41')]({},_0x4d8610,_0x35fa86['options']);return db['ChatGroup']['find'](_0x4d8610)['then'](handleEntityNotFound(_0x15e1cc,null))['then'](respondWithResult(_0x15e1cc,null))[_0xc0b5('0x4a')](handleError(_0x15e1cc,null));};exports[_0xc0b5('0x4b')]=function(_0x9c6ee3,_0x34edda){return db['ChatGroup'][_0xc0b5('0x4b')](_0x9c6ee3[_0xc0b5('0x4c')],{})[_0xc0b5('0x2a')](respondWithResult(_0x34edda,0xc9))[_0xc0b5('0x4a')](handleError(_0x34edda,null));};exports[_0xc0b5('0x4d')]=function(_0x8a94b4,_0x394f81){if(_0x8a94b4['body']['id']){delete _0x8a94b4['body']['id'];}return db[_0xc0b5('0x31')][_0xc0b5('0x4e')]({'where':{'id':_0x8a94b4['params']['id']}})[_0xc0b5('0x2a')](handleEntityNotFound(_0x394f81,null))[_0xc0b5('0x2a')](saveUpdates(_0x8a94b4[_0xc0b5('0x4c')],null))[_0xc0b5('0x2a')](respondWithResult(_0x394f81,null))[_0xc0b5('0x4a')](handleError(_0x394f81,null));};exports['destroy']=function(_0x1c8391,_0x2c59d3){return db['ChatGroup']['find']({'where':{'id':_0x1c8391[_0xc0b5('0x4f')]['id']}})[_0xc0b5('0x2a')](handleEntityNotFound(_0x2c59d3,null))[_0xc0b5('0x2a')](removeEntity(_0x2c59d3,null))['catch'](handleError(_0x2c59d3,null));};exports['describe']=function(_0x52619f,_0x27ba50){return db['ChatGroup']['describe']()[_0xc0b5('0x2a')](respondWithResult(_0x27ba50,null))[_0xc0b5('0x4a')](handleError(_0x27ba50,null));};exports[_0xc0b5('0x50')]=function(_0x5f278d,_0x15aae7,_0x30bedc){return db['ChatInternalMessage']['count']({'where':{'ChatGroupId':_0x5f278d[_0xc0b5('0x4f')]['id'],'ToId':_0x5f278d[_0xc0b5('0x51')]['id'],'read':![]}})[_0xc0b5('0x2a')](function(_0xc921f6){return{'id':_[_0xc0b5('0x52')](_0x5f278d[_0xc0b5('0x4f')]['id']),'count':_0xc921f6};})[_0xc0b5('0x2a')](respondWithResult(_0x15aae7,null))[_0xc0b5('0x4a')](handleError(_0x15aae7,null));};exports['addMembers']=function(_0x76717d,_0x218bb3,_0x4900e4){return db[_0xc0b5('0x31')][_0xc0b5('0x4e')]({'where':{'id':_0x76717d['params']['id']}})['then'](handleEntityNotFound(_0x218bb3,null))[_0xc0b5('0x2a')](function(_0x47407a){if(_0x47407a){return _0x47407a[_0xc0b5('0x53')](_0x76717d[_0xc0b5('0x4c')][_0xc0b5('0x54')],_[_0xc0b5('0x55')](_0x76717d['body'],[_0xc0b5('0x54'),'id'])||{});}})[_0xc0b5('0x2a')](respondWithResult(_0x218bb3,null))[_0xc0b5('0x4a')](handleError(_0x218bb3,null));};exports['getMembers']=function(_0x432b44,_0x1a93c5,_0x274e9f){var _0x25ed69={};var _0x9d67b3={};var _0x21f817;var _0x495318;return db[_0xc0b5('0x31')]['findOne']({'where':{'id':_0x432b44[_0xc0b5('0x4f')]['id']}})[_0xc0b5('0x2a')](handleEntityNotFound(_0x1a93c5,null))[_0xc0b5('0x2a')](function(_0xffb750){if(_0xffb750){_0x21f817=_0xffb750;_0x9d67b3[_0xc0b5('0x36')]=_[_0xc0b5('0x47')](db[_0xc0b5('0x56')][_0xc0b5('0x48')]);_0x9d67b3[_0xc0b5('0x35')]=_[_0xc0b5('0x47')](_0x432b44[_0xc0b5('0x35')]);_0x9d67b3[_0xc0b5('0x3e')]=_[_0xc0b5('0x38')](_0x9d67b3[_0xc0b5('0x36')],_0x9d67b3['query']);_0x25ed69['attributes']=_[_0xc0b5('0x38')](_0x9d67b3[_0xc0b5('0x36')],qs[_0xc0b5('0x39')](_0x432b44[_0xc0b5('0x35')][_0xc0b5('0x39')]));_0x25ed69[_0xc0b5('0x37')]=_0x25ed69[_0xc0b5('0x37')][_0xc0b5('0x3a')]?_0x25ed69[_0xc0b5('0x37')]:_0x9d67b3[_0xc0b5('0x36')];_0x25ed69['order']=qs[_0xc0b5('0x57')](_0x432b44[_0xc0b5('0x35')]['sort']);_0x25ed69[_0xc0b5('0x3d')]=qs[_0xc0b5('0x3e')](_[_0xc0b5('0x58')](_0x432b44[_0xc0b5('0x35')],_0x9d67b3['filters']));if(_0x432b44['query']['filter']){_0x25ed69[_0xc0b5('0x3d')]=_[_0xc0b5('0x41')](_0x25ed69[_0xc0b5('0x3d')],{'$or':_['map'](_0x25ed69[_0xc0b5('0x37')],function(_0x26babd){var _0x3147ff={};_0x3147ff[_0x26babd]={'$like':'%'+_0x432b44[_0xc0b5('0x35')][_0xc0b5('0x3f')]+'%'};return _0x3147ff;})});}_0x25ed69=_[_0xc0b5('0x41')]({},_0x25ed69,_0x432b44[_0xc0b5('0x42')]);return _0x21f817[_0xc0b5('0x59')](_0x25ed69);}})[_0xc0b5('0x2a')](function(_0x1a18e9){if(_0x1a18e9){_0x495318=_0x1a18e9[_0xc0b5('0x3a')];if(!_0x432b44['query'][_0xc0b5('0x5a')](_0xc0b5('0x3b'))){_0x25ed69[_0xc0b5('0x25')]=qs[_0xc0b5('0x25')](_0x432b44[_0xc0b5('0x35')][_0xc0b5('0x25')]);_0x25ed69[_0xc0b5('0x23')]=qs[_0xc0b5('0x23')](_0x432b44[_0xc0b5('0x35')][_0xc0b5('0x23')]);}return _0x21f817[_0xc0b5('0x59')](_0x25ed69);}})[_0xc0b5('0x2a')](function(_0x149fd2){if(_0x149fd2){return _0x149fd2?{'count':_0x495318,'rows':_0x149fd2}:null;}})[_0xc0b5('0x2a')](respondWithResult(_0x1a93c5,null))['catch'](handleError(_0x1a93c5,null));};exports[_0xc0b5('0x5b')]=function(_0x56b4d8,_0x395355,_0x3c9861){return db['ChatGroup'][_0xc0b5('0x4e')]({'where':{'id':_0x56b4d8[_0xc0b5('0x4f')]['id']}})[_0xc0b5('0x2a')](handleEntityNotFound(_0x395355,null))[_0xc0b5('0x2a')](function(_0x2c7ab3){if(_0x2c7ab3){return _0x2c7ab3['removeMembers'](_0x56b4d8['query'][_0xc0b5('0x54')]);}})[_0xc0b5('0x2a')](respondWithStatusCode(_0x395355,null))['catch'](handleError(_0x395355,null));};exports[_0xc0b5('0x5c')]=function(_0x1d7cfc,_0x4135c2,_0x496513){if(_0x1d7cfc[_0xc0b5('0x4c')]['id']){delete _0x1d7cfc[_0xc0b5('0x4c')]['id'];}return db['ChatGroup'][_0xc0b5('0x4e')]({'where':{'id':_0x1d7cfc['params']['id']}})['then'](handleEntityNotFound(_0x4135c2,null))[_0xc0b5('0x2a')](function(_0x4d47a2){if(_0x4d47a2){_0x1d7cfc[_0xc0b5('0x4c')][_0xc0b5('0x5d')]=_0x4d47a2['id'];return db[_0xc0b5('0x5e')][_0xc0b5('0x4b')](_0x1d7cfc['body']);}})[_0xc0b5('0x2a')](respondWithResult(_0x4135c2,null))[_0xc0b5('0x4a')](handleError(_0x4135c2,null));};exports[_0xc0b5('0x5f')]=function(_0x1274a2,_0x1be1ab,_0x45434f){var _0x39f180={};var _0x37bbb9={};var _0x5185fb;var _0x330e6b;return db[_0xc0b5('0x31')][_0xc0b5('0x60')]({'where':{'id':_0x1274a2['params']['id']}})[_0xc0b5('0x2a')](handleEntityNotFound(_0x1be1ab,null))['then'](function(_0x1fcbdd){if(_0x1fcbdd){_0x5185fb=_0x1fcbdd;_0x37bbb9[_0xc0b5('0x36')]=_[_0xc0b5('0x47')](db['ChatInternalMessage'][_0xc0b5('0x48')]);_0x37bbb9[_0xc0b5('0x35')]=_[_0xc0b5('0x47')](_0x1274a2[_0xc0b5('0x35')]);_0x37bbb9['filters']=_[_0xc0b5('0x38')](_0x37bbb9[_0xc0b5('0x36')],_0x37bbb9[_0xc0b5('0x35')]);_0x39f180[_0xc0b5('0x37')]=_['intersection'](_0x37bbb9[_0xc0b5('0x36')],qs[_0xc0b5('0x39')](_0x1274a2[_0xc0b5('0x35')][_0xc0b5('0x39')]));_0x39f180['attributes']=_0x39f180[_0xc0b5('0x37')]['length']?_0x39f180[_0xc0b5('0x37')]:_0x37bbb9[_0xc0b5('0x36')];_0x39f180[_0xc0b5('0x3c')]=qs[_0xc0b5('0x57')](_0x1274a2['query']['sort']);_0x39f180['where']=qs[_0xc0b5('0x3e')](_[_0xc0b5('0x58')](_0x1274a2['query'],_0x37bbb9[_0xc0b5('0x3e')]));if(_0x1274a2['query'][_0xc0b5('0x3f')]){_0x39f180[_0xc0b5('0x3d')]=_[_0xc0b5('0x41')](_0x39f180[_0xc0b5('0x3d')],{'$or':_[_0xc0b5('0x30')](_0x39f180['attributes'],function(_0x5dbf6b){var _0x42446a={};_0x42446a[_0x5dbf6b]={'$like':'%'+_0x1274a2[_0xc0b5('0x35')][_0xc0b5('0x3f')]+'%'};return _0x42446a;})});}if(_0x1274a2[_0xc0b5('0x35')][_0xc0b5('0x61')]){var _0x3cd638=_0x1274a2[_0xc0b5('0x35')][_0xc0b5('0x61')][_0xc0b5('0x62')](',');var _0xe9f4f7={};_0xe9f4f7[_0x3cd638[0x0]]={'$gte':moment(_0x3cd638[0x1])[_0xc0b5('0x63')](_0xc0b5('0x64'))};_0x39f180[_0xc0b5('0x3d')]=_[_0xc0b5('0x41')](_0x39f180[_0xc0b5('0x3d')],_0xe9f4f7);}_0x39f180=_[_0xc0b5('0x41')]({},_0x39f180,_0x1274a2[_0xc0b5('0x42')]);return _0x5185fb[_0xc0b5('0x5f')](_0x39f180);}})[_0xc0b5('0x2a')](function(_0x270b06){if(_0x270b06){_0x330e6b=_0x270b06[_0xc0b5('0x3a')];if(!_0x1274a2[_0xc0b5('0x35')][_0xc0b5('0x5a')](_0xc0b5('0x3b'))){_0x39f180[_0xc0b5('0x25')]=qs[_0xc0b5('0x25')](_0x1274a2[_0xc0b5('0x35')]['limit']);_0x39f180[_0xc0b5('0x23')]=qs[_0xc0b5('0x23')](_0x1274a2['query'][_0xc0b5('0x23')]);}return _0x5185fb['getMessages'](_0x39f180);}})[_0xc0b5('0x2a')](function(_0xcffd7c){if(_0xcffd7c){return _0xcffd7c?{'count':_0x330e6b,'rows':_0xcffd7c}:null;}})['then'](respondWithResult(_0x1be1ab,null))[_0xc0b5('0x4a')](handleError(_0x1be1ab,null));};
\ No newline at end of file