Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / squareMessage / squareMessage.controller.js
index bf07053..c70b82b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x414f=['intersection','attributes','fields','hasOwnProperty','limit','order','sort','where','filters','pick','merge','map','type','VIRTUAL','filter','options','SquareMessage','includeAll','include','findAll','catch','params','length','find','create','body','update','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','apply','reject','save','then','destroy','error','stack','name','send','rawAttributes','fieldName','model','query','keys'];(function(_0x3f6368,_0x9ba37f){var _0x75cea4=function(_0x113196){while(--_0x113196){_0x3f6368['push'](_0x3f6368['shift']());}};_0x75cea4(++_0x9ba37f);}(_0x414f,0x13f));var _0xf414=function(_0x26f03d,_0x4866c2){_0x26f03d=_0x26f03d-0x0;var _0x42dc9f=_0x414f[_0x26f03d];return _0x42dc9f;};'use strict';var emlformat=require(_0xf414('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xf414('0x1'));var jsonpatch=require(_0xf414('0x2'));var rp=require('request-promise');var moment=require(_0xf414('0x3'));var BPromise=require(_0xf414('0x4'));var Mustache=require(_0xf414('0x5'));var util=require(_0xf414('0x6'));var path=require(_0xf414('0x7'));var sox=require(_0xf414('0x8'));var csv=require(_0xf414('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf414('0xa'));var _=require('lodash');var squel=require(_0xf414('0xb'));var crypto=require(_0xf414('0xc'));var jsforce=require(_0xf414('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xf414('0xe'));var Papa=require(_0xf414('0xf'));var Redis=require(_0xf414('0x10'));var authService=require(_0xf414('0x11'));var qs=require(_0xf414('0x12'));var as=require(_0xf414('0x13'));var hardwareService=require(_0xf414('0x14'));var logger=require(_0xf414('0x15'))('api');var utils=require('../../config/utils');var config=require(_0xf414('0x16'));var licenseUtil=require(_0xf414('0x17'));var db=require(_0xf414('0x18'))['db'];function respondWithStatusCode(_0x396c30,_0x9be4f8){_0x9be4f8=_0x9be4f8||0xcc;return function(_0x488d03){if(_0x488d03){return _0x396c30[_0xf414('0x19')](_0x9be4f8);}return _0x396c30[_0xf414('0x1a')](_0x9be4f8)[_0xf414('0x1b')]();};}function respondWithResult(_0x46d679,_0x99bbd1){_0x99bbd1=_0x99bbd1||0xc8;return function(_0x5da0b7){if(_0x5da0b7){return _0x46d679[_0xf414('0x1a')](_0x99bbd1)[_0xf414('0x1c')](_0x5da0b7);}};}function respondWithFilteredResult(_0x46fb28,_0x706d2e){return function(_0x4d3021){if(_0x4d3021){var _0x17125d=typeof _0x706d2e[_0xf414('0x1d')]===_0xf414('0x1e')&&typeof _0x706d2e['limit']===_0xf414('0x1e');var _0x452904=_0x4d3021[_0xf414('0x1f')];var _0x32e970=_0x17125d?0x0:_0x706d2e[_0xf414('0x1d')];var _0x4f9658=_0x17125d?_0x4d3021[_0xf414('0x1f')]:_0x706d2e['offset']+_0x706d2e['limit'];var _0x24b65e;if(_0x4f9658>=_0x452904){_0x4f9658=_0x452904;_0x24b65e=0xc8;}else{_0x24b65e=0xce;}_0x46fb28[_0xf414('0x1a')](_0x24b65e);return _0x46fb28['set']('Content-Range',_0x32e970+'-'+_0x4f9658+'/'+_0x452904)['json'](_0x4d3021);}return null;};}function patchUpdates(_0x3145ed){return function(_0x1ccfce){try{jsonpatch[_0xf414('0x20')](_0x1ccfce,_0x3145ed,!![]);}catch(_0x417af1){return BPromise[_0xf414('0x21')](_0x417af1);}return _0x1ccfce[_0xf414('0x22')]();};}function saveUpdates(_0x3bbbe8,_0x1e116c){return function(_0x1dbfa9){if(_0x1dbfa9){return _0x1dbfa9['update'](_0x3bbbe8)[_0xf414('0x23')](function(_0x3ae2a0){return _0x3ae2a0;});}return null;};}function removeEntity(_0x236504,_0x4999e4){return function(_0x8bd1d0){if(_0x8bd1d0){return _0x8bd1d0[_0xf414('0x24')]()[_0xf414('0x23')](function(){_0x236504[_0xf414('0x1a')](0xcc)[_0xf414('0x1b')]();});}};}function handleEntityNotFound(_0x398631,_0x1340d8){return function(_0x3f7a7d){if(!_0x3f7a7d){_0x398631['sendStatus'](0x194);}return _0x3f7a7d;};}function handleError(_0x2f9cb3,_0x564c66){_0x564c66=_0x564c66||0x1f4;return function(_0x47e0a1){logger[_0xf414('0x25')](_0x47e0a1[_0xf414('0x26')]);if(_0x47e0a1[_0xf414('0x27')]){delete _0x47e0a1[_0xf414('0x27')];}_0x2f9cb3[_0xf414('0x1a')](_0x564c66)[_0xf414('0x28')](_0x47e0a1);};}exports['index']=function(_0x53efd2,_0x306a1c){var _0x25b40f={},_0x209790={},_0x5e925b={'count':0x0,'rows':[]};var _0x433425=_['map'](db['SquareMessage'][_0xf414('0x29')],function(_0x8cf16c){return{'name':_0x8cf16c[_0xf414('0x2a')],'type':_0x8cf16c['type']['key']};});_0x209790[_0xf414('0x2b')]=_['map'](_0x433425,_0xf414('0x27'));_0x209790[_0xf414('0x2c')]=_[_0xf414('0x2d')](_0x53efd2[_0xf414('0x2c')]);_0x209790['filters']=_[_0xf414('0x2e')](_0x209790['model'],_0x209790['query']);_0x25b40f[_0xf414('0x2f')]=_[_0xf414('0x2e')](_0x209790[_0xf414('0x2b')],qs[_0xf414('0x30')](_0x53efd2[_0xf414('0x2c')][_0xf414('0x30')]));_0x25b40f[_0xf414('0x2f')]=_0x25b40f[_0xf414('0x2f')]['length']?_0x25b40f['attributes']:_0x209790[_0xf414('0x2b')];if(!_0x53efd2[_0xf414('0x2c')][_0xf414('0x31')]('nolimit')){_0x25b40f['limit']=qs[_0xf414('0x32')](_0x53efd2['query'][_0xf414('0x32')]);_0x25b40f['offset']=qs[_0xf414('0x1d')](_0x53efd2[_0xf414('0x2c')]['offset']);}_0x25b40f[_0xf414('0x33')]=qs[_0xf414('0x34')](_0x53efd2[_0xf414('0x2c')]['sort']);_0x25b40f[_0xf414('0x35')]=qs[_0xf414('0x36')](_[_0xf414('0x37')](_0x53efd2[_0xf414('0x2c')],_0x209790[_0xf414('0x36')]),_0x433425);if(_0x53efd2[_0xf414('0x2c')]['filter']){_0x25b40f[_0xf414('0x35')]=_[_0xf414('0x38')](_0x25b40f[_0xf414('0x35')],{'$or':_[_0xf414('0x39')](_0x433425,function(_0x21142c){if(_0x21142c[_0xf414('0x3a')]!==_0xf414('0x3b')){var _0xa0638a={};_0xa0638a[_0x21142c[_0xf414('0x27')]]={'$like':'%'+_0x53efd2['query'][_0xf414('0x3c')]+'%'};return _0xa0638a;}})});}_0x25b40f=_[_0xf414('0x38')]({},_0x25b40f,_0x53efd2[_0xf414('0x3d')]);var _0x16dd5e={'where':_0x25b40f[_0xf414('0x35')]};return db[_0xf414('0x3e')][_0xf414('0x1f')](_0x16dd5e)[_0xf414('0x23')](function(_0x248f7f){_0x5e925b[_0xf414('0x1f')]=_0x248f7f;if(_0x53efd2[_0xf414('0x2c')][_0xf414('0x3f')]){_0x25b40f[_0xf414('0x40')]=[{'all':!![]}];}return db[_0xf414('0x3e')][_0xf414('0x41')](_0x25b40f);})[_0xf414('0x23')](function(_0x43d141){_0x5e925b['rows']=_0x43d141;return _0x5e925b;})[_0xf414('0x23')](respondWithFilteredResult(_0x306a1c,_0x25b40f))[_0xf414('0x42')](handleError(_0x306a1c,null));};exports['show']=function(_0x29c5ef,_0x3c95e6){var _0x56c830={'raw':!![],'where':{'id':_0x29c5ef[_0xf414('0x43')]['id']}},_0x41706d={};_0x41706d[_0xf414('0x2b')]=_[_0xf414('0x2d')](db[_0xf414('0x3e')][_0xf414('0x29')]);_0x41706d[_0xf414('0x2c')]=_['keys'](_0x29c5ef[_0xf414('0x2c')]);_0x41706d[_0xf414('0x36')]=_[_0xf414('0x2e')](_0x41706d[_0xf414('0x2b')],_0x41706d[_0xf414('0x2c')]);_0x56c830[_0xf414('0x2f')]=_[_0xf414('0x2e')](_0x41706d[_0xf414('0x2b')],qs[_0xf414('0x30')](_0x29c5ef['query'][_0xf414('0x30')]));_0x56c830[_0xf414('0x2f')]=_0x56c830[_0xf414('0x2f')][_0xf414('0x44')]?_0x56c830['attributes']:_0x41706d['model'];if(_0x29c5ef[_0xf414('0x2c')][_0xf414('0x3f')]){_0x56c830['include']=[{'all':!![]}];}_0x56c830=_['merge']({},_0x56c830,_0x29c5ef[_0xf414('0x3d')]);return db[_0xf414('0x3e')][_0xf414('0x45')](_0x56c830)[_0xf414('0x23')](handleEntityNotFound(_0x3c95e6,null))[_0xf414('0x23')](respondWithResult(_0x3c95e6,null))[_0xf414('0x42')](handleError(_0x3c95e6,null));};exports[_0xf414('0x46')]=function(_0x269beb,_0x49ad21){return db[_0xf414('0x3e')][_0xf414('0x46')](_0x269beb[_0xf414('0x47')],{})[_0xf414('0x23')](respondWithResult(_0x49ad21,0xc9))[_0xf414('0x42')](handleError(_0x49ad21,null));};exports[_0xf414('0x48')]=function(_0x2670f5,_0x5c7ec1){if(_0x2670f5[_0xf414('0x47')]['id']){delete _0x2670f5[_0xf414('0x47')]['id'];}return db['SquareMessage'][_0xf414('0x45')]({'where':{'id':_0x2670f5[_0xf414('0x43')]['id']}})[_0xf414('0x23')](handleEntityNotFound(_0x5c7ec1,null))[_0xf414('0x23')](saveUpdates(_0x2670f5[_0xf414('0x47')],null))[_0xf414('0x23')](respondWithResult(_0x5c7ec1,null))['catch'](handleError(_0x5c7ec1,null));};exports[_0xf414('0x24')]=function(_0x5b5b69,_0x528379){return db[_0xf414('0x3e')][_0xf414('0x45')]({'where':{'id':_0x5b5b69[_0xf414('0x43')]['id']}})['then'](handleEntityNotFound(_0x528379,null))[_0xf414('0x23')](removeEntity(_0x528379,null))[_0xf414('0x42')](handleError(_0x528379,null));};
\ No newline at end of file
+var _0x023d=['map','SquareMessage','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','includeAll','include','findAll','rows','show','params','rawAttributes','options','find','catch','body','rimraf','fast-json-patch','request-promise','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','index'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0x023d,0x67));var _0xd023=function(_0x3c5878,_0x4c5058){_0x3c5878=_0x3c5878-0x0;var _0x49e8cf=_0x023d[_0x3c5878];return _0x49e8cf;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xd023('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd023('0x1'));var rp=require(_0xd023('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xd023('0x3'));var util=require('util');var path=require(_0xd023('0x4'));var sox=require(_0xd023('0x5'));var csv=require(_0xd023('0x6'));var ejs=require(_0xd023('0x7'));var fs=require('fs');var fs_extra=require(_0xd023('0x8'));var _=require(_0xd023('0x9'));var squel=require(_0xd023('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xd023('0xb'));var toCsv=require('to-csv');var querystring=require(_0xd023('0xc'));var Papa=require(_0xd023('0xd'));var Redis=require('ioredis');var authService=require(_0xd023('0xe'));var qs=require(_0xd023('0xf'));var as=require(_0xd023('0x10'));var hardwareService=require(_0xd023('0x11'));var logger=require(_0xd023('0x12'))(_0xd023('0x13'));var utils=require(_0xd023('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xd023('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3a0cb8,_0x426567){_0x426567=_0x426567||0xcc;return function(_0x3e9be1){if(_0x3e9be1){return _0x3a0cb8[_0xd023('0x16')](_0x426567);}return _0x3a0cb8['status'](_0x426567)['end']();};}function respondWithResult(_0x56a8bf,_0x32efb9){_0x32efb9=_0x32efb9||0xc8;return function(_0x49a76e){if(_0x49a76e){return _0x56a8bf[_0xd023('0x17')](_0x32efb9)[_0xd023('0x18')](_0x49a76e);}};}function respondWithFilteredResult(_0x551df1,_0x19f1ed){return function(_0x552c9e){if(_0x552c9e){var _0x43f2cf=typeof _0x19f1ed['offset']===_0xd023('0x19')&&typeof _0x19f1ed[_0xd023('0x1a')]===_0xd023('0x19');var _0x1b2974=_0x552c9e[_0xd023('0x1b')];var _0x372bcc=_0x43f2cf?0x0:_0x19f1ed[_0xd023('0x1c')];var _0x154daf=_0x43f2cf?_0x552c9e['count']:_0x19f1ed[_0xd023('0x1c')]+_0x19f1ed[_0xd023('0x1a')];var _0x3288dc;if(_0x154daf>=_0x1b2974){_0x154daf=_0x1b2974;_0x3288dc=0xc8;}else{_0x3288dc=0xce;}_0x551df1[_0xd023('0x17')](_0x3288dc);return _0x551df1[_0xd023('0x1d')](_0xd023('0x1e'),_0x372bcc+'-'+_0x154daf+'/'+_0x1b2974)[_0xd023('0x18')](_0x552c9e);}return null;};}function patchUpdates(_0x2694ce){return function(_0x58f3d8){try{jsonpatch[_0xd023('0x1f')](_0x58f3d8,_0x2694ce,!![]);}catch(_0x346927){return BPromise[_0xd023('0x20')](_0x346927);}return _0x58f3d8[_0xd023('0x21')]();};}function saveUpdates(_0x2a05d8,_0x5eda8b){return function(_0x44536c){if(_0x44536c){return _0x44536c['update'](_0x2a05d8)[_0xd023('0x22')](function(_0xc5d335){return _0xc5d335;});}return null;};}function removeEntity(_0xddafdd,_0x225731){return function(_0x3f05ce){if(_0x3f05ce){return _0x3f05ce[_0xd023('0x23')]()['then'](function(){_0xddafdd['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0xd14642,_0x350adb){return function(_0x21fa1d){if(!_0x21fa1d){_0xd14642['sendStatus'](0x194);}return _0x21fa1d;};}function handleError(_0x35c6f2,_0x351d3a){_0x351d3a=_0x351d3a||0x1f4;return function(_0x31c0c0){logger[_0xd023('0x24')](_0x31c0c0[_0xd023('0x25')]);if(_0x31c0c0['name']){delete _0x31c0c0[_0xd023('0x26')];}_0x35c6f2[_0xd023('0x17')](_0x351d3a)[_0xd023('0x27')](_0x31c0c0);};}exports[_0xd023('0x28')]=function(_0x2155e4,_0x1ddabe){var _0x5b49ca={},_0x181a94={},_0x5bec1e={'count':0x0,'rows':[]};var _0xeba5d2=_[_0xd023('0x29')](db[_0xd023('0x2a')]['rawAttributes'],function(_0x277f2a){return{'name':_0x277f2a[_0xd023('0x2b')],'type':_0x277f2a[_0xd023('0x2c')][_0xd023('0x2d')]};});_0x181a94[_0xd023('0x2e')]=_[_0xd023('0x29')](_0xeba5d2,_0xd023('0x26'));_0x181a94['query']=_[_0xd023('0x2f')](_0x2155e4[_0xd023('0x30')]);_0x181a94[_0xd023('0x31')]=_[_0xd023('0x32')](_0x181a94[_0xd023('0x2e')],_0x181a94[_0xd023('0x30')]);_0x5b49ca[_0xd023('0x33')]=_[_0xd023('0x32')](_0x181a94[_0xd023('0x2e')],qs[_0xd023('0x34')](_0x2155e4['query'][_0xd023('0x34')]));_0x5b49ca['attributes']=_0x5b49ca[_0xd023('0x33')][_0xd023('0x35')]?_0x5b49ca['attributes']:_0x181a94[_0xd023('0x2e')];if(!_0x2155e4['query'][_0xd023('0x36')](_0xd023('0x37'))){_0x5b49ca[_0xd023('0x1a')]=qs['limit'](_0x2155e4['query'][_0xd023('0x1a')]);_0x5b49ca['offset']=qs[_0xd023('0x1c')](_0x2155e4['query'][_0xd023('0x1c')]);}_0x5b49ca['order']=qs[_0xd023('0x38')](_0x2155e4[_0xd023('0x30')]['sort']);_0x5b49ca[_0xd023('0x39')]=qs['filters'](_[_0xd023('0x3a')](_0x2155e4[_0xd023('0x30')],_0x181a94[_0xd023('0x31')]),_0xeba5d2);if(_0x2155e4['query'][_0xd023('0x3b')]){_0x5b49ca[_0xd023('0x39')]=_['merge'](_0x5b49ca[_0xd023('0x39')],{'$or':_[_0xd023('0x29')](_0xeba5d2,function(_0x173aba){if(_0x173aba[_0xd023('0x2c')]!=='VIRTUAL'){var _0x5d31de={};_0x5d31de[_0x173aba[_0xd023('0x26')]]={'$like':'%'+_0x2155e4[_0xd023('0x30')][_0xd023('0x3b')]+'%'};return _0x5d31de;}})});}_0x5b49ca=_[_0xd023('0x3c')]({},_0x5b49ca,_0x2155e4['options']);var _0x173dcd={'where':_0x5b49ca[_0xd023('0x39')]};return db[_0xd023('0x2a')][_0xd023('0x1b')](_0x173dcd)['then'](function(_0x5892d2){_0x5bec1e['count']=_0x5892d2;if(_0x2155e4['query'][_0xd023('0x3d')]){_0x5b49ca[_0xd023('0x3e')]=[{'all':!![]}];}return db[_0xd023('0x2a')][_0xd023('0x3f')](_0x5b49ca);})[_0xd023('0x22')](function(_0xf0b768){_0x5bec1e[_0xd023('0x40')]=_0xf0b768;return _0x5bec1e;})[_0xd023('0x22')](respondWithFilteredResult(_0x1ddabe,_0x5b49ca))['catch'](handleError(_0x1ddabe,null));};exports[_0xd023('0x41')]=function(_0x485985,_0x18c4a4){var _0x366aad={'raw':!![],'where':{'id':_0x485985[_0xd023('0x42')]['id']}},_0x45b304={};_0x45b304[_0xd023('0x2e')]=_['keys'](db[_0xd023('0x2a')][_0xd023('0x43')]);_0x45b304[_0xd023('0x30')]=_[_0xd023('0x2f')](_0x485985['query']);_0x45b304[_0xd023('0x31')]=_['intersection'](_0x45b304[_0xd023('0x2e')],_0x45b304[_0xd023('0x30')]);_0x366aad[_0xd023('0x33')]=_[_0xd023('0x32')](_0x45b304[_0xd023('0x2e')],qs[_0xd023('0x34')](_0x485985[_0xd023('0x30')][_0xd023('0x34')]));_0x366aad[_0xd023('0x33')]=_0x366aad['attributes'][_0xd023('0x35')]?_0x366aad[_0xd023('0x33')]:_0x45b304[_0xd023('0x2e')];if(_0x485985[_0xd023('0x30')][_0xd023('0x3d')]){_0x366aad[_0xd023('0x3e')]=[{'all':!![]}];}_0x366aad=_[_0xd023('0x3c')]({},_0x366aad,_0x485985[_0xd023('0x44')]);return db[_0xd023('0x2a')][_0xd023('0x45')](_0x366aad)['then'](handleEntityNotFound(_0x18c4a4,null))[_0xd023('0x22')](respondWithResult(_0x18c4a4,null))[_0xd023('0x46')](handleError(_0x18c4a4,null));};exports['create']=function(_0x5e4d8e,_0x3f18b7){return db[_0xd023('0x2a')]['create'](_0x5e4d8e['body'],{})[_0xd023('0x22')](respondWithResult(_0x3f18b7,0xc9))[_0xd023('0x46')](handleError(_0x3f18b7,null));};exports['update']=function(_0x258645,_0x5a84d2){if(_0x258645[_0xd023('0x47')]['id']){delete _0x258645[_0xd023('0x47')]['id'];}return db[_0xd023('0x2a')][_0xd023('0x45')]({'where':{'id':_0x258645[_0xd023('0x42')]['id']}})[_0xd023('0x22')](handleEntityNotFound(_0x5a84d2,null))['then'](saveUpdates(_0x258645['body'],null))[_0xd023('0x22')](respondWithResult(_0x5a84d2,null))['catch'](handleError(_0x5a84d2,null));};exports[_0xd023('0x23')]=function(_0x30f265,_0x481420){return db['SquareMessage'][_0xd023('0x45')]({'where':{'id':_0x30f265[_0xd023('0x42')]['id']}})['then'](handleEntityNotFound(_0x481420,null))[_0xd023('0x22')](removeEntity(_0x481420,null))[_0xd023('0x46')](handleError(_0x481420,null));};
\ No newline at end of file