Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index f7e335e..5e57ca9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9749=['fields','length','hasOwnProperty','nolimit','order','sort','where','filters','merge','map','type','VIRTUAL','filter','options','DeskAccount','include','findAll','rows','rawAttributes','includeAll','find','body','params','getConfigurations','findOne','DeskConfiguration','pick','catch','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','create','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','token','tokenSecret','slice','substring','lastIndexOf','format','%s/custom_fields','application/json','headers','Authorization','Basic\x20%s','%s:%s','base64','_embedded','entries','active','label','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','update','destroy','then','error','name','send','index','fieldName','key','model','query','keys','attributes','intersection'];(function(_0xeddf5,_0x428c05){var _0x54f012=function(_0x1170d2){while(--_0x1170d2){_0xeddf5['push'](_0xeddf5['shift']());}};_0x54f012(++_0x428c05);}(_0x9749,0x137));var _0x9974=function(_0x4fee26,_0x1119dc){_0x4fee26=_0x4fee26-0x0;var _0x4f72d5=_0x9749[_0x4fee26];return _0x4f72d5;};'use strict';var emlformat=require(_0x9974('0x0'));var rimraf=require(_0x9974('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x9974('0x2'));var rp=require(_0x9974('0x3'));var moment=require(_0x9974('0x4'));var BPromise=require(_0x9974('0x5'));var Mustache=require(_0x9974('0x6'));var util=require(_0x9974('0x7'));var path=require(_0x9974('0x8'));var sox=require(_0x9974('0x9'));var csv=require(_0x9974('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9974('0xb'));var _=require(_0x9974('0xc'));var squel=require(_0x9974('0xd'));var crypto=require(_0x9974('0xe'));var jsforce=require(_0x9974('0xf'));var deskjs=require(_0x9974('0x10'));var toCsv=require(_0x9974('0xa'));var querystring=require(_0x9974('0x11'));var Papa=require(_0x9974('0x12'));var Redis=require(_0x9974('0x13'));var authService=require(_0x9974('0x14'));var qs=require(_0x9974('0x15'));var as=require(_0x9974('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9974('0x17'))(_0x9974('0x18'));var utils=require(_0x9974('0x19'));var config=require(_0x9974('0x1a'));var licenseUtil=require('../../config/license/util');var db=require(_0x9974('0x1b'))['db'];var integrations=require(_0x9974('0x1c'));function respondWithStatusCode(_0x37c96c,_0x382df9){_0x382df9=_0x382df9||0xcc;return function(_0x245d83){if(_0x245d83){return _0x37c96c[_0x9974('0x1d')](_0x382df9);}return _0x37c96c[_0x9974('0x1e')](_0x382df9)[_0x9974('0x1f')]();};}function respondWithResult(_0x49670f,_0x3a1cea){_0x3a1cea=_0x3a1cea||0xc8;return function(_0x3b964f){if(_0x3b964f){return _0x49670f[_0x9974('0x1e')](_0x3a1cea)[_0x9974('0x20')](_0x3b964f);}};}function respondWithFilteredResult(_0x3da125,_0xa3a291){return function(_0x5a9523){if(_0x5a9523){var _0x13d579=typeof _0xa3a291[_0x9974('0x21')]===_0x9974('0x22')&&typeof _0xa3a291['limit']===_0x9974('0x22');var _0x1c0943=_0x5a9523[_0x9974('0x23')];var _0x1e68e1=_0x13d579?0x0:_0xa3a291[_0x9974('0x21')];var _0x165db6=_0x13d579?_0x5a9523[_0x9974('0x23')]:_0xa3a291['offset']+_0xa3a291[_0x9974('0x24')];var _0x1a67e3;if(_0x165db6>=_0x1c0943){_0x165db6=_0x1c0943;_0x1a67e3=0xc8;}else{_0x1a67e3=0xce;}_0x3da125[_0x9974('0x1e')](_0x1a67e3);return _0x3da125[_0x9974('0x25')](_0x9974('0x26'),_0x1e68e1+'-'+_0x165db6+'/'+_0x1c0943)[_0x9974('0x20')](_0x5a9523);}return null;};}function patchUpdates(_0x2ff7a5){return function(_0x27998e){try{jsonpatch[_0x9974('0x27')](_0x27998e,_0x2ff7a5,!![]);}catch(_0x31adb9){return BPromise[_0x9974('0x28')](_0x31adb9);}return _0x27998e['save']();};}function saveUpdates(_0x119cae,_0x598303){return function(_0x2182c5){if(_0x2182c5){return _0x2182c5[_0x9974('0x29')](_0x119cae)['then'](function(_0x734b9b){return _0x734b9b;});}return null;};}function removeEntity(_0x26b4af,_0x6c84cd){return function(_0x1c4599){if(_0x1c4599){return _0x1c4599[_0x9974('0x2a')]()[_0x9974('0x2b')](function(){_0x26b4af['status'](0xcc)[_0x9974('0x1f')]();});}};}function handleEntityNotFound(_0x504225,_0x1f5c44){return function(_0x11624b){if(!_0x11624b){_0x504225[_0x9974('0x1d')](0x194);}return _0x11624b;};}function handleError(_0x463363,_0x1acf20){_0x1acf20=_0x1acf20||0x1f4;return function(_0x8495c6){logger[_0x9974('0x2c')](_0x8495c6['stack']);if(_0x8495c6[_0x9974('0x2d')]){delete _0x8495c6[_0x9974('0x2d')];}_0x463363[_0x9974('0x1e')](_0x1acf20)[_0x9974('0x2e')](_0x8495c6);};}exports[_0x9974('0x2f')]=function(_0x4cb4a4,_0x27ce10){var _0x132823={},_0x298f6c={},_0x1fbb16={'count':0x0,'rows':[]};var _0x38fb56=_['map'](db['DeskAccount']['rawAttributes'],function(_0x7622d7){return{'name':_0x7622d7[_0x9974('0x30')],'type':_0x7622d7['type'][_0x9974('0x31')]};});_0x298f6c[_0x9974('0x32')]=_['map'](_0x38fb56,'name');_0x298f6c[_0x9974('0x33')]=_[_0x9974('0x34')](_0x4cb4a4['query']);_0x298f6c['filters']=_['intersection'](_0x298f6c[_0x9974('0x32')],_0x298f6c[_0x9974('0x33')]);_0x132823[_0x9974('0x35')]=_[_0x9974('0x36')](_0x298f6c[_0x9974('0x32')],qs[_0x9974('0x37')](_0x4cb4a4['query'][_0x9974('0x37')]));_0x132823[_0x9974('0x35')]=_0x132823[_0x9974('0x35')][_0x9974('0x38')]?_0x132823['attributes']:_0x298f6c['model'];if(!_0x4cb4a4['query'][_0x9974('0x39')](_0x9974('0x3a'))){_0x132823[_0x9974('0x24')]=qs[_0x9974('0x24')](_0x4cb4a4[_0x9974('0x33')]['limit']);_0x132823['offset']=qs[_0x9974('0x21')](_0x4cb4a4[_0x9974('0x33')][_0x9974('0x21')]);}_0x132823[_0x9974('0x3b')]=qs[_0x9974('0x3c')](_0x4cb4a4[_0x9974('0x33')]['sort']);_0x132823[_0x9974('0x3d')]=qs[_0x9974('0x3e')](_['pick'](_0x4cb4a4[_0x9974('0x33')],_0x298f6c['filters']),_0x38fb56);if(_0x4cb4a4[_0x9974('0x33')]['filter']){_0x132823['where']=_[_0x9974('0x3f')](_0x132823[_0x9974('0x3d')],{'$or':_[_0x9974('0x40')](_0x38fb56,function(_0x3b3554){if(_0x3b3554[_0x9974('0x41')]!==_0x9974('0x42')){var _0x31d117={};_0x31d117[_0x3b3554[_0x9974('0x2d')]]={'$like':'%'+_0x4cb4a4['query'][_0x9974('0x43')]+'%'};return _0x31d117;}})});}_0x132823=_[_0x9974('0x3f')]({},_0x132823,_0x4cb4a4[_0x9974('0x44')]);var _0xc19c9f={'where':_0x132823['where']};return db[_0x9974('0x45')][_0x9974('0x23')](_0xc19c9f)['then'](function(_0x1ad9b6){_0x1fbb16[_0x9974('0x23')]=_0x1ad9b6;if(_0x4cb4a4[_0x9974('0x33')]['includeAll']){_0x132823[_0x9974('0x46')]=[{'all':!![]}];}return db[_0x9974('0x45')][_0x9974('0x47')](_0x132823);})[_0x9974('0x2b')](function(_0xf06689){_0x1fbb16[_0x9974('0x48')]=_0xf06689;return _0x1fbb16;})[_0x9974('0x2b')](respondWithFilteredResult(_0x27ce10,_0x132823))['catch'](handleError(_0x27ce10,null));};exports['show']=function(_0x554dc0,_0x5b95df){var _0x117a9e={'raw':![],'where':{'id':_0x554dc0['params']['id']}},_0x2c8613={};_0x2c8613[_0x9974('0x32')]=_['keys'](db[_0x9974('0x45')][_0x9974('0x49')]);_0x2c8613[_0x9974('0x33')]=_[_0x9974('0x34')](_0x554dc0[_0x9974('0x33')]);_0x2c8613[_0x9974('0x3e')]=_[_0x9974('0x36')](_0x2c8613[_0x9974('0x32')],_0x2c8613[_0x9974('0x33')]);_0x117a9e[_0x9974('0x35')]=_['intersection'](_0x2c8613[_0x9974('0x32')],qs['fields'](_0x554dc0[_0x9974('0x33')][_0x9974('0x37')]));_0x117a9e[_0x9974('0x35')]=_0x117a9e[_0x9974('0x35')]['length']?_0x117a9e[_0x9974('0x35')]:_0x2c8613[_0x9974('0x32')];if(_0x554dc0[_0x9974('0x33')][_0x9974('0x4a')]){_0x117a9e[_0x9974('0x46')]=[{'all':!![]}];}_0x117a9e=_[_0x9974('0x3f')]({},_0x117a9e,_0x554dc0['options']);return db[_0x9974('0x45')][_0x9974('0x4b')](_0x117a9e)['then'](handleEntityNotFound(_0x5b95df,null))['then'](respondWithResult(_0x5b95df,null))['catch'](handleError(_0x5b95df,null));};exports['create']=function(_0x3cab27,_0x239906){return db[_0x9974('0x45')]['create'](_0x3cab27[_0x9974('0x4c')],{})[_0x9974('0x2b')](respondWithResult(_0x239906,0xc9))['catch'](handleError(_0x239906,null));};exports['update']=function(_0x3420bb,_0x2cec14){if(_0x3420bb[_0x9974('0x4c')]['id']){delete _0x3420bb[_0x9974('0x4c')]['id'];}return db['DeskAccount']['find']({'where':{'id':_0x3420bb[_0x9974('0x4d')]['id']}})[_0x9974('0x2b')](handleEntityNotFound(_0x2cec14,null))[_0x9974('0x2b')](saveUpdates(_0x3420bb[_0x9974('0x4c')],null))['then'](respondWithResult(_0x2cec14,null))['catch'](handleError(_0x2cec14,null));};exports[_0x9974('0x2a')]=function(_0x3edf72,_0xb20ed8){return db['DeskAccount'][_0x9974('0x4b')]({'where':{'id':_0x3edf72[_0x9974('0x4d')]['id']}})[_0x9974('0x2b')](handleEntityNotFound(_0xb20ed8,null))[_0x9974('0x2b')](removeEntity(_0xb20ed8,null))['catch'](handleError(_0xb20ed8,null));};exports[_0x9974('0x4e')]=function(_0x54ee9e,_0x2efdef,_0xaf8515){var _0x4afbd8={};var _0x4672fb={};var _0x3fd70f;var _0x1a47c9;return db['DeskAccount'][_0x9974('0x4f')]({'where':{'id':_0x54ee9e['params']['id']}})['then'](handleEntityNotFound(_0x2efdef,null))[_0x9974('0x2b')](function(_0x24a442){if(_0x24a442){_0x3fd70f=_0x24a442;_0x4672fb[_0x9974('0x32')]=_[_0x9974('0x34')](db[_0x9974('0x50')][_0x9974('0x49')]);_0x4672fb['query']=_[_0x9974('0x34')](_0x54ee9e[_0x9974('0x33')]);_0x4672fb[_0x9974('0x3e')]=_[_0x9974('0x36')](_0x4672fb[_0x9974('0x32')],_0x4672fb[_0x9974('0x33')]);_0x4afbd8[_0x9974('0x35')]=_[_0x9974('0x36')](_0x4672fb[_0x9974('0x32')],qs[_0x9974('0x37')](_0x54ee9e[_0x9974('0x33')]['fields']));_0x4afbd8[_0x9974('0x35')]=_0x4afbd8['attributes'][_0x9974('0x38')]?_0x4afbd8[_0x9974('0x35')]:_0x4672fb['model'];_0x4afbd8['order']=qs[_0x9974('0x3c')](_0x54ee9e[_0x9974('0x33')][_0x9974('0x3c')]);_0x4afbd8[_0x9974('0x3d')]=qs['filters'](_[_0x9974('0x51')](_0x54ee9e[_0x9974('0x33')],_0x4672fb[_0x9974('0x3e')]));if(_0x54ee9e[_0x9974('0x33')][_0x9974('0x43')]){_0x4afbd8[_0x9974('0x3d')]=_[_0x9974('0x3f')](_0x4afbd8[_0x9974('0x3d')],{'$or':_[_0x9974('0x40')](_0x4afbd8[_0x9974('0x35')],function(_0x4cb8e2){var _0x183d29={};_0x183d29[_0x4cb8e2]={'$like':'%'+_0x54ee9e[_0x9974('0x33')][_0x9974('0x43')]+'%'};return _0x183d29;})});}_0x4afbd8=_[_0x9974('0x3f')]({},_0x4afbd8,_0x54ee9e[_0x9974('0x44')]);return _0x3fd70f[_0x9974('0x4e')](_0x4afbd8);}})[_0x9974('0x2b')](function(_0x9f3a4){if(_0x9f3a4){_0x1a47c9=_0x9f3a4[_0x9974('0x38')];if(!_0x54ee9e[_0x9974('0x33')][_0x9974('0x39')]('nolimit')){_0x4afbd8[_0x9974('0x24')]=qs[_0x9974('0x24')](_0x54ee9e[_0x9974('0x33')][_0x9974('0x24')]);_0x4afbd8['offset']=qs['offset'](_0x54ee9e[_0x9974('0x33')][_0x9974('0x21')]);}return _0x3fd70f[_0x9974('0x4e')](_0x4afbd8);}})[_0x9974('0x2b')](function(_0x28f95a){if(_0x28f95a){return _0x28f95a?{'count':_0x1a47c9,'rows':_0x28f95a}:null;}})['then'](respondWithResult(_0x2efdef,null))[_0x9974('0x52')](handleError(_0x2efdef,null));};exports[_0x9974('0x53')]=function(_0x200280,_0x469860,_0xa78008){if(_0x200280[_0x9974('0x4c')]['id']){delete _0x200280['body']['id'];}return db[_0x9974('0x45')][_0x9974('0x4f')]({'where':{'id':_0x200280[_0x9974('0x4d')]['id']}})[_0x9974('0x2b')](handleEntityNotFound(_0x469860,null))[_0x9974('0x2b')](function(_0x2be4c2){if(_0x2be4c2){_0x200280[_0x9974('0x4c')][_0x9974('0x54')]=_0x2be4c2['id'];_0x200280[_0x9974('0x4c')][_0x9974('0x55')]=integrations[_0x9974('0x56')](_0x200280['body'][_0x9974('0x57')],_0x200280[_0x9974('0x4c')][_0x9974('0x41')]);_0x200280['body'][_0x9974('0x58')]=integrations[_0x9974('0x59')](_0x200280['body'][_0x9974('0x57')],_0x200280['body'][_0x9974('0x41')]);return db['DeskConfiguration'][_0x9974('0x5a')](_0x200280[_0x9974('0x4c')],{'include':[{'model':db['DeskField'],'as':_0x9974('0x55')},{'model':db[_0x9974('0x5b')],'as':_0x9974('0x58')}]});}return null;})[_0x9974('0x2b')](respondWithResult(_0x469860,null))[_0x9974('0x52')](handleError(_0x469860,null));};exports[_0x9974('0x5c')]=function(_0xdbf8b0,_0x27a6a9,_0x5364f0){var _0x697da3=[{'name':_0x9974('0x5d'),'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 _0x1138e9='';return db[_0x9974('0x45')][_0x9974('0x4f')]({'where':{'id':_0xdbf8b0[_0x9974('0x4d')]['id']},'attributes':['id',_0x9974('0x5e'),_0x9974('0x5f'),_0x9974('0x60'),_0x9974('0x61'),_0x9974('0x62'),_0x9974('0x63'),_0x9974('0x64'),_0x9974('0x65')]})[_0x9974('0x2b')](handleEntityNotFound(_0x27a6a9,null))[_0x9974('0x2b')](function(_0x2a1c39){if(_0x2a1c39){_0x1138e9=_0x2a1c39[_0x9974('0x5e')];var _0x14235e=_0x1138e9[_0x9974('0x66')](-0x1);if(_0x14235e==='/'){_0x1138e9=_0x1138e9[_0x9974('0x67')](0x0,_0x1138e9[_0x9974('0x68')](_0x14235e));}var _0x5030ee={'method':'GET','uri':util[_0x9974('0x69')](_0x9974('0x6a'),_0x1138e9),'headers':{'Content-Type':_0x9974('0x6b'),'Accept':_0x9974('0x6b')},'json':!![]};if(_0x2a1c39[_0x9974('0x5f')]==='basic'){_0x5030ee[_0x9974('0x6c')][_0x9974('0x6d')]=util['format'](_0x9974('0x6e'),new Buffer(util[_0x9974('0x69')](_0x9974('0x6f'),_0x2a1c39[_0x9974('0x60')],_0x2a1c39[_0x9974('0x61')]))['toString'](_0x9974('0x70')));}return rp(_0x5030ee)[_0x9974('0x2b')](function(_0x3356b0){return _0x697da3['concat'](_[_0x9974('0x40')](_0x3356b0[_0x9974('0x71')][_0x9974('0x72')],function(_0xb9defd){return{'id':_0xb9defd[_0x9974('0x2d')],'name':_0xb9defd[_0x9974('0x2d')],'type':_0xb9defd['type'],'active':_0xb9defd[_0x9974('0x73')],'label':_0xb9defd[_0x9974('0x74')],'custom':!![]};}));});}})[_0x9974('0x2b')](function(_0x5dd16a){return{'count':_0x5dd16a[_0x9974('0x38')],'rows':_0x5dd16a};})[_0x9974('0x2b')](respondWithResult(_0x27a6a9,null))[_0x9974('0x52')](function(_0x6237af){var _0x2c5d07=_0xdbf8b0[_0x9974('0x33')][_0x9974('0x75')]?0x1f4:_0x6237af[_0x9974('0x76')]||0x1f4;logger[_0x9974('0x2c')](_0x9974('0x77'),_0x9974('0x5c'),_0x2c5d07,JSON[_0x9974('0x78')](_0x6237af));delete _0x6237af[_0x9974('0x2d')];if(_0x2c5d07===0x191){_0x2c5d07=0x190;}_0x27a6a9['status'](_0x2c5d07)[_0x9974('0x2e')](_0xdbf8b0['query']['test']?{'message':_0x9974('0x79'),'statusCode':_0x6237af[_0x9974('0x76')]}:_0x6237af);});};
\ No newline at end of file
+var _0xfa79=['apply','reject','save','update','destroy','then','error','stack','name','send','index','map','DeskAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','find','create','body','getConfigurations','findOne','sort','addConfiguration','AccountId','channel','getDescriptions','DeskConfiguration','Descriptions','getFields','priority','remoteUri','password','consumerKey','consumerSecret','token','slice','lastIndexOf','GET','format','%s/custom_fields','application/json','authType','basic','headers','Authorization','Basic\x20%s','%s:%s','username','toString','base64','concat','_embedded','entries','active','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range'];(function(_0x5465e6,_0x2a8809){var _0x10044e=function(_0x1d5dcd){while(--_0x1d5dcd){_0x5465e6['push'](_0x5465e6['shift']());}};_0x10044e(++_0x2a8809);}(_0xfa79,0x1b2));var _0x9fa7=function(_0x450a7e,_0x39ca8b){_0x450a7e=_0x450a7e-0x0;var _0x42c4c4=_0xfa79[_0x450a7e];return _0x42c4c4;};'use strict';var emlformat=require(_0x9fa7('0x0'));var rimraf=require(_0x9fa7('0x1'));var zipdir=require(_0x9fa7('0x2'));var jsonpatch=require(_0x9fa7('0x3'));var rp=require(_0x9fa7('0x4'));var moment=require('moment');var BPromise=require(_0x9fa7('0x5'));var Mustache=require(_0x9fa7('0x6'));var util=require('util');var path=require(_0x9fa7('0x7'));var sox=require(_0x9fa7('0x8'));var csv=require(_0x9fa7('0x9'));var ejs=require(_0x9fa7('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9fa7('0xb'));var squel=require(_0x9fa7('0xc'));var crypto=require(_0x9fa7('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x9fa7('0xe'));var toCsv=require(_0x9fa7('0x9'));var querystring=require('querystring');var Papa=require(_0x9fa7('0xf'));var Redis=require(_0x9fa7('0x10'));var authService=require(_0x9fa7('0x11'));var qs=require(_0x9fa7('0x12'));var as=require(_0x9fa7('0x13'));var hardwareService=require(_0x9fa7('0x14'));var logger=require(_0x9fa7('0x15'))(_0x9fa7('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x9fa7('0x17'));var db=require('../../mysqldb')['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x161926,_0xec8176){_0xec8176=_0xec8176||0xcc;return function(_0x5bd783){if(_0x5bd783){return _0x161926[_0x9fa7('0x18')](_0xec8176);}return _0x161926[_0x9fa7('0x19')](_0xec8176)[_0x9fa7('0x1a')]();};}function respondWithResult(_0x4ef89f,_0x536cca){_0x536cca=_0x536cca||0xc8;return function(_0x53746f){if(_0x53746f){return _0x4ef89f[_0x9fa7('0x19')](_0x536cca)[_0x9fa7('0x1b')](_0x53746f);}};}function respondWithFilteredResult(_0x5a57d9,_0x11e85b){return function(_0x436901){if(_0x436901){var _0x54eb09=typeof _0x11e85b[_0x9fa7('0x1c')]==='undefined'&&typeof _0x11e85b[_0x9fa7('0x1d')]===_0x9fa7('0x1e');var _0x4f8d5c=_0x436901[_0x9fa7('0x1f')];var _0x2fee26=_0x54eb09?0x0:_0x11e85b[_0x9fa7('0x1c')];var _0x2e1a24=_0x54eb09?_0x436901[_0x9fa7('0x1f')]:_0x11e85b[_0x9fa7('0x1c')]+_0x11e85b[_0x9fa7('0x1d')];var _0x505b16;if(_0x2e1a24>=_0x4f8d5c){_0x2e1a24=_0x4f8d5c;_0x505b16=0xc8;}else{_0x505b16=0xce;}_0x5a57d9[_0x9fa7('0x19')](_0x505b16);return _0x5a57d9[_0x9fa7('0x20')](_0x9fa7('0x21'),_0x2fee26+'-'+_0x2e1a24+'/'+_0x4f8d5c)['json'](_0x436901);}return null;};}function patchUpdates(_0x1d82c6){return function(_0x2c028a){try{jsonpatch[_0x9fa7('0x22')](_0x2c028a,_0x1d82c6,!![]);}catch(_0xad7005){return BPromise[_0x9fa7('0x23')](_0xad7005);}return _0x2c028a[_0x9fa7('0x24')]();};}function saveUpdates(_0x396552,_0x4eb861){return function(_0x98fa19){if(_0x98fa19){return _0x98fa19[_0x9fa7('0x25')](_0x396552)['then'](function(_0x56e705){return _0x56e705;});}return null;};}function removeEntity(_0x41cfd0,_0x239f2d){return function(_0x5d0a4b){if(_0x5d0a4b){return _0x5d0a4b[_0x9fa7('0x26')]()[_0x9fa7('0x27')](function(){_0x41cfd0['status'](0xcc)[_0x9fa7('0x1a')]();});}};}function handleEntityNotFound(_0x4c1378,_0x1dc989){return function(_0x2cedfc){if(!_0x2cedfc){_0x4c1378['sendStatus'](0x194);}return _0x2cedfc;};}function handleError(_0x55f792,_0x5f548f){_0x5f548f=_0x5f548f||0x1f4;return function(_0x252879){logger[_0x9fa7('0x28')](_0x252879[_0x9fa7('0x29')]);if(_0x252879[_0x9fa7('0x2a')]){delete _0x252879[_0x9fa7('0x2a')];}_0x55f792[_0x9fa7('0x19')](_0x5f548f)[_0x9fa7('0x2b')](_0x252879);};}exports[_0x9fa7('0x2c')]=function(_0x5f013a,_0x430824){var _0x1600e6={},_0x5d03cc={},_0x147b21={'count':0x0,'rows':[]};var _0xa69820=_[_0x9fa7('0x2d')](db[_0x9fa7('0x2e')][_0x9fa7('0x2f')],function(_0x2a801b){return{'name':_0x2a801b[_0x9fa7('0x30')],'type':_0x2a801b[_0x9fa7('0x31')]['key']};});_0x5d03cc[_0x9fa7('0x32')]=_[_0x9fa7('0x2d')](_0xa69820,'name');_0x5d03cc[_0x9fa7('0x33')]=_[_0x9fa7('0x34')](_0x5f013a[_0x9fa7('0x33')]);_0x5d03cc[_0x9fa7('0x35')]=_[_0x9fa7('0x36')](_0x5d03cc[_0x9fa7('0x32')],_0x5d03cc[_0x9fa7('0x33')]);_0x1600e6['attributes']=_['intersection'](_0x5d03cc[_0x9fa7('0x32')],qs[_0x9fa7('0x37')](_0x5f013a[_0x9fa7('0x33')][_0x9fa7('0x37')]));_0x1600e6[_0x9fa7('0x38')]=_0x1600e6[_0x9fa7('0x38')][_0x9fa7('0x39')]?_0x1600e6[_0x9fa7('0x38')]:_0x5d03cc[_0x9fa7('0x32')];if(!_0x5f013a['query'][_0x9fa7('0x3a')](_0x9fa7('0x3b'))){_0x1600e6[_0x9fa7('0x1d')]=qs['limit'](_0x5f013a[_0x9fa7('0x33')][_0x9fa7('0x1d')]);_0x1600e6[_0x9fa7('0x1c')]=qs['offset'](_0x5f013a[_0x9fa7('0x33')][_0x9fa7('0x1c')]);}_0x1600e6[_0x9fa7('0x3c')]=qs['sort'](_0x5f013a['query']['sort']);_0x1600e6[_0x9fa7('0x3d')]=qs['filters'](_[_0x9fa7('0x3e')](_0x5f013a['query'],_0x5d03cc[_0x9fa7('0x35')]),_0xa69820);if(_0x5f013a[_0x9fa7('0x33')][_0x9fa7('0x3f')]){_0x1600e6[_0x9fa7('0x3d')]=_[_0x9fa7('0x40')](_0x1600e6[_0x9fa7('0x3d')],{'$or':_[_0x9fa7('0x2d')](_0xa69820,function(_0x2158ff){if(_0x2158ff['type']!==_0x9fa7('0x41')){var _0x4dfe65={};_0x4dfe65[_0x2158ff[_0x9fa7('0x2a')]]={'$like':'%'+_0x5f013a[_0x9fa7('0x33')][_0x9fa7('0x3f')]+'%'};return _0x4dfe65;}})});}_0x1600e6=_[_0x9fa7('0x40')]({},_0x1600e6,_0x5f013a[_0x9fa7('0x42')]);var _0x53378b={'where':_0x1600e6['where']};return db[_0x9fa7('0x2e')]['count'](_0x53378b)[_0x9fa7('0x27')](function(_0x17a76c){_0x147b21[_0x9fa7('0x1f')]=_0x17a76c;if(_0x5f013a[_0x9fa7('0x33')][_0x9fa7('0x43')]){_0x1600e6[_0x9fa7('0x44')]=[{'all':!![]}];}return db[_0x9fa7('0x2e')][_0x9fa7('0x45')](_0x1600e6);})[_0x9fa7('0x27')](function(_0x3e3a2a){_0x147b21['rows']=_0x3e3a2a;return _0x147b21;})[_0x9fa7('0x27')](respondWithFilteredResult(_0x430824,_0x1600e6))[_0x9fa7('0x46')](handleError(_0x430824,null));};exports[_0x9fa7('0x47')]=function(_0x10003a,_0x817c77){var _0x47116b={'raw':![],'where':{'id':_0x10003a[_0x9fa7('0x48')]['id']}},_0x186c89={};_0x186c89[_0x9fa7('0x32')]=_['keys'](db[_0x9fa7('0x2e')][_0x9fa7('0x2f')]);_0x186c89[_0x9fa7('0x33')]=_['keys'](_0x10003a[_0x9fa7('0x33')]);_0x186c89[_0x9fa7('0x35')]=_[_0x9fa7('0x36')](_0x186c89[_0x9fa7('0x32')],_0x186c89['query']);_0x47116b[_0x9fa7('0x38')]=_[_0x9fa7('0x36')](_0x186c89[_0x9fa7('0x32')],qs[_0x9fa7('0x37')](_0x10003a[_0x9fa7('0x33')][_0x9fa7('0x37')]));_0x47116b['attributes']=_0x47116b[_0x9fa7('0x38')][_0x9fa7('0x39')]?_0x47116b[_0x9fa7('0x38')]:_0x186c89[_0x9fa7('0x32')];if(_0x10003a[_0x9fa7('0x33')][_0x9fa7('0x43')]){_0x47116b['include']=[{'all':!![]}];}_0x47116b=_[_0x9fa7('0x40')]({},_0x47116b,_0x10003a['options']);return db[_0x9fa7('0x2e')][_0x9fa7('0x49')](_0x47116b)[_0x9fa7('0x27')](handleEntityNotFound(_0x817c77,null))[_0x9fa7('0x27')](respondWithResult(_0x817c77,null))[_0x9fa7('0x46')](handleError(_0x817c77,null));};exports[_0x9fa7('0x4a')]=function(_0x334f15,_0x345da6){return db[_0x9fa7('0x2e')][_0x9fa7('0x4a')](_0x334f15[_0x9fa7('0x4b')],{})[_0x9fa7('0x27')](respondWithResult(_0x345da6,0xc9))[_0x9fa7('0x46')](handleError(_0x345da6,null));};exports['update']=function(_0x450897,_0x406c86){if(_0x450897[_0x9fa7('0x4b')]['id']){delete _0x450897['body']['id'];}return db[_0x9fa7('0x2e')][_0x9fa7('0x49')]({'where':{'id':_0x450897[_0x9fa7('0x48')]['id']}})[_0x9fa7('0x27')](handleEntityNotFound(_0x406c86,null))[_0x9fa7('0x27')](saveUpdates(_0x450897['body'],null))['then'](respondWithResult(_0x406c86,null))[_0x9fa7('0x46')](handleError(_0x406c86,null));};exports[_0x9fa7('0x26')]=function(_0x21f67c,_0x360712){return db[_0x9fa7('0x2e')]['find']({'where':{'id':_0x21f67c[_0x9fa7('0x48')]['id']}})['then'](handleEntityNotFound(_0x360712,null))[_0x9fa7('0x27')](removeEntity(_0x360712,null))[_0x9fa7('0x46')](handleError(_0x360712,null));};exports[_0x9fa7('0x4c')]=function(_0xbd15d8,_0x39bcc8,_0x78ef82){var _0x1dc4e8={};var _0x3f5ef1={};var _0x1b562a;var _0x37e86a;return db['DeskAccount'][_0x9fa7('0x4d')]({'where':{'id':_0xbd15d8[_0x9fa7('0x48')]['id']}})['then'](handleEntityNotFound(_0x39bcc8,null))[_0x9fa7('0x27')](function(_0x453a91){if(_0x453a91){_0x1b562a=_0x453a91;_0x3f5ef1[_0x9fa7('0x32')]=_[_0x9fa7('0x34')](db['DeskConfiguration'][_0x9fa7('0x2f')]);_0x3f5ef1[_0x9fa7('0x33')]=_['keys'](_0xbd15d8[_0x9fa7('0x33')]);_0x3f5ef1[_0x9fa7('0x35')]=_['intersection'](_0x3f5ef1['model'],_0x3f5ef1[_0x9fa7('0x33')]);_0x1dc4e8[_0x9fa7('0x38')]=_[_0x9fa7('0x36')](_0x3f5ef1[_0x9fa7('0x32')],qs[_0x9fa7('0x37')](_0xbd15d8[_0x9fa7('0x33')]['fields']));_0x1dc4e8[_0x9fa7('0x38')]=_0x1dc4e8[_0x9fa7('0x38')]['length']?_0x1dc4e8['attributes']:_0x3f5ef1[_0x9fa7('0x32')];_0x1dc4e8[_0x9fa7('0x3c')]=qs['sort'](_0xbd15d8[_0x9fa7('0x33')][_0x9fa7('0x4e')]);_0x1dc4e8['where']=qs['filters'](_['pick'](_0xbd15d8[_0x9fa7('0x33')],_0x3f5ef1[_0x9fa7('0x35')]));if(_0xbd15d8['query']['filter']){_0x1dc4e8[_0x9fa7('0x3d')]=_['merge'](_0x1dc4e8[_0x9fa7('0x3d')],{'$or':_[_0x9fa7('0x2d')](_0x1dc4e8['attributes'],function(_0x5bdaf9){var _0x5ea4f1={};_0x5ea4f1[_0x5bdaf9]={'$like':'%'+_0xbd15d8['query'][_0x9fa7('0x3f')]+'%'};return _0x5ea4f1;})});}_0x1dc4e8=_['merge']({},_0x1dc4e8,_0xbd15d8[_0x9fa7('0x42')]);return _0x1b562a[_0x9fa7('0x4c')](_0x1dc4e8);}})[_0x9fa7('0x27')](function(_0x356c5e){if(_0x356c5e){_0x37e86a=_0x356c5e[_0x9fa7('0x39')];if(!_0xbd15d8[_0x9fa7('0x33')][_0x9fa7('0x3a')](_0x9fa7('0x3b'))){_0x1dc4e8[_0x9fa7('0x1d')]=qs[_0x9fa7('0x1d')](_0xbd15d8['query']['limit']);_0x1dc4e8[_0x9fa7('0x1c')]=qs[_0x9fa7('0x1c')](_0xbd15d8[_0x9fa7('0x33')][_0x9fa7('0x1c')]);}return _0x1b562a[_0x9fa7('0x4c')](_0x1dc4e8);}})['then'](function(_0x419b4f){if(_0x419b4f){return _0x419b4f?{'count':_0x37e86a,'rows':_0x419b4f}:null;}})['then'](respondWithResult(_0x39bcc8,null))['catch'](handleError(_0x39bcc8,null));};exports[_0x9fa7('0x4f')]=function(_0x5d5102,_0x23671f,_0x12d87f){if(_0x5d5102[_0x9fa7('0x4b')]['id']){delete _0x5d5102[_0x9fa7('0x4b')]['id'];}return db[_0x9fa7('0x2e')][_0x9fa7('0x4d')]({'where':{'id':_0x5d5102['params']['id']}})[_0x9fa7('0x27')](handleEntityNotFound(_0x23671f,null))[_0x9fa7('0x27')](function(_0x2b0fc9){if(_0x2b0fc9){_0x5d5102[_0x9fa7('0x4b')][_0x9fa7('0x50')]=_0x2b0fc9['id'];_0x5d5102[_0x9fa7('0x4b')]['Subjects']=integrations['getSubjects'](_0x5d5102[_0x9fa7('0x4b')][_0x9fa7('0x51')],_0x5d5102[_0x9fa7('0x4b')][_0x9fa7('0x31')]);_0x5d5102['body']['Descriptions']=integrations[_0x9fa7('0x52')](_0x5d5102[_0x9fa7('0x4b')][_0x9fa7('0x51')],_0x5d5102[_0x9fa7('0x4b')][_0x9fa7('0x31')]);return db[_0x9fa7('0x53')]['create'](_0x5d5102[_0x9fa7('0x4b')],{'include':[{'model':db['DeskField'],'as':'Subjects'},{'model':db['DeskField'],'as':_0x9fa7('0x54')}]});}return null;})[_0x9fa7('0x27')](respondWithResult(_0x23671f,null))[_0x9fa7('0x46')](handleError(_0x23671f,null));};exports[_0x9fa7('0x55')]=function(_0x58b835,_0x2dd867,_0x5e5dcb){var _0x550e1f=[{'name':'priority','label':_0x9fa7('0x56'),'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 _0x25ebb4='';return db[_0x9fa7('0x2e')][_0x9fa7('0x4d')]({'where':{'id':_0x58b835[_0x9fa7('0x48')]['id']},'attributes':['id',_0x9fa7('0x57'),'authType','username',_0x9fa7('0x58'),_0x9fa7('0x59'),_0x9fa7('0x5a'),_0x9fa7('0x5b'),'tokenSecret']})[_0x9fa7('0x27')](handleEntityNotFound(_0x2dd867,null))[_0x9fa7('0x27')](function(_0x468022){if(_0x468022){_0x25ebb4=_0x468022[_0x9fa7('0x57')];var _0x4ed604=_0x25ebb4[_0x9fa7('0x5c')](-0x1);if(_0x4ed604==='/'){_0x25ebb4=_0x25ebb4['substring'](0x0,_0x25ebb4[_0x9fa7('0x5d')](_0x4ed604));}var _0x8954f9={'method':_0x9fa7('0x5e'),'uri':util[_0x9fa7('0x5f')](_0x9fa7('0x60'),_0x25ebb4),'headers':{'Content-Type':_0x9fa7('0x61'),'Accept':_0x9fa7('0x61')},'json':!![]};if(_0x468022[_0x9fa7('0x62')]===_0x9fa7('0x63')){_0x8954f9[_0x9fa7('0x64')][_0x9fa7('0x65')]=util['format'](_0x9fa7('0x66'),new Buffer(util[_0x9fa7('0x5f')](_0x9fa7('0x67'),_0x468022[_0x9fa7('0x68')],_0x468022[_0x9fa7('0x58')]))[_0x9fa7('0x69')](_0x9fa7('0x6a')));}return rp(_0x8954f9)[_0x9fa7('0x27')](function(_0x16a71a){return _0x550e1f[_0x9fa7('0x6b')](_[_0x9fa7('0x2d')](_0x16a71a[_0x9fa7('0x6c')][_0x9fa7('0x6d')],function(_0x6324e4){return{'id':_0x6324e4[_0x9fa7('0x2a')],'name':_0x6324e4[_0x9fa7('0x2a')],'type':_0x6324e4['type'],'active':_0x6324e4[_0x9fa7('0x6e')],'label':_0x6324e4[_0x9fa7('0x6f')],'custom':!![]};}));});}})[_0x9fa7('0x27')](function(_0x45e7f5){return{'count':_0x45e7f5['length'],'rows':_0x45e7f5};})[_0x9fa7('0x27')](respondWithResult(_0x2dd867,null))['catch'](function(_0x4fc08a){var _0x4c6d14=_0x58b835[_0x9fa7('0x33')]['test']?0x1f4:_0x4fc08a[_0x9fa7('0x70')]||0x1f4;logger[_0x9fa7('0x28')](_0x9fa7('0x71'),'getFields',_0x4c6d14,JSON[_0x9fa7('0x72')](_0x4fc08a));delete _0x4fc08a[_0x9fa7('0x2a')];if(_0x4c6d14===0x191){_0x4c6d14=0x190;}_0x2dd867[_0x9fa7('0x19')](_0x4c6d14)['send'](_0x58b835[_0x9fa7('0x33')][_0x9fa7('0x73')]?{'message':_0x9fa7('0x74'),'statusCode':_0x4fc08a['statusCode']}:_0x4fc08a);});};
\ No newline at end of file