Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index fd7e860..6a004d4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2cfd=['../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','localhost','socket.io-emitter','register','status','end','json','offset','undefined','limit','count','Content-Range','apply','update','destroy','name','send','index','ChatGroup','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','map','VIRTUAL','then','includeAll','include','findAll','rows','catch','params','keys','create','body','find','describe','getUnread','ChatInternalMessage','user','addMembers','omit','getMembers','findOne','User','pick','options','removeMembers','ids','addMessage','getMessages','$gte','YYYY-MM-DD\x20HH:mm:ss','eml-format','rimraf','zip-dir','request-promise','moment','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x3a7e01,_0x51204c){var _0x5b8398=function(_0x4dcfab){while(--_0x4dcfab){_0x3a7e01['push'](_0x3a7e01['shift']());}};_0x5b8398(++_0x51204c);}(_0x2cfd,0x15b));var _0xd2cf=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x2cfd[_0x20a584];return _0x4b41a8;};'use strict';var emlformat=require(_0xd2cf('0x0'));var rimraf=require(_0xd2cf('0x1'));var zipdir=require(_0xd2cf('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xd2cf('0x3'));var moment=require(_0xd2cf('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xd2cf('0x5'));var path=require(_0xd2cf('0x6'));var sox=require(_0xd2cf('0x7'));var csv=require(_0xd2cf('0x8'));var ejs=require(_0xd2cf('0x9'));var fs=require('fs');var fs_extra=require(_0xd2cf('0xa'));var _=require(_0xd2cf('0xb'));var squel=require(_0xd2cf('0xc'));var crypto=require(_0xd2cf('0xd'));var jsforce=require(_0xd2cf('0xe'));var deskjs=require(_0xd2cf('0xf'));var toCsv=require('to-csv');var querystring=require(_0xd2cf('0x10'));var Papa=require(_0xd2cf('0x11'));var Redis=require(_0xd2cf('0x12'));var authService=require(_0xd2cf('0x13'));var qs=require(_0xd2cf('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xd2cf('0x15'))('api');var utils=require(_0xd2cf('0x16'));var config=require(_0xd2cf('0x17'));var licenseUtil=require(_0xd2cf('0x18'));var db=require(_0xd2cf('0x19'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0xd2cf('0x1a'),'port':0x18eb});var socket=require(_0xd2cf('0x1b'))(new Redis(config['redis']));require('./chatGroup.socket')[_0xd2cf('0x1c')](socket);function respondWithStatusCode(_0x1386ec,_0x4149ce){_0x4149ce=_0x4149ce||0xcc;return function(_0x277440){if(_0x277440){return _0x1386ec['sendStatus'](_0x4149ce);}return _0x1386ec[_0xd2cf('0x1d')](_0x4149ce)[_0xd2cf('0x1e')]();};}function respondWithResult(_0xcb5c64,_0x4424a8){_0x4424a8=_0x4424a8||0xc8;return function(_0x330a4a){if(_0x330a4a){return _0xcb5c64[_0xd2cf('0x1d')](_0x4424a8)[_0xd2cf('0x1f')](_0x330a4a);}};}function respondWithFilteredResult(_0x28b7db,_0x16b41b){return function(_0x17c9b7){if(_0x17c9b7){var _0x3d03c8=typeof _0x16b41b[_0xd2cf('0x20')]===_0xd2cf('0x21')&&typeof _0x16b41b[_0xd2cf('0x22')]===_0xd2cf('0x21');var _0x49e390=_0x17c9b7[_0xd2cf('0x23')];var _0x16221e=_0x3d03c8?0x0:_0x16b41b[_0xd2cf('0x20')];var _0x2387b1=_0x3d03c8?_0x17c9b7[_0xd2cf('0x23')]:_0x16b41b[_0xd2cf('0x20')]+_0x16b41b['limit'];var _0x1db341;if(_0x2387b1>=_0x49e390){_0x2387b1=_0x49e390;_0x1db341=0xc8;}else{_0x1db341=0xce;}_0x28b7db[_0xd2cf('0x1d')](_0x1db341);return _0x28b7db['set'](_0xd2cf('0x24'),_0x16221e+'-'+_0x2387b1+'/'+_0x49e390)[_0xd2cf('0x1f')](_0x17c9b7);}return null;};}function patchUpdates(_0x57e2aa){return function(_0x1dff23){try{jsonpatch[_0xd2cf('0x25')](_0x1dff23,_0x57e2aa,!![]);}catch(_0x4ea000){return BPromise['reject'](_0x4ea000);}return _0x1dff23['save']();};}function saveUpdates(_0x17ebc6,_0x422959){return function(_0x382d16){if(_0x382d16){return _0x382d16[_0xd2cf('0x26')](_0x17ebc6)['then'](function(_0x2e8d45){return _0x2e8d45;});}return null;};}function removeEntity(_0x47b3fb,_0x4d1af8){return function(_0x3e8ef9){if(_0x3e8ef9){return _0x3e8ef9[_0xd2cf('0x27')]()['then'](function(){_0x47b3fb[_0xd2cf('0x1d')](0xcc)[_0xd2cf('0x1e')]();});}};}function handleEntityNotFound(_0x5cd6a7,_0x38f6c3){return function(_0x5666ef){if(!_0x5666ef){_0x5cd6a7['sendStatus'](0x194);}return _0x5666ef;};}function handleError(_0x29c32a,_0x3caa69){_0x3caa69=_0x3caa69||0x1f4;return function(_0x5e4620){logger['error'](_0x5e4620['stack']);if(_0x5e4620[_0xd2cf('0x28')]){delete _0x5e4620['name'];}_0x29c32a[_0xd2cf('0x1d')](_0x3caa69)[_0xd2cf('0x29')](_0x5e4620);};}exports[_0xd2cf('0x2a')]=function(_0x725ae,_0x7729fa){var _0x3eb104={},_0x1c1c17={},_0x55da75={'count':0x0,'rows':[]};var _0x2d00fd=_['map'](db[_0xd2cf('0x2b')][_0xd2cf('0x2c')],function(_0x36233c){return{'name':_0x36233c[_0xd2cf('0x2d')],'type':_0x36233c[_0xd2cf('0x2e')][_0xd2cf('0x2f')]};});_0x1c1c17[_0xd2cf('0x30')]=_['map'](_0x2d00fd,'name');_0x1c1c17['query']=_['keys'](_0x725ae[_0xd2cf('0x31')]);_0x1c1c17[_0xd2cf('0x32')]=_[_0xd2cf('0x33')](_0x1c1c17[_0xd2cf('0x30')],_0x1c1c17[_0xd2cf('0x31')]);_0x3eb104[_0xd2cf('0x34')]=_[_0xd2cf('0x33')](_0x1c1c17[_0xd2cf('0x30')],qs[_0xd2cf('0x35')](_0x725ae[_0xd2cf('0x31')]['fields']));_0x3eb104[_0xd2cf('0x34')]=_0x3eb104['attributes'][_0xd2cf('0x36')]?_0x3eb104[_0xd2cf('0x34')]:_0x1c1c17['model'];if(!_0x725ae['query'][_0xd2cf('0x37')](_0xd2cf('0x38'))){_0x3eb104[_0xd2cf('0x22')]=qs['limit'](_0x725ae[_0xd2cf('0x31')][_0xd2cf('0x22')]);_0x3eb104[_0xd2cf('0x20')]=qs[_0xd2cf('0x20')](_0x725ae[_0xd2cf('0x31')][_0xd2cf('0x20')]);}_0x3eb104[_0xd2cf('0x39')]=qs[_0xd2cf('0x3a')](_0x725ae[_0xd2cf('0x31')][_0xd2cf('0x3a')]);_0x3eb104[_0xd2cf('0x3b')]=qs[_0xd2cf('0x32')](_['pick'](_0x725ae['query'],_0x1c1c17['filters']),_0x2d00fd);if(_0x725ae[_0xd2cf('0x31')][_0xd2cf('0x3c')]){_0x3eb104[_0xd2cf('0x3b')]=_[_0xd2cf('0x3d')](_0x3eb104[_0xd2cf('0x3b')],{'$or':_[_0xd2cf('0x3e')](_0x2d00fd,function(_0x268854){if(_0x268854['type']!==_0xd2cf('0x3f')){var _0x1b2a77={};_0x1b2a77[_0x268854[_0xd2cf('0x28')]]={'$like':'%'+_0x725ae[_0xd2cf('0x31')][_0xd2cf('0x3c')]+'%'};return _0x1b2a77;}})});}_0x3eb104=_[_0xd2cf('0x3d')]({},_0x3eb104,_0x725ae['options']);var _0x586f77={'where':_0x3eb104[_0xd2cf('0x3b')]};return db['ChatGroup'][_0xd2cf('0x23')](_0x586f77)[_0xd2cf('0x40')](function(_0xca667){_0x55da75[_0xd2cf('0x23')]=_0xca667;if(_0x725ae['query'][_0xd2cf('0x41')]){_0x3eb104[_0xd2cf('0x42')]=[{'all':!![]}];}return db[_0xd2cf('0x2b')][_0xd2cf('0x43')](_0x3eb104);})[_0xd2cf('0x40')](function(_0x38d3e7){_0x55da75[_0xd2cf('0x44')]=_0x38d3e7;return _0x55da75;})[_0xd2cf('0x40')](respondWithFilteredResult(_0x7729fa,_0x3eb104))[_0xd2cf('0x45')](handleError(_0x7729fa,null));};exports['show']=function(_0x96bcc5,_0x1a2f1c){var _0xb58767={'raw':!![],'where':{'id':_0x96bcc5[_0xd2cf('0x46')]['id']}},_0x495c27={};_0x495c27[_0xd2cf('0x30')]=_[_0xd2cf('0x47')](db['ChatGroup']['rawAttributes']);_0x495c27[_0xd2cf('0x31')]=_[_0xd2cf('0x47')](_0x96bcc5['query']);_0x495c27[_0xd2cf('0x32')]=_[_0xd2cf('0x33')](_0x495c27[_0xd2cf('0x30')],_0x495c27[_0xd2cf('0x31')]);_0xb58767[_0xd2cf('0x34')]=_[_0xd2cf('0x33')](_0x495c27[_0xd2cf('0x30')],qs[_0xd2cf('0x35')](_0x96bcc5[_0xd2cf('0x31')][_0xd2cf('0x35')]));_0xb58767[_0xd2cf('0x34')]=_0xb58767[_0xd2cf('0x34')][_0xd2cf('0x36')]?_0xb58767['attributes']:_0x495c27[_0xd2cf('0x30')];if(_0x96bcc5[_0xd2cf('0x31')][_0xd2cf('0x41')]){_0xb58767[_0xd2cf('0x42')]=[{'all':!![]}];}_0xb58767=_[_0xd2cf('0x3d')]({},_0xb58767,_0x96bcc5['options']);return db[_0xd2cf('0x2b')]['find'](_0xb58767)[_0xd2cf('0x40')](handleEntityNotFound(_0x1a2f1c,null))[_0xd2cf('0x40')](respondWithResult(_0x1a2f1c,null))[_0xd2cf('0x45')](handleError(_0x1a2f1c,null));};exports[_0xd2cf('0x48')]=function(_0xa79592,_0x431b6e){return db['ChatGroup'][_0xd2cf('0x48')](_0xa79592['body'],{})['then'](respondWithResult(_0x431b6e,0xc9))['catch'](handleError(_0x431b6e,null));};exports[_0xd2cf('0x26')]=function(_0x116632,_0x124ce3){if(_0x116632[_0xd2cf('0x49')]['id']){delete _0x116632[_0xd2cf('0x49')]['id'];}return db['ChatGroup'][_0xd2cf('0x4a')]({'where':{'id':_0x116632[_0xd2cf('0x46')]['id']}})['then'](handleEntityNotFound(_0x124ce3,null))[_0xd2cf('0x40')](saveUpdates(_0x116632[_0xd2cf('0x49')],null))[_0xd2cf('0x40')](respondWithResult(_0x124ce3,null))['catch'](handleError(_0x124ce3,null));};exports[_0xd2cf('0x27')]=function(_0x1508c2,_0x16bbe8){return db[_0xd2cf('0x2b')]['find']({'where':{'id':_0x1508c2[_0xd2cf('0x46')]['id']}})['then'](handleEntityNotFound(_0x16bbe8,null))[_0xd2cf('0x40')](removeEntity(_0x16bbe8,null))[_0xd2cf('0x45')](handleError(_0x16bbe8,null));};exports[_0xd2cf('0x4b')]=function(_0x465dde,_0x25e67d){return db['ChatGroup'][_0xd2cf('0x4b')]()[_0xd2cf('0x40')](respondWithResult(_0x25e67d,null))[_0xd2cf('0x45')](handleError(_0x25e67d,null));};exports[_0xd2cf('0x4c')]=function(_0x1a8204,_0xd93696,_0x526ca4){return db[_0xd2cf('0x4d')]['count']({'where':{'ChatGroupId':_0x1a8204[_0xd2cf('0x46')]['id'],'ToId':_0x1a8204[_0xd2cf('0x4e')]['id'],'read':![]}})['then'](function(_0x51c2b8){return{'id':_['toInteger'](_0x1a8204['params']['id']),'count':_0x51c2b8};})[_0xd2cf('0x40')](respondWithResult(_0xd93696,null))[_0xd2cf('0x45')](handleError(_0xd93696,null));};exports[_0xd2cf('0x4f')]=function(_0x545d8f,_0x5b3477,_0x23966f){return db[_0xd2cf('0x2b')]['find']({'where':{'id':_0x545d8f[_0xd2cf('0x46')]['id']}})[_0xd2cf('0x40')](handleEntityNotFound(_0x5b3477,null))[_0xd2cf('0x40')](function(_0x390717){if(_0x390717){return _0x390717[_0xd2cf('0x4f')](_0x545d8f[_0xd2cf('0x49')]['ids'],_[_0xd2cf('0x50')](_0x545d8f[_0xd2cf('0x49')],['ids','id'])||{});}})['then'](respondWithResult(_0x5b3477,null))[_0xd2cf('0x45')](handleError(_0x5b3477,null));};exports[_0xd2cf('0x51')]=function(_0x525ead,_0x2e4170,_0x3b2a16){var _0x36f252={};var _0x416d25={};var _0x39eb8a;var _0x5ee064;return db[_0xd2cf('0x2b')][_0xd2cf('0x52')]({'where':{'id':_0x525ead[_0xd2cf('0x46')]['id']}})['then'](handleEntityNotFound(_0x2e4170,null))[_0xd2cf('0x40')](function(_0x5127f1){if(_0x5127f1){_0x39eb8a=_0x5127f1;_0x416d25['model']=_[_0xd2cf('0x47')](db[_0xd2cf('0x53')][_0xd2cf('0x2c')]);_0x416d25[_0xd2cf('0x31')]=_[_0xd2cf('0x47')](_0x525ead[_0xd2cf('0x31')]);_0x416d25[_0xd2cf('0x32')]=_[_0xd2cf('0x33')](_0x416d25[_0xd2cf('0x30')],_0x416d25[_0xd2cf('0x31')]);_0x36f252[_0xd2cf('0x34')]=_[_0xd2cf('0x33')](_0x416d25[_0xd2cf('0x30')],qs[_0xd2cf('0x35')](_0x525ead['query'][_0xd2cf('0x35')]));_0x36f252[_0xd2cf('0x34')]=_0x36f252['attributes'][_0xd2cf('0x36')]?_0x36f252[_0xd2cf('0x34')]:_0x416d25['model'];_0x36f252['order']=qs[_0xd2cf('0x3a')](_0x525ead[_0xd2cf('0x31')][_0xd2cf('0x3a')]);_0x36f252[_0xd2cf('0x3b')]=qs[_0xd2cf('0x32')](_[_0xd2cf('0x54')](_0x525ead['query'],_0x416d25[_0xd2cf('0x32')]));if(_0x525ead[_0xd2cf('0x31')][_0xd2cf('0x3c')]){_0x36f252[_0xd2cf('0x3b')]=_[_0xd2cf('0x3d')](_0x36f252[_0xd2cf('0x3b')],{'$or':_[_0xd2cf('0x3e')](_0x36f252[_0xd2cf('0x34')],function(_0x293028){var _0x23c4f0={};_0x23c4f0[_0x293028]={'$like':'%'+_0x525ead[_0xd2cf('0x31')][_0xd2cf('0x3c')]+'%'};return _0x23c4f0;})});}_0x36f252=_[_0xd2cf('0x3d')]({},_0x36f252,_0x525ead[_0xd2cf('0x55')]);return _0x39eb8a[_0xd2cf('0x51')](_0x36f252);}})[_0xd2cf('0x40')](function(_0x411434){if(_0x411434){_0x5ee064=_0x411434[_0xd2cf('0x36')];if(!_0x525ead[_0xd2cf('0x31')][_0xd2cf('0x37')]('nolimit')){_0x36f252['limit']=qs[_0xd2cf('0x22')](_0x525ead[_0xd2cf('0x31')]['limit']);_0x36f252[_0xd2cf('0x20')]=qs['offset'](_0x525ead['query']['offset']);}return _0x39eb8a[_0xd2cf('0x51')](_0x36f252);}})[_0xd2cf('0x40')](function(_0x4d50f0){if(_0x4d50f0){return _0x4d50f0?{'count':_0x5ee064,'rows':_0x4d50f0}:null;}})[_0xd2cf('0x40')](respondWithResult(_0x2e4170,null))[_0xd2cf('0x45')](handleError(_0x2e4170,null));};exports['removeMembers']=function(_0x2d1a80,_0x300adc,_0x2d1764){return db[_0xd2cf('0x2b')][_0xd2cf('0x4a')]({'where':{'id':_0x2d1a80[_0xd2cf('0x46')]['id']}})['then'](handleEntityNotFound(_0x300adc,null))[_0xd2cf('0x40')](function(_0x29c3f1){if(_0x29c3f1){return _0x29c3f1[_0xd2cf('0x56')](_0x2d1a80[_0xd2cf('0x31')][_0xd2cf('0x57')]);}})[_0xd2cf('0x40')](respondWithStatusCode(_0x300adc,null))[_0xd2cf('0x45')](handleError(_0x300adc,null));};exports[_0xd2cf('0x58')]=function(_0x5d20b3,_0x407eea,_0x4ebfe0){if(_0x5d20b3[_0xd2cf('0x49')]['id']){delete _0x5d20b3[_0xd2cf('0x49')]['id'];}return db[_0xd2cf('0x2b')][_0xd2cf('0x4a')]({'where':{'id':_0x5d20b3[_0xd2cf('0x46')]['id']}})[_0xd2cf('0x40')](handleEntityNotFound(_0x407eea,null))['then'](function(_0x228160){if(_0x228160){_0x5d20b3[_0xd2cf('0x49')]['ChatGroupId']=_0x228160['id'];return db['ChatInternalMessage'][_0xd2cf('0x48')](_0x5d20b3[_0xd2cf('0x49')]);}})[_0xd2cf('0x40')](respondWithResult(_0x407eea,null))['catch'](handleError(_0x407eea,null));};exports[_0xd2cf('0x59')]=function(_0x3c5944,_0x25e27c,_0xeeddc9){var _0x54e098={};var _0x403963={};var _0xfbf86a;var _0x56393f;return db[_0xd2cf('0x2b')][_0xd2cf('0x52')]({'where':{'id':_0x3c5944[_0xd2cf('0x46')]['id']}})['then'](handleEntityNotFound(_0x25e27c,null))[_0xd2cf('0x40')](function(_0x1e8b1c){if(_0x1e8b1c){_0xfbf86a=_0x1e8b1c;_0x403963[_0xd2cf('0x30')]=_[_0xd2cf('0x47')](db['ChatInternalMessage'][_0xd2cf('0x2c')]);_0x403963[_0xd2cf('0x31')]=_['keys'](_0x3c5944[_0xd2cf('0x31')]);_0x403963[_0xd2cf('0x32')]=_[_0xd2cf('0x33')](_0x403963['model'],_0x403963['query']);_0x54e098[_0xd2cf('0x34')]=_[_0xd2cf('0x33')](_0x403963[_0xd2cf('0x30')],qs[_0xd2cf('0x35')](_0x3c5944['query']['fields']));_0x54e098[_0xd2cf('0x34')]=_0x54e098['attributes'][_0xd2cf('0x36')]?_0x54e098[_0xd2cf('0x34')]:_0x403963['model'];_0x54e098[_0xd2cf('0x39')]=qs['sort'](_0x3c5944[_0xd2cf('0x31')][_0xd2cf('0x3a')]);_0x54e098[_0xd2cf('0x3b')]=qs[_0xd2cf('0x32')](_[_0xd2cf('0x54')](_0x3c5944[_0xd2cf('0x31')],_0x403963[_0xd2cf('0x32')]));if(_0x3c5944[_0xd2cf('0x31')][_0xd2cf('0x3c')]){_0x54e098[_0xd2cf('0x3b')]=_['merge'](_0x54e098['where'],{'$or':_[_0xd2cf('0x3e')](_0x54e098['attributes'],function(_0x5c320c){var _0x8bb366={};_0x8bb366[_0x5c320c]={'$like':'%'+_0x3c5944[_0xd2cf('0x31')][_0xd2cf('0x3c')]+'%'};return _0x8bb366;})});}if(_0x3c5944[_0xd2cf('0x31')]['$gte']){var _0x131484=_0x3c5944[_0xd2cf('0x31')][_0xd2cf('0x5a')]['split'](',');var _0xd4269b={};_0xd4269b[_0x131484[0x0]]={'$gte':moment(_0x131484[0x1])['format'](_0xd2cf('0x5b'))};_0x54e098[_0xd2cf('0x3b')]=_['merge'](_0x54e098[_0xd2cf('0x3b')],_0xd4269b);}_0x54e098=_[_0xd2cf('0x3d')]({},_0x54e098,_0x3c5944[_0xd2cf('0x55')]);return _0xfbf86a[_0xd2cf('0x59')](_0x54e098);}})[_0xd2cf('0x40')](function(_0x120545){if(_0x120545){_0x56393f=_0x120545[_0xd2cf('0x36')];if(!_0x3c5944[_0xd2cf('0x31')]['hasOwnProperty']('nolimit')){_0x54e098[_0xd2cf('0x22')]=qs['limit'](_0x3c5944[_0xd2cf('0x31')][_0xd2cf('0x22')]);_0x54e098[_0xd2cf('0x20')]=qs[_0xd2cf('0x20')](_0x3c5944['query'][_0xd2cf('0x20')]);}return _0xfbf86a['getMessages'](_0x54e098);}})[_0xd2cf('0x40')](function(_0x3b011c){if(_0x3b011c){return _0x3b011c?{'count':_0x56393f,'rows':_0x3b011c}:null;}})['then'](respondWithResult(_0x25e27c,null))['catch'](handleError(_0x25e27c,null));};
\ No newline at end of file
+var _0xa6c1=['toInteger','addMembers','ids','omit','getMembers','findOne','User','pick','removeMembers','ChatGroupId','format','YYYY-MM-DD\x20HH:mm:ss','getMessages','hasOwnProperty','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','defaults','redis','localhost','socket.io-emitter','./chatGroup.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','save','update','then','destroy','error','name','send','map','ChatGroup','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','rows','catch','params','keys','find','create','body','describe','ChatInternalMessage'];(function(_0x353171,_0x56d557){var _0x4a36ee=function(_0x58b837){while(--_0x58b837){_0x353171['push'](_0x353171['shift']());}};_0x4a36ee(++_0x56d557);}(_0xa6c1,0x6b));var _0x1a6c=function(_0x24a88e,_0x22a0b8){_0x24a88e=_0x24a88e-0x0;var _0x232cbb=_0xa6c1[_0x24a88e];return _0x232cbb;};'use strict';var emlformat=require(_0x1a6c('0x0'));var rimraf=require(_0x1a6c('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x1a6c('0x2'));var rp=require(_0x1a6c('0x3'));var moment=require(_0x1a6c('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x1a6c('0x5'));var util=require(_0x1a6c('0x6'));var path=require(_0x1a6c('0x7'));var sox=require(_0x1a6c('0x8'));var csv=require('to-csv');var ejs=require(_0x1a6c('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x1a6c('0xa'));var squel=require(_0x1a6c('0xb'));var crypto=require(_0x1a6c('0xc'));var jsforce=require(_0x1a6c('0xd'));var deskjs=require(_0x1a6c('0xe'));var toCsv=require(_0x1a6c('0xf'));var querystring=require(_0x1a6c('0x10'));var Papa=require(_0x1a6c('0x11'));var Redis=require(_0x1a6c('0x12'));var authService=require(_0x1a6c('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x1a6c('0x14'));var logger=require(_0x1a6c('0x15'))('api');var utils=require(_0x1a6c('0x16'));var config=require(_0x1a6c('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config['redis']=_[_0x1a6c('0x18')](config[_0x1a6c('0x19')],{'host':_0x1a6c('0x1a'),'port':0x18eb});var socket=require(_0x1a6c('0x1b'))(new Redis(config[_0x1a6c('0x19')]));require(_0x1a6c('0x1c'))[_0x1a6c('0x1d')](socket);function respondWithStatusCode(_0x385828,_0x47d030){_0x47d030=_0x47d030||0xcc;return function(_0x4a8bd8){if(_0x4a8bd8){return _0x385828[_0x1a6c('0x1e')](_0x47d030);}return _0x385828[_0x1a6c('0x1f')](_0x47d030)[_0x1a6c('0x20')]();};}function respondWithResult(_0x509454,_0xbfbd17){_0xbfbd17=_0xbfbd17||0xc8;return function(_0x312496){if(_0x312496){return _0x509454[_0x1a6c('0x1f')](_0xbfbd17)[_0x1a6c('0x21')](_0x312496);}};}function respondWithFilteredResult(_0x48c11a,_0x26d80a){return function(_0xee038){if(_0xee038){var _0x4e94ea=typeof _0x26d80a[_0x1a6c('0x22')]===_0x1a6c('0x23')&&typeof _0x26d80a[_0x1a6c('0x24')]===_0x1a6c('0x23');var _0x5dac19=_0xee038[_0x1a6c('0x25')];var _0x2f753f=_0x4e94ea?0x0:_0x26d80a[_0x1a6c('0x22')];var _0x2df482=_0x4e94ea?_0xee038['count']:_0x26d80a[_0x1a6c('0x22')]+_0x26d80a[_0x1a6c('0x24')];var _0x4335ce;if(_0x2df482>=_0x5dac19){_0x2df482=_0x5dac19;_0x4335ce=0xc8;}else{_0x4335ce=0xce;}_0x48c11a[_0x1a6c('0x1f')](_0x4335ce);return _0x48c11a[_0x1a6c('0x26')]('Content-Range',_0x2f753f+'-'+_0x2df482+'/'+_0x5dac19)[_0x1a6c('0x21')](_0xee038);}return null;};}function patchUpdates(_0x1deb8f){return function(_0x12d166){try{jsonpatch[_0x1a6c('0x27')](_0x12d166,_0x1deb8f,!![]);}catch(_0x330efd){return BPromise['reject'](_0x330efd);}return _0x12d166[_0x1a6c('0x28')]();};}function saveUpdates(_0x355664,_0x44ecf1){return function(_0x43476a){if(_0x43476a){return _0x43476a[_0x1a6c('0x29')](_0x355664)[_0x1a6c('0x2a')](function(_0xe81ba8){return _0xe81ba8;});}return null;};}function removeEntity(_0x1e24fc,_0x609d98){return function(_0x1f32bb){if(_0x1f32bb){return _0x1f32bb[_0x1a6c('0x2b')]()[_0x1a6c('0x2a')](function(){_0x1e24fc[_0x1a6c('0x1f')](0xcc)[_0x1a6c('0x20')]();});}};}function handleEntityNotFound(_0x397eda,_0x1f59a1){return function(_0x29d1a1){if(!_0x29d1a1){_0x397eda[_0x1a6c('0x1e')](0x194);}return _0x29d1a1;};}function handleError(_0x4d33a5,_0x2c5fab){_0x2c5fab=_0x2c5fab||0x1f4;return function(_0x2d41a0){logger[_0x1a6c('0x2c')](_0x2d41a0['stack']);if(_0x2d41a0[_0x1a6c('0x2d')]){delete _0x2d41a0[_0x1a6c('0x2d')];}_0x4d33a5[_0x1a6c('0x1f')](_0x2c5fab)[_0x1a6c('0x2e')](_0x2d41a0);};}exports['index']=function(_0x892af5,_0x4a0086){var _0x181035={},_0x43c3f8={},_0x322872={'count':0x0,'rows':[]};var _0x5525f3=_[_0x1a6c('0x2f')](db[_0x1a6c('0x30')][_0x1a6c('0x31')],function(_0x257a8f){return{'name':_0x257a8f[_0x1a6c('0x32')],'type':_0x257a8f[_0x1a6c('0x33')][_0x1a6c('0x34')]};});_0x43c3f8[_0x1a6c('0x35')]=_['map'](_0x5525f3,'name');_0x43c3f8[_0x1a6c('0x36')]=_['keys'](_0x892af5[_0x1a6c('0x36')]);_0x43c3f8[_0x1a6c('0x37')]=_[_0x1a6c('0x38')](_0x43c3f8[_0x1a6c('0x35')],_0x43c3f8[_0x1a6c('0x36')]);_0x181035[_0x1a6c('0x39')]=_[_0x1a6c('0x38')](_0x43c3f8[_0x1a6c('0x35')],qs[_0x1a6c('0x3a')](_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x3a')]));_0x181035[_0x1a6c('0x39')]=_0x181035[_0x1a6c('0x39')][_0x1a6c('0x3b')]?_0x181035['attributes']:_0x43c3f8[_0x1a6c('0x35')];if(!_0x892af5[_0x1a6c('0x36')]['hasOwnProperty'](_0x1a6c('0x3c'))){_0x181035['limit']=qs[_0x1a6c('0x24')](_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x24')]);_0x181035['offset']=qs[_0x1a6c('0x22')](_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x22')]);}_0x181035[_0x1a6c('0x3d')]=qs[_0x1a6c('0x3e')](_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x3e')]);_0x181035[_0x1a6c('0x3f')]=qs['filters'](_['pick'](_0x892af5[_0x1a6c('0x36')],_0x43c3f8[_0x1a6c('0x37')]),_0x5525f3);if(_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x40')]){_0x181035[_0x1a6c('0x3f')]=_[_0x1a6c('0x41')](_0x181035[_0x1a6c('0x3f')],{'$or':_[_0x1a6c('0x2f')](_0x5525f3,function(_0x4acccf){if(_0x4acccf['type']!==_0x1a6c('0x42')){var _0x5425ca={};_0x5425ca[_0x4acccf[_0x1a6c('0x2d')]]={'$like':'%'+_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x40')]+'%'};return _0x5425ca;}})});}_0x181035=_['merge']({},_0x181035,_0x892af5[_0x1a6c('0x43')]);var _0x236035={'where':_0x181035[_0x1a6c('0x3f')]};return db['ChatGroup'][_0x1a6c('0x25')](_0x236035)[_0x1a6c('0x2a')](function(_0xc23a4e){_0x322872[_0x1a6c('0x25')]=_0xc23a4e;if(_0x892af5[_0x1a6c('0x36')][_0x1a6c('0x44')]){_0x181035[_0x1a6c('0x45')]=[{'all':!![]}];}return db['ChatGroup']['findAll'](_0x181035);})[_0x1a6c('0x2a')](function(_0x532942){_0x322872[_0x1a6c('0x46')]=_0x532942;return _0x322872;})[_0x1a6c('0x2a')](respondWithFilteredResult(_0x4a0086,_0x181035))[_0x1a6c('0x47')](handleError(_0x4a0086,null));};exports['show']=function(_0x38bc17,_0xffde1a){var _0xa08d94={'raw':!![],'where':{'id':_0x38bc17[_0x1a6c('0x48')]['id']}},_0x1171dd={};_0x1171dd[_0x1a6c('0x35')]=_[_0x1a6c('0x49')](db['ChatGroup'][_0x1a6c('0x31')]);_0x1171dd[_0x1a6c('0x36')]=_[_0x1a6c('0x49')](_0x38bc17['query']);_0x1171dd[_0x1a6c('0x37')]=_[_0x1a6c('0x38')](_0x1171dd[_0x1a6c('0x35')],_0x1171dd['query']);_0xa08d94['attributes']=_[_0x1a6c('0x38')](_0x1171dd[_0x1a6c('0x35')],qs['fields'](_0x38bc17[_0x1a6c('0x36')][_0x1a6c('0x3a')]));_0xa08d94[_0x1a6c('0x39')]=_0xa08d94[_0x1a6c('0x39')][_0x1a6c('0x3b')]?_0xa08d94[_0x1a6c('0x39')]:_0x1171dd[_0x1a6c('0x35')];if(_0x38bc17[_0x1a6c('0x36')][_0x1a6c('0x44')]){_0xa08d94['include']=[{'all':!![]}];}_0xa08d94=_[_0x1a6c('0x41')]({},_0xa08d94,_0x38bc17[_0x1a6c('0x43')]);return db['ChatGroup'][_0x1a6c('0x4a')](_0xa08d94)[_0x1a6c('0x2a')](handleEntityNotFound(_0xffde1a,null))[_0x1a6c('0x2a')](respondWithResult(_0xffde1a,null))[_0x1a6c('0x47')](handleError(_0xffde1a,null));};exports[_0x1a6c('0x4b')]=function(_0xb37fd1,_0x4c816e){return db[_0x1a6c('0x30')][_0x1a6c('0x4b')](_0xb37fd1[_0x1a6c('0x4c')],{})[_0x1a6c('0x2a')](respondWithResult(_0x4c816e,0xc9))['catch'](handleError(_0x4c816e,null));};exports['update']=function(_0x1b1b92,_0x6ca930){if(_0x1b1b92[_0x1a6c('0x4c')]['id']){delete _0x1b1b92[_0x1a6c('0x4c')]['id'];}return db[_0x1a6c('0x30')][_0x1a6c('0x4a')]({'where':{'id':_0x1b1b92[_0x1a6c('0x48')]['id']}})[_0x1a6c('0x2a')](handleEntityNotFound(_0x6ca930,null))[_0x1a6c('0x2a')](saveUpdates(_0x1b1b92[_0x1a6c('0x4c')],null))[_0x1a6c('0x2a')](respondWithResult(_0x6ca930,null))[_0x1a6c('0x47')](handleError(_0x6ca930,null));};exports['destroy']=function(_0x2ebd7c,_0x269702){return db[_0x1a6c('0x30')][_0x1a6c('0x4a')]({'where':{'id':_0x2ebd7c['params']['id']}})[_0x1a6c('0x2a')](handleEntityNotFound(_0x269702,null))['then'](removeEntity(_0x269702,null))[_0x1a6c('0x47')](handleError(_0x269702,null));};exports[_0x1a6c('0x4d')]=function(_0x591df9,_0x3d9d95){return db[_0x1a6c('0x30')][_0x1a6c('0x4d')]()['then'](respondWithResult(_0x3d9d95,null))[_0x1a6c('0x47')](handleError(_0x3d9d95,null));};exports['getUnread']=function(_0x577c28,_0x229fb4,_0x6a4863){return db[_0x1a6c('0x4e')][_0x1a6c('0x25')]({'where':{'ChatGroupId':_0x577c28[_0x1a6c('0x48')]['id'],'ToId':_0x577c28['user']['id'],'read':![]}})[_0x1a6c('0x2a')](function(_0x373d4b){return{'id':_[_0x1a6c('0x4f')](_0x577c28[_0x1a6c('0x48')]['id']),'count':_0x373d4b};})[_0x1a6c('0x2a')](respondWithResult(_0x229fb4,null))['catch'](handleError(_0x229fb4,null));};exports[_0x1a6c('0x50')]=function(_0x1ca724,_0x35d460,_0x1b0258){return db[_0x1a6c('0x30')][_0x1a6c('0x4a')]({'where':{'id':_0x1ca724[_0x1a6c('0x48')]['id']}})[_0x1a6c('0x2a')](handleEntityNotFound(_0x35d460,null))['then'](function(_0x21f806){if(_0x21f806){return _0x21f806['addMembers'](_0x1ca724['body'][_0x1a6c('0x51')],_[_0x1a6c('0x52')](_0x1ca724[_0x1a6c('0x4c')],[_0x1a6c('0x51'),'id'])||{});}})['then'](respondWithResult(_0x35d460,null))[_0x1a6c('0x47')](handleError(_0x35d460,null));};exports[_0x1a6c('0x53')]=function(_0x116318,_0x4efb91,_0x344a4b){var _0x928c21={};var _0x3b82f5={};var _0x3c88f0;var _0x5edadf;return db[_0x1a6c('0x30')][_0x1a6c('0x54')]({'where':{'id':_0x116318[_0x1a6c('0x48')]['id']}})['then'](handleEntityNotFound(_0x4efb91,null))[_0x1a6c('0x2a')](function(_0x251076){if(_0x251076){_0x3c88f0=_0x251076;_0x3b82f5[_0x1a6c('0x35')]=_[_0x1a6c('0x49')](db[_0x1a6c('0x55')][_0x1a6c('0x31')]);_0x3b82f5[_0x1a6c('0x36')]=_[_0x1a6c('0x49')](_0x116318[_0x1a6c('0x36')]);_0x3b82f5[_0x1a6c('0x37')]=_[_0x1a6c('0x38')](_0x3b82f5[_0x1a6c('0x35')],_0x3b82f5[_0x1a6c('0x36')]);_0x928c21[_0x1a6c('0x39')]=_[_0x1a6c('0x38')](_0x3b82f5['model'],qs[_0x1a6c('0x3a')](_0x116318[_0x1a6c('0x36')][_0x1a6c('0x3a')]));_0x928c21[_0x1a6c('0x39')]=_0x928c21[_0x1a6c('0x39')][_0x1a6c('0x3b')]?_0x928c21[_0x1a6c('0x39')]:_0x3b82f5[_0x1a6c('0x35')];_0x928c21[_0x1a6c('0x3d')]=qs[_0x1a6c('0x3e')](_0x116318[_0x1a6c('0x36')][_0x1a6c('0x3e')]);_0x928c21[_0x1a6c('0x3f')]=qs[_0x1a6c('0x37')](_[_0x1a6c('0x56')](_0x116318['query'],_0x3b82f5[_0x1a6c('0x37')]));if(_0x116318[_0x1a6c('0x36')]['filter']){_0x928c21[_0x1a6c('0x3f')]=_[_0x1a6c('0x41')](_0x928c21[_0x1a6c('0x3f')],{'$or':_[_0x1a6c('0x2f')](_0x928c21[_0x1a6c('0x39')],function(_0x697889){var _0x1bb683={};_0x1bb683[_0x697889]={'$like':'%'+_0x116318[_0x1a6c('0x36')][_0x1a6c('0x40')]+'%'};return _0x1bb683;})});}_0x928c21=_[_0x1a6c('0x41')]({},_0x928c21,_0x116318[_0x1a6c('0x43')]);return _0x3c88f0[_0x1a6c('0x53')](_0x928c21);}})['then'](function(_0x4cbbf8){if(_0x4cbbf8){_0x5edadf=_0x4cbbf8[_0x1a6c('0x3b')];if(!_0x116318[_0x1a6c('0x36')]['hasOwnProperty']('nolimit')){_0x928c21[_0x1a6c('0x24')]=qs[_0x1a6c('0x24')](_0x116318[_0x1a6c('0x36')][_0x1a6c('0x24')]);_0x928c21[_0x1a6c('0x22')]=qs[_0x1a6c('0x22')](_0x116318[_0x1a6c('0x36')][_0x1a6c('0x22')]);}return _0x3c88f0[_0x1a6c('0x53')](_0x928c21);}})[_0x1a6c('0x2a')](function(_0xe879f0){if(_0xe879f0){return _0xe879f0?{'count':_0x5edadf,'rows':_0xe879f0}:null;}})['then'](respondWithResult(_0x4efb91,null))[_0x1a6c('0x47')](handleError(_0x4efb91,null));};exports[_0x1a6c('0x57')]=function(_0x2da57c,_0x6c5a54,_0x37891b){return db[_0x1a6c('0x30')][_0x1a6c('0x4a')]({'where':{'id':_0x2da57c[_0x1a6c('0x48')]['id']}})[_0x1a6c('0x2a')](handleEntityNotFound(_0x6c5a54,null))[_0x1a6c('0x2a')](function(_0x37a36b){if(_0x37a36b){return _0x37a36b[_0x1a6c('0x57')](_0x2da57c[_0x1a6c('0x36')][_0x1a6c('0x51')]);}})[_0x1a6c('0x2a')](respondWithStatusCode(_0x6c5a54,null))[_0x1a6c('0x47')](handleError(_0x6c5a54,null));};exports['addMessage']=function(_0x4f1449,_0x104c47,_0xd1750a){if(_0x4f1449[_0x1a6c('0x4c')]['id']){delete _0x4f1449[_0x1a6c('0x4c')]['id'];}return db[_0x1a6c('0x30')]['find']({'where':{'id':_0x4f1449[_0x1a6c('0x48')]['id']}})['then'](handleEntityNotFound(_0x104c47,null))[_0x1a6c('0x2a')](function(_0x573f8d){if(_0x573f8d){_0x4f1449['body'][_0x1a6c('0x58')]=_0x573f8d['id'];return db['ChatInternalMessage'][_0x1a6c('0x4b')](_0x4f1449[_0x1a6c('0x4c')]);}})[_0x1a6c('0x2a')](respondWithResult(_0x104c47,null))[_0x1a6c('0x47')](handleError(_0x104c47,null));};exports['getMessages']=function(_0x1401cc,_0x2142f9,_0x2ab7d0){var _0x4f09dd={};var _0x39d940={};var _0x23ee12;var _0x55856a;return db['ChatGroup']['findOne']({'where':{'id':_0x1401cc[_0x1a6c('0x48')]['id']}})[_0x1a6c('0x2a')](handleEntityNotFound(_0x2142f9,null))[_0x1a6c('0x2a')](function(_0x316baa){if(_0x316baa){_0x23ee12=_0x316baa;_0x39d940[_0x1a6c('0x35')]=_[_0x1a6c('0x49')](db[_0x1a6c('0x4e')][_0x1a6c('0x31')]);_0x39d940['query']=_['keys'](_0x1401cc[_0x1a6c('0x36')]);_0x39d940[_0x1a6c('0x37')]=_[_0x1a6c('0x38')](_0x39d940['model'],_0x39d940[_0x1a6c('0x36')]);_0x4f09dd[_0x1a6c('0x39')]=_[_0x1a6c('0x38')](_0x39d940['model'],qs['fields'](_0x1401cc[_0x1a6c('0x36')][_0x1a6c('0x3a')]));_0x4f09dd[_0x1a6c('0x39')]=_0x4f09dd[_0x1a6c('0x39')]['length']?_0x4f09dd[_0x1a6c('0x39')]:_0x39d940[_0x1a6c('0x35')];_0x4f09dd[_0x1a6c('0x3d')]=qs[_0x1a6c('0x3e')](_0x1401cc[_0x1a6c('0x36')][_0x1a6c('0x3e')]);_0x4f09dd['where']=qs['filters'](_[_0x1a6c('0x56')](_0x1401cc[_0x1a6c('0x36')],_0x39d940[_0x1a6c('0x37')]));if(_0x1401cc[_0x1a6c('0x36')][_0x1a6c('0x40')]){_0x4f09dd[_0x1a6c('0x3f')]=_[_0x1a6c('0x41')](_0x4f09dd[_0x1a6c('0x3f')],{'$or':_['map'](_0x4f09dd[_0x1a6c('0x39')],function(_0x33dd63){var _0x32c85e={};_0x32c85e[_0x33dd63]={'$like':'%'+_0x1401cc[_0x1a6c('0x36')][_0x1a6c('0x40')]+'%'};return _0x32c85e;})});}if(_0x1401cc[_0x1a6c('0x36')]['$gte']){var _0xd7a643=_0x1401cc['query']['$gte']['split'](',');var _0x31ea91={};_0x31ea91[_0xd7a643[0x0]]={'$gte':moment(_0xd7a643[0x1])[_0x1a6c('0x59')](_0x1a6c('0x5a'))};_0x4f09dd[_0x1a6c('0x3f')]=_[_0x1a6c('0x41')](_0x4f09dd[_0x1a6c('0x3f')],_0x31ea91);}_0x4f09dd=_[_0x1a6c('0x41')]({},_0x4f09dd,_0x1401cc['options']);return _0x23ee12[_0x1a6c('0x5b')](_0x4f09dd);}})[_0x1a6c('0x2a')](function(_0x35f16e){if(_0x35f16e){_0x55856a=_0x35f16e[_0x1a6c('0x3b')];if(!_0x1401cc[_0x1a6c('0x36')][_0x1a6c('0x5c')](_0x1a6c('0x3c'))){_0x4f09dd[_0x1a6c('0x24')]=qs[_0x1a6c('0x24')](_0x1401cc[_0x1a6c('0x36')]['limit']);_0x4f09dd[_0x1a6c('0x22')]=qs[_0x1a6c('0x22')](_0x1401cc['query']['offset']);}return _0x23ee12[_0x1a6c('0x5b')](_0x4f09dd);}})['then'](function(_0x4fe0be){if(_0x4fe0be){return _0x4fe0be?{'count':_0x55856a,'rows':_0x4fe0be}:null;}})[_0x1a6c('0x2a')](respondWithResult(_0x2142f9,null))[_0x1a6c('0x47')](handleError(_0x2142f9,null));};
\ No newline at end of file