Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index 2220366..da110ef 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa0c8=['status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','stack','name','index','map','ChatGroup','key','model','query','keys','filters','fields','attributes','hasOwnProperty','nolimit','order','sort','where','filter','type','VIRTUAL','options','includeAll','findAll','rows','catch','params','rawAttributes','intersection','include','merge','find','create','body','describe','getUnread','ChatInternalMessage','user','toInteger','addMembers','ids','getMembers','pick','removeMembers','addMessage','findOne','length','split','format','YYYY-MM-DD\x20HH:mm:ss','getMessages','eml-format','rimraf','request-promise','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','redis','defaults','socket.io-emitter','./chatGroup.socket'];(function(_0xf880a5,_0x2d7476){var _0x5cd65b=function(_0x1e50f3){while(--_0x1e50f3){_0xf880a5['push'](_0xf880a5['shift']());}};_0x5cd65b(++_0x2d7476);}(_0xa0c8,0x9f));var _0x8a0c=function(_0x1653b1,_0x35b7d1){_0x1653b1=_0x1653b1-0x0;var _0x3e0b17=_0xa0c8[_0x1653b1];return _0x3e0b17;};'use strict';var emlformat=require(_0x8a0c('0x0'));var rimraf=require(_0x8a0c('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x8a0c('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x8a0c('0x3'));var util=require(_0x8a0c('0x4'));var path=require(_0x8a0c('0x5'));var sox=require('sox');var csv=require(_0x8a0c('0x6'));var ejs=require(_0x8a0c('0x7'));var fs=require('fs');var fs_extra=require(_0x8a0c('0x8'));var _=require(_0x8a0c('0x9'));var squel=require(_0x8a0c('0xa'));var crypto=require('crypto');var jsforce=require(_0x8a0c('0xb'));var deskjs=require(_0x8a0c('0xc'));var toCsv=require(_0x8a0c('0x6'));var querystring=require(_0x8a0c('0xd'));var Papa=require(_0x8a0c('0xe'));var Redis=require(_0x8a0c('0xf'));var authService=require(_0x8a0c('0x10'));var qs=require(_0x8a0c('0x11'));var as=require(_0x8a0c('0x12'));var hardwareService=require(_0x8a0c('0x13'));var logger=require('../../config/logger')(_0x8a0c('0x14'));var utils=require(_0x8a0c('0x15'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x8a0c('0x16'))['db'];config[_0x8a0c('0x17')]=_[_0x8a0c('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x8a0c('0x19'))(new Redis(config['redis']));require(_0x8a0c('0x1a'))['register'](socket);function respondWithStatusCode(_0x340fbb,_0x4131d1){_0x4131d1=_0x4131d1||0xcc;return function(_0x22dd58){if(_0x22dd58){return _0x340fbb['sendStatus'](_0x4131d1);}return _0x340fbb[_0x8a0c('0x1b')](_0x4131d1)[_0x8a0c('0x1c')]();};}function respondWithResult(_0x37fda1,_0x477694){_0x477694=_0x477694||0xc8;return function(_0x354ee7){if(_0x354ee7){return _0x37fda1[_0x8a0c('0x1b')](_0x477694)[_0x8a0c('0x1d')](_0x354ee7);}};}function respondWithFilteredResult(_0x122bb9,_0x531517){return function(_0x56e394){if(_0x56e394){var _0x1e7be3=typeof _0x531517[_0x8a0c('0x1e')]===_0x8a0c('0x1f')&&typeof _0x531517[_0x8a0c('0x20')]===_0x8a0c('0x1f');var _0x8b63d0=_0x56e394[_0x8a0c('0x21')];var _0x3ae1bf=_0x1e7be3?0x0:_0x531517[_0x8a0c('0x1e')];var _0x41de13=_0x1e7be3?_0x56e394[_0x8a0c('0x21')]:_0x531517[_0x8a0c('0x1e')]+_0x531517[_0x8a0c('0x20')];var _0x48eb5b;if(_0x41de13>=_0x8b63d0){_0x41de13=_0x8b63d0;_0x48eb5b=0xc8;}else{_0x48eb5b=0xce;}_0x122bb9['status'](_0x48eb5b);return _0x122bb9[_0x8a0c('0x22')](_0x8a0c('0x23'),_0x3ae1bf+'-'+_0x41de13+'/'+_0x8b63d0)[_0x8a0c('0x1d')](_0x56e394);}return null;};}function patchUpdates(_0x2f14dd){return function(_0xd60d5c){try{jsonpatch[_0x8a0c('0x24')](_0xd60d5c,_0x2f14dd,!![]);}catch(_0x239a08){return BPromise[_0x8a0c('0x25')](_0x239a08);}return _0xd60d5c[_0x8a0c('0x26')]();};}function saveUpdates(_0xde130e,_0x52648b){return function(_0x4e8cba){if(_0x4e8cba){return _0x4e8cba[_0x8a0c('0x27')](_0xde130e)[_0x8a0c('0x28')](function(_0x5d9806){return _0x5d9806;});}return null;};}function removeEntity(_0x4252a7,_0x368023){return function(_0x3df912){if(_0x3df912){return _0x3df912[_0x8a0c('0x29')]()['then'](function(){_0x4252a7['status'](0xcc)[_0x8a0c('0x1c')]();});}};}function handleEntityNotFound(_0x2004ac,_0x2d5023){return function(_0x414891){if(!_0x414891){_0x2004ac[_0x8a0c('0x2a')](0x194);}return _0x414891;};}function handleError(_0x1821c6,_0x321c27){_0x321c27=_0x321c27||0x1f4;return function(_0x2dd1b5){logger['error'](_0x2dd1b5[_0x8a0c('0x2b')]);if(_0x2dd1b5['name']){delete _0x2dd1b5[_0x8a0c('0x2c')];}_0x1821c6[_0x8a0c('0x1b')](_0x321c27)['send'](_0x2dd1b5);};}exports[_0x8a0c('0x2d')]=function(_0x4f2b87,_0x336121){var _0x16887e={},_0x2e1b46={},_0x26e1c4={'count':0x0,'rows':[]};var _0x1cc0ad=_[_0x8a0c('0x2e')](db[_0x8a0c('0x2f')]['rawAttributes'],function(_0x581335){return{'name':_0x581335['fieldName'],'type':_0x581335['type'][_0x8a0c('0x30')]};});_0x2e1b46[_0x8a0c('0x31')]=_['map'](_0x1cc0ad,_0x8a0c('0x2c'));_0x2e1b46[_0x8a0c('0x32')]=_[_0x8a0c('0x33')](_0x4f2b87[_0x8a0c('0x32')]);_0x2e1b46[_0x8a0c('0x34')]=_['intersection'](_0x2e1b46['model'],_0x2e1b46[_0x8a0c('0x32')]);_0x16887e['attributes']=_['intersection'](_0x2e1b46[_0x8a0c('0x31')],qs['fields'](_0x4f2b87['query'][_0x8a0c('0x35')]));_0x16887e[_0x8a0c('0x36')]=_0x16887e[_0x8a0c('0x36')]['length']?_0x16887e[_0x8a0c('0x36')]:_0x2e1b46['model'];if(!_0x4f2b87[_0x8a0c('0x32')][_0x8a0c('0x37')](_0x8a0c('0x38'))){_0x16887e['limit']=qs[_0x8a0c('0x20')](_0x4f2b87[_0x8a0c('0x32')][_0x8a0c('0x20')]);_0x16887e['offset']=qs['offset'](_0x4f2b87[_0x8a0c('0x32')]['offset']);}_0x16887e[_0x8a0c('0x39')]=qs[_0x8a0c('0x3a')](_0x4f2b87[_0x8a0c('0x32')][_0x8a0c('0x3a')]);_0x16887e[_0x8a0c('0x3b')]=qs[_0x8a0c('0x34')](_['pick'](_0x4f2b87[_0x8a0c('0x32')],_0x2e1b46[_0x8a0c('0x34')]),_0x1cc0ad);if(_0x4f2b87[_0x8a0c('0x32')][_0x8a0c('0x3c')]){_0x16887e[_0x8a0c('0x3b')]=_['merge'](_0x16887e[_0x8a0c('0x3b')],{'$or':_[_0x8a0c('0x2e')](_0x1cc0ad,function(_0x1d6b1b){if(_0x1d6b1b[_0x8a0c('0x3d')]!==_0x8a0c('0x3e')){var _0x597d47={};_0x597d47[_0x1d6b1b[_0x8a0c('0x2c')]]={'$like':'%'+_0x4f2b87['query'][_0x8a0c('0x3c')]+'%'};return _0x597d47;}})});}_0x16887e=_['merge']({},_0x16887e,_0x4f2b87[_0x8a0c('0x3f')]);var _0x408b5d={'where':_0x16887e[_0x8a0c('0x3b')]};return db[_0x8a0c('0x2f')]['count'](_0x408b5d)[_0x8a0c('0x28')](function(_0x2d27e0){_0x26e1c4[_0x8a0c('0x21')]=_0x2d27e0;if(_0x4f2b87['query'][_0x8a0c('0x40')]){_0x16887e['include']=[{'all':!![]}];}return db[_0x8a0c('0x2f')][_0x8a0c('0x41')](_0x16887e);})[_0x8a0c('0x28')](function(_0x5ab54b){_0x26e1c4[_0x8a0c('0x42')]=_0x5ab54b;return _0x26e1c4;})[_0x8a0c('0x28')](respondWithFilteredResult(_0x336121,_0x16887e))[_0x8a0c('0x43')](handleError(_0x336121,null));};exports['show']=function(_0x2be01f,_0x22f70c){var _0x4d24e5={'raw':!![],'where':{'id':_0x2be01f[_0x8a0c('0x44')]['id']}},_0x44643c={};_0x44643c[_0x8a0c('0x31')]=_['keys'](db[_0x8a0c('0x2f')][_0x8a0c('0x45')]);_0x44643c[_0x8a0c('0x32')]=_[_0x8a0c('0x33')](_0x2be01f[_0x8a0c('0x32')]);_0x44643c[_0x8a0c('0x34')]=_[_0x8a0c('0x46')](_0x44643c['model'],_0x44643c[_0x8a0c('0x32')]);_0x4d24e5[_0x8a0c('0x36')]=_[_0x8a0c('0x46')](_0x44643c[_0x8a0c('0x31')],qs['fields'](_0x2be01f[_0x8a0c('0x32')][_0x8a0c('0x35')]));_0x4d24e5['attributes']=_0x4d24e5[_0x8a0c('0x36')]['length']?_0x4d24e5[_0x8a0c('0x36')]:_0x44643c[_0x8a0c('0x31')];if(_0x2be01f[_0x8a0c('0x32')][_0x8a0c('0x40')]){_0x4d24e5[_0x8a0c('0x47')]=[{'all':!![]}];}_0x4d24e5=_[_0x8a0c('0x48')]({},_0x4d24e5,_0x2be01f[_0x8a0c('0x3f')]);return db['ChatGroup'][_0x8a0c('0x49')](_0x4d24e5)['then'](handleEntityNotFound(_0x22f70c,null))[_0x8a0c('0x28')](respondWithResult(_0x22f70c,null))[_0x8a0c('0x43')](handleError(_0x22f70c,null));};exports[_0x8a0c('0x4a')]=function(_0x14db1f,_0x263644){return db[_0x8a0c('0x2f')][_0x8a0c('0x4a')](_0x14db1f['body'],{})['then'](respondWithResult(_0x263644,0xc9))[_0x8a0c('0x43')](handleError(_0x263644,null));};exports['update']=function(_0x4f8423,_0x36260){if(_0x4f8423[_0x8a0c('0x4b')]['id']){delete _0x4f8423[_0x8a0c('0x4b')]['id'];}return db[_0x8a0c('0x2f')][_0x8a0c('0x49')]({'where':{'id':_0x4f8423[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x36260,null))['then'](saveUpdates(_0x4f8423[_0x8a0c('0x4b')],null))[_0x8a0c('0x28')](respondWithResult(_0x36260,null))[_0x8a0c('0x43')](handleError(_0x36260,null));};exports['destroy']=function(_0x51cf81,_0x482d31){return db['ChatGroup']['find']({'where':{'id':_0x51cf81[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x482d31,null))[_0x8a0c('0x28')](removeEntity(_0x482d31,null))[_0x8a0c('0x43')](handleError(_0x482d31,null));};exports[_0x8a0c('0x4c')]=function(_0x43a784,_0x2b3f0a){return db[_0x8a0c('0x2f')][_0x8a0c('0x4c')]()['then'](respondWithResult(_0x2b3f0a,null))[_0x8a0c('0x43')](handleError(_0x2b3f0a,null));};exports[_0x8a0c('0x4d')]=function(_0x1fbb57,_0x2058de,_0x41dfce){return db[_0x8a0c('0x4e')]['count']({'where':{'ChatGroupId':_0x1fbb57['params']['id'],'ToId':_0x1fbb57[_0x8a0c('0x4f')]['id'],'read':![]}})[_0x8a0c('0x28')](function(_0x321f1e){return{'id':_[_0x8a0c('0x50')](_0x1fbb57['params']['id']),'count':_0x321f1e};})['then'](respondWithResult(_0x2058de,null))[_0x8a0c('0x43')](handleError(_0x2058de,null));};exports[_0x8a0c('0x51')]=function(_0x141fde,_0x2001f3,_0x3681ec){return db[_0x8a0c('0x2f')][_0x8a0c('0x49')]({'where':{'id':_0x141fde[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x2001f3,null))[_0x8a0c('0x28')](function(_0x3ba0b0){if(_0x3ba0b0){return _0x3ba0b0['addMembers'](_0x141fde[_0x8a0c('0x4b')][_0x8a0c('0x52')],_['omit'](_0x141fde[_0x8a0c('0x4b')],[_0x8a0c('0x52'),'id'])||{});}})[_0x8a0c('0x28')](respondWithResult(_0x2001f3,null))[_0x8a0c('0x43')](handleError(_0x2001f3,null));};exports[_0x8a0c('0x53')]=function(_0x1439fb,_0x5c39b1,_0x243168){var _0x1ce4ab={};var _0x5f388f={};var _0x5375c3;var _0x542910;return db[_0x8a0c('0x2f')]['findOne']({'where':{'id':_0x1439fb[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x5c39b1,null))[_0x8a0c('0x28')](function(_0xfb078f){if(_0xfb078f){_0x5375c3=_0xfb078f;_0x5f388f[_0x8a0c('0x31')]=_[_0x8a0c('0x33')](db['User'][_0x8a0c('0x45')]);_0x5f388f[_0x8a0c('0x32')]=_[_0x8a0c('0x33')](_0x1439fb['query']);_0x5f388f['filters']=_[_0x8a0c('0x46')](_0x5f388f[_0x8a0c('0x31')],_0x5f388f[_0x8a0c('0x32')]);_0x1ce4ab[_0x8a0c('0x36')]=_['intersection'](_0x5f388f[_0x8a0c('0x31')],qs[_0x8a0c('0x35')](_0x1439fb['query']['fields']));_0x1ce4ab['attributes']=_0x1ce4ab[_0x8a0c('0x36')]['length']?_0x1ce4ab[_0x8a0c('0x36')]:_0x5f388f[_0x8a0c('0x31')];_0x1ce4ab[_0x8a0c('0x39')]=qs[_0x8a0c('0x3a')](_0x1439fb[_0x8a0c('0x32')][_0x8a0c('0x3a')]);_0x1ce4ab['where']=qs[_0x8a0c('0x34')](_[_0x8a0c('0x54')](_0x1439fb[_0x8a0c('0x32')],_0x5f388f[_0x8a0c('0x34')]));if(_0x1439fb['query'][_0x8a0c('0x3c')]){_0x1ce4ab[_0x8a0c('0x3b')]=_[_0x8a0c('0x48')](_0x1ce4ab[_0x8a0c('0x3b')],{'$or':_[_0x8a0c('0x2e')](_0x1ce4ab[_0x8a0c('0x36')],function(_0x187c9f){var _0x4b564c={};_0x4b564c[_0x187c9f]={'$like':'%'+_0x1439fb[_0x8a0c('0x32')][_0x8a0c('0x3c')]+'%'};return _0x4b564c;})});}_0x1ce4ab=_['merge']({},_0x1ce4ab,_0x1439fb[_0x8a0c('0x3f')]);return _0x5375c3['getMembers'](_0x1ce4ab);}})['then'](function(_0x526107){if(_0x526107){_0x542910=_0x526107['length'];if(!_0x1439fb[_0x8a0c('0x32')]['hasOwnProperty'](_0x8a0c('0x38'))){_0x1ce4ab[_0x8a0c('0x20')]=qs[_0x8a0c('0x20')](_0x1439fb['query']['limit']);_0x1ce4ab[_0x8a0c('0x1e')]=qs[_0x8a0c('0x1e')](_0x1439fb[_0x8a0c('0x32')][_0x8a0c('0x1e')]);}return _0x5375c3['getMembers'](_0x1ce4ab);}})[_0x8a0c('0x28')](function(_0x4145e2){if(_0x4145e2){return _0x4145e2?{'count':_0x542910,'rows':_0x4145e2}:null;}})[_0x8a0c('0x28')](respondWithResult(_0x5c39b1,null))[_0x8a0c('0x43')](handleError(_0x5c39b1,null));};exports[_0x8a0c('0x55')]=function(_0x351752,_0x1e408c,_0x3915c0){return db['ChatGroup']['find']({'where':{'id':_0x351752[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x1e408c,null))[_0x8a0c('0x28')](function(_0x2c46f9){if(_0x2c46f9){return _0x2c46f9[_0x8a0c('0x55')](_0x351752['query']['ids']);}})['then'](respondWithStatusCode(_0x1e408c,null))['catch'](handleError(_0x1e408c,null));};exports[_0x8a0c('0x56')]=function(_0xd7caea,_0x3a4631,_0x226216){if(_0xd7caea[_0x8a0c('0x4b')]['id']){delete _0xd7caea[_0x8a0c('0x4b')]['id'];}return db[_0x8a0c('0x2f')][_0x8a0c('0x49')]({'where':{'id':_0xd7caea[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x3a4631,null))['then'](function(_0x26cb59){if(_0x26cb59){_0xd7caea[_0x8a0c('0x4b')]['ChatGroupId']=_0x26cb59['id'];return db[_0x8a0c('0x4e')]['create'](_0xd7caea['body']);}})['then'](respondWithResult(_0x3a4631,null))[_0x8a0c('0x43')](handleError(_0x3a4631,null));};exports['getMessages']=function(_0xcd5be8,_0x119f28,_0x3ec134){var _0x5426c2={};var _0x520891={};var _0x5ea9cc;var _0x820431;return db[_0x8a0c('0x2f')][_0x8a0c('0x57')]({'where':{'id':_0xcd5be8[_0x8a0c('0x44')]['id']}})[_0x8a0c('0x28')](handleEntityNotFound(_0x119f28,null))[_0x8a0c('0x28')](function(_0x75b0a1){if(_0x75b0a1){_0x5ea9cc=_0x75b0a1;_0x520891[_0x8a0c('0x31')]=_[_0x8a0c('0x33')](db['ChatInternalMessage'][_0x8a0c('0x45')]);_0x520891[_0x8a0c('0x32')]=_[_0x8a0c('0x33')](_0xcd5be8[_0x8a0c('0x32')]);_0x520891[_0x8a0c('0x34')]=_[_0x8a0c('0x46')](_0x520891[_0x8a0c('0x31')],_0x520891[_0x8a0c('0x32')]);_0x5426c2[_0x8a0c('0x36')]=_[_0x8a0c('0x46')](_0x520891[_0x8a0c('0x31')],qs[_0x8a0c('0x35')](_0xcd5be8[_0x8a0c('0x32')]['fields']));_0x5426c2['attributes']=_0x5426c2[_0x8a0c('0x36')][_0x8a0c('0x58')]?_0x5426c2['attributes']:_0x520891['model'];_0x5426c2[_0x8a0c('0x39')]=qs[_0x8a0c('0x3a')](_0xcd5be8[_0x8a0c('0x32')][_0x8a0c('0x3a')]);_0x5426c2[_0x8a0c('0x3b')]=qs[_0x8a0c('0x34')](_[_0x8a0c('0x54')](_0xcd5be8[_0x8a0c('0x32')],_0x520891['filters']));if(_0xcd5be8[_0x8a0c('0x32')][_0x8a0c('0x3c')]){_0x5426c2[_0x8a0c('0x3b')]=_[_0x8a0c('0x48')](_0x5426c2['where'],{'$or':_[_0x8a0c('0x2e')](_0x5426c2[_0x8a0c('0x36')],function(_0x9f9a92){var _0xd1857e={};_0xd1857e[_0x9f9a92]={'$like':'%'+_0xcd5be8['query'][_0x8a0c('0x3c')]+'%'};return _0xd1857e;})});}if(_0xcd5be8[_0x8a0c('0x32')]['$gte']){var _0x50d7d9=_0xcd5be8[_0x8a0c('0x32')]['$gte'][_0x8a0c('0x59')](',');var _0x215bcd={};_0x215bcd[_0x50d7d9[0x0]]={'$gte':moment(_0x50d7d9[0x1])[_0x8a0c('0x5a')](_0x8a0c('0x5b'))};_0x5426c2[_0x8a0c('0x3b')]=_[_0x8a0c('0x48')](_0x5426c2[_0x8a0c('0x3b')],_0x215bcd);}_0x5426c2=_[_0x8a0c('0x48')]({},_0x5426c2,_0xcd5be8['options']);return _0x5ea9cc[_0x8a0c('0x5c')](_0x5426c2);}})[_0x8a0c('0x28')](function(_0x492a16){if(_0x492a16){_0x820431=_0x492a16[_0x8a0c('0x58')];if(!_0xcd5be8[_0x8a0c('0x32')][_0x8a0c('0x37')](_0x8a0c('0x38'))){_0x5426c2[_0x8a0c('0x20')]=qs[_0x8a0c('0x20')](_0xcd5be8[_0x8a0c('0x32')][_0x8a0c('0x20')]);_0x5426c2[_0x8a0c('0x1e')]=qs[_0x8a0c('0x1e')](_0xcd5be8['query'][_0x8a0c('0x1e')]);}return _0x5ea9cc[_0x8a0c('0x5c')](_0x5426c2);}})[_0x8a0c('0x28')](function(_0x2986b1){if(_0x2986b1){return _0x2986b1?{'count':_0x820431,'rows':_0x2986b1}:null;}})[_0x8a0c('0x28')](respondWithResult(_0x119f28,null))[_0x8a0c('0x43')](handleError(_0x119f28,null));};
\ No newline at end of file
+var _0xb450=['format','YYYY-MM-DD\x20HH:mm:ss','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','redis','register','sendStatus','end','json','offset','limit','count','status','set','Content-Range','apply','reject','save','then','destroy','error','name','send','index','map','ChatGroup','fieldName','type','key','query','keys','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','rawAttributes','find','body','catch','params','ChatInternalMessage','toInteger','ids','getMembers','findOne','User','removeMembers','ChatGroupId','create','getMessages','$gte'];(function(_0x1108d7,_0x16c93c){var _0x1d7eca=function(_0x4925ce){while(--_0x4925ce){_0x1108d7['push'](_0x1108d7['shift']());}};_0x1d7eca(++_0x16c93c);}(_0xb450,0x172));var _0x0b45=function(_0x29e2fe,_0x6b9ce6){_0x29e2fe=_0x29e2fe-0x0;var _0x16f447=_0xb450[_0x29e2fe];return _0x16f447;};'use strict';var emlformat=require(_0x0b45('0x0'));var rimraf=require(_0x0b45('0x1'));var zipdir=require(_0x0b45('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x0b45('0x3'));var moment=require(_0x0b45('0x4'));var BPromise=require(_0x0b45('0x5'));var Mustache=require(_0x0b45('0x6'));var util=require(_0x0b45('0x7'));var path=require(_0x0b45('0x8'));var sox=require(_0x0b45('0x9'));var csv=require(_0x0b45('0xa'));var ejs=require(_0x0b45('0xb'));var fs=require('fs');var fs_extra=require(_0x0b45('0xc'));var _=require(_0x0b45('0xd'));var squel=require(_0x0b45('0xe'));var crypto=require(_0x0b45('0xf'));var jsforce=require(_0x0b45('0x10'));var deskjs=require(_0x0b45('0x11'));var toCsv=require(_0x0b45('0xa'));var querystring=require(_0x0b45('0x12'));var Papa=require('papaparse');var Redis=require(_0x0b45('0x13'));var authService=require(_0x0b45('0x14'));var qs=require(_0x0b45('0x15'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0b45('0x16'));var logger=require('../../config/logger')(_0x0b45('0x17'));var utils=require('../../config/utils');var config=require(_0x0b45('0x18'));var licenseUtil=require(_0x0b45('0x19'));var db=require(_0x0b45('0x1a'))['db'];config[_0x0b45('0x1b')]=_['defaults'](config[_0x0b45('0x1b')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0b45('0x1b')]));require('./chatGroup.socket')[_0x0b45('0x1c')](socket);function respondWithStatusCode(_0x42a563,_0x111582){_0x111582=_0x111582||0xcc;return function(_0x415a6f){if(_0x415a6f){return _0x42a563[_0x0b45('0x1d')](_0x111582);}return _0x42a563['status'](_0x111582)[_0x0b45('0x1e')]();};}function respondWithResult(_0x270272,_0x122f10){_0x122f10=_0x122f10||0xc8;return function(_0x1ce2f7){if(_0x1ce2f7){return _0x270272['status'](_0x122f10)[_0x0b45('0x1f')](_0x1ce2f7);}};}function respondWithFilteredResult(_0x7226ab,_0x1337e5){return function(_0x16a57b){if(_0x16a57b){var _0x2d91ca=typeof _0x1337e5[_0x0b45('0x20')]==='undefined'&&typeof _0x1337e5[_0x0b45('0x21')]==='undefined';var _0x470101=_0x16a57b[_0x0b45('0x22')];var _0x4e9aea=_0x2d91ca?0x0:_0x1337e5[_0x0b45('0x20')];var _0x1c0782=_0x2d91ca?_0x16a57b['count']:_0x1337e5[_0x0b45('0x20')]+_0x1337e5[_0x0b45('0x21')];var _0x251f59;if(_0x1c0782>=_0x470101){_0x1c0782=_0x470101;_0x251f59=0xc8;}else{_0x251f59=0xce;}_0x7226ab[_0x0b45('0x23')](_0x251f59);return _0x7226ab[_0x0b45('0x24')](_0x0b45('0x25'),_0x4e9aea+'-'+_0x1c0782+'/'+_0x470101)[_0x0b45('0x1f')](_0x16a57b);}return null;};}function patchUpdates(_0x493299){return function(_0x29df47){try{jsonpatch[_0x0b45('0x26')](_0x29df47,_0x493299,!![]);}catch(_0x450aec){return BPromise[_0x0b45('0x27')](_0x450aec);}return _0x29df47[_0x0b45('0x28')]();};}function saveUpdates(_0x3bfaf3,_0x5722bf){return function(_0x1c228c){if(_0x1c228c){return _0x1c228c['update'](_0x3bfaf3)[_0x0b45('0x29')](function(_0x38fe15){return _0x38fe15;});}return null;};}function removeEntity(_0x1ef1bd,_0x83206e){return function(_0x10b421){if(_0x10b421){return _0x10b421[_0x0b45('0x2a')]()['then'](function(){_0x1ef1bd['status'](0xcc)[_0x0b45('0x1e')]();});}};}function handleEntityNotFound(_0x919961,_0x43bbfb){return function(_0x1b55f8){if(!_0x1b55f8){_0x919961['sendStatus'](0x194);}return _0x1b55f8;};}function handleError(_0x49f04b,_0x39d81c){_0x39d81c=_0x39d81c||0x1f4;return function(_0x4ba84e){logger[_0x0b45('0x2b')](_0x4ba84e['stack']);if(_0x4ba84e[_0x0b45('0x2c')]){delete _0x4ba84e[_0x0b45('0x2c')];}_0x49f04b[_0x0b45('0x23')](_0x39d81c)[_0x0b45('0x2d')](_0x4ba84e);};}exports[_0x0b45('0x2e')]=function(_0x5abf1b,_0x5c6bc8){var _0x2ede53={},_0x44e25d={},_0x4c536a={'count':0x0,'rows':[]};var _0x5aa47e=_[_0x0b45('0x2f')](db[_0x0b45('0x30')]['rawAttributes'],function(_0x448a5f){return{'name':_0x448a5f[_0x0b45('0x31')],'type':_0x448a5f[_0x0b45('0x32')][_0x0b45('0x33')]};});_0x44e25d['model']=_[_0x0b45('0x2f')](_0x5aa47e,'name');_0x44e25d[_0x0b45('0x34')]=_[_0x0b45('0x35')](_0x5abf1b[_0x0b45('0x34')]);_0x44e25d['filters']=_[_0x0b45('0x36')](_0x44e25d['model'],_0x44e25d[_0x0b45('0x34')]);_0x2ede53[_0x0b45('0x37')]=_[_0x0b45('0x36')](_0x44e25d[_0x0b45('0x38')],qs[_0x0b45('0x39')](_0x5abf1b[_0x0b45('0x34')][_0x0b45('0x39')]));_0x2ede53[_0x0b45('0x37')]=_0x2ede53['attributes'][_0x0b45('0x3a')]?_0x2ede53['attributes']:_0x44e25d[_0x0b45('0x38')];if(!_0x5abf1b['query'][_0x0b45('0x3b')](_0x0b45('0x3c'))){_0x2ede53['limit']=qs[_0x0b45('0x21')](_0x5abf1b[_0x0b45('0x34')]['limit']);_0x2ede53['offset']=qs[_0x0b45('0x20')](_0x5abf1b[_0x0b45('0x34')]['offset']);}_0x2ede53[_0x0b45('0x3d')]=qs[_0x0b45('0x3e')](_0x5abf1b[_0x0b45('0x34')]['sort']);_0x2ede53[_0x0b45('0x3f')]=qs[_0x0b45('0x40')](_[_0x0b45('0x41')](_0x5abf1b[_0x0b45('0x34')],_0x44e25d[_0x0b45('0x40')]),_0x5aa47e);if(_0x5abf1b[_0x0b45('0x34')][_0x0b45('0x42')]){_0x2ede53[_0x0b45('0x3f')]=_[_0x0b45('0x43')](_0x2ede53['where'],{'$or':_[_0x0b45('0x2f')](_0x5aa47e,function(_0x181b26){if(_0x181b26[_0x0b45('0x32')]!==_0x0b45('0x44')){var _0x50f278={};_0x50f278[_0x181b26[_0x0b45('0x2c')]]={'$like':'%'+_0x5abf1b[_0x0b45('0x34')][_0x0b45('0x42')]+'%'};return _0x50f278;}})});}_0x2ede53=_[_0x0b45('0x43')]({},_0x2ede53,_0x5abf1b[_0x0b45('0x45')]);var _0x427984={'where':_0x2ede53[_0x0b45('0x3f')]};return db[_0x0b45('0x30')]['count'](_0x427984)[_0x0b45('0x29')](function(_0x1c2ab8){_0x4c536a[_0x0b45('0x22')]=_0x1c2ab8;if(_0x5abf1b[_0x0b45('0x34')][_0x0b45('0x46')]){_0x2ede53[_0x0b45('0x47')]=[{'all':!![]}];}return db[_0x0b45('0x30')][_0x0b45('0x48')](_0x2ede53);})[_0x0b45('0x29')](function(_0x1135f0){_0x4c536a[_0x0b45('0x49')]=_0x1135f0;return _0x4c536a;})['then'](respondWithFilteredResult(_0x5c6bc8,_0x2ede53))['catch'](handleError(_0x5c6bc8,null));};exports['show']=function(_0x52eace,_0x547454){var _0x4554f4={'raw':!![],'where':{'id':_0x52eace['params']['id']}},_0x2fa93f={};_0x2fa93f[_0x0b45('0x38')]=_[_0x0b45('0x35')](db[_0x0b45('0x30')][_0x0b45('0x4a')]);_0x2fa93f[_0x0b45('0x34')]=_[_0x0b45('0x35')](_0x52eace[_0x0b45('0x34')]);_0x2fa93f[_0x0b45('0x40')]=_[_0x0b45('0x36')](_0x2fa93f['model'],_0x2fa93f['query']);_0x4554f4['attributes']=_['intersection'](_0x2fa93f[_0x0b45('0x38')],qs[_0x0b45('0x39')](_0x52eace[_0x0b45('0x34')][_0x0b45('0x39')]));_0x4554f4[_0x0b45('0x37')]=_0x4554f4[_0x0b45('0x37')][_0x0b45('0x3a')]?_0x4554f4['attributes']:_0x2fa93f[_0x0b45('0x38')];if(_0x52eace[_0x0b45('0x34')]['includeAll']){_0x4554f4[_0x0b45('0x47')]=[{'all':!![]}];}_0x4554f4=_[_0x0b45('0x43')]({},_0x4554f4,_0x52eace[_0x0b45('0x45')]);return db[_0x0b45('0x30')][_0x0b45('0x4b')](_0x4554f4)[_0x0b45('0x29')](handleEntityNotFound(_0x547454,null))['then'](respondWithResult(_0x547454,null))['catch'](handleError(_0x547454,null));};exports['create']=function(_0x3fb57b,_0x5a5419){return db[_0x0b45('0x30')]['create'](_0x3fb57b[_0x0b45('0x4c')],{})[_0x0b45('0x29')](respondWithResult(_0x5a5419,0xc9))[_0x0b45('0x4d')](handleError(_0x5a5419,null));};exports['update']=function(_0x52c1c1,_0x4f41cd){if(_0x52c1c1[_0x0b45('0x4c')]['id']){delete _0x52c1c1[_0x0b45('0x4c')]['id'];}return db[_0x0b45('0x30')][_0x0b45('0x4b')]({'where':{'id':_0x52c1c1[_0x0b45('0x4e')]['id']}})[_0x0b45('0x29')](handleEntityNotFound(_0x4f41cd,null))[_0x0b45('0x29')](saveUpdates(_0x52c1c1[_0x0b45('0x4c')],null))[_0x0b45('0x29')](respondWithResult(_0x4f41cd,null))[_0x0b45('0x4d')](handleError(_0x4f41cd,null));};exports[_0x0b45('0x2a')]=function(_0x885922,_0x2344e3){return db[_0x0b45('0x30')][_0x0b45('0x4b')]({'where':{'id':_0x885922[_0x0b45('0x4e')]['id']}})[_0x0b45('0x29')](handleEntityNotFound(_0x2344e3,null))[_0x0b45('0x29')](removeEntity(_0x2344e3,null))[_0x0b45('0x4d')](handleError(_0x2344e3,null));};exports['describe']=function(_0x142e68,_0x1c6b98){return db[_0x0b45('0x30')]['describe']()['then'](respondWithResult(_0x1c6b98,null))[_0x0b45('0x4d')](handleError(_0x1c6b98,null));};exports['getUnread']=function(_0x38cbeb,_0x4257c1,_0xc823d9){return db[_0x0b45('0x4f')][_0x0b45('0x22')]({'where':{'ChatGroupId':_0x38cbeb[_0x0b45('0x4e')]['id'],'ToId':_0x38cbeb['user']['id'],'read':![]}})[_0x0b45('0x29')](function(_0x4aaceb){return{'id':_[_0x0b45('0x50')](_0x38cbeb[_0x0b45('0x4e')]['id']),'count':_0x4aaceb};})['then'](respondWithResult(_0x4257c1,null))['catch'](handleError(_0x4257c1,null));};exports['addMembers']=function(_0x1c1f8f,_0x4bc576,_0x295fb8){return db[_0x0b45('0x30')][_0x0b45('0x4b')]({'where':{'id':_0x1c1f8f[_0x0b45('0x4e')]['id']}})[_0x0b45('0x29')](handleEntityNotFound(_0x4bc576,null))['then'](function(_0x5cd897){if(_0x5cd897){return _0x5cd897['addMembers'](_0x1c1f8f[_0x0b45('0x4c')][_0x0b45('0x51')],_['omit'](_0x1c1f8f[_0x0b45('0x4c')],['ids','id'])||{});}})['then'](respondWithResult(_0x4bc576,null))[_0x0b45('0x4d')](handleError(_0x4bc576,null));};exports[_0x0b45('0x52')]=function(_0x3d163a,_0x217f27,_0x52ca65){var _0x2af765={};var _0x415669={};var _0xcbced4;var _0x1da544;return db[_0x0b45('0x30')][_0x0b45('0x53')]({'where':{'id':_0x3d163a['params']['id']}})[_0x0b45('0x29')](handleEntityNotFound(_0x217f27,null))[_0x0b45('0x29')](function(_0x340504){if(_0x340504){_0xcbced4=_0x340504;_0x415669['model']=_[_0x0b45('0x35')](db[_0x0b45('0x54')][_0x0b45('0x4a')]);_0x415669[_0x0b45('0x34')]=_[_0x0b45('0x35')](_0x3d163a[_0x0b45('0x34')]);_0x415669[_0x0b45('0x40')]=_['intersection'](_0x415669[_0x0b45('0x38')],_0x415669[_0x0b45('0x34')]);_0x2af765[_0x0b45('0x37')]=_[_0x0b45('0x36')](_0x415669[_0x0b45('0x38')],qs[_0x0b45('0x39')](_0x3d163a[_0x0b45('0x34')][_0x0b45('0x39')]));_0x2af765[_0x0b45('0x37')]=_0x2af765[_0x0b45('0x37')][_0x0b45('0x3a')]?_0x2af765[_0x0b45('0x37')]:_0x415669[_0x0b45('0x38')];_0x2af765['order']=qs[_0x0b45('0x3e')](_0x3d163a[_0x0b45('0x34')][_0x0b45('0x3e')]);_0x2af765[_0x0b45('0x3f')]=qs[_0x0b45('0x40')](_[_0x0b45('0x41')](_0x3d163a['query'],_0x415669['filters']));if(_0x3d163a['query']['filter']){_0x2af765[_0x0b45('0x3f')]=_['merge'](_0x2af765[_0x0b45('0x3f')],{'$or':_[_0x0b45('0x2f')](_0x2af765[_0x0b45('0x37')],function(_0x19c736){var _0x249cdf={};_0x249cdf[_0x19c736]={'$like':'%'+_0x3d163a[_0x0b45('0x34')][_0x0b45('0x42')]+'%'};return _0x249cdf;})});}_0x2af765=_['merge']({},_0x2af765,_0x3d163a['options']);return _0xcbced4['getMembers'](_0x2af765);}})[_0x0b45('0x29')](function(_0x48e435){if(_0x48e435){_0x1da544=_0x48e435['length'];if(!_0x3d163a['query'][_0x0b45('0x3b')](_0x0b45('0x3c'))){_0x2af765[_0x0b45('0x21')]=qs[_0x0b45('0x21')](_0x3d163a['query'][_0x0b45('0x21')]);_0x2af765[_0x0b45('0x20')]=qs[_0x0b45('0x20')](_0x3d163a[_0x0b45('0x34')]['offset']);}return _0xcbced4[_0x0b45('0x52')](_0x2af765);}})[_0x0b45('0x29')](function(_0x3d9263){if(_0x3d9263){return _0x3d9263?{'count':_0x1da544,'rows':_0x3d9263}:null;}})[_0x0b45('0x29')](respondWithResult(_0x217f27,null))[_0x0b45('0x4d')](handleError(_0x217f27,null));};exports[_0x0b45('0x55')]=function(_0x3d2906,_0x64b159,_0x5d801a){return db[_0x0b45('0x30')][_0x0b45('0x4b')]({'where':{'id':_0x3d2906[_0x0b45('0x4e')]['id']}})['then'](handleEntityNotFound(_0x64b159,null))[_0x0b45('0x29')](function(_0x9a97b8){if(_0x9a97b8){return _0x9a97b8[_0x0b45('0x55')](_0x3d2906[_0x0b45('0x34')][_0x0b45('0x51')]);}})[_0x0b45('0x29')](respondWithStatusCode(_0x64b159,null))[_0x0b45('0x4d')](handleError(_0x64b159,null));};exports['addMessage']=function(_0x4656b1,_0xf0357a,_0x4a3945){if(_0x4656b1[_0x0b45('0x4c')]['id']){delete _0x4656b1[_0x0b45('0x4c')]['id'];}return db[_0x0b45('0x30')][_0x0b45('0x4b')]({'where':{'id':_0x4656b1[_0x0b45('0x4e')]['id']}})[_0x0b45('0x29')](handleEntityNotFound(_0xf0357a,null))['then'](function(_0x8966b6){if(_0x8966b6){_0x4656b1['body'][_0x0b45('0x56')]=_0x8966b6['id'];return db[_0x0b45('0x4f')][_0x0b45('0x57')](_0x4656b1[_0x0b45('0x4c')]);}})[_0x0b45('0x29')](respondWithResult(_0xf0357a,null))[_0x0b45('0x4d')](handleError(_0xf0357a,null));};exports[_0x0b45('0x58')]=function(_0x4cc2ba,_0x198379,_0x5a6c07){var _0x54fc96={};var _0x1024b4={};var _0x8e4512;var _0x4d4b30;return db[_0x0b45('0x30')]['findOne']({'where':{'id':_0x4cc2ba[_0x0b45('0x4e')]['id']}})['then'](handleEntityNotFound(_0x198379,null))[_0x0b45('0x29')](function(_0x4f4612){if(_0x4f4612){_0x8e4512=_0x4f4612;_0x1024b4[_0x0b45('0x38')]=_[_0x0b45('0x35')](db[_0x0b45('0x4f')][_0x0b45('0x4a')]);_0x1024b4['query']=_[_0x0b45('0x35')](_0x4cc2ba[_0x0b45('0x34')]);_0x1024b4[_0x0b45('0x40')]=_['intersection'](_0x1024b4[_0x0b45('0x38')],_0x1024b4[_0x0b45('0x34')]);_0x54fc96['attributes']=_[_0x0b45('0x36')](_0x1024b4[_0x0b45('0x38')],qs[_0x0b45('0x39')](_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x39')]));_0x54fc96['attributes']=_0x54fc96[_0x0b45('0x37')][_0x0b45('0x3a')]?_0x54fc96[_0x0b45('0x37')]:_0x1024b4[_0x0b45('0x38')];_0x54fc96[_0x0b45('0x3d')]=qs[_0x0b45('0x3e')](_0x4cc2ba[_0x0b45('0x34')]['sort']);_0x54fc96[_0x0b45('0x3f')]=qs[_0x0b45('0x40')](_[_0x0b45('0x41')](_0x4cc2ba[_0x0b45('0x34')],_0x1024b4[_0x0b45('0x40')]));if(_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x42')]){_0x54fc96[_0x0b45('0x3f')]=_['merge'](_0x54fc96[_0x0b45('0x3f')],{'$or':_['map'](_0x54fc96[_0x0b45('0x37')],function(_0x538471){var _0x13b954={};_0x13b954[_0x538471]={'$like':'%'+_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x42')]+'%'};return _0x13b954;})});}if(_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x59')]){var _0x596bf3=_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x59')]['split'](',');var _0x492be4={};_0x492be4[_0x596bf3[0x0]]={'$gte':moment(_0x596bf3[0x1])[_0x0b45('0x5a')](_0x0b45('0x5b'))};_0x54fc96[_0x0b45('0x3f')]=_[_0x0b45('0x43')](_0x54fc96[_0x0b45('0x3f')],_0x492be4);}_0x54fc96=_[_0x0b45('0x43')]({},_0x54fc96,_0x4cc2ba[_0x0b45('0x45')]);return _0x8e4512['getMessages'](_0x54fc96);}})[_0x0b45('0x29')](function(_0xb1c411){if(_0xb1c411){_0x4d4b30=_0xb1c411['length'];if(!_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x3b')](_0x0b45('0x3c'))){_0x54fc96[_0x0b45('0x21')]=qs[_0x0b45('0x21')](_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x21')]);_0x54fc96[_0x0b45('0x20')]=qs[_0x0b45('0x20')](_0x4cc2ba[_0x0b45('0x34')][_0x0b45('0x20')]);}return _0x8e4512[_0x0b45('0x58')](_0x54fc96);}})['then'](function(_0x710b0c){if(_0x710b0c){return _0x710b0c?{'count':_0x4d4b30,'rows':_0x710b0c}:null;}})[_0x0b45('0x29')](respondWithResult(_0x198379,null))['catch'](handleError(_0x198379,null));};
\ No newline at end of file