Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / squareMessage / squareMessage.controller.js
index 9765b3a..27d0efa 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb986=['find','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','sox','to-csv','lodash','crypto','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','Content-Range','json','apply','reject','save','then','destroy','stack','name','send','index','map','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','SquareMessage','includeAll','catch','show','params','include','options','create','body','update'];(function(_0x38a260,_0x1f0880){var _0x45bccc=function(_0x94868e){while(--_0x94868e){_0x38a260['push'](_0x38a260['shift']());}};_0x45bccc(++_0x1f0880);}(_0xb986,0x89));var _0x6b98=function(_0x5c79e7,_0x5bbbac){_0x5c79e7=_0x5c79e7-0x0;var _0x48d1aa=_0xb986[_0x5c79e7];return _0x48d1aa;};'use strict';var emlformat=require(_0x6b98('0x0'));var rimraf=require(_0x6b98('0x1'));var zipdir=require(_0x6b98('0x2'));var jsonpatch=require(_0x6b98('0x3'));var rp=require(_0x6b98('0x4'));var moment=require(_0x6b98('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x6b98('0x6'));var util=require('util');var path=require('path');var sox=require(_0x6b98('0x7'));var csv=require(_0x6b98('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6b98('0x9'));var squel=require('squel');var crypto=require(_0x6b98('0xa'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x6b98('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x6b98('0xb'));var authService=require(_0x6b98('0xc'));var qs=require(_0x6b98('0xd'));var as=require(_0x6b98('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x6b98('0xf'));var utils=require('../../config/utils');var config=require(_0x6b98('0x10'));var licenseUtil=require('../../config/license/util');var db=require(_0x6b98('0x11'))['db'];function respondWithStatusCode(_0x3b4d78,_0x3f3a7e){_0x3f3a7e=_0x3f3a7e||0xcc;return function(_0x40bfb3){if(_0x40bfb3){return _0x3b4d78[_0x6b98('0x12')](_0x3f3a7e);}return _0x3b4d78[_0x6b98('0x13')](_0x3f3a7e)[_0x6b98('0x14')]();};}function respondWithResult(_0x4efa0a,_0xfbc073){_0xfbc073=_0xfbc073||0xc8;return function(_0x29c6a4){if(_0x29c6a4){return _0x4efa0a[_0x6b98('0x13')](_0xfbc073)['json'](_0x29c6a4);}};}function respondWithFilteredResult(_0x3a785c,_0x1a60e7){return function(_0x24ae2e){if(_0x24ae2e){var _0x1e53b8=typeof _0x1a60e7[_0x6b98('0x15')]===_0x6b98('0x16')&&typeof _0x1a60e7[_0x6b98('0x17')]===_0x6b98('0x16');var _0x2a9512=_0x24ae2e[_0x6b98('0x18')];var _0x333435=_0x1e53b8?0x0:_0x1a60e7[_0x6b98('0x15')];var _0x3af701=_0x1e53b8?_0x24ae2e[_0x6b98('0x18')]:_0x1a60e7[_0x6b98('0x15')]+_0x1a60e7[_0x6b98('0x17')];var _0x301faa;if(_0x3af701>=_0x2a9512){_0x3af701=_0x2a9512;_0x301faa=0xc8;}else{_0x301faa=0xce;}_0x3a785c[_0x6b98('0x13')](_0x301faa);return _0x3a785c['set'](_0x6b98('0x19'),_0x333435+'-'+_0x3af701+'/'+_0x2a9512)[_0x6b98('0x1a')](_0x24ae2e);}return null;};}function patchUpdates(_0x187ccd){return function(_0x1f996c){try{jsonpatch[_0x6b98('0x1b')](_0x1f996c,_0x187ccd,!![]);}catch(_0x11b86b){return BPromise[_0x6b98('0x1c')](_0x11b86b);}return _0x1f996c[_0x6b98('0x1d')]();};}function saveUpdates(_0x542e5f,_0x4f8e53){return function(_0x31bad4){if(_0x31bad4){return _0x31bad4['update'](_0x542e5f)[_0x6b98('0x1e')](function(_0x385c50){return _0x385c50;});}return null;};}function removeEntity(_0x4cc9ec,_0xd12e5b){return function(_0x3f4f34){if(_0x3f4f34){return _0x3f4f34[_0x6b98('0x1f')]()['then'](function(){_0x4cc9ec[_0x6b98('0x13')](0xcc)[_0x6b98('0x14')]();});}};}function handleEntityNotFound(_0x21c1ba,_0xb8081b){return function(_0x6c7b44){if(!_0x6c7b44){_0x21c1ba[_0x6b98('0x12')](0x194);}return _0x6c7b44;};}function handleError(_0xe3c167,_0x1d3955){_0x1d3955=_0x1d3955||0x1f4;return function(_0x211a9a){logger['error'](_0x211a9a[_0x6b98('0x20')]);if(_0x211a9a[_0x6b98('0x21')]){delete _0x211a9a[_0x6b98('0x21')];}_0xe3c167[_0x6b98('0x13')](_0x1d3955)[_0x6b98('0x22')](_0x211a9a);};}exports[_0x6b98('0x23')]=function(_0x3c7e41,_0x269687){var _0x3512bc={},_0x5681bf={},_0x2f0b37={'count':0x0,'rows':[]};var _0x443dd8=_[_0x6b98('0x24')](db['SquareMessage'][_0x6b98('0x25')],function(_0x1a5b12){return{'name':_0x1a5b12[_0x6b98('0x26')],'type':_0x1a5b12[_0x6b98('0x27')][_0x6b98('0x28')]};});_0x5681bf['model']=_['map'](_0x443dd8,_0x6b98('0x21'));_0x5681bf[_0x6b98('0x29')]=_[_0x6b98('0x2a')](_0x3c7e41[_0x6b98('0x29')]);_0x5681bf[_0x6b98('0x2b')]=_[_0x6b98('0x2c')](_0x5681bf[_0x6b98('0x2d')],_0x5681bf['query']);_0x3512bc[_0x6b98('0x2e')]=_[_0x6b98('0x2c')](_0x5681bf['model'],qs[_0x6b98('0x2f')](_0x3c7e41['query'][_0x6b98('0x2f')]));_0x3512bc[_0x6b98('0x2e')]=_0x3512bc['attributes'][_0x6b98('0x30')]?_0x3512bc['attributes']:_0x5681bf[_0x6b98('0x2d')];if(!_0x3c7e41[_0x6b98('0x29')]['hasOwnProperty'](_0x6b98('0x31'))){_0x3512bc[_0x6b98('0x17')]=qs[_0x6b98('0x17')](_0x3c7e41[_0x6b98('0x29')][_0x6b98('0x17')]);_0x3512bc['offset']=qs[_0x6b98('0x15')](_0x3c7e41[_0x6b98('0x29')][_0x6b98('0x15')]);}_0x3512bc[_0x6b98('0x32')]=qs[_0x6b98('0x33')](_0x3c7e41['query'][_0x6b98('0x33')]);_0x3512bc[_0x6b98('0x34')]=qs[_0x6b98('0x2b')](_[_0x6b98('0x35')](_0x3c7e41['query'],_0x5681bf[_0x6b98('0x2b')]),_0x443dd8);if(_0x3c7e41[_0x6b98('0x29')][_0x6b98('0x36')]){_0x3512bc[_0x6b98('0x34')]=_['merge'](_0x3512bc[_0x6b98('0x34')],{'$or':_[_0x6b98('0x24')](_0x443dd8,function(_0x2d4f8b){if(_0x2d4f8b[_0x6b98('0x27')]!==_0x6b98('0x37')){var _0x372053={};_0x372053[_0x2d4f8b[_0x6b98('0x21')]]={'$like':'%'+_0x3c7e41[_0x6b98('0x29')][_0x6b98('0x36')]+'%'};return _0x372053;}})});}_0x3512bc=_[_0x6b98('0x38')]({},_0x3512bc,_0x3c7e41['options']);var _0x1f58fc={'where':_0x3512bc[_0x6b98('0x34')]};return db[_0x6b98('0x39')][_0x6b98('0x18')](_0x1f58fc)[_0x6b98('0x1e')](function(_0x3c706a){_0x2f0b37[_0x6b98('0x18')]=_0x3c706a;if(_0x3c7e41[_0x6b98('0x29')][_0x6b98('0x3a')]){_0x3512bc['include']=[{'all':!![]}];}return db[_0x6b98('0x39')]['findAll'](_0x3512bc);})[_0x6b98('0x1e')](function(_0x2aecba){_0x2f0b37['rows']=_0x2aecba;return _0x2f0b37;})[_0x6b98('0x1e')](respondWithFilteredResult(_0x269687,_0x3512bc))[_0x6b98('0x3b')](handleError(_0x269687,null));};exports[_0x6b98('0x3c')]=function(_0x4fec42,_0x1a8565){var _0x406e32={'raw':!![],'where':{'id':_0x4fec42[_0x6b98('0x3d')]['id']}},_0x4ed523={};_0x4ed523['model']=_[_0x6b98('0x2a')](db[_0x6b98('0x39')]['rawAttributes']);_0x4ed523[_0x6b98('0x29')]=_[_0x6b98('0x2a')](_0x4fec42[_0x6b98('0x29')]);_0x4ed523[_0x6b98('0x2b')]=_[_0x6b98('0x2c')](_0x4ed523[_0x6b98('0x2d')],_0x4ed523['query']);_0x406e32['attributes']=_['intersection'](_0x4ed523[_0x6b98('0x2d')],qs[_0x6b98('0x2f')](_0x4fec42[_0x6b98('0x29')]['fields']));_0x406e32['attributes']=_0x406e32[_0x6b98('0x2e')]['length']?_0x406e32[_0x6b98('0x2e')]:_0x4ed523[_0x6b98('0x2d')];if(_0x4fec42[_0x6b98('0x29')][_0x6b98('0x3a')]){_0x406e32[_0x6b98('0x3e')]=[{'all':!![]}];}_0x406e32=_['merge']({},_0x406e32,_0x4fec42[_0x6b98('0x3f')]);return db['SquareMessage']['find'](_0x406e32)['then'](handleEntityNotFound(_0x1a8565,null))[_0x6b98('0x1e')](respondWithResult(_0x1a8565,null))[_0x6b98('0x3b')](handleError(_0x1a8565,null));};exports[_0x6b98('0x40')]=function(_0x41dae7,_0x3a9b80){return db[_0x6b98('0x39')][_0x6b98('0x40')](_0x41dae7[_0x6b98('0x41')],{})[_0x6b98('0x1e')](respondWithResult(_0x3a9b80,0xc9))[_0x6b98('0x3b')](handleError(_0x3a9b80,null));};exports[_0x6b98('0x42')]=function(_0x108771,_0x5cf575){if(_0x108771['body']['id']){delete _0x108771[_0x6b98('0x41')]['id'];}return db['SquareMessage'][_0x6b98('0x43')]({'where':{'id':_0x108771[_0x6b98('0x3d')]['id']}})['then'](handleEntityNotFound(_0x5cf575,null))[_0x6b98('0x1e')](saveUpdates(_0x108771[_0x6b98('0x41')],null))['then'](respondWithResult(_0x5cf575,null))['catch'](handleError(_0x5cf575,null));};exports[_0x6b98('0x1f')]=function(_0x1a2ac0,_0x28cf35){return db[_0x6b98('0x39')][_0x6b98('0x43')]({'where':{'id':_0x1a2ac0[_0x6b98('0x3d')]['id']}})[_0x6b98('0x1e')](handleEntityNotFound(_0x28cf35,null))[_0x6b98('0x1e')](removeEntity(_0x28cf35,null))['catch'](handleError(_0x28cf35,null));};
\ No newline at end of file
+var _0x094f=['mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','then','end','sendStatus','error','stack','name','map','SquareMessage','rawAttributes','type','keys','query','filters','intersection','model','attributes','fields','length','order','sort','where','pick','filter','merge','options','includeAll','include','rows','catch','show','params','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird'];(function(_0x397e5f,_0x454c8f){var _0x5302b8=function(_0x1a29ef){while(--_0x1a29ef){_0x397e5f['push'](_0x397e5f['shift']());}};_0x5302b8(++_0x454c8f);}(_0x094f,0x80));var _0xf094=function(_0x396466,_0xe9857b){_0x396466=_0x396466-0x0;var _0x5e9ab4=_0x094f[_0x396466];return _0x5e9ab4;};'use strict';var emlformat=require(_0xf094('0x0'));var rimraf=require(_0xf094('0x1'));var zipdir=require(_0xf094('0x2'));var jsonpatch=require(_0xf094('0x3'));var rp=require('request-promise');var moment=require(_0xf094('0x4'));var BPromise=require(_0xf094('0x5'));var Mustache=require(_0xf094('0x6'));var util=require('util');var path=require('path');var sox=require(_0xf094('0x7'));var csv=require(_0xf094('0x8'));var ejs=require(_0xf094('0x9'));var fs=require('fs');var fs_extra=require(_0xf094('0xa'));var _=require(_0xf094('0xb'));var squel=require(_0xf094('0xc'));var crypto=require(_0xf094('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xf094('0xe'));var authService=require(_0xf094('0xf'));var qs=require(_0xf094('0x10'));var as=require(_0xf094('0x11'));var hardwareService=require(_0xf094('0x12'));var logger=require('../../config/logger')(_0xf094('0x13'));var utils=require(_0xf094('0x14'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x41d385,_0x4d99bd){_0x4d99bd=_0x4d99bd||0xcc;return function(_0x583a23){if(_0x583a23){return _0x41d385['sendStatus'](_0x4d99bd);}return _0x41d385[_0xf094('0x15')](_0x4d99bd)['end']();};}function respondWithResult(_0x4b97cb,_0x32f64d){_0x32f64d=_0x32f64d||0xc8;return function(_0x29d688){if(_0x29d688){return _0x4b97cb[_0xf094('0x15')](_0x32f64d)[_0xf094('0x16')](_0x29d688);}};}function respondWithFilteredResult(_0x13471a,_0x187460){return function(_0x51f2af){if(_0x51f2af){var _0x47ecb1=typeof _0x187460[_0xf094('0x17')]===_0xf094('0x18')&&typeof _0x187460[_0xf094('0x19')]===_0xf094('0x18');var _0x2be8d0=_0x51f2af[_0xf094('0x1a')];var _0x584e99=_0x47ecb1?0x0:_0x187460[_0xf094('0x17')];var _0x45542d=_0x47ecb1?_0x51f2af[_0xf094('0x1a')]:_0x187460['offset']+_0x187460['limit'];var _0x5ec15d;if(_0x45542d>=_0x2be8d0){_0x45542d=_0x2be8d0;_0x5ec15d=0xc8;}else{_0x5ec15d=0xce;}_0x13471a['status'](_0x5ec15d);return _0x13471a[_0xf094('0x1b')](_0xf094('0x1c'),_0x584e99+'-'+_0x45542d+'/'+_0x2be8d0)[_0xf094('0x16')](_0x51f2af);}return null;};}function patchUpdates(_0x4e601d){return function(_0x109a0f){try{jsonpatch[_0xf094('0x1d')](_0x109a0f,_0x4e601d,!![]);}catch(_0x7b77b8){return BPromise[_0xf094('0x1e')](_0x7b77b8);}return _0x109a0f['save']();};}function saveUpdates(_0x3aff2f,_0x2db49d){return function(_0x5e9de5){if(_0x5e9de5){return _0x5e9de5[_0xf094('0x1f')](_0x3aff2f)['then'](function(_0x3a9fe3){return _0x3a9fe3;});}return null;};}function removeEntity(_0x4f74af,_0x2e0c75){return function(_0xbf4029){if(_0xbf4029){return _0xbf4029[_0xf094('0x20')]()[_0xf094('0x21')](function(){_0x4f74af[_0xf094('0x15')](0xcc)[_0xf094('0x22')]();});}};}function handleEntityNotFound(_0x51f7f4,_0x5f44ff){return function(_0xaf91fa){if(!_0xaf91fa){_0x51f7f4[_0xf094('0x23')](0x194);}return _0xaf91fa;};}function handleError(_0x5621d8,_0x14016c){_0x14016c=_0x14016c||0x1f4;return function(_0xc1ff00){logger[_0xf094('0x24')](_0xc1ff00[_0xf094('0x25')]);if(_0xc1ff00[_0xf094('0x26')]){delete _0xc1ff00['name'];}_0x5621d8[_0xf094('0x15')](_0x14016c)['send'](_0xc1ff00);};}exports['index']=function(_0xfef319,_0x32f5ca){var _0x211faa={},_0x112415={},_0x5537cf={'count':0x0,'rows':[]};var _0x4a7575=_[_0xf094('0x27')](db[_0xf094('0x28')][_0xf094('0x29')],function(_0xcc5640){return{'name':_0xcc5640['fieldName'],'type':_0xcc5640[_0xf094('0x2a')]['key']};});_0x112415['model']=_[_0xf094('0x27')](_0x4a7575,_0xf094('0x26'));_0x112415['query']=_[_0xf094('0x2b')](_0xfef319[_0xf094('0x2c')]);_0x112415[_0xf094('0x2d')]=_[_0xf094('0x2e')](_0x112415[_0xf094('0x2f')],_0x112415[_0xf094('0x2c')]);_0x211faa[_0xf094('0x30')]=_[_0xf094('0x2e')](_0x112415['model'],qs[_0xf094('0x31')](_0xfef319[_0xf094('0x2c')][_0xf094('0x31')]));_0x211faa[_0xf094('0x30')]=_0x211faa['attributes'][_0xf094('0x32')]?_0x211faa['attributes']:_0x112415['model'];if(!_0xfef319[_0xf094('0x2c')]['hasOwnProperty']('nolimit')){_0x211faa[_0xf094('0x19')]=qs[_0xf094('0x19')](_0xfef319[_0xf094('0x2c')][_0xf094('0x19')]);_0x211faa[_0xf094('0x17')]=qs[_0xf094('0x17')](_0xfef319[_0xf094('0x2c')][_0xf094('0x17')]);}_0x211faa[_0xf094('0x33')]=qs[_0xf094('0x34')](_0xfef319[_0xf094('0x2c')]['sort']);_0x211faa[_0xf094('0x35')]=qs[_0xf094('0x2d')](_[_0xf094('0x36')](_0xfef319[_0xf094('0x2c')],_0x112415[_0xf094('0x2d')]),_0x4a7575);if(_0xfef319[_0xf094('0x2c')][_0xf094('0x37')]){_0x211faa['where']=_[_0xf094('0x38')](_0x211faa[_0xf094('0x35')],{'$or':_[_0xf094('0x27')](_0x4a7575,function(_0x5320d6){if(_0x5320d6[_0xf094('0x2a')]!=='VIRTUAL'){var _0x281e56={};_0x281e56[_0x5320d6[_0xf094('0x26')]]={'$like':'%'+_0xfef319['query'][_0xf094('0x37')]+'%'};return _0x281e56;}})});}_0x211faa=_[_0xf094('0x38')]({},_0x211faa,_0xfef319[_0xf094('0x39')]);var _0x46c703={'where':_0x211faa[_0xf094('0x35')]};return db[_0xf094('0x28')][_0xf094('0x1a')](_0x46c703)[_0xf094('0x21')](function(_0xb92643){_0x5537cf['count']=_0xb92643;if(_0xfef319['query'][_0xf094('0x3a')]){_0x211faa[_0xf094('0x3b')]=[{'all':!![]}];}return db['SquareMessage']['findAll'](_0x211faa);})[_0xf094('0x21')](function(_0x306812){_0x5537cf[_0xf094('0x3c')]=_0x306812;return _0x5537cf;})['then'](respondWithFilteredResult(_0x32f5ca,_0x211faa))[_0xf094('0x3d')](handleError(_0x32f5ca,null));};exports[_0xf094('0x3e')]=function(_0x4da2b2,_0x1ce616){var _0x1090c2={'raw':!![],'where':{'id':_0x4da2b2[_0xf094('0x3f')]['id']}},_0x237b59={};_0x237b59[_0xf094('0x2f')]=_[_0xf094('0x2b')](db['SquareMessage']['rawAttributes']);_0x237b59[_0xf094('0x2c')]=_['keys'](_0x4da2b2['query']);_0x237b59[_0xf094('0x2d')]=_[_0xf094('0x2e')](_0x237b59[_0xf094('0x2f')],_0x237b59['query']);_0x1090c2['attributes']=_[_0xf094('0x2e')](_0x237b59[_0xf094('0x2f')],qs[_0xf094('0x31')](_0x4da2b2[_0xf094('0x2c')][_0xf094('0x31')]));_0x1090c2[_0xf094('0x30')]=_0x1090c2[_0xf094('0x30')]['length']?_0x1090c2[_0xf094('0x30')]:_0x237b59['model'];if(_0x4da2b2['query'][_0xf094('0x3a')]){_0x1090c2[_0xf094('0x3b')]=[{'all':!![]}];}_0x1090c2=_[_0xf094('0x38')]({},_0x1090c2,_0x4da2b2[_0xf094('0x39')]);return db[_0xf094('0x28')][_0xf094('0x40')](_0x1090c2)[_0xf094('0x21')](handleEntityNotFound(_0x1ce616,null))[_0xf094('0x21')](respondWithResult(_0x1ce616,null))['catch'](handleError(_0x1ce616,null));};exports[_0xf094('0x41')]=function(_0x33e906,_0x32370a){return db['SquareMessage']['create'](_0x33e906[_0xf094('0x42')],{})['then'](respondWithResult(_0x32370a,0xc9))[_0xf094('0x3d')](handleError(_0x32370a,null));};exports[_0xf094('0x1f')]=function(_0x30e70d,_0x1af84e){if(_0x30e70d[_0xf094('0x42')]['id']){delete _0x30e70d[_0xf094('0x42')]['id'];}return db[_0xf094('0x28')]['find']({'where':{'id':_0x30e70d[_0xf094('0x3f')]['id']}})['then'](handleEntityNotFound(_0x1af84e,null))[_0xf094('0x21')](saveUpdates(_0x30e70d['body'],null))[_0xf094('0x21')](respondWithResult(_0x1af84e,null))[_0xf094('0x3d')](handleError(_0x1af84e,null));};exports[_0xf094('0x20')]=function(_0x431cc2,_0x451847){return db[_0xf094('0x28')]['find']({'where':{'id':_0x431cc2[_0xf094('0x3f')]['id']}})[_0xf094('0x21')](handleEntityNotFound(_0x451847,null))['then'](removeEntity(_0x451847,null))[_0xf094('0x3d')](handleError(_0x451847,null));};
\ No newline at end of file