Built motion from commit 1fd437e9.|2.6.19
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index ee8aaaa..768da68 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0ed6=['params','intersection','find','create','update','body','getConfigurations','findOne','DeskConfiguration','nolimit','addConfiguration','Subjects','getSubjects','channel','Descriptions','getDescriptions','DeskField','priority','remoteUri','authType','username','password','token','tokenSecret','slice','substring','lastIndexOf','GET','%s/custom_fields','basic','Authorization','format','%s:%s','toString','base64','concat','_embedded','entries','label','test','getFields','stringify','Wrong\x20credentials','statusCode','zip-dir','fast-json-patch','bluebird','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','limit','undefined','count','offset','apply','reject','then','destroy','sendStatus','error','stack','name','send','map','DeskAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','fields','attributes','length','hasOwnProperty','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show'];(function(_0x2812c5,_0x124b54){var _0x4a99a1=function(_0x9116e2){while(--_0x9116e2){_0x2812c5['push'](_0x2812c5['shift']());}};_0x4a99a1(++_0x124b54);}(_0x0ed6,0x1d4));var _0x60ed=function(_0x21ea6f,_0x4416ad){_0x21ea6f=_0x21ea6f-0x0;var _0x30b29b=_0x0ed6[_0x21ea6f];return _0x30b29b;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x60ed('0x0'));var jsonpatch=require(_0x60ed('0x1'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x60ed('0x2'));var Mustache=require('mustache');var util=require('util');var path=require(_0x60ed('0x3'));var sox=require('sox');var csv=require(_0x60ed('0x4'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x60ed('0x5'));var _=require(_0x60ed('0x6'));var squel=require(_0x60ed('0x7'));var crypto=require(_0x60ed('0x8'));var jsforce=require(_0x60ed('0x9'));var deskjs=require(_0x60ed('0xa'));var toCsv=require('to-csv');var querystring=require(_0x60ed('0xb'));var Papa=require(_0x60ed('0xc'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x60ed('0xd'));var hardwareService=require(_0x60ed('0xe'));var logger=require('../../config/logger')('api');var utils=require(_0x60ed('0xf'));var config=require(_0x60ed('0x10'));var licenseUtil=require(_0x60ed('0x11'));var db=require(_0x60ed('0x12'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x34ee9f,_0x522327){_0x522327=_0x522327||0xcc;return function(_0x3f9831){if(_0x3f9831){return _0x34ee9f['sendStatus'](_0x522327);}return _0x34ee9f['status'](_0x522327)[_0x60ed('0x13')]();};}function respondWithResult(_0x1255a9,_0x5f24b6){_0x5f24b6=_0x5f24b6||0xc8;return function(_0x170f58){if(_0x170f58){return _0x1255a9[_0x60ed('0x14')](_0x5f24b6)[_0x60ed('0x15')](_0x170f58);}};}function respondWithFilteredResult(_0x3e8942,_0x38ebb5){return function(_0x26f08e){if(_0x26f08e){var _0x3032a8=typeof _0x38ebb5['offset']==='undefined'&&typeof _0x38ebb5[_0x60ed('0x16')]===_0x60ed('0x17');var _0x1f69aa=_0x26f08e[_0x60ed('0x18')];var _0x585a86=_0x3032a8?0x0:_0x38ebb5['offset'];var _0x4aa3d3=_0x3032a8?_0x26f08e[_0x60ed('0x18')]:_0x38ebb5[_0x60ed('0x19')]+_0x38ebb5['limit'];var _0x211afd;if(_0x4aa3d3>=_0x1f69aa){_0x4aa3d3=_0x1f69aa;_0x211afd=0xc8;}else{_0x211afd=0xce;}_0x3e8942[_0x60ed('0x14')](_0x211afd);return _0x3e8942['set']('Content-Range',_0x585a86+'-'+_0x4aa3d3+'/'+_0x1f69aa)[_0x60ed('0x15')](_0x26f08e);}return null;};}function patchUpdates(_0x5d2928){return function(_0x5ac76d){try{jsonpatch[_0x60ed('0x1a')](_0x5ac76d,_0x5d2928,!![]);}catch(_0x151993){return BPromise[_0x60ed('0x1b')](_0x151993);}return _0x5ac76d['save']();};}function saveUpdates(_0x5371f5,_0x1ccda6){return function(_0x419e60){if(_0x419e60){return _0x419e60['update'](_0x5371f5)[_0x60ed('0x1c')](function(_0x30af8d){return _0x30af8d;});}return null;};}function removeEntity(_0x15aacb,_0x1e9009){return function(_0x26606d){if(_0x26606d){return _0x26606d[_0x60ed('0x1d')]()[_0x60ed('0x1c')](function(){_0x15aacb[_0x60ed('0x14')](0xcc)[_0x60ed('0x13')]();});}};}function handleEntityNotFound(_0x4ab71b,_0x285eab){return function(_0x5c9ce4){if(!_0x5c9ce4){_0x4ab71b[_0x60ed('0x1e')](0x194);}return _0x5c9ce4;};}function handleError(_0xd153c,_0x1a7834){_0x1a7834=_0x1a7834||0x1f4;return function(_0x5b0916){logger[_0x60ed('0x1f')](_0x5b0916[_0x60ed('0x20')]);if(_0x5b0916[_0x60ed('0x21')]){delete _0x5b0916['name'];}_0xd153c[_0x60ed('0x14')](_0x1a7834)[_0x60ed('0x22')](_0x5b0916);};}exports['index']=function(_0x3199ef,_0x3232c8){var _0x35299e={},_0xfde300={},_0x4ead6e={'count':0x0,'rows':[]};var _0x596f6e=_[_0x60ed('0x23')](db[_0x60ed('0x24')][_0x60ed('0x25')],function(_0x216f39){return{'name':_0x216f39[_0x60ed('0x26')],'type':_0x216f39[_0x60ed('0x27')][_0x60ed('0x28')]};});_0xfde300[_0x60ed('0x29')]=_[_0x60ed('0x23')](_0x596f6e,_0x60ed('0x21'));_0xfde300[_0x60ed('0x2a')]=_[_0x60ed('0x2b')](_0x3199ef[_0x60ed('0x2a')]);_0xfde300[_0x60ed('0x2c')]=_['intersection'](_0xfde300[_0x60ed('0x29')],_0xfde300[_0x60ed('0x2a')]);_0x35299e['attributes']=_['intersection'](_0xfde300['model'],qs[_0x60ed('0x2d')](_0x3199ef['query'][_0x60ed('0x2d')]));_0x35299e[_0x60ed('0x2e')]=_0x35299e[_0x60ed('0x2e')][_0x60ed('0x2f')]?_0x35299e[_0x60ed('0x2e')]:_0xfde300[_0x60ed('0x29')];if(!_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x30')]('nolimit')){_0x35299e[_0x60ed('0x16')]=qs[_0x60ed('0x16')](_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x16')]);_0x35299e[_0x60ed('0x19')]=qs[_0x60ed('0x19')](_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x19')]);}_0x35299e['order']=qs[_0x60ed('0x31')](_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x31')]);_0x35299e[_0x60ed('0x32')]=qs[_0x60ed('0x2c')](_[_0x60ed('0x33')](_0x3199ef['query'],_0xfde300[_0x60ed('0x2c')]),_0x596f6e);if(_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x34')]){_0x35299e[_0x60ed('0x32')]=_[_0x60ed('0x35')](_0x35299e[_0x60ed('0x32')],{'$or':_[_0x60ed('0x23')](_0x596f6e,function(_0x2b160b){if(_0x2b160b[_0x60ed('0x27')]!==_0x60ed('0x36')){var _0x11a2ab={};_0x11a2ab[_0x2b160b[_0x60ed('0x21')]]={'$like':'%'+_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x34')]+'%'};return _0x11a2ab;}})});}_0x35299e=_['merge']({},_0x35299e,_0x3199ef[_0x60ed('0x37')]);var _0x38048e={'where':_0x35299e['where']};return db[_0x60ed('0x24')][_0x60ed('0x18')](_0x38048e)[_0x60ed('0x1c')](function(_0x3462c8){_0x4ead6e[_0x60ed('0x18')]=_0x3462c8;if(_0x3199ef[_0x60ed('0x2a')][_0x60ed('0x38')]){_0x35299e[_0x60ed('0x39')]=[{'all':!![]}];}return db['DeskAccount'][_0x60ed('0x3a')](_0x35299e);})['then'](function(_0x3388c9){_0x4ead6e[_0x60ed('0x3b')]=_0x3388c9;return _0x4ead6e;})[_0x60ed('0x1c')](respondWithFilteredResult(_0x3232c8,_0x35299e))[_0x60ed('0x3c')](handleError(_0x3232c8,null));};exports[_0x60ed('0x3d')]=function(_0x393c66,_0x487374){var _0x20ac59={'raw':![],'where':{'id':_0x393c66[_0x60ed('0x3e')]['id']}},_0x46d73a={};_0x46d73a['model']=_[_0x60ed('0x2b')](db['DeskAccount'][_0x60ed('0x25')]);_0x46d73a['query']=_[_0x60ed('0x2b')](_0x393c66['query']);_0x46d73a[_0x60ed('0x2c')]=_[_0x60ed('0x3f')](_0x46d73a[_0x60ed('0x29')],_0x46d73a[_0x60ed('0x2a')]);_0x20ac59['attributes']=_[_0x60ed('0x3f')](_0x46d73a[_0x60ed('0x29')],qs['fields'](_0x393c66[_0x60ed('0x2a')][_0x60ed('0x2d')]));_0x20ac59[_0x60ed('0x2e')]=_0x20ac59[_0x60ed('0x2e')][_0x60ed('0x2f')]?_0x20ac59[_0x60ed('0x2e')]:_0x46d73a[_0x60ed('0x29')];if(_0x393c66[_0x60ed('0x2a')][_0x60ed('0x38')]){_0x20ac59[_0x60ed('0x39')]=[{'all':!![]}];}_0x20ac59=_['merge']({},_0x20ac59,_0x393c66[_0x60ed('0x37')]);return db[_0x60ed('0x24')][_0x60ed('0x40')](_0x20ac59)[_0x60ed('0x1c')](handleEntityNotFound(_0x487374,null))[_0x60ed('0x1c')](respondWithResult(_0x487374,null))['catch'](handleError(_0x487374,null));};exports['create']=function(_0x4bb53c,_0x5838dc){return db[_0x60ed('0x24')][_0x60ed('0x41')](_0x4bb53c['body'],{})['then'](respondWithResult(_0x5838dc,0xc9))[_0x60ed('0x3c')](handleError(_0x5838dc,null));};exports[_0x60ed('0x42')]=function(_0x5b4cf5,_0xd4de5d){if(_0x5b4cf5[_0x60ed('0x43')]['id']){delete _0x5b4cf5['body']['id'];}return db['DeskAccount']['find']({'where':{'id':_0x5b4cf5['params']['id']}})[_0x60ed('0x1c')](handleEntityNotFound(_0xd4de5d,null))[_0x60ed('0x1c')](saveUpdates(_0x5b4cf5[_0x60ed('0x43')],null))[_0x60ed('0x1c')](respondWithResult(_0xd4de5d,null))['catch'](handleError(_0xd4de5d,null));};exports[_0x60ed('0x1d')]=function(_0x271746,_0x47ce0e){return db[_0x60ed('0x24')]['find']({'where':{'id':_0x271746[_0x60ed('0x3e')]['id']}})[_0x60ed('0x1c')](handleEntityNotFound(_0x47ce0e,null))[_0x60ed('0x1c')](removeEntity(_0x47ce0e,null))['catch'](handleError(_0x47ce0e,null));};exports[_0x60ed('0x44')]=function(_0x73a479,_0x48670d,_0x32825d){var _0x8b3787={};var _0x3f15fb={};var _0x2e134e;var _0x20ea23;return db[_0x60ed('0x24')][_0x60ed('0x45')]({'where':{'id':_0x73a479[_0x60ed('0x3e')]['id']}})['then'](handleEntityNotFound(_0x48670d,null))[_0x60ed('0x1c')](function(_0x44b56d){if(_0x44b56d){_0x2e134e=_0x44b56d;_0x3f15fb[_0x60ed('0x29')]=_[_0x60ed('0x2b')](db[_0x60ed('0x46')][_0x60ed('0x25')]);_0x3f15fb['query']=_[_0x60ed('0x2b')](_0x73a479[_0x60ed('0x2a')]);_0x3f15fb[_0x60ed('0x2c')]=_[_0x60ed('0x3f')](_0x3f15fb[_0x60ed('0x29')],_0x3f15fb[_0x60ed('0x2a')]);_0x8b3787[_0x60ed('0x2e')]=_[_0x60ed('0x3f')](_0x3f15fb[_0x60ed('0x29')],qs[_0x60ed('0x2d')](_0x73a479[_0x60ed('0x2a')][_0x60ed('0x2d')]));_0x8b3787[_0x60ed('0x2e')]=_0x8b3787[_0x60ed('0x2e')]['length']?_0x8b3787[_0x60ed('0x2e')]:_0x3f15fb[_0x60ed('0x29')];_0x8b3787['order']=qs[_0x60ed('0x31')](_0x73a479['query'][_0x60ed('0x31')]);_0x8b3787[_0x60ed('0x32')]=qs[_0x60ed('0x2c')](_['pick'](_0x73a479[_0x60ed('0x2a')],_0x3f15fb[_0x60ed('0x2c')]));if(_0x73a479['query'][_0x60ed('0x34')]){_0x8b3787['where']=_[_0x60ed('0x35')](_0x8b3787['where'],{'$or':_['map'](_0x8b3787[_0x60ed('0x2e')],function(_0x5ebd2b){var _0x25b18f={};_0x25b18f[_0x5ebd2b]={'$like':'%'+_0x73a479[_0x60ed('0x2a')][_0x60ed('0x34')]+'%'};return _0x25b18f;})});}_0x8b3787=_[_0x60ed('0x35')]({},_0x8b3787,_0x73a479['options']);return _0x2e134e[_0x60ed('0x44')](_0x8b3787);}})['then'](function(_0x22f1fd){if(_0x22f1fd){_0x20ea23=_0x22f1fd[_0x60ed('0x2f')];if(!_0x73a479['query']['hasOwnProperty'](_0x60ed('0x47'))){_0x8b3787[_0x60ed('0x16')]=qs[_0x60ed('0x16')](_0x73a479['query']['limit']);_0x8b3787[_0x60ed('0x19')]=qs[_0x60ed('0x19')](_0x73a479['query'][_0x60ed('0x19')]);}return _0x2e134e[_0x60ed('0x44')](_0x8b3787);}})[_0x60ed('0x1c')](function(_0x3f0c05){if(_0x3f0c05){return _0x3f0c05?{'count':_0x20ea23,'rows':_0x3f0c05}:null;}})['then'](respondWithResult(_0x48670d,null))[_0x60ed('0x3c')](handleError(_0x48670d,null));};exports[_0x60ed('0x48')]=function(_0x23beb5,_0x136f9e,_0x13f3e8){if(_0x23beb5[_0x60ed('0x43')]['id']){delete _0x23beb5[_0x60ed('0x43')]['id'];}return db[_0x60ed('0x24')][_0x60ed('0x45')]({'where':{'id':_0x23beb5[_0x60ed('0x3e')]['id']}})[_0x60ed('0x1c')](handleEntityNotFound(_0x136f9e,null))['then'](function(_0x3e6e31){if(_0x3e6e31){_0x23beb5['body']['AccountId']=_0x3e6e31['id'];_0x23beb5['body'][_0x60ed('0x49')]=integrations[_0x60ed('0x4a')](_0x23beb5[_0x60ed('0x43')][_0x60ed('0x4b')],_0x23beb5['body']['type']);_0x23beb5[_0x60ed('0x43')][_0x60ed('0x4c')]=integrations[_0x60ed('0x4d')](_0x23beb5[_0x60ed('0x43')]['channel'],_0x23beb5['body']['type']);return db['DeskConfiguration'][_0x60ed('0x41')](_0x23beb5[_0x60ed('0x43')],{'include':[{'model':db[_0x60ed('0x4e')],'as':_0x60ed('0x49')},{'model':db[_0x60ed('0x4e')],'as':'Descriptions'}]});}return null;})[_0x60ed('0x1c')](respondWithResult(_0x136f9e,null))[_0x60ed('0x3c')](handleError(_0x136f9e,null));};exports['getFields']=function(_0x12775f,_0x455473,_0x58e429){var _0x322b68=[{'name':_0x60ed('0x4f'),'label':_0x60ed('0x4f'),'custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x4b4be0='';return db[_0x60ed('0x24')][_0x60ed('0x45')]({'where':{'id':_0x12775f['params']['id']},'attributes':['id',_0x60ed('0x50'),_0x60ed('0x51'),_0x60ed('0x52'),_0x60ed('0x53'),'consumerKey','consumerSecret',_0x60ed('0x54'),_0x60ed('0x55')]})[_0x60ed('0x1c')](handleEntityNotFound(_0x455473,null))[_0x60ed('0x1c')](function(_0x3f4bf2){if(_0x3f4bf2){_0x4b4be0=_0x3f4bf2[_0x60ed('0x50')];var _0x1ed31e=_0x4b4be0[_0x60ed('0x56')](-0x1);if(_0x1ed31e==='/'){_0x4b4be0=_0x4b4be0[_0x60ed('0x57')](0x0,_0x4b4be0[_0x60ed('0x58')](_0x1ed31e));}var _0x797413={'method':_0x60ed('0x59'),'uri':util['format'](_0x60ed('0x5a'),_0x4b4be0),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x3f4bf2[_0x60ed('0x51')]===_0x60ed('0x5b')){_0x797413['headers'][_0x60ed('0x5c')]=util['format']('Basic\x20%s',new Buffer(util[_0x60ed('0x5d')](_0x60ed('0x5e'),_0x3f4bf2[_0x60ed('0x52')],_0x3f4bf2[_0x60ed('0x53')]))[_0x60ed('0x5f')](_0x60ed('0x60')));}return rp(_0x797413)[_0x60ed('0x1c')](function(_0x1abeaa){return _0x322b68[_0x60ed('0x61')](_[_0x60ed('0x23')](_0x1abeaa[_0x60ed('0x62')][_0x60ed('0x63')],function(_0x2f370b){return{'id':_0x2f370b[_0x60ed('0x21')],'name':_0x2f370b[_0x60ed('0x21')],'type':_0x2f370b[_0x60ed('0x27')],'active':_0x2f370b['active'],'label':_0x2f370b[_0x60ed('0x64')],'custom':!![]};}));});}})[_0x60ed('0x1c')](function(_0x444fec){return{'count':_0x444fec[_0x60ed('0x2f')],'rows':_0x444fec};})[_0x60ed('0x1c')](respondWithResult(_0x455473,null))[_0x60ed('0x3c')](function(_0x548d13){var _0x4958c7=_0x12775f['query'][_0x60ed('0x65')]?0x1f4:_0x548d13['statusCode']||0x1f4;logger[_0x60ed('0x1f')]('getFields,\x20%s,\x20%s,\x20%s',_0x60ed('0x66'),_0x4958c7,JSON[_0x60ed('0x67')](_0x548d13));delete _0x548d13[_0x60ed('0x21')];if(_0x4958c7===0x191){_0x4958c7=0x190;}_0x455473[_0x60ed('0x14')](_0x4958c7)[_0x60ed('0x22')](_0x12775f[_0x60ed('0x2a')]['test']?{'message':_0x60ed('0x68'),'statusCode':_0x548d13[_0x60ed('0x69')]}:_0x548d13);});};
\ No newline at end of file
+var _0x2bcf=['Basic\x20%s','%s:%s','base64','concat','_embedded','entries','active','label','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/environment','../../components/integrations/configuration','sendStatus','status','end','json','offset','limit','undefined','count','set','reject','save','update','destroy','error','name','send','index','DeskAccount','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','then','rows','catch','show','params','includeAll','find','create','body','getConfigurations','findOne','DeskConfiguration','AccountId','Descriptions','getDescriptions','channel','Subjects','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','token','slice','substring','lastIndexOf','GET','format','%s/custom_fields','application/json','basic','Authorization'];(function(_0x5872f4,_0x399432){var _0xcb6124=function(_0x591aba){while(--_0x591aba){_0x5872f4['push'](_0x5872f4['shift']());}};_0xcb6124(++_0x399432);}(_0x2bcf,0x1d7));var _0xf2bc=function(_0x529f79,_0x5b4c85){_0x529f79=_0x529f79-0x0;var _0x21e1d5=_0x2bcf[_0x529f79];return _0x21e1d5;};'use strict';var emlformat=require(_0xf2bc('0x0'));var rimraf=require(_0xf2bc('0x1'));var zipdir=require(_0xf2bc('0x2'));var jsonpatch=require(_0xf2bc('0x3'));var rp=require(_0xf2bc('0x4'));var moment=require(_0xf2bc('0x5'));var BPromise=require(_0xf2bc('0x6'));var Mustache=require(_0xf2bc('0x7'));var util=require(_0xf2bc('0x8'));var path=require(_0xf2bc('0x9'));var sox=require(_0xf2bc('0xa'));var csv=require(_0xf2bc('0xb'));var ejs=require(_0xf2bc('0xc'));var fs=require('fs');var fs_extra=require(_0xf2bc('0xd'));var _=require(_0xf2bc('0xe'));var squel=require(_0xf2bc('0xf'));var crypto=require(_0xf2bc('0x10'));var jsforce=require(_0xf2bc('0x11'));var deskjs=require(_0xf2bc('0x12'));var toCsv=require(_0xf2bc('0xb'));var querystring=require(_0xf2bc('0x13'));var Papa=require(_0xf2bc('0x14'));var Redis=require(_0xf2bc('0x15'));var authService=require('../../components/auth/service');var qs=require(_0xf2bc('0x16'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf2bc('0x17'));var logger=require('../../config/logger')(_0xf2bc('0x18'));var utils=require('../../config/utils');var config=require(_0xf2bc('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0xf2bc('0x1a'));function respondWithStatusCode(_0x371733,_0x18e8e9){_0x18e8e9=_0x18e8e9||0xcc;return function(_0x3829e2){if(_0x3829e2){return _0x371733[_0xf2bc('0x1b')](_0x18e8e9);}return _0x371733[_0xf2bc('0x1c')](_0x18e8e9)[_0xf2bc('0x1d')]();};}function respondWithResult(_0x163966,_0x4b488c){_0x4b488c=_0x4b488c||0xc8;return function(_0x16a728){if(_0x16a728){return _0x163966[_0xf2bc('0x1c')](_0x4b488c)[_0xf2bc('0x1e')](_0x16a728);}};}function respondWithFilteredResult(_0x6203c5,_0x474223){return function(_0x1f2aac){if(_0x1f2aac){var _0x45191c=typeof _0x474223[_0xf2bc('0x1f')]==='undefined'&&typeof _0x474223[_0xf2bc('0x20')]===_0xf2bc('0x21');var _0x105826=_0x1f2aac[_0xf2bc('0x22')];var _0x43957f=_0x45191c?0x0:_0x474223[_0xf2bc('0x1f')];var _0x5c8705=_0x45191c?_0x1f2aac[_0xf2bc('0x22')]:_0x474223[_0xf2bc('0x1f')]+_0x474223[_0xf2bc('0x20')];var _0x43bbd5;if(_0x5c8705>=_0x105826){_0x5c8705=_0x105826;_0x43bbd5=0xc8;}else{_0x43bbd5=0xce;}_0x6203c5[_0xf2bc('0x1c')](_0x43bbd5);return _0x6203c5[_0xf2bc('0x23')]('Content-Range',_0x43957f+'-'+_0x5c8705+'/'+_0x105826)['json'](_0x1f2aac);}return null;};}function patchUpdates(_0x4a36f0){return function(_0x2bd6c0){try{jsonpatch['apply'](_0x2bd6c0,_0x4a36f0,!![]);}catch(_0x2c76ca){return BPromise[_0xf2bc('0x24')](_0x2c76ca);}return _0x2bd6c0[_0xf2bc('0x25')]();};}function saveUpdates(_0x294b0e,_0x453129){return function(_0x1b08b0){if(_0x1b08b0){return _0x1b08b0[_0xf2bc('0x26')](_0x294b0e)['then'](function(_0x20417e){return _0x20417e;});}return null;};}function removeEntity(_0x255d00,_0x212d67){return function(_0x3a8506){if(_0x3a8506){return _0x3a8506[_0xf2bc('0x27')]()['then'](function(){_0x255d00['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x598468,_0x4466fd){return function(_0x6d1ca){if(!_0x6d1ca){_0x598468['sendStatus'](0x194);}return _0x6d1ca;};}function handleError(_0x3b5cbb,_0x2ab897){_0x2ab897=_0x2ab897||0x1f4;return function(_0x1fefd6){logger[_0xf2bc('0x28')](_0x1fefd6['stack']);if(_0x1fefd6[_0xf2bc('0x29')]){delete _0x1fefd6['name'];}_0x3b5cbb['status'](_0x2ab897)[_0xf2bc('0x2a')](_0x1fefd6);};}exports[_0xf2bc('0x2b')]=function(_0x357095,_0x437343){var _0x298a7b={},_0x5d1a25={},_0x4714df={'count':0x0,'rows':[]};var _0x14dde3=_['map'](db[_0xf2bc('0x2c')][_0xf2bc('0x2d')],function(_0x3cbd08){return{'name':_0x3cbd08[_0xf2bc('0x2e')],'type':_0x3cbd08[_0xf2bc('0x2f')][_0xf2bc('0x30')]};});_0x5d1a25[_0xf2bc('0x31')]=_[_0xf2bc('0x32')](_0x14dde3,_0xf2bc('0x29'));_0x5d1a25[_0xf2bc('0x33')]=_[_0xf2bc('0x34')](_0x357095['query']);_0x5d1a25[_0xf2bc('0x35')]=_[_0xf2bc('0x36')](_0x5d1a25[_0xf2bc('0x31')],_0x5d1a25[_0xf2bc('0x33')]);_0x298a7b['attributes']=_[_0xf2bc('0x36')](_0x5d1a25[_0xf2bc('0x31')],qs[_0xf2bc('0x37')](_0x357095[_0xf2bc('0x33')][_0xf2bc('0x37')]));_0x298a7b['attributes']=_0x298a7b[_0xf2bc('0x38')][_0xf2bc('0x39')]?_0x298a7b['attributes']:_0x5d1a25['model'];if(!_0x357095[_0xf2bc('0x33')][_0xf2bc('0x3a')](_0xf2bc('0x3b'))){_0x298a7b[_0xf2bc('0x20')]=qs[_0xf2bc('0x20')](_0x357095[_0xf2bc('0x33')]['limit']);_0x298a7b[_0xf2bc('0x1f')]=qs[_0xf2bc('0x1f')](_0x357095[_0xf2bc('0x33')][_0xf2bc('0x1f')]);}_0x298a7b[_0xf2bc('0x3c')]=qs[_0xf2bc('0x3d')](_0x357095[_0xf2bc('0x33')][_0xf2bc('0x3d')]);_0x298a7b['where']=qs[_0xf2bc('0x35')](_[_0xf2bc('0x3e')](_0x357095[_0xf2bc('0x33')],_0x5d1a25[_0xf2bc('0x35')]),_0x14dde3);if(_0x357095['query'][_0xf2bc('0x3f')]){_0x298a7b[_0xf2bc('0x40')]=_[_0xf2bc('0x41')](_0x298a7b[_0xf2bc('0x40')],{'$or':_[_0xf2bc('0x32')](_0x14dde3,function(_0x34b06e){if(_0x34b06e[_0xf2bc('0x2f')]!==_0xf2bc('0x42')){var _0x178d4b={};_0x178d4b[_0x34b06e[_0xf2bc('0x29')]]={'$like':'%'+_0x357095[_0xf2bc('0x33')][_0xf2bc('0x3f')]+'%'};return _0x178d4b;}})});}_0x298a7b=_[_0xf2bc('0x41')]({},_0x298a7b,_0x357095[_0xf2bc('0x43')]);var _0x4ec48f={'where':_0x298a7b[_0xf2bc('0x40')]};return db[_0xf2bc('0x2c')]['count'](_0x4ec48f)[_0xf2bc('0x44')](function(_0x4c642b){_0x4714df['count']=_0x4c642b;if(_0x357095[_0xf2bc('0x33')]['includeAll']){_0x298a7b['include']=[{'all':!![]}];}return db[_0xf2bc('0x2c')]['findAll'](_0x298a7b);})[_0xf2bc('0x44')](function(_0x456dae){_0x4714df[_0xf2bc('0x45')]=_0x456dae;return _0x4714df;})[_0xf2bc('0x44')](respondWithFilteredResult(_0x437343,_0x298a7b))[_0xf2bc('0x46')](handleError(_0x437343,null));};exports[_0xf2bc('0x47')]=function(_0x2ce06c,_0x281215){var _0x573847={'raw':![],'where':{'id':_0x2ce06c[_0xf2bc('0x48')]['id']}},_0x1e94c7={};_0x1e94c7[_0xf2bc('0x31')]=_[_0xf2bc('0x34')](db['DeskAccount']['rawAttributes']);_0x1e94c7[_0xf2bc('0x33')]=_[_0xf2bc('0x34')](_0x2ce06c[_0xf2bc('0x33')]);_0x1e94c7[_0xf2bc('0x35')]=_[_0xf2bc('0x36')](_0x1e94c7[_0xf2bc('0x31')],_0x1e94c7[_0xf2bc('0x33')]);_0x573847[_0xf2bc('0x38')]=_[_0xf2bc('0x36')](_0x1e94c7[_0xf2bc('0x31')],qs['fields'](_0x2ce06c[_0xf2bc('0x33')][_0xf2bc('0x37')]));_0x573847[_0xf2bc('0x38')]=_0x573847[_0xf2bc('0x38')][_0xf2bc('0x39')]?_0x573847['attributes']:_0x1e94c7[_0xf2bc('0x31')];if(_0x2ce06c[_0xf2bc('0x33')][_0xf2bc('0x49')]){_0x573847['include']=[{'all':!![]}];}_0x573847=_[_0xf2bc('0x41')]({},_0x573847,_0x2ce06c[_0xf2bc('0x43')]);return db['DeskAccount'][_0xf2bc('0x4a')](_0x573847)[_0xf2bc('0x44')](handleEntityNotFound(_0x281215,null))[_0xf2bc('0x44')](respondWithResult(_0x281215,null))[_0xf2bc('0x46')](handleError(_0x281215,null));};exports['create']=function(_0x938628,_0xdfe0c6){return db[_0xf2bc('0x2c')][_0xf2bc('0x4b')](_0x938628[_0xf2bc('0x4c')],{})[_0xf2bc('0x44')](respondWithResult(_0xdfe0c6,0xc9))[_0xf2bc('0x46')](handleError(_0xdfe0c6,null));};exports[_0xf2bc('0x26')]=function(_0x380371,_0x51b641){if(_0x380371[_0xf2bc('0x4c')]['id']){delete _0x380371[_0xf2bc('0x4c')]['id'];}return db[_0xf2bc('0x2c')][_0xf2bc('0x4a')]({'where':{'id':_0x380371[_0xf2bc('0x48')]['id']}})[_0xf2bc('0x44')](handleEntityNotFound(_0x51b641,null))[_0xf2bc('0x44')](saveUpdates(_0x380371['body'],null))['then'](respondWithResult(_0x51b641,null))[_0xf2bc('0x46')](handleError(_0x51b641,null));};exports[_0xf2bc('0x27')]=function(_0x3cbf64,_0x308765){return db[_0xf2bc('0x2c')][_0xf2bc('0x4a')]({'where':{'id':_0x3cbf64[_0xf2bc('0x48')]['id']}})['then'](handleEntityNotFound(_0x308765,null))['then'](removeEntity(_0x308765,null))[_0xf2bc('0x46')](handleError(_0x308765,null));};exports[_0xf2bc('0x4d')]=function(_0x321f8c,_0x5ef482,_0x39075b){var _0x4bb49a={};var _0x301c88={};var _0x2fb607;var _0x1a8215;return db[_0xf2bc('0x2c')][_0xf2bc('0x4e')]({'where':{'id':_0x321f8c[_0xf2bc('0x48')]['id']}})[_0xf2bc('0x44')](handleEntityNotFound(_0x5ef482,null))['then'](function(_0x272cb3){if(_0x272cb3){_0x2fb607=_0x272cb3;_0x301c88[_0xf2bc('0x31')]=_['keys'](db[_0xf2bc('0x4f')][_0xf2bc('0x2d')]);_0x301c88[_0xf2bc('0x33')]=_[_0xf2bc('0x34')](_0x321f8c[_0xf2bc('0x33')]);_0x301c88[_0xf2bc('0x35')]=_[_0xf2bc('0x36')](_0x301c88[_0xf2bc('0x31')],_0x301c88['query']);_0x4bb49a[_0xf2bc('0x38')]=_[_0xf2bc('0x36')](_0x301c88['model'],qs[_0xf2bc('0x37')](_0x321f8c['query'][_0xf2bc('0x37')]));_0x4bb49a[_0xf2bc('0x38')]=_0x4bb49a[_0xf2bc('0x38')][_0xf2bc('0x39')]?_0x4bb49a['attributes']:_0x301c88[_0xf2bc('0x31')];_0x4bb49a[_0xf2bc('0x3c')]=qs[_0xf2bc('0x3d')](_0x321f8c[_0xf2bc('0x33')]['sort']);_0x4bb49a['where']=qs['filters'](_[_0xf2bc('0x3e')](_0x321f8c['query'],_0x301c88[_0xf2bc('0x35')]));if(_0x321f8c[_0xf2bc('0x33')][_0xf2bc('0x3f')]){_0x4bb49a[_0xf2bc('0x40')]=_['merge'](_0x4bb49a['where'],{'$or':_[_0xf2bc('0x32')](_0x4bb49a[_0xf2bc('0x38')],function(_0x3ef723){var _0x50010f={};_0x50010f[_0x3ef723]={'$like':'%'+_0x321f8c[_0xf2bc('0x33')]['filter']+'%'};return _0x50010f;})});}_0x4bb49a=_[_0xf2bc('0x41')]({},_0x4bb49a,_0x321f8c['options']);return _0x2fb607['getConfigurations'](_0x4bb49a);}})[_0xf2bc('0x44')](function(_0x2c973f){if(_0x2c973f){_0x1a8215=_0x2c973f['length'];if(!_0x321f8c[_0xf2bc('0x33')][_0xf2bc('0x3a')]('nolimit')){_0x4bb49a['limit']=qs[_0xf2bc('0x20')](_0x321f8c[_0xf2bc('0x33')]['limit']);_0x4bb49a['offset']=qs[_0xf2bc('0x1f')](_0x321f8c[_0xf2bc('0x33')][_0xf2bc('0x1f')]);}return _0x2fb607[_0xf2bc('0x4d')](_0x4bb49a);}})['then'](function(_0x42a1de){if(_0x42a1de){return _0x42a1de?{'count':_0x1a8215,'rows':_0x42a1de}:null;}})['then'](respondWithResult(_0x5ef482,null))[_0xf2bc('0x46')](handleError(_0x5ef482,null));};exports['addConfiguration']=function(_0x5285d6,_0x584f8b,_0x2be745){if(_0x5285d6[_0xf2bc('0x4c')]['id']){delete _0x5285d6[_0xf2bc('0x4c')]['id'];}return db[_0xf2bc('0x2c')][_0xf2bc('0x4e')]({'where':{'id':_0x5285d6[_0xf2bc('0x48')]['id']}})[_0xf2bc('0x44')](handleEntityNotFound(_0x584f8b,null))[_0xf2bc('0x44')](function(_0x4796d8){if(_0x4796d8){_0x5285d6[_0xf2bc('0x4c')][_0xf2bc('0x50')]=_0x4796d8['id'];_0x5285d6[_0xf2bc('0x4c')]['Subjects']=integrations['getSubjects'](_0x5285d6[_0xf2bc('0x4c')]['channel'],_0x5285d6[_0xf2bc('0x4c')][_0xf2bc('0x2f')]);_0x5285d6[_0xf2bc('0x4c')][_0xf2bc('0x51')]=integrations[_0xf2bc('0x52')](_0x5285d6[_0xf2bc('0x4c')][_0xf2bc('0x53')],_0x5285d6['body'][_0xf2bc('0x2f')]);return db['DeskConfiguration']['create'](_0x5285d6[_0xf2bc('0x4c')],{'include':[{'model':db['DeskField'],'as':_0xf2bc('0x54')},{'model':db[_0xf2bc('0x55')],'as':'Descriptions'}]});}return null;})[_0xf2bc('0x44')](respondWithResult(_0x584f8b,null))[_0xf2bc('0x46')](handleError(_0x584f8b,null));};exports[_0xf2bc('0x56')]=function(_0x1bca07,_0x19179c,_0x1a3a63){var _0x100597=[{'name':_0xf2bc('0x57'),'label':'priority','custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x52d02d='';return db[_0xf2bc('0x2c')][_0xf2bc('0x4e')]({'where':{'id':_0x1bca07['params']['id']},'attributes':['id',_0xf2bc('0x58'),_0xf2bc('0x59'),_0xf2bc('0x5a'),_0xf2bc('0x5b'),_0xf2bc('0x5c'),_0xf2bc('0x5d'),_0xf2bc('0x5e'),'tokenSecret']})[_0xf2bc('0x44')](handleEntityNotFound(_0x19179c,null))[_0xf2bc('0x44')](function(_0x206a1d){if(_0x206a1d){_0x52d02d=_0x206a1d[_0xf2bc('0x58')];var _0x360601=_0x52d02d[_0xf2bc('0x5f')](-0x1);if(_0x360601==='/'){_0x52d02d=_0x52d02d[_0xf2bc('0x60')](0x0,_0x52d02d[_0xf2bc('0x61')](_0x360601));}var _0x1c864e={'method':_0xf2bc('0x62'),'uri':util[_0xf2bc('0x63')](_0xf2bc('0x64'),_0x52d02d),'headers':{'Content-Type':_0xf2bc('0x65'),'Accept':'application/json'},'json':!![]};if(_0x206a1d[_0xf2bc('0x59')]===_0xf2bc('0x66')){_0x1c864e['headers'][_0xf2bc('0x67')]=util['format'](_0xf2bc('0x68'),new Buffer(util[_0xf2bc('0x63')](_0xf2bc('0x69'),_0x206a1d[_0xf2bc('0x5a')],_0x206a1d[_0xf2bc('0x5b')]))['toString'](_0xf2bc('0x6a')));}return rp(_0x1c864e)[_0xf2bc('0x44')](function(_0x5e200f){return _0x100597[_0xf2bc('0x6b')](_[_0xf2bc('0x32')](_0x5e200f[_0xf2bc('0x6c')][_0xf2bc('0x6d')],function(_0x5ec0e5){return{'id':_0x5ec0e5[_0xf2bc('0x29')],'name':_0x5ec0e5[_0xf2bc('0x29')],'type':_0x5ec0e5['type'],'active':_0x5ec0e5[_0xf2bc('0x6e')],'label':_0x5ec0e5[_0xf2bc('0x6f')],'custom':!![]};}));});}})[_0xf2bc('0x44')](function(_0x2bd746){return{'count':_0x2bd746[_0xf2bc('0x39')],'rows':_0x2bd746};})[_0xf2bc('0x44')](respondWithResult(_0x19179c,null))[_0xf2bc('0x46')](function(_0x295a75){var _0x3d1e71=_0x1bca07[_0xf2bc('0x33')][_0xf2bc('0x70')]?0x1f4:_0x295a75[_0xf2bc('0x71')]||0x1f4;logger[_0xf2bc('0x28')](_0xf2bc('0x72'),_0xf2bc('0x56'),_0x3d1e71,JSON['stringify'](_0x295a75));delete _0x295a75[_0xf2bc('0x29')];if(_0x3d1e71===0x191){_0x3d1e71=0x190;}_0x19179c[_0xf2bc('0x1c')](_0x3d1e71)['send'](_0x1bca07['query'][_0xf2bc('0x70')]?{'message':'Wrong\x20credentials','statusCode':_0x295a75[_0xf2bc('0x71')]}:_0x295a75);});};
\ No newline at end of file