Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / squareMessage / squareMessage.controller.js
index f547a33..ac65b62 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x26b0=['options','find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','then','error','name','send','index','rawAttributes','fieldName','key','model','map','keys','filters','attributes','intersection','fields','query','length','hasOwnProperty','nolimit','order','where','filter','merge','type','VIRTUAL','SquareMessage','includeAll','include','findAll','rows','catch','show','params'];(function(_0x3a1953,_0x440442){var _0x51c757=function(_0x7846eb){while(--_0x7846eb){_0x3a1953['push'](_0x3a1953['shift']());}};_0x51c757(++_0x440442);}(_0x26b0,0x134));var _0x026b=function(_0x59f691,_0x1b656d){_0x59f691=_0x59f691-0x0;var _0x1f80bb=_0x26b0[_0x59f691];return _0x1f80bb;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x026b('0x0'));var rimraf=require(_0x026b('0x1'));var zipdir=require(_0x026b('0x2'));var jsonpatch=require(_0x026b('0x3'));var rp=require('request-promise');var moment=require(_0x026b('0x4'));var BPromise=require(_0x026b('0x5'));var Mustache=require(_0x026b('0x6'));var util=require(_0x026b('0x7'));var path=require(_0x026b('0x8'));var sox=require(_0x026b('0x9'));var csv=require(_0x026b('0xa'));var ejs=require(_0x026b('0xb'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x026b('0xc'));var jsforce=require(_0x026b('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x026b('0xa'));var querystring=require(_0x026b('0xe'));var Papa=require(_0x026b('0xf'));var Redis=require(_0x026b('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x026b('0x11'));var as=require(_0x026b('0x12'));var hardwareService=require(_0x026b('0x13'));var logger=require(_0x026b('0x14'))('api');var utils=require(_0x026b('0x15'));var config=require(_0x026b('0x16'));var licenseUtil=require(_0x026b('0x17'));var db=require(_0x026b('0x18'))['db'];function respondWithStatusCode(_0x29e30f,_0x56e90e){_0x56e90e=_0x56e90e||0xcc;return function(_0x25fd77){if(_0x25fd77){return _0x29e30f[_0x026b('0x19')](_0x56e90e);}return _0x29e30f[_0x026b('0x1a')](_0x56e90e)[_0x026b('0x1b')]();};}function respondWithResult(_0x3e8e04,_0x3040d1){_0x3040d1=_0x3040d1||0xc8;return function(_0x5e5c8a){if(_0x5e5c8a){return _0x3e8e04[_0x026b('0x1a')](_0x3040d1)[_0x026b('0x1c')](_0x5e5c8a);}};}function respondWithFilteredResult(_0x13c239,_0x22b86e){return function(_0x56eec1){if(_0x56eec1){var _0x34b058=_0x56eec1[_0x026b('0x1d')],_0x38f1d3=_0x22b86e['offset'],_0x215eff=_0x22b86e[_0x026b('0x1e')]+_0x22b86e[_0x026b('0x1f')],_0x59bfd2;if(_0x215eff>=_0x34b058){_0x215eff=_0x34b058;_0x59bfd2=0xc8;}else{_0x59bfd2=0xce;}_0x13c239[_0x026b('0x1a')](_0x59bfd2);return _0x13c239[_0x026b('0x20')](_0x026b('0x21'),_0x38f1d3+'-'+_0x215eff+'/'+_0x34b058)['json'](_0x56eec1);}return null;};}function patchUpdates(_0x2fdd64){return function(_0x2380f8){try{jsonpatch[_0x026b('0x22')](_0x2380f8,_0x2fdd64,!![]);}catch(_0x21f31c){return BPromise[_0x026b('0x23')](_0x21f31c);}return _0x2380f8[_0x026b('0x24')]();};}function saveUpdates(_0x511851,_0xe190a2){return function(_0x2601a2){if(_0x2601a2){return _0x2601a2[_0x026b('0x25')](_0x511851)['then'](function(_0x5d6f6c){return _0x5d6f6c;});}return null;};}function removeEntity(_0x584168,_0x2b640c){return function(_0x1a73ca){if(_0x1a73ca){return _0x1a73ca[_0x026b('0x26')]()[_0x026b('0x27')](function(){_0x584168[_0x026b('0x1a')](0xcc)[_0x026b('0x1b')]();});}};}function handleEntityNotFound(_0x32d3b7,_0x231d3){return function(_0x1b5214){if(!_0x1b5214){_0x32d3b7['sendStatus'](0x194);}return _0x1b5214;};}function handleError(_0x5e3edc,_0x392c39){_0x392c39=_0x392c39||0x1f4;return function(_0x5d7f73){logger[_0x026b('0x28')](_0x5d7f73['stack']);if(_0x5d7f73[_0x026b('0x29')]){delete _0x5d7f73[_0x026b('0x29')];}_0x5e3edc[_0x026b('0x1a')](_0x392c39)[_0x026b('0x2a')](_0x5d7f73);};}exports[_0x026b('0x2b')]=function(_0x47c6d7,_0x2b6adc){var _0x4034fd={},_0x387d53={},_0x36ef57={'count':0x0,'rows':[]};var _0xc44a58=_['map'](db['SquareMessage'][_0x026b('0x2c')],function(_0x53bc3f){return{'name':_0x53bc3f[_0x026b('0x2d')],'type':_0x53bc3f['type'][_0x026b('0x2e')]};});_0x387d53[_0x026b('0x2f')]=_[_0x026b('0x30')](_0xc44a58,_0x026b('0x29'));_0x387d53['query']=_[_0x026b('0x31')](_0x47c6d7['query']);_0x387d53[_0x026b('0x32')]=_['intersection'](_0x387d53['model'],_0x387d53['query']);_0x4034fd[_0x026b('0x33')]=_[_0x026b('0x34')](_0x387d53[_0x026b('0x2f')],qs[_0x026b('0x35')](_0x47c6d7[_0x026b('0x36')]['fields']));_0x4034fd[_0x026b('0x33')]=_0x4034fd[_0x026b('0x33')][_0x026b('0x37')]?_0x4034fd[_0x026b('0x33')]:_0x387d53[_0x026b('0x2f')];if(!_0x47c6d7[_0x026b('0x36')][_0x026b('0x38')](_0x026b('0x39'))){_0x4034fd[_0x026b('0x1f')]=qs[_0x026b('0x1f')](_0x47c6d7[_0x026b('0x36')]['limit']);_0x4034fd[_0x026b('0x1e')]=qs['offset'](_0x47c6d7[_0x026b('0x36')][_0x026b('0x1e')]);}_0x4034fd[_0x026b('0x3a')]=qs['sort'](_0x47c6d7[_0x026b('0x36')]['sort']);_0x4034fd[_0x026b('0x3b')]=qs[_0x026b('0x32')](_['pick'](_0x47c6d7[_0x026b('0x36')],_0x387d53[_0x026b('0x32')]),_0xc44a58);if(_0x47c6d7[_0x026b('0x36')][_0x026b('0x3c')]){_0x4034fd['where']=_[_0x026b('0x3d')](_0x4034fd[_0x026b('0x3b')],{'$or':_[_0x026b('0x30')](_0xc44a58,function(_0x5420c8){if(_0x5420c8[_0x026b('0x3e')]!==_0x026b('0x3f')){var _0x27978f={};_0x27978f[_0x5420c8[_0x026b('0x29')]]={'$like':'%'+_0x47c6d7[_0x026b('0x36')]['filter']+'%'};return _0x27978f;}})});}_0x4034fd=_[_0x026b('0x3d')]({},_0x4034fd,_0x47c6d7['options']);var _0x33275f={'where':_0x4034fd[_0x026b('0x3b')]};return db[_0x026b('0x40')][_0x026b('0x1d')](_0x33275f)[_0x026b('0x27')](function(_0xe9f09f){_0x36ef57[_0x026b('0x1d')]=_0xe9f09f;if(_0x47c6d7[_0x026b('0x36')][_0x026b('0x41')]){_0x4034fd[_0x026b('0x42')]=[{'all':!![]}];}return db[_0x026b('0x40')][_0x026b('0x43')](_0x4034fd);})[_0x026b('0x27')](function(_0x17a5a0){_0x36ef57[_0x026b('0x44')]=_0x17a5a0;return _0x36ef57;})[_0x026b('0x27')](respondWithFilteredResult(_0x2b6adc,_0x4034fd))[_0x026b('0x45')](handleError(_0x2b6adc,null));};exports[_0x026b('0x46')]=function(_0x3eeb9c,_0x446aa7){var _0x41f7e3={'raw':!![],'where':{'id':_0x3eeb9c[_0x026b('0x47')]['id']}},_0xd6ccb9={};_0xd6ccb9[_0x026b('0x2f')]=_[_0x026b('0x31')](db['SquareMessage'][_0x026b('0x2c')]);_0xd6ccb9[_0x026b('0x36')]=_['keys'](_0x3eeb9c['query']);_0xd6ccb9[_0x026b('0x32')]=_['intersection'](_0xd6ccb9[_0x026b('0x2f')],_0xd6ccb9[_0x026b('0x36')]);_0x41f7e3['attributes']=_[_0x026b('0x34')](_0xd6ccb9['model'],qs[_0x026b('0x35')](_0x3eeb9c[_0x026b('0x36')][_0x026b('0x35')]));_0x41f7e3[_0x026b('0x33')]=_0x41f7e3[_0x026b('0x33')][_0x026b('0x37')]?_0x41f7e3[_0x026b('0x33')]:_0xd6ccb9[_0x026b('0x2f')];if(_0x3eeb9c[_0x026b('0x36')][_0x026b('0x41')]){_0x41f7e3[_0x026b('0x42')]=[{'all':!![]}];}_0x41f7e3=_[_0x026b('0x3d')]({},_0x41f7e3,_0x3eeb9c[_0x026b('0x48')]);return db[_0x026b('0x40')][_0x026b('0x49')](_0x41f7e3)[_0x026b('0x27')](handleEntityNotFound(_0x446aa7,null))[_0x026b('0x27')](respondWithResult(_0x446aa7,null))[_0x026b('0x45')](handleError(_0x446aa7,null));};exports[_0x026b('0x4a')]=function(_0x389953,_0x1a7257){return db[_0x026b('0x40')]['create'](_0x389953[_0x026b('0x4b')],{})['then'](respondWithResult(_0x1a7257,0xc9))['catch'](handleError(_0x1a7257,null));};exports[_0x026b('0x25')]=function(_0x49647f,_0x4af2f3){if(_0x49647f[_0x026b('0x4b')]['id']){delete _0x49647f[_0x026b('0x4b')]['id'];}return db[_0x026b('0x40')][_0x026b('0x49')]({'where':{'id':_0x49647f[_0x026b('0x47')]['id']}})[_0x026b('0x27')](handleEntityNotFound(_0x4af2f3,null))[_0x026b('0x27')](saveUpdates(_0x49647f[_0x026b('0x4b')],null))[_0x026b('0x27')](respondWithResult(_0x4af2f3,null))[_0x026b('0x45')](handleError(_0x4af2f3,null));};exports[_0x026b('0x26')]=function(_0x55a80f,_0xa16c67){return db[_0x026b('0x40')][_0x026b('0x49')]({'where':{'id':_0x55a80f[_0x026b('0x47')]['id']}})[_0x026b('0x27')](handleEntityNotFound(_0xa16c67,null))[_0x026b('0x27')](removeEntity(_0xa16c67,null))['catch'](handleError(_0xa16c67,null));};
\ No newline at end of file
+var _0xe469=['limit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','catch','params','rawAttributes','include','find','create','body','destroy','eml-format','rimraf','zip-dir','moment','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','offset','undefined','count','set','Content-Range','json','save','update','then','end','stack','name','send','index','map','SquareMessage','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit'];(function(_0x2c41f9,_0x550191){var _0x5f3d76=function(_0x19ff0c){while(--_0x19ff0c){_0x2c41f9['push'](_0x2c41f9['shift']());}};_0x5f3d76(++_0x550191);}(_0xe469,0xef));var _0x9e46=function(_0x1337c6,_0x3e8010){_0x1337c6=_0x1337c6-0x0;var _0x28bcf4=_0xe469[_0x1337c6];return _0x28bcf4;};'use strict';var emlformat=require(_0x9e46('0x0'));var rimraf=require(_0x9e46('0x1'));var zipdir=require(_0x9e46('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9e46('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x9e46('0x4'));var path=require(_0x9e46('0x5'));var sox=require(_0x9e46('0x6'));var csv=require(_0x9e46('0x7'));var ejs=require(_0x9e46('0x8'));var fs=require('fs');var fs_extra=require(_0x9e46('0x9'));var _=require(_0x9e46('0xa'));var squel=require('squel');var crypto=require(_0x9e46('0xb'));var jsforce=require(_0x9e46('0xc'));var deskjs=require(_0x9e46('0xd'));var toCsv=require(_0x9e46('0x7'));var querystring=require(_0x9e46('0xe'));var Papa=require(_0x9e46('0xf'));var Redis=require(_0x9e46('0x10'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9e46('0x11'));var logger=require(_0x9e46('0x12'))(_0x9e46('0x13'));var utils=require('../../config/utils');var config=require(_0x9e46('0x14'));var licenseUtil=require(_0x9e46('0x15'));var db=require(_0x9e46('0x16'))['db'];function respondWithStatusCode(_0x3cbd98,_0x136c82){_0x136c82=_0x136c82||0xcc;return function(_0x4f85b3){if(_0x4f85b3){return _0x3cbd98[_0x9e46('0x17')](_0x136c82);}return _0x3cbd98['status'](_0x136c82)['end']();};}function respondWithResult(_0x2a5d04,_0x22efa0){_0x22efa0=_0x22efa0||0xc8;return function(_0x100911){if(_0x100911){return _0x2a5d04[_0x9e46('0x18')](_0x22efa0)['json'](_0x100911);}};}function respondWithFilteredResult(_0x1cd770,_0x201bae){return function(_0x53ebc0){if(_0x53ebc0){var _0x480f5f=typeof _0x201bae[_0x9e46('0x19')]===_0x9e46('0x1a')&&typeof _0x201bae['limit']==='undefined';var _0x519525=_0x53ebc0['count'];var _0x3a027a=_0x480f5f?0x0:_0x201bae[_0x9e46('0x19')];var _0x5b54c6=_0x480f5f?_0x53ebc0[_0x9e46('0x1b')]:_0x201bae[_0x9e46('0x19')]+_0x201bae['limit'];var _0x25e777;if(_0x5b54c6>=_0x519525){_0x5b54c6=_0x519525;_0x25e777=0xc8;}else{_0x25e777=0xce;}_0x1cd770[_0x9e46('0x18')](_0x25e777);return _0x1cd770[_0x9e46('0x1c')](_0x9e46('0x1d'),_0x3a027a+'-'+_0x5b54c6+'/'+_0x519525)[_0x9e46('0x1e')](_0x53ebc0);}return null;};}function patchUpdates(_0x1f2131){return function(_0x2c334d){try{jsonpatch['apply'](_0x2c334d,_0x1f2131,!![]);}catch(_0xaa8b60){return BPromise['reject'](_0xaa8b60);}return _0x2c334d[_0x9e46('0x1f')]();};}function saveUpdates(_0x590f73,_0x52b780){return function(_0x5a2b81){if(_0x5a2b81){return _0x5a2b81[_0x9e46('0x20')](_0x590f73)['then'](function(_0x3b89ab){return _0x3b89ab;});}return null;};}function removeEntity(_0x223557,_0x330ea6){return function(_0x1f8d35){if(_0x1f8d35){return _0x1f8d35['destroy']()[_0x9e46('0x21')](function(){_0x223557[_0x9e46('0x18')](0xcc)[_0x9e46('0x22')]();});}};}function handleEntityNotFound(_0x2454a6,_0x5bc271){return function(_0x37c568){if(!_0x37c568){_0x2454a6['sendStatus'](0x194);}return _0x37c568;};}function handleError(_0x28a43a,_0x49aaaa){_0x49aaaa=_0x49aaaa||0x1f4;return function(_0x4a665e){logger['error'](_0x4a665e[_0x9e46('0x23')]);if(_0x4a665e[_0x9e46('0x24')]){delete _0x4a665e[_0x9e46('0x24')];}_0x28a43a[_0x9e46('0x18')](_0x49aaaa)[_0x9e46('0x25')](_0x4a665e);};}exports[_0x9e46('0x26')]=function(_0x1cb0a1,_0x1dbe55){var _0x47997d={},_0x13b25c={},_0x194c70={'count':0x0,'rows':[]};var _0x10c6cd=_[_0x9e46('0x27')](db[_0x9e46('0x28')]['rawAttributes'],function(_0x4d5fc8){return{'name':_0x4d5fc8[_0x9e46('0x29')],'type':_0x4d5fc8[_0x9e46('0x2a')][_0x9e46('0x2b')]};});_0x13b25c[_0x9e46('0x2c')]=_['map'](_0x10c6cd,_0x9e46('0x24'));_0x13b25c[_0x9e46('0x2d')]=_[_0x9e46('0x2e')](_0x1cb0a1[_0x9e46('0x2d')]);_0x13b25c[_0x9e46('0x2f')]=_[_0x9e46('0x30')](_0x13b25c[_0x9e46('0x2c')],_0x13b25c[_0x9e46('0x2d')]);_0x47997d[_0x9e46('0x31')]=_[_0x9e46('0x30')](_0x13b25c['model'],qs['fields'](_0x1cb0a1['query'][_0x9e46('0x32')]));_0x47997d[_0x9e46('0x31')]=_0x47997d['attributes']['length']?_0x47997d[_0x9e46('0x31')]:_0x13b25c['model'];if(!_0x1cb0a1['query'][_0x9e46('0x33')](_0x9e46('0x34'))){_0x47997d['limit']=qs[_0x9e46('0x35')](_0x1cb0a1['query'][_0x9e46('0x35')]);_0x47997d[_0x9e46('0x19')]=qs['offset'](_0x1cb0a1['query']['offset']);}_0x47997d[_0x9e46('0x36')]=qs['sort'](_0x1cb0a1['query'][_0x9e46('0x37')]);_0x47997d[_0x9e46('0x38')]=qs['filters'](_[_0x9e46('0x39')](_0x1cb0a1['query'],_0x13b25c[_0x9e46('0x2f')]),_0x10c6cd);if(_0x1cb0a1[_0x9e46('0x2d')][_0x9e46('0x3a')]){_0x47997d['where']=_[_0x9e46('0x3b')](_0x47997d['where'],{'$or':_[_0x9e46('0x27')](_0x10c6cd,function(_0x26dce9){if(_0x26dce9['type']!==_0x9e46('0x3c')){var _0x5e4b3a={};_0x5e4b3a[_0x26dce9[_0x9e46('0x24')]]={'$like':'%'+_0x1cb0a1[_0x9e46('0x2d')][_0x9e46('0x3a')]+'%'};return _0x5e4b3a;}})});}_0x47997d=_['merge']({},_0x47997d,_0x1cb0a1[_0x9e46('0x3d')]);var _0x2e695d={'where':_0x47997d[_0x9e46('0x38')]};return db['SquareMessage'][_0x9e46('0x1b')](_0x2e695d)[_0x9e46('0x21')](function(_0x1f8acb){_0x194c70[_0x9e46('0x1b')]=_0x1f8acb;if(_0x1cb0a1['query'][_0x9e46('0x3e')]){_0x47997d['include']=[{'all':!![]}];}return db[_0x9e46('0x28')][_0x9e46('0x3f')](_0x47997d);})[_0x9e46('0x21')](function(_0x37d3b5){_0x194c70[_0x9e46('0x40')]=_0x37d3b5;return _0x194c70;})[_0x9e46('0x21')](respondWithFilteredResult(_0x1dbe55,_0x47997d))[_0x9e46('0x41')](handleError(_0x1dbe55,null));};exports['show']=function(_0xdfa815,_0x50ea44){var _0x3d468d={'raw':!![],'where':{'id':_0xdfa815[_0x9e46('0x42')]['id']}},_0x1e3bb4={};_0x1e3bb4[_0x9e46('0x2c')]=_['keys'](db[_0x9e46('0x28')][_0x9e46('0x43')]);_0x1e3bb4[_0x9e46('0x2d')]=_[_0x9e46('0x2e')](_0xdfa815['query']);_0x1e3bb4[_0x9e46('0x2f')]=_[_0x9e46('0x30')](_0x1e3bb4[_0x9e46('0x2c')],_0x1e3bb4[_0x9e46('0x2d')]);_0x3d468d[_0x9e46('0x31')]=_['intersection'](_0x1e3bb4[_0x9e46('0x2c')],qs[_0x9e46('0x32')](_0xdfa815[_0x9e46('0x2d')][_0x9e46('0x32')]));_0x3d468d[_0x9e46('0x31')]=_0x3d468d[_0x9e46('0x31')]['length']?_0x3d468d['attributes']:_0x1e3bb4[_0x9e46('0x2c')];if(_0xdfa815[_0x9e46('0x2d')][_0x9e46('0x3e')]){_0x3d468d[_0x9e46('0x44')]=[{'all':!![]}];}_0x3d468d=_[_0x9e46('0x3b')]({},_0x3d468d,_0xdfa815[_0x9e46('0x3d')]);return db[_0x9e46('0x28')][_0x9e46('0x45')](_0x3d468d)[_0x9e46('0x21')](handleEntityNotFound(_0x50ea44,null))[_0x9e46('0x21')](respondWithResult(_0x50ea44,null))[_0x9e46('0x41')](handleError(_0x50ea44,null));};exports[_0x9e46('0x46')]=function(_0x1cc59b,_0x9cf596){return db['SquareMessage'][_0x9e46('0x46')](_0x1cc59b[_0x9e46('0x47')],{})[_0x9e46('0x21')](respondWithResult(_0x9cf596,0xc9))[_0x9e46('0x41')](handleError(_0x9cf596,null));};exports['update']=function(_0x3be8b4,_0x4223dd){if(_0x3be8b4[_0x9e46('0x47')]['id']){delete _0x3be8b4[_0x9e46('0x47')]['id'];}return db[_0x9e46('0x28')]['find']({'where':{'id':_0x3be8b4[_0x9e46('0x42')]['id']}})['then'](handleEntityNotFound(_0x4223dd,null))[_0x9e46('0x21')](saveUpdates(_0x3be8b4[_0x9e46('0x47')],null))[_0x9e46('0x21')](respondWithResult(_0x4223dd,null))[_0x9e46('0x41')](handleError(_0x4223dd,null));};exports[_0x9e46('0x48')]=function(_0x5d71b4,_0x5b1419){return db[_0x9e46('0x28')]['find']({'where':{'id':_0x5d71b4[_0x9e46('0x42')]['id']}})['then'](handleEntityNotFound(_0x5b1419,null))['then'](removeEntity(_0x5b1419,null))[_0x9e46('0x41')](handleError(_0x5b1419,null));};
\ No newline at end of file