Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / squareMessage / squareMessage.controller.js
index 3c2302a..bbe6f95 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf680=['rawAttributes','fieldName','type','key','query','filters','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','count','includeAll','include','SquareMessage','findAll','rows','catch','show','params','keys','intersection','find','create','body','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','ejs','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../config/license/hardware','api','../../config/environment','../../mysqldb','sendStatus','status','end','offset','limit','set','Content-Range','json','apply','update','then','destroy','name','index','map'];(function(_0x54186e,_0x5edbeb){var _0x20b1a5=function(_0x5d7637){while(--_0x5d7637){_0x54186e['push'](_0x54186e['shift']());}};_0x20b1a5(++_0x5edbeb);}(_0xf680,0x175));var _0x0f68=function(_0x466818,_0xc71220){_0x466818=_0x466818-0x0;var _0x28f621=_0xf680[_0x466818];return _0x28f621;};'use strict';var pdf=require(_0x0f68('0x0'));var emlformat=require(_0x0f68('0x1'));var rimraf=require(_0x0f68('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0f68('0x3'));var rp=require(_0x0f68('0x4'));var moment=require('moment');var BPromise=require(_0x0f68('0x5'));var Mustache=require(_0x0f68('0x6'));var util=require(_0x0f68('0x7'));var path=require('path');var sox=require(_0x0f68('0x8'));var csv=require(_0x0f68('0x9'));var ejs=require(_0x0f68('0xa'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x0f68('0xb'));var jsforce=require(_0x0f68('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x0f68('0x9'));var querystring=require(_0x0f68('0xd'));var Papa=require(_0x0f68('0xe'));var Redis=require('ioredis');var authService=require(_0x0f68('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0f68('0x10'));var logger=require('../../config/logger')(_0x0f68('0x11'));var utils=require('../../config/utils');var config=require(_0x0f68('0x12'));var licenseUtil=require('../../config/license/util');var db=require(_0x0f68('0x13'))['db'];function respondWithStatusCode(_0x2f9648,_0xd0eed6){_0xd0eed6=_0xd0eed6||0xcc;return function(_0x4f9cdf){if(_0x4f9cdf){return _0x2f9648[_0x0f68('0x14')](_0xd0eed6);}return _0x2f9648[_0x0f68('0x15')](_0xd0eed6)[_0x0f68('0x16')]();};}function respondWithResult(_0x3c6cb9,_0x242edb){_0x242edb=_0x242edb||0xc8;return function(_0x37b818){if(_0x37b818){return _0x3c6cb9[_0x0f68('0x15')](_0x242edb)['json'](_0x37b818);}};}function respondWithFilteredResult(_0x38a420,_0x5835d2){return function(_0x54ff45){if(_0x54ff45){var _0x4eb779=_0x54ff45['count'],_0x4a80d6=_0x5835d2[_0x0f68('0x17')],_0x89ddb3=_0x5835d2[_0x0f68('0x17')]+_0x5835d2[_0x0f68('0x18')],_0x31e88f;if(_0x89ddb3>=_0x4eb779){_0x89ddb3=_0x4eb779;_0x31e88f=0xc8;}else{_0x31e88f=0xce;}_0x38a420[_0x0f68('0x15')](_0x31e88f);return _0x38a420[_0x0f68('0x19')](_0x0f68('0x1a'),_0x4a80d6+'-'+_0x89ddb3+'/'+_0x4eb779)[_0x0f68('0x1b')](_0x54ff45);}return null;};}function patchUpdates(_0x3d2806){return function(_0x3d628d){try{jsonpatch[_0x0f68('0x1c')](_0x3d628d,_0x3d2806,!![]);}catch(_0x47cdd0){return BPromise['reject'](_0x47cdd0);}return _0x3d628d['save']();};}function saveUpdates(_0x41878a,_0x31518a){return function(_0x20ba50){if(_0x20ba50){return _0x20ba50[_0x0f68('0x1d')](_0x41878a)[_0x0f68('0x1e')](function(_0x4763ca){return _0x4763ca;});}return null;};}function removeEntity(_0x56eea2,_0x551705){return function(_0x467941){if(_0x467941){return _0x467941[_0x0f68('0x1f')]()[_0x0f68('0x1e')](function(){_0x56eea2[_0x0f68('0x15')](0xcc)[_0x0f68('0x16')]();});}};}function handleEntityNotFound(_0x19c69c,_0x9eba3d){return function(_0x43b84e){if(!_0x43b84e){_0x19c69c[_0x0f68('0x14')](0x194);}return _0x43b84e;};}function handleError(_0x3a885e,_0x2e67c4){_0x2e67c4=_0x2e67c4||0x1f4;return function(_0x2c0204){logger['error'](_0x2c0204['stack']);if(_0x2c0204['name']){delete _0x2c0204[_0x0f68('0x20')];}_0x3a885e[_0x0f68('0x15')](_0x2e67c4)['send'](_0x2c0204);};}exports[_0x0f68('0x21')]=function(_0x2eb48b,_0x2f8ecd){var _0xa1f15d={},_0x459094={},_0x4c7980={'count':0x0,'rows':[]};var _0x5b48df=_[_0x0f68('0x22')](db['SquareMessage'][_0x0f68('0x23')],function(_0xa2e245){return{'name':_0xa2e245[_0x0f68('0x24')],'type':_0xa2e245[_0x0f68('0x25')][_0x0f68('0x26')]};});_0x459094['model']=_[_0x0f68('0x22')](_0x5b48df,'name');_0x459094[_0x0f68('0x27')]=_['keys'](_0x2eb48b['query']);_0x459094[_0x0f68('0x28')]=_['intersection'](_0x459094[_0x0f68('0x29')],_0x459094[_0x0f68('0x27')]);_0xa1f15d['attributes']=_['intersection'](_0x459094[_0x0f68('0x29')],qs[_0x0f68('0x2a')](_0x2eb48b['query']['fields']));_0xa1f15d[_0x0f68('0x2b')]=_0xa1f15d['attributes'][_0x0f68('0x2c')]?_0xa1f15d['attributes']:_0x459094[_0x0f68('0x29')];if(!_0x2eb48b['query'][_0x0f68('0x2d')](_0x0f68('0x2e'))){_0xa1f15d[_0x0f68('0x18')]=qs[_0x0f68('0x18')](_0x2eb48b['query'][_0x0f68('0x18')]);_0xa1f15d[_0x0f68('0x17')]=qs[_0x0f68('0x17')](_0x2eb48b[_0x0f68('0x27')]['offset']);}_0xa1f15d[_0x0f68('0x2f')]=qs[_0x0f68('0x30')](_0x2eb48b[_0x0f68('0x27')][_0x0f68('0x30')]);_0xa1f15d[_0x0f68('0x31')]=qs[_0x0f68('0x28')](_[_0x0f68('0x32')](_0x2eb48b['query'],_0x459094['filters']),_0x5b48df);if(_0x2eb48b[_0x0f68('0x27')][_0x0f68('0x33')]){_0xa1f15d[_0x0f68('0x31')]=_[_0x0f68('0x34')](_0xa1f15d[_0x0f68('0x31')],{'$or':_['map'](_0x5b48df,function(_0x46f3e2){if(_0x46f3e2['type']!=='VIRTUAL'){var _0x2380e4={};_0x2380e4[_0x46f3e2[_0x0f68('0x20')]]={'$like':'%'+_0x2eb48b[_0x0f68('0x27')][_0x0f68('0x33')]+'%'};return _0x2380e4;}})});}_0xa1f15d=_['merge']({},_0xa1f15d,_0x2eb48b[_0x0f68('0x35')]);var _0x4d62ac={'where':_0xa1f15d[_0x0f68('0x31')]};return db['SquareMessage'][_0x0f68('0x36')](_0x4d62ac)['then'](function(_0x18aba6){_0x4c7980['count']=_0x18aba6;if(_0x2eb48b[_0x0f68('0x27')][_0x0f68('0x37')]){_0xa1f15d[_0x0f68('0x38')]=[{'all':!![]}];}return db[_0x0f68('0x39')][_0x0f68('0x3a')](_0xa1f15d);})[_0x0f68('0x1e')](function(_0x35bb1e){_0x4c7980[_0x0f68('0x3b')]=_0x35bb1e;return _0x4c7980;})[_0x0f68('0x1e')](respondWithFilteredResult(_0x2f8ecd,_0xa1f15d))[_0x0f68('0x3c')](handleError(_0x2f8ecd,null));};exports[_0x0f68('0x3d')]=function(_0x26ab66,_0x206f8a){var _0x568194={'raw':!![],'where':{'id':_0x26ab66[_0x0f68('0x3e')]['id']}},_0x4d52e0={};_0x4d52e0[_0x0f68('0x29')]=_[_0x0f68('0x3f')](db['SquareMessage']['rawAttributes']);_0x4d52e0['query']=_[_0x0f68('0x3f')](_0x26ab66['query']);_0x4d52e0[_0x0f68('0x28')]=_[_0x0f68('0x40')](_0x4d52e0[_0x0f68('0x29')],_0x4d52e0[_0x0f68('0x27')]);_0x568194[_0x0f68('0x2b')]=_[_0x0f68('0x40')](_0x4d52e0[_0x0f68('0x29')],qs[_0x0f68('0x2a')](_0x26ab66[_0x0f68('0x27')][_0x0f68('0x2a')]));_0x568194[_0x0f68('0x2b')]=_0x568194['attributes']['length']?_0x568194[_0x0f68('0x2b')]:_0x4d52e0[_0x0f68('0x29')];if(_0x26ab66[_0x0f68('0x27')][_0x0f68('0x37')]){_0x568194['include']=[{'all':!![]}];}_0x568194=_[_0x0f68('0x34')]({},_0x568194,_0x26ab66['options']);return db[_0x0f68('0x39')][_0x0f68('0x41')](_0x568194)[_0x0f68('0x1e')](handleEntityNotFound(_0x206f8a,null))[_0x0f68('0x1e')](respondWithResult(_0x206f8a,null))[_0x0f68('0x3c')](handleError(_0x206f8a,null));};exports[_0x0f68('0x42')]=function(_0x213334,_0x4ff33c){return db[_0x0f68('0x39')]['create'](_0x213334[_0x0f68('0x43')],{})['then'](respondWithResult(_0x4ff33c,0xc9))[_0x0f68('0x3c')](handleError(_0x4ff33c,null));};exports[_0x0f68('0x1d')]=function(_0xa26392,_0x628d97){if(_0xa26392[_0x0f68('0x43')]['id']){delete _0xa26392[_0x0f68('0x43')]['id'];}return db[_0x0f68('0x39')][_0x0f68('0x41')]({'where':{'id':_0xa26392[_0x0f68('0x3e')]['id']}})[_0x0f68('0x1e')](handleEntityNotFound(_0x628d97,null))['then'](saveUpdates(_0xa26392[_0x0f68('0x43')],null))['then'](respondWithResult(_0x628d97,null))['catch'](handleError(_0x628d97,null));};exports[_0x0f68('0x1f')]=function(_0x435e48,_0x497325){return db[_0x0f68('0x39')][_0x0f68('0x41')]({'where':{'id':_0x435e48[_0x0f68('0x3e')]['id']}})[_0x0f68('0x1e')](handleEntityNotFound(_0x497325,null))['then'](removeEntity(_0x497325,null))[_0x0f68('0x3c')](handleError(_0x497325,null));};
\ No newline at end of file
+var _0xc2c7=['nolimit','order','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','keys','find','params','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','Content-Range','reject','save','update','destroy','then','error','name','send','index','map','SquareMessage','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xc2c7,0x134));var _0x7c2c=function(_0x12e428,_0x3ad891){_0x12e428=_0x12e428-0x0;var _0x564df9=_0xc2c7[_0x12e428];return _0x564df9;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x7c2c('0x0'));var zipdir=require(_0x7c2c('0x1'));var jsonpatch=require(_0x7c2c('0x2'));var rp=require(_0x7c2c('0x3'));var moment=require(_0x7c2c('0x4'));var BPromise=require(_0x7c2c('0x5'));var Mustache=require(_0x7c2c('0x6'));var util=require(_0x7c2c('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x7c2c('0x8'));var ejs=require(_0x7c2c('0x9'));var fs=require('fs');var fs_extra=require(_0x7c2c('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x7c2c('0xb'));var deskjs=require(_0x7c2c('0xc'));var toCsv=require(_0x7c2c('0x8'));var querystring=require(_0x7c2c('0xd'));var Papa=require(_0x7c2c('0xe'));var Redis=require('ioredis');var authService=require(_0x7c2c('0xf'));var qs=require(_0x7c2c('0x10'));var as=require(_0x7c2c('0x11'));var hardwareService=require(_0x7c2c('0x12'));var logger=require(_0x7c2c('0x13'))(_0x7c2c('0x14'));var utils=require(_0x7c2c('0x15'));var config=require(_0x7c2c('0x16'));var licenseUtil=require(_0x7c2c('0x17'));var db=require(_0x7c2c('0x18'))['db'];function respondWithStatusCode(_0xae8441,_0x45847d){_0x45847d=_0x45847d||0xcc;return function(_0x68398a){if(_0x68398a){return _0xae8441[_0x7c2c('0x19')](_0x45847d);}return _0xae8441[_0x7c2c('0x1a')](_0x45847d)[_0x7c2c('0x1b')]();};}function respondWithResult(_0x4c4aaf,_0x5b5729){_0x5b5729=_0x5b5729||0xc8;return function(_0x102778){if(_0x102778){return _0x4c4aaf[_0x7c2c('0x1a')](_0x5b5729)[_0x7c2c('0x1c')](_0x102778);}};}function respondWithFilteredResult(_0x5ae94f,_0x11424c){return function(_0x206ecd){if(_0x206ecd){var _0x5e55e0=typeof _0x11424c[_0x7c2c('0x1d')]==='undefined'&&typeof _0x11424c[_0x7c2c('0x1e')]==='undefined';var _0x342ea2=_0x206ecd[_0x7c2c('0x1f')];var _0x14453f=_0x5e55e0?0x0:_0x11424c[_0x7c2c('0x1d')];var _0x17df4a=_0x5e55e0?_0x206ecd[_0x7c2c('0x1f')]:_0x11424c[_0x7c2c('0x1d')]+_0x11424c[_0x7c2c('0x1e')];var _0x2d356e;if(_0x17df4a>=_0x342ea2){_0x17df4a=_0x342ea2;_0x2d356e=0xc8;}else{_0x2d356e=0xce;}_0x5ae94f[_0x7c2c('0x1a')](_0x2d356e);return _0x5ae94f[_0x7c2c('0x20')](_0x7c2c('0x21'),_0x14453f+'-'+_0x17df4a+'/'+_0x342ea2)['json'](_0x206ecd);}return null;};}function patchUpdates(_0x1c5491){return function(_0x4adb62){try{jsonpatch['apply'](_0x4adb62,_0x1c5491,!![]);}catch(_0x15ae33){return BPromise[_0x7c2c('0x22')](_0x15ae33);}return _0x4adb62[_0x7c2c('0x23')]();};}function saveUpdates(_0x38ae30,_0x41552f){return function(_0x1883b5){if(_0x1883b5){return _0x1883b5[_0x7c2c('0x24')](_0x38ae30)['then'](function(_0x10c356){return _0x10c356;});}return null;};}function removeEntity(_0x4dedd8,_0x302c93){return function(_0x57f510){if(_0x57f510){return _0x57f510[_0x7c2c('0x25')]()[_0x7c2c('0x26')](function(){_0x4dedd8[_0x7c2c('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4d6ec7,_0x31a50c){return function(_0x30c53e){if(!_0x30c53e){_0x4d6ec7[_0x7c2c('0x19')](0x194);}return _0x30c53e;};}function handleError(_0x150690,_0x31d8f3){_0x31d8f3=_0x31d8f3||0x1f4;return function(_0xa8e145){logger[_0x7c2c('0x27')](_0xa8e145['stack']);if(_0xa8e145[_0x7c2c('0x28')]){delete _0xa8e145[_0x7c2c('0x28')];}_0x150690[_0x7c2c('0x1a')](_0x31d8f3)[_0x7c2c('0x29')](_0xa8e145);};}exports[_0x7c2c('0x2a')]=function(_0x1f8846,_0xf2bfd1){var _0x26f472={},_0xa040ff={},_0x5769ec={'count':0x0,'rows':[]};var _0x465ad6=_[_0x7c2c('0x2b')](db[_0x7c2c('0x2c')][_0x7c2c('0x2d')],function(_0x53ad23){return{'name':_0x53ad23[_0x7c2c('0x2e')],'type':_0x53ad23[_0x7c2c('0x2f')][_0x7c2c('0x30')]};});_0xa040ff[_0x7c2c('0x31')]=_[_0x7c2c('0x2b')](_0x465ad6,_0x7c2c('0x28'));_0xa040ff[_0x7c2c('0x32')]=_['keys'](_0x1f8846[_0x7c2c('0x32')]);_0xa040ff[_0x7c2c('0x33')]=_[_0x7c2c('0x34')](_0xa040ff[_0x7c2c('0x31')],_0xa040ff[_0x7c2c('0x32')]);_0x26f472['attributes']=_['intersection'](_0xa040ff[_0x7c2c('0x31')],qs['fields'](_0x1f8846['query'][_0x7c2c('0x35')]));_0x26f472[_0x7c2c('0x36')]=_0x26f472[_0x7c2c('0x36')][_0x7c2c('0x37')]?_0x26f472['attributes']:_0xa040ff[_0x7c2c('0x31')];if(!_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x38')](_0x7c2c('0x39'))){_0x26f472[_0x7c2c('0x1e')]=qs[_0x7c2c('0x1e')](_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x1e')]);_0x26f472[_0x7c2c('0x1d')]=qs[_0x7c2c('0x1d')](_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x1d')]);}_0x26f472[_0x7c2c('0x3a')]=qs['sort'](_0x1f8846['query'][_0x7c2c('0x3b')]);_0x26f472['where']=qs['filters'](_['pick'](_0x1f8846[_0x7c2c('0x32')],_0xa040ff[_0x7c2c('0x33')]),_0x465ad6);if(_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x3c')]){_0x26f472[_0x7c2c('0x3d')]=_[_0x7c2c('0x3e')](_0x26f472[_0x7c2c('0x3d')],{'$or':_[_0x7c2c('0x2b')](_0x465ad6,function(_0x2b6520){if(_0x2b6520[_0x7c2c('0x2f')]!==_0x7c2c('0x3f')){var _0x58696a={};_0x58696a[_0x2b6520['name']]={'$like':'%'+_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x3c')]+'%'};return _0x58696a;}})});}_0x26f472=_[_0x7c2c('0x3e')]({},_0x26f472,_0x1f8846[_0x7c2c('0x40')]);var _0x5e8c96={'where':_0x26f472[_0x7c2c('0x3d')]};return db[_0x7c2c('0x2c')][_0x7c2c('0x1f')](_0x5e8c96)[_0x7c2c('0x26')](function(_0x18e288){_0x5769ec[_0x7c2c('0x1f')]=_0x18e288;if(_0x1f8846[_0x7c2c('0x32')][_0x7c2c('0x41')]){_0x26f472[_0x7c2c('0x42')]=[{'all':!![]}];}return db['SquareMessage'][_0x7c2c('0x43')](_0x26f472);})['then'](function(_0x2c3f40){_0x5769ec[_0x7c2c('0x44')]=_0x2c3f40;return _0x5769ec;})['then'](respondWithFilteredResult(_0xf2bfd1,_0x26f472))[_0x7c2c('0x45')](handleError(_0xf2bfd1,null));};exports['show']=function(_0x3014fb,_0x33b2be){var _0x9b9813={'raw':!![],'where':{'id':_0x3014fb['params']['id']}},_0x26351e={};_0x26351e[_0x7c2c('0x31')]=_['keys'](db['SquareMessage'][_0x7c2c('0x2d')]);_0x26351e[_0x7c2c('0x32')]=_[_0x7c2c('0x46')](_0x3014fb['query']);_0x26351e[_0x7c2c('0x33')]=_[_0x7c2c('0x34')](_0x26351e['model'],_0x26351e[_0x7c2c('0x32')]);_0x9b9813['attributes']=_[_0x7c2c('0x34')](_0x26351e[_0x7c2c('0x31')],qs['fields'](_0x3014fb['query'][_0x7c2c('0x35')]));_0x9b9813[_0x7c2c('0x36')]=_0x9b9813['attributes'][_0x7c2c('0x37')]?_0x9b9813['attributes']:_0x26351e['model'];if(_0x3014fb[_0x7c2c('0x32')][_0x7c2c('0x41')]){_0x9b9813[_0x7c2c('0x42')]=[{'all':!![]}];}_0x9b9813=_[_0x7c2c('0x3e')]({},_0x9b9813,_0x3014fb[_0x7c2c('0x40')]);return db[_0x7c2c('0x2c')][_0x7c2c('0x47')](_0x9b9813)[_0x7c2c('0x26')](handleEntityNotFound(_0x33b2be,null))[_0x7c2c('0x26')](respondWithResult(_0x33b2be,null))['catch'](handleError(_0x33b2be,null));};exports['create']=function(_0xeb067b,_0x3091bd){return db[_0x7c2c('0x2c')]['create'](_0xeb067b['body'],{})[_0x7c2c('0x26')](respondWithResult(_0x3091bd,0xc9))[_0x7c2c('0x45')](handleError(_0x3091bd,null));};exports[_0x7c2c('0x24')]=function(_0x2b79d5,_0x5f3de8){if(_0x2b79d5['body']['id']){delete _0x2b79d5['body']['id'];}return db[_0x7c2c('0x2c')][_0x7c2c('0x47')]({'where':{'id':_0x2b79d5[_0x7c2c('0x48')]['id']}})[_0x7c2c('0x26')](handleEntityNotFound(_0x5f3de8,null))[_0x7c2c('0x26')](saveUpdates(_0x2b79d5['body'],null))[_0x7c2c('0x26')](respondWithResult(_0x5f3de8,null))[_0x7c2c('0x45')](handleError(_0x5f3de8,null));};exports['destroy']=function(_0x19621a,_0x56e09d){return db[_0x7c2c('0x2c')][_0x7c2c('0x47')]({'where':{'id':_0x19621a[_0x7c2c('0x48')]['id']}})['then'](handleEntityNotFound(_0x56e09d,null))['then'](removeEntity(_0x56e09d,null))[_0x7c2c('0x45')](handleError(_0x56e09d,null));};
\ No newline at end of file