Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index 3589bcc..0ca2821 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5a6b=['model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','then','include','findAll','catch','show','params','includeAll','find','create','body','update','getUnread','addMembers','ids','omit','getMembers','findOne','User','ChatGroupId','ChatInternalMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','getMessages','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','defaults','localhost','redis','register','sendStatus','status','end','json','offset','undefined','count','limit','Content-Range','reject','destroy','name','send','index','map','ChatGroup','rawAttributes','fieldName'];(function(_0x346fbc,_0x48ea7b){var _0x1d94d2=function(_0x575060){while(--_0x575060){_0x346fbc['push'](_0x346fbc['shift']());}};_0x1d94d2(++_0x48ea7b);}(_0x5a6b,0x84));var _0xb5a6=function(_0x1f6bb6,_0x298ef3){_0x1f6bb6=_0x1f6bb6-0x0;var _0x4d14c7=_0x5a6b[_0x1f6bb6];return _0x4d14c7;};'use strict';var emlformat=require(_0xb5a6('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xb5a6('0x1'));var rp=require(_0xb5a6('0x2'));var moment=require(_0xb5a6('0x3'));var BPromise=require(_0xb5a6('0x4'));var Mustache=require(_0xb5a6('0x5'));var util=require('util');var path=require(_0xb5a6('0x6'));var sox=require(_0xb5a6('0x7'));var csv=require(_0xb5a6('0x8'));var ejs=require(_0xb5a6('0x9'));var fs=require('fs');var fs_extra=require(_0xb5a6('0xa'));var _=require(_0xb5a6('0xb'));var squel=require('squel');var crypto=require(_0xb5a6('0xc'));var jsforce=require(_0xb5a6('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xb5a6('0xe'));var Redis=require('ioredis');var authService=require(_0xb5a6('0xf'));var qs=require(_0xb5a6('0x10'));var as=require(_0xb5a6('0x11'));var hardwareService=require(_0xb5a6('0x12'));var logger=require(_0xb5a6('0x13'))(_0xb5a6('0x14'));var utils=require(_0xb5a6('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xb5a6('0x16'));var db=require(_0xb5a6('0x17'))['db'];config['redis']=_[_0xb5a6('0x18')](config['redis'],{'host':_0xb5a6('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb5a6('0x1a')]));require('./chatGroup.socket')[_0xb5a6('0x1b')](socket);function respondWithStatusCode(_0x4a463e,_0x4290ea){_0x4290ea=_0x4290ea||0xcc;return function(_0x538be6){if(_0x538be6){return _0x4a463e[_0xb5a6('0x1c')](_0x4290ea);}return _0x4a463e[_0xb5a6('0x1d')](_0x4290ea)[_0xb5a6('0x1e')]();};}function respondWithResult(_0x1f0100,_0x219cf2){_0x219cf2=_0x219cf2||0xc8;return function(_0x1e19ec){if(_0x1e19ec){return _0x1f0100[_0xb5a6('0x1d')](_0x219cf2)[_0xb5a6('0x1f')](_0x1e19ec);}};}function respondWithFilteredResult(_0x14939a,_0xe44f52){return function(_0x2a2c1d){if(_0x2a2c1d){var _0xf6eba7=typeof _0xe44f52[_0xb5a6('0x20')]===_0xb5a6('0x21')&&typeof _0xe44f52['limit']===_0xb5a6('0x21');var _0x2bc31a=_0x2a2c1d[_0xb5a6('0x22')];var _0x2f1ef9=_0xf6eba7?0x0:_0xe44f52[_0xb5a6('0x20')];var _0x2a28b1=_0xf6eba7?_0x2a2c1d['count']:_0xe44f52[_0xb5a6('0x20')]+_0xe44f52[_0xb5a6('0x23')];var _0x15f249;if(_0x2a28b1>=_0x2bc31a){_0x2a28b1=_0x2bc31a;_0x15f249=0xc8;}else{_0x15f249=0xce;}_0x14939a['status'](_0x15f249);return _0x14939a['set'](_0xb5a6('0x24'),_0x2f1ef9+'-'+_0x2a28b1+'/'+_0x2bc31a)[_0xb5a6('0x1f')](_0x2a2c1d);}return null;};}function patchUpdates(_0x162019){return function(_0x356426){try{jsonpatch['apply'](_0x356426,_0x162019,!![]);}catch(_0x3c0bef){return BPromise[_0xb5a6('0x25')](_0x3c0bef);}return _0x356426['save']();};}function saveUpdates(_0x57e1cc,_0x30e7f6){return function(_0x65276e){if(_0x65276e){return _0x65276e['update'](_0x57e1cc)['then'](function(_0xaaad89){return _0xaaad89;});}return null;};}function removeEntity(_0x5bb825,_0x548990){return function(_0x4cb24f){if(_0x4cb24f){return _0x4cb24f[_0xb5a6('0x26')]()['then'](function(){_0x5bb825['status'](0xcc)[_0xb5a6('0x1e')]();});}};}function handleEntityNotFound(_0x2f1d2b,_0x2c70c6){return function(_0x5e454e){if(!_0x5e454e){_0x2f1d2b[_0xb5a6('0x1c')](0x194);}return _0x5e454e;};}function handleError(_0x3c063a,_0x138dce){_0x138dce=_0x138dce||0x1f4;return function(_0x346b5b){logger['error'](_0x346b5b['stack']);if(_0x346b5b[_0xb5a6('0x27')]){delete _0x346b5b[_0xb5a6('0x27')];}_0x3c063a['status'](_0x138dce)[_0xb5a6('0x28')](_0x346b5b);};}exports[_0xb5a6('0x29')]=function(_0x2417ba,_0x14e30d){var _0x3b3f4b={},_0x521ad0={},_0x4a7594={'count':0x0,'rows':[]};var _0x5d0a2f=_[_0xb5a6('0x2a')](db[_0xb5a6('0x2b')][_0xb5a6('0x2c')],function(_0x1719dd){return{'name':_0x1719dd[_0xb5a6('0x2d')],'type':_0x1719dd['type']['key']};});_0x521ad0[_0xb5a6('0x2e')]=_[_0xb5a6('0x2a')](_0x5d0a2f,_0xb5a6('0x27'));_0x521ad0[_0xb5a6('0x2f')]=_[_0xb5a6('0x30')](_0x2417ba[_0xb5a6('0x2f')]);_0x521ad0[_0xb5a6('0x31')]=_[_0xb5a6('0x32')](_0x521ad0['model'],_0x521ad0[_0xb5a6('0x2f')]);_0x3b3f4b['attributes']=_[_0xb5a6('0x32')](_0x521ad0[_0xb5a6('0x2e')],qs['fields'](_0x2417ba[_0xb5a6('0x2f')][_0xb5a6('0x33')]));_0x3b3f4b[_0xb5a6('0x34')]=_0x3b3f4b[_0xb5a6('0x34')][_0xb5a6('0x35')]?_0x3b3f4b[_0xb5a6('0x34')]:_0x521ad0['model'];if(!_0x2417ba['query'][_0xb5a6('0x36')](_0xb5a6('0x37'))){_0x3b3f4b[_0xb5a6('0x23')]=qs[_0xb5a6('0x23')](_0x2417ba[_0xb5a6('0x2f')]['limit']);_0x3b3f4b['offset']=qs[_0xb5a6('0x20')](_0x2417ba['query'][_0xb5a6('0x20')]);}_0x3b3f4b[_0xb5a6('0x38')]=qs[_0xb5a6('0x39')](_0x2417ba[_0xb5a6('0x2f')][_0xb5a6('0x39')]);_0x3b3f4b[_0xb5a6('0x3a')]=qs[_0xb5a6('0x31')](_[_0xb5a6('0x3b')](_0x2417ba[_0xb5a6('0x2f')],_0x521ad0[_0xb5a6('0x31')]),_0x5d0a2f);if(_0x2417ba[_0xb5a6('0x2f')][_0xb5a6('0x3c')]){_0x3b3f4b['where']=_[_0xb5a6('0x3d')](_0x3b3f4b[_0xb5a6('0x3a')],{'$or':_[_0xb5a6('0x2a')](_0x5d0a2f,function(_0x132cef){if(_0x132cef['type']!==_0xb5a6('0x3e')){var _0x4f6904={};_0x4f6904[_0x132cef['name']]={'$like':'%'+_0x2417ba[_0xb5a6('0x2f')]['filter']+'%'};return _0x4f6904;}})});}_0x3b3f4b=_[_0xb5a6('0x3d')]({},_0x3b3f4b,_0x2417ba[_0xb5a6('0x3f')]);var _0x2b93d1={'where':_0x3b3f4b[_0xb5a6('0x3a')]};return db['ChatGroup'][_0xb5a6('0x22')](_0x2b93d1)[_0xb5a6('0x40')](function(_0x28fa1e){_0x4a7594[_0xb5a6('0x22')]=_0x28fa1e;if(_0x2417ba[_0xb5a6('0x2f')]['includeAll']){_0x3b3f4b[_0xb5a6('0x41')]=[{'all':!![]}];}return db['ChatGroup'][_0xb5a6('0x42')](_0x3b3f4b);})['then'](function(_0x3700db){_0x4a7594['rows']=_0x3700db;return _0x4a7594;})[_0xb5a6('0x40')](respondWithFilteredResult(_0x14e30d,_0x3b3f4b))[_0xb5a6('0x43')](handleError(_0x14e30d,null));};exports[_0xb5a6('0x44')]=function(_0x62096a,_0x44f255){var _0x197b10={'raw':!![],'where':{'id':_0x62096a[_0xb5a6('0x45')]['id']}},_0x272ebd={};_0x272ebd[_0xb5a6('0x2e')]=_[_0xb5a6('0x30')](db[_0xb5a6('0x2b')][_0xb5a6('0x2c')]);_0x272ebd[_0xb5a6('0x2f')]=_[_0xb5a6('0x30')](_0x62096a['query']);_0x272ebd['filters']=_[_0xb5a6('0x32')](_0x272ebd[_0xb5a6('0x2e')],_0x272ebd[_0xb5a6('0x2f')]);_0x197b10[_0xb5a6('0x34')]=_[_0xb5a6('0x32')](_0x272ebd[_0xb5a6('0x2e')],qs[_0xb5a6('0x33')](_0x62096a[_0xb5a6('0x2f')][_0xb5a6('0x33')]));_0x197b10[_0xb5a6('0x34')]=_0x197b10[_0xb5a6('0x34')]['length']?_0x197b10[_0xb5a6('0x34')]:_0x272ebd['model'];if(_0x62096a[_0xb5a6('0x2f')][_0xb5a6('0x46')]){_0x197b10['include']=[{'all':!![]}];}_0x197b10=_['merge']({},_0x197b10,_0x62096a['options']);return db[_0xb5a6('0x2b')][_0xb5a6('0x47')](_0x197b10)['then'](handleEntityNotFound(_0x44f255,null))[_0xb5a6('0x40')](respondWithResult(_0x44f255,null))[_0xb5a6('0x43')](handleError(_0x44f255,null));};exports[_0xb5a6('0x48')]=function(_0x362a77,_0x2ebb2b){return db['ChatGroup']['create'](_0x362a77[_0xb5a6('0x49')],{})[_0xb5a6('0x40')](respondWithResult(_0x2ebb2b,0xc9))[_0xb5a6('0x43')](handleError(_0x2ebb2b,null));};exports[_0xb5a6('0x4a')]=function(_0x5460ac,_0xea0536){if(_0x5460ac['body']['id']){delete _0x5460ac[_0xb5a6('0x49')]['id'];}return db['ChatGroup'][_0xb5a6('0x47')]({'where':{'id':_0x5460ac['params']['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0xea0536,null))[_0xb5a6('0x40')](saveUpdates(_0x5460ac[_0xb5a6('0x49')],null))['then'](respondWithResult(_0xea0536,null))['catch'](handleError(_0xea0536,null));};exports[_0xb5a6('0x26')]=function(_0x4faa22,_0x5dd078){return db[_0xb5a6('0x2b')]['find']({'where':{'id':_0x4faa22[_0xb5a6('0x45')]['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0x5dd078,null))[_0xb5a6('0x40')](removeEntity(_0x5dd078,null))[_0xb5a6('0x43')](handleError(_0x5dd078,null));};exports['describe']=function(_0x4edd10,_0x1bcd1e){return db['ChatGroup']['describe']()[_0xb5a6('0x40')](respondWithResult(_0x1bcd1e,null))['catch'](handleError(_0x1bcd1e,null));};exports[_0xb5a6('0x4b')]=function(_0xc3c5ee,_0x5615c2,_0x4289d1){return db['ChatInternalMessage']['count']({'where':{'ChatGroupId':_0xc3c5ee[_0xb5a6('0x45')]['id'],'ToId':_0xc3c5ee['user']['id'],'read':![]}})['then'](function(_0x2ff3a8){return{'id':_['toInteger'](_0xc3c5ee[_0xb5a6('0x45')]['id']),'count':_0x2ff3a8};})[_0xb5a6('0x40')](respondWithResult(_0x5615c2,null))[_0xb5a6('0x43')](handleError(_0x5615c2,null));};exports[_0xb5a6('0x4c')]=function(_0x299346,_0x4616ae,_0x25e529){return db['ChatGroup'][_0xb5a6('0x47')]({'where':{'id':_0x299346['params']['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0x4616ae,null))[_0xb5a6('0x40')](function(_0x59faaa){if(_0x59faaa){return _0x59faaa[_0xb5a6('0x4c')](_0x299346['body'][_0xb5a6('0x4d')],_[_0xb5a6('0x4e')](_0x299346['body'],[_0xb5a6('0x4d'),'id'])||{});}})['then'](respondWithResult(_0x4616ae,null))[_0xb5a6('0x43')](handleError(_0x4616ae,null));};exports[_0xb5a6('0x4f')]=function(_0x5ccc57,_0x1d6008,_0x3969f3){var _0x29187a={};var _0x5e6b58={};var _0x11ac51;var _0x5d03f6;return db['ChatGroup'][_0xb5a6('0x50')]({'where':{'id':_0x5ccc57['params']['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0x1d6008,null))['then'](function(_0x12f5ee){if(_0x12f5ee){_0x11ac51=_0x12f5ee;_0x5e6b58['model']=_[_0xb5a6('0x30')](db[_0xb5a6('0x51')]['rawAttributes']);_0x5e6b58['query']=_[_0xb5a6('0x30')](_0x5ccc57[_0xb5a6('0x2f')]);_0x5e6b58['filters']=_[_0xb5a6('0x32')](_0x5e6b58['model'],_0x5e6b58[_0xb5a6('0x2f')]);_0x29187a[_0xb5a6('0x34')]=_[_0xb5a6('0x32')](_0x5e6b58[_0xb5a6('0x2e')],qs[_0xb5a6('0x33')](_0x5ccc57[_0xb5a6('0x2f')][_0xb5a6('0x33')]));_0x29187a[_0xb5a6('0x34')]=_0x29187a['attributes'][_0xb5a6('0x35')]?_0x29187a[_0xb5a6('0x34')]:_0x5e6b58['model'];_0x29187a[_0xb5a6('0x38')]=qs['sort'](_0x5ccc57[_0xb5a6('0x2f')]['sort']);_0x29187a[_0xb5a6('0x3a')]=qs[_0xb5a6('0x31')](_[_0xb5a6('0x3b')](_0x5ccc57[_0xb5a6('0x2f')],_0x5e6b58[_0xb5a6('0x31')]));if(_0x5ccc57[_0xb5a6('0x2f')][_0xb5a6('0x3c')]){_0x29187a[_0xb5a6('0x3a')]=_[_0xb5a6('0x3d')](_0x29187a[_0xb5a6('0x3a')],{'$or':_['map'](_0x29187a[_0xb5a6('0x34')],function(_0x5f5953){var _0x4fb32c={};_0x4fb32c[_0x5f5953]={'$like':'%'+_0x5ccc57[_0xb5a6('0x2f')][_0xb5a6('0x3c')]+'%'};return _0x4fb32c;})});}_0x29187a=_[_0xb5a6('0x3d')]({},_0x29187a,_0x5ccc57['options']);return _0x11ac51[_0xb5a6('0x4f')](_0x29187a);}})[_0xb5a6('0x40')](function(_0x501601){if(_0x501601){_0x5d03f6=_0x501601[_0xb5a6('0x35')];if(!_0x5ccc57[_0xb5a6('0x2f')]['hasOwnProperty'](_0xb5a6('0x37'))){_0x29187a[_0xb5a6('0x23')]=qs[_0xb5a6('0x23')](_0x5ccc57['query'][_0xb5a6('0x23')]);_0x29187a[_0xb5a6('0x20')]=qs[_0xb5a6('0x20')](_0x5ccc57[_0xb5a6('0x2f')][_0xb5a6('0x20')]);}return _0x11ac51[_0xb5a6('0x4f')](_0x29187a);}})['then'](function(_0x4d8722){if(_0x4d8722){return _0x4d8722?{'count':_0x5d03f6,'rows':_0x4d8722}:null;}})[_0xb5a6('0x40')](respondWithResult(_0x1d6008,null))['catch'](handleError(_0x1d6008,null));};exports['removeMembers']=function(_0x1cd08b,_0x204dbc,_0x22184e){return db[_0xb5a6('0x2b')][_0xb5a6('0x47')]({'where':{'id':_0x1cd08b[_0xb5a6('0x45')]['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0x204dbc,null))['then'](function(_0x2a466f){if(_0x2a466f){return _0x2a466f['removeMembers'](_0x1cd08b[_0xb5a6('0x2f')][_0xb5a6('0x4d')]);}})[_0xb5a6('0x40')](respondWithStatusCode(_0x204dbc,null))[_0xb5a6('0x43')](handleError(_0x204dbc,null));};exports['addMessage']=function(_0xecd9e2,_0x5190e4,_0x5132ea){if(_0xecd9e2[_0xb5a6('0x49')]['id']){delete _0xecd9e2['body']['id'];}return db['ChatGroup'][_0xb5a6('0x47')]({'where':{'id':_0xecd9e2[_0xb5a6('0x45')]['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0x5190e4,null))[_0xb5a6('0x40')](function(_0x35ca9c){if(_0x35ca9c){_0xecd9e2[_0xb5a6('0x49')][_0xb5a6('0x52')]=_0x35ca9c['id'];return db[_0xb5a6('0x53')]['create'](_0xecd9e2[_0xb5a6('0x49')]);}})[_0xb5a6('0x40')](respondWithResult(_0x5190e4,null))[_0xb5a6('0x43')](handleError(_0x5190e4,null));};exports['getMessages']=function(_0x21fc40,_0x32c7e8,_0x4d16fb){var _0x37d7ee={};var _0xb33acf={};var _0x100611;var _0x2a0c7c;return db[_0xb5a6('0x2b')]['findOne']({'where':{'id':_0x21fc40[_0xb5a6('0x45')]['id']}})[_0xb5a6('0x40')](handleEntityNotFound(_0x32c7e8,null))[_0xb5a6('0x40')](function(_0x206696){if(_0x206696){_0x100611=_0x206696;_0xb33acf[_0xb5a6('0x2e')]=_[_0xb5a6('0x30')](db[_0xb5a6('0x53')][_0xb5a6('0x2c')]);_0xb33acf['query']=_[_0xb5a6('0x30')](_0x21fc40[_0xb5a6('0x2f')]);_0xb33acf['filters']=_[_0xb5a6('0x32')](_0xb33acf['model'],_0xb33acf[_0xb5a6('0x2f')]);_0x37d7ee[_0xb5a6('0x34')]=_[_0xb5a6('0x32')](_0xb33acf['model'],qs[_0xb5a6('0x33')](_0x21fc40['query'][_0xb5a6('0x33')]));_0x37d7ee[_0xb5a6('0x34')]=_0x37d7ee['attributes'][_0xb5a6('0x35')]?_0x37d7ee[_0xb5a6('0x34')]:_0xb33acf['model'];_0x37d7ee['order']=qs['sort'](_0x21fc40[_0xb5a6('0x2f')][_0xb5a6('0x39')]);_0x37d7ee['where']=qs[_0xb5a6('0x31')](_[_0xb5a6('0x3b')](_0x21fc40[_0xb5a6('0x2f')],_0xb33acf[_0xb5a6('0x31')]));if(_0x21fc40['query'][_0xb5a6('0x3c')]){_0x37d7ee['where']=_[_0xb5a6('0x3d')](_0x37d7ee[_0xb5a6('0x3a')],{'$or':_[_0xb5a6('0x2a')](_0x37d7ee[_0xb5a6('0x34')],function(_0x3fcaed){var _0x4f8749={};_0x4f8749[_0x3fcaed]={'$like':'%'+_0x21fc40[_0xb5a6('0x2f')][_0xb5a6('0x3c')]+'%'};return _0x4f8749;})});}if(_0x21fc40[_0xb5a6('0x2f')][_0xb5a6('0x54')]){var _0x2371e6=_0x21fc40[_0xb5a6('0x2f')]['$gte'][_0xb5a6('0x55')](',');var _0x2a0416={};_0x2a0416[_0x2371e6[0x0]]={'$gte':moment(_0x2371e6[0x1])[_0xb5a6('0x56')](_0xb5a6('0x57'))};_0x37d7ee[_0xb5a6('0x3a')]=_['merge'](_0x37d7ee[_0xb5a6('0x3a')],_0x2a0416);}_0x37d7ee=_[_0xb5a6('0x3d')]({},_0x37d7ee,_0x21fc40[_0xb5a6('0x3f')]);return _0x100611[_0xb5a6('0x58')](_0x37d7ee);}})[_0xb5a6('0x40')](function(_0xcbcac9){if(_0xcbcac9){_0x2a0c7c=_0xcbcac9[_0xb5a6('0x35')];if(!_0x21fc40[_0xb5a6('0x2f')][_0xb5a6('0x36')](_0xb5a6('0x37'))){_0x37d7ee[_0xb5a6('0x23')]=qs[_0xb5a6('0x23')](_0x21fc40['query'][_0xb5a6('0x23')]);_0x37d7ee['offset']=qs[_0xb5a6('0x20')](_0x21fc40[_0xb5a6('0x2f')][_0xb5a6('0x20')]);}return _0x100611[_0xb5a6('0x58')](_0x37d7ee);}})[_0xb5a6('0x40')](function(_0x542a84){if(_0x542a84){return _0x542a84?{'count':_0x2a0c7c,'rows':_0x542a84}:null;}})[_0xb5a6('0x40')](respondWithResult(_0x32c7e8,null))[_0xb5a6('0x43')](handleError(_0x32c7e8,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