Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index dc57cab..44a2d6d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xadc0=['save','update','then','destroy','name','send','index','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','VIRTUAL','include','DeskAccount','rows','catch','show','params','options','find','create','body','getConfigurations','findOne','DeskConfiguration','addConfiguration','AccountId','Subjects','getSubjects','channel','DeskField','getFields','priority','remoteUri','authType','username','consumerKey','consumerSecret','token','tokenSecret','substring','lastIndexOf','format','application/json','basic','headers','Basic\x20%s','password','toString','base64','concat','_embedded','active','test','error','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../components/integrations/configuration','sendStatus','status','json','undefined','limit','count','offset','Content-Range','apply'];(function(_0x25a386,_0x4acd61){var _0x4d3d47=function(_0x2e4efb){while(--_0x2e4efb){_0x25a386['push'](_0x25a386['shift']());}};_0x4d3d47(++_0x4acd61);}(_0xadc0,0x125));var _0x0adc=function(_0x4e9b99,_0x124be9){_0x4e9b99=_0x4e9b99-0x0;var _0x2c63dd=_0xadc0[_0x4e9b99];return _0x2c63dd;};'use strict';var emlformat=require(_0x0adc('0x0'));var rimraf=require(_0x0adc('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0adc('0x2'));var rp=require(_0x0adc('0x3'));var moment=require(_0x0adc('0x4'));var BPromise=require(_0x0adc('0x5'));var Mustache=require(_0x0adc('0x6'));var util=require('util');var path=require('path');var sox=require(_0x0adc('0x7'));var csv=require('to-csv');var ejs=require(_0x0adc('0x8'));var fs=require('fs');var fs_extra=require(_0x0adc('0x9'));var _=require(_0x0adc('0xa'));var squel=require(_0x0adc('0xb'));var crypto=require(_0x0adc('0xc'));var jsforce=require(_0x0adc('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x0adc('0xe'));var querystring=require('querystring');var Papa=require(_0x0adc('0xf'));var Redis=require(_0x0adc('0x10'));var authService=require(_0x0adc('0x11'));var qs=require(_0x0adc('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0adc('0x13'));var logger=require(_0x0adc('0x14'))('api');var utils=require(_0x0adc('0x15'));var config=require(_0x0adc('0x16'));var licenseUtil=require(_0x0adc('0x17'));var db=require('../../mysqldb')['db'];var integrations=require(_0x0adc('0x18'));function respondWithStatusCode(_0x233dda,_0x3d09eb){_0x3d09eb=_0x3d09eb||0xcc;return function(_0x12c998){if(_0x12c998){return _0x233dda[_0x0adc('0x19')](_0x3d09eb);}return _0x233dda[_0x0adc('0x1a')](_0x3d09eb)['end']();};}function respondWithResult(_0x262448,_0x1a669b){_0x1a669b=_0x1a669b||0xc8;return function(_0xea8097){if(_0xea8097){return _0x262448[_0x0adc('0x1a')](_0x1a669b)[_0x0adc('0x1b')](_0xea8097);}};}function respondWithFilteredResult(_0x383a46,_0x25f780){return function(_0x580dc9){if(_0x580dc9){var _0x425126=typeof _0x25f780['offset']===_0x0adc('0x1c')&&typeof _0x25f780[_0x0adc('0x1d')]===_0x0adc('0x1c');var _0x4f566=_0x580dc9[_0x0adc('0x1e')];var _0x4198f5=_0x425126?0x0:_0x25f780[_0x0adc('0x1f')];var _0x2cfd03=_0x425126?_0x580dc9[_0x0adc('0x1e')]:_0x25f780[_0x0adc('0x1f')]+_0x25f780[_0x0adc('0x1d')];var _0x386bba;if(_0x2cfd03>=_0x4f566){_0x2cfd03=_0x4f566;_0x386bba=0xc8;}else{_0x386bba=0xce;}_0x383a46[_0x0adc('0x1a')](_0x386bba);return _0x383a46['set'](_0x0adc('0x20'),_0x4198f5+'-'+_0x2cfd03+'/'+_0x4f566)['json'](_0x580dc9);}return null;};}function patchUpdates(_0x244360){return function(_0x98318c){try{jsonpatch[_0x0adc('0x21')](_0x98318c,_0x244360,!![]);}catch(_0x4cbded){return BPromise['reject'](_0x4cbded);}return _0x98318c[_0x0adc('0x22')]();};}function saveUpdates(_0x30e75d,_0x47ced2){return function(_0x2d373b){if(_0x2d373b){return _0x2d373b[_0x0adc('0x23')](_0x30e75d)[_0x0adc('0x24')](function(_0xd2113a){return _0xd2113a;});}return null;};}function removeEntity(_0x27a7f3,_0x5e4692){return function(_0x1e0581){if(_0x1e0581){return _0x1e0581[_0x0adc('0x25')]()['then'](function(){_0x27a7f3['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x478263,_0x3f0c33){return function(_0x4f4c5a){if(!_0x4f4c5a){_0x478263[_0x0adc('0x19')](0x194);}return _0x4f4c5a;};}function handleError(_0x2715d5,_0x3d74fd){_0x3d74fd=_0x3d74fd||0x1f4;return function(_0x4beb08){logger['error'](_0x4beb08['stack']);if(_0x4beb08[_0x0adc('0x26')]){delete _0x4beb08[_0x0adc('0x26')];}_0x2715d5[_0x0adc('0x1a')](_0x3d74fd)[_0x0adc('0x27')](_0x4beb08);};}exports[_0x0adc('0x28')]=function(_0x1bac44,_0x331689){var _0x41d856={},_0xf74b03={},_0x12fa08={'count':0x0,'rows':[]};var _0x51cdec=_['map'](db['DeskAccount'][_0x0adc('0x29')],function(_0x16e86f){return{'name':_0x16e86f[_0x0adc('0x2a')],'type':_0x16e86f[_0x0adc('0x2b')][_0x0adc('0x2c')]};});_0xf74b03['model']=_['map'](_0x51cdec,_0x0adc('0x26'));_0xf74b03[_0x0adc('0x2d')]=_[_0x0adc('0x2e')](_0x1bac44[_0x0adc('0x2d')]);_0xf74b03[_0x0adc('0x2f')]=_[_0x0adc('0x30')](_0xf74b03['model'],_0xf74b03['query']);_0x41d856['attributes']=_['intersection'](_0xf74b03[_0x0adc('0x31')],qs[_0x0adc('0x32')](_0x1bac44[_0x0adc('0x2d')][_0x0adc('0x32')]));_0x41d856[_0x0adc('0x33')]=_0x41d856[_0x0adc('0x33')][_0x0adc('0x34')]?_0x41d856[_0x0adc('0x33')]:_0xf74b03['model'];if(!_0x1bac44[_0x0adc('0x2d')][_0x0adc('0x35')](_0x0adc('0x36'))){_0x41d856[_0x0adc('0x1d')]=qs[_0x0adc('0x1d')](_0x1bac44[_0x0adc('0x2d')][_0x0adc('0x1d')]);_0x41d856[_0x0adc('0x1f')]=qs[_0x0adc('0x1f')](_0x1bac44[_0x0adc('0x2d')][_0x0adc('0x1f')]);}_0x41d856[_0x0adc('0x37')]=qs[_0x0adc('0x38')](_0x1bac44['query'][_0x0adc('0x38')]);_0x41d856[_0x0adc('0x39')]=qs['filters'](_[_0x0adc('0x3a')](_0x1bac44[_0x0adc('0x2d')],_0xf74b03['filters']),_0x51cdec);if(_0x1bac44['query'][_0x0adc('0x3b')]){_0x41d856[_0x0adc('0x39')]=_[_0x0adc('0x3c')](_0x41d856[_0x0adc('0x39')],{'$or':_[_0x0adc('0x3d')](_0x51cdec,function(_0xe65d38){if(_0xe65d38[_0x0adc('0x2b')]!==_0x0adc('0x3e')){var _0x398a02={};_0x398a02[_0xe65d38[_0x0adc('0x26')]]={'$like':'%'+_0x1bac44[_0x0adc('0x2d')][_0x0adc('0x3b')]+'%'};return _0x398a02;}})});}_0x41d856=_['merge']({},_0x41d856,_0x1bac44['options']);var _0x1f1c69={'where':_0x41d856[_0x0adc('0x39')]};return db['DeskAccount'][_0x0adc('0x1e')](_0x1f1c69)[_0x0adc('0x24')](function(_0x127dec){_0x12fa08[_0x0adc('0x1e')]=_0x127dec;if(_0x1bac44[_0x0adc('0x2d')]['includeAll']){_0x41d856[_0x0adc('0x3f')]=[{'all':!![]}];}return db[_0x0adc('0x40')]['findAll'](_0x41d856);})['then'](function(_0x1476ef){_0x12fa08[_0x0adc('0x41')]=_0x1476ef;return _0x12fa08;})[_0x0adc('0x24')](respondWithFilteredResult(_0x331689,_0x41d856))[_0x0adc('0x42')](handleError(_0x331689,null));};exports[_0x0adc('0x43')]=function(_0x1a2365,_0x3dab35){var _0x27400f={'raw':![],'where':{'id':_0x1a2365[_0x0adc('0x44')]['id']}},_0x97ea4={};_0x97ea4[_0x0adc('0x31')]=_[_0x0adc('0x2e')](db[_0x0adc('0x40')][_0x0adc('0x29')]);_0x97ea4[_0x0adc('0x2d')]=_[_0x0adc('0x2e')](_0x1a2365[_0x0adc('0x2d')]);_0x97ea4[_0x0adc('0x2f')]=_[_0x0adc('0x30')](_0x97ea4['model'],_0x97ea4['query']);_0x27400f[_0x0adc('0x33')]=_[_0x0adc('0x30')](_0x97ea4[_0x0adc('0x31')],qs[_0x0adc('0x32')](_0x1a2365[_0x0adc('0x2d')]['fields']));_0x27400f['attributes']=_0x27400f[_0x0adc('0x33')]['length']?_0x27400f[_0x0adc('0x33')]:_0x97ea4['model'];if(_0x1a2365[_0x0adc('0x2d')]['includeAll']){_0x27400f[_0x0adc('0x3f')]=[{'all':!![]}];}_0x27400f=_[_0x0adc('0x3c')]({},_0x27400f,_0x1a2365[_0x0adc('0x45')]);return db[_0x0adc('0x40')][_0x0adc('0x46')](_0x27400f)['then'](handleEntityNotFound(_0x3dab35,null))[_0x0adc('0x24')](respondWithResult(_0x3dab35,null))[_0x0adc('0x42')](handleError(_0x3dab35,null));};exports[_0x0adc('0x47')]=function(_0x345dc7,_0x17347a){return db[_0x0adc('0x40')]['create'](_0x345dc7[_0x0adc('0x48')],{})[_0x0adc('0x24')](respondWithResult(_0x17347a,0xc9))[_0x0adc('0x42')](handleError(_0x17347a,null));};exports['update']=function(_0x55b9d1,_0x2ed30b){if(_0x55b9d1[_0x0adc('0x48')]['id']){delete _0x55b9d1['body']['id'];}return db[_0x0adc('0x40')][_0x0adc('0x46')]({'where':{'id':_0x55b9d1[_0x0adc('0x44')]['id']}})['then'](handleEntityNotFound(_0x2ed30b,null))[_0x0adc('0x24')](saveUpdates(_0x55b9d1['body'],null))[_0x0adc('0x24')](respondWithResult(_0x2ed30b,null))[_0x0adc('0x42')](handleError(_0x2ed30b,null));};exports[_0x0adc('0x25')]=function(_0x164555,_0x3fc14c){return db[_0x0adc('0x40')][_0x0adc('0x46')]({'where':{'id':_0x164555[_0x0adc('0x44')]['id']}})[_0x0adc('0x24')](handleEntityNotFound(_0x3fc14c,null))[_0x0adc('0x24')](removeEntity(_0x3fc14c,null))[_0x0adc('0x42')](handleError(_0x3fc14c,null));};exports[_0x0adc('0x49')]=function(_0x43e4dd,_0x47083e,_0x41a5b3){var _0x5256c3={};var _0x1da100={};var _0x4c237e;var _0x3ed42d;return db['DeskAccount'][_0x0adc('0x4a')]({'where':{'id':_0x43e4dd['params']['id']}})[_0x0adc('0x24')](handleEntityNotFound(_0x47083e,null))[_0x0adc('0x24')](function(_0x10227d){if(_0x10227d){_0x4c237e=_0x10227d;_0x1da100[_0x0adc('0x31')]=_[_0x0adc('0x2e')](db[_0x0adc('0x4b')][_0x0adc('0x29')]);_0x1da100[_0x0adc('0x2d')]=_[_0x0adc('0x2e')](_0x43e4dd['query']);_0x1da100[_0x0adc('0x2f')]=_[_0x0adc('0x30')](_0x1da100[_0x0adc('0x31')],_0x1da100[_0x0adc('0x2d')]);_0x5256c3[_0x0adc('0x33')]=_[_0x0adc('0x30')](_0x1da100[_0x0adc('0x31')],qs['fields'](_0x43e4dd['query'][_0x0adc('0x32')]));_0x5256c3['attributes']=_0x5256c3['attributes'][_0x0adc('0x34')]?_0x5256c3['attributes']:_0x1da100[_0x0adc('0x31')];_0x5256c3[_0x0adc('0x37')]=qs[_0x0adc('0x38')](_0x43e4dd[_0x0adc('0x2d')][_0x0adc('0x38')]);_0x5256c3['where']=qs[_0x0adc('0x2f')](_['pick'](_0x43e4dd['query'],_0x1da100[_0x0adc('0x2f')]));if(_0x43e4dd['query'][_0x0adc('0x3b')]){_0x5256c3[_0x0adc('0x39')]=_[_0x0adc('0x3c')](_0x5256c3['where'],{'$or':_[_0x0adc('0x3d')](_0x5256c3['attributes'],function(_0x4f888e){var _0x33756c={};_0x33756c[_0x4f888e]={'$like':'%'+_0x43e4dd[_0x0adc('0x2d')][_0x0adc('0x3b')]+'%'};return _0x33756c;})});}_0x5256c3=_[_0x0adc('0x3c')]({},_0x5256c3,_0x43e4dd[_0x0adc('0x45')]);return _0x4c237e[_0x0adc('0x49')](_0x5256c3);}})[_0x0adc('0x24')](function(_0x27619b){if(_0x27619b){_0x3ed42d=_0x27619b[_0x0adc('0x34')];if(!_0x43e4dd['query'][_0x0adc('0x35')](_0x0adc('0x36'))){_0x5256c3[_0x0adc('0x1d')]=qs[_0x0adc('0x1d')](_0x43e4dd['query']['limit']);_0x5256c3[_0x0adc('0x1f')]=qs[_0x0adc('0x1f')](_0x43e4dd[_0x0adc('0x2d')][_0x0adc('0x1f')]);}return _0x4c237e[_0x0adc('0x49')](_0x5256c3);}})[_0x0adc('0x24')](function(_0x2dac70){if(_0x2dac70){return _0x2dac70?{'count':_0x3ed42d,'rows':_0x2dac70}:null;}})['then'](respondWithResult(_0x47083e,null))[_0x0adc('0x42')](handleError(_0x47083e,null));};exports[_0x0adc('0x4c')]=function(_0x4859c7,_0x215847,_0x1323c1){if(_0x4859c7[_0x0adc('0x48')]['id']){delete _0x4859c7['body']['id'];}return db['DeskAccount']['findOne']({'where':{'id':_0x4859c7[_0x0adc('0x44')]['id']}})[_0x0adc('0x24')](handleEntityNotFound(_0x215847,null))[_0x0adc('0x24')](function(_0xe7fa9f){if(_0xe7fa9f){_0x4859c7[_0x0adc('0x48')][_0x0adc('0x4d')]=_0xe7fa9f['id'];_0x4859c7[_0x0adc('0x48')][_0x0adc('0x4e')]=integrations[_0x0adc('0x4f')](_0x4859c7[_0x0adc('0x48')]['channel'],_0x4859c7[_0x0adc('0x48')]['type']);_0x4859c7[_0x0adc('0x48')]['Descriptions']=integrations['getDescriptions'](_0x4859c7[_0x0adc('0x48')][_0x0adc('0x50')],_0x4859c7[_0x0adc('0x48')][_0x0adc('0x2b')]);return db[_0x0adc('0x4b')][_0x0adc('0x47')](_0x4859c7[_0x0adc('0x48')],{'include':[{'model':db[_0x0adc('0x51')],'as':_0x0adc('0x4e')},{'model':db[_0x0adc('0x51')],'as':'Descriptions'}]});}return null;})[_0x0adc('0x24')](respondWithResult(_0x215847,null))[_0x0adc('0x42')](handleError(_0x215847,null));};exports[_0x0adc('0x52')]=function(_0x1dfc11,_0x141304,_0x17fdc9){var _0x353823=[{'name':_0x0adc('0x53'),'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 _0x368120='';return db[_0x0adc('0x40')][_0x0adc('0x4a')]({'where':{'id':_0x1dfc11[_0x0adc('0x44')]['id']},'attributes':['id',_0x0adc('0x54'),_0x0adc('0x55'),_0x0adc('0x56'),'password',_0x0adc('0x57'),_0x0adc('0x58'),_0x0adc('0x59'),_0x0adc('0x5a')]})[_0x0adc('0x24')](handleEntityNotFound(_0x141304,null))[_0x0adc('0x24')](function(_0x48c597){if(_0x48c597){_0x368120=_0x48c597['remoteUri'];var _0x2ecc99=_0x368120['slice'](-0x1);if(_0x2ecc99==='/'){_0x368120=_0x368120[_0x0adc('0x5b')](0x0,_0x368120[_0x0adc('0x5c')](_0x2ecc99));}var _0x5ed466={'method':'GET','uri':util[_0x0adc('0x5d')]('%s/custom_fields',_0x368120),'headers':{'Content-Type':_0x0adc('0x5e'),'Accept':_0x0adc('0x5e')},'json':!![]};if(_0x48c597[_0x0adc('0x55')]===_0x0adc('0x5f')){_0x5ed466[_0x0adc('0x60')]['Authorization']=util[_0x0adc('0x5d')](_0x0adc('0x61'),new Buffer(util[_0x0adc('0x5d')]('%s:%s',_0x48c597['username'],_0x48c597[_0x0adc('0x62')]))[_0x0adc('0x63')](_0x0adc('0x64')));}return rp(_0x5ed466)[_0x0adc('0x24')](function(_0x365655){return _0x353823[_0x0adc('0x65')](_[_0x0adc('0x3d')](_0x365655[_0x0adc('0x66')]['entries'],function(_0x808483){return{'id':_0x808483[_0x0adc('0x26')],'name':_0x808483['name'],'type':_0x808483[_0x0adc('0x2b')],'active':_0x808483[_0x0adc('0x67')],'label':_0x808483['label'],'custom':!![]};}));});}})[_0x0adc('0x24')](function(_0x124a85){return{'count':_0x124a85[_0x0adc('0x34')],'rows':_0x124a85};})[_0x0adc('0x24')](respondWithResult(_0x141304,null))[_0x0adc('0x42')](function(_0x44a9af){var _0x4363e5=_0x1dfc11[_0x0adc('0x2d')][_0x0adc('0x68')]?0x1f4:_0x44a9af['statusCode']||0x1f4;logger[_0x0adc('0x69')](_0x0adc('0x6a'),_0x0adc('0x52'),_0x4363e5,JSON[_0x0adc('0x6b')](_0x44a9af));delete _0x44a9af[_0x0adc('0x26')];if(_0x4363e5===0x191){_0x4363e5=0x190;}_0x141304[_0x0adc('0x1a')](_0x4363e5)[_0x0adc('0x27')](_0x1dfc11[_0x0adc('0x2d')][_0x0adc('0x68')]?{'message':_0x0adc('0x6c'),'statusCode':_0x44a9af['statusCode']}:_0x44a9af);});};
\ No newline at end of file
+var _0x2bfc=['intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','merge','type','VIRTUAL','filter','includeAll','findAll','rows','catch','show','params','include','options','create','body','update','find','pick','getConfigurations','findOne','getSubjects','channel','getDescriptions','DeskConfiguration','DeskField','Subjects','Descriptions','getFields','priority','remoteUri','username','password','consumerKey','token','tokenSecret','lastIndexOf','GET','format','authType','basic','headers','Authorization','%s:%s','concat','_embedded','label','error','stringify','test','Wrong\x20credentials','statusCode','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','json','offset','limit','undefined','count','set','Content-Range','save','then','destroy','end','stack','name','send','map','DeskAccount','rawAttributes','fieldName','key','model','query','keys'];(function(_0x59f904,_0x1f7075){var _0x98fc40=function(_0x33df50){while(--_0x33df50){_0x59f904['push'](_0x59f904['shift']());}};_0x98fc40(++_0x1f7075);}(_0x2bfc,0x118));var _0xc2bf=function(_0x5bc694,_0x568ae1){_0x5bc694=_0x5bc694-0x0;var _0x22f607=_0x2bfc[_0x5bc694];return _0x22f607;};'use strict';var emlformat=require(_0xc2bf('0x0'));var rimraf=require(_0xc2bf('0x1'));var zipdir=require(_0xc2bf('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc2bf('0x3'));var moment=require(_0xc2bf('0x4'));var BPromise=require(_0xc2bf('0x5'));var Mustache=require(_0xc2bf('0x6'));var util=require(_0xc2bf('0x7'));var path=require(_0xc2bf('0x8'));var sox=require(_0xc2bf('0x9'));var csv=require('to-csv');var ejs=require(_0xc2bf('0xa'));var fs=require('fs');var fs_extra=require(_0xc2bf('0xb'));var _=require('lodash');var squel=require(_0xc2bf('0xc'));var crypto=require(_0xc2bf('0xd'));var jsforce=require(_0xc2bf('0xe'));var deskjs=require(_0xc2bf('0xf'));var toCsv=require(_0xc2bf('0x10'));var querystring=require(_0xc2bf('0x11'));var Papa=require(_0xc2bf('0x12'));var Redis=require('ioredis');var authService=require(_0xc2bf('0x13'));var qs=require(_0xc2bf('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xc2bf('0x15'));var utils=require('../../config/utils');var config=require(_0xc2bf('0x16'));var licenseUtil=require(_0xc2bf('0x17'));var db=require(_0xc2bf('0x18'))['db'];var integrations=require(_0xc2bf('0x19'));function respondWithStatusCode(_0x301d4c,_0x4a3a56){_0x4a3a56=_0x4a3a56||0xcc;return function(_0x49d0a5){if(_0x49d0a5){return _0x301d4c[_0xc2bf('0x1a')](_0x4a3a56);}return _0x301d4c[_0xc2bf('0x1b')](_0x4a3a56)['end']();};}function respondWithResult(_0x3c9542,_0x253906){_0x253906=_0x253906||0xc8;return function(_0x2410e8){if(_0x2410e8){return _0x3c9542[_0xc2bf('0x1b')](_0x253906)[_0xc2bf('0x1c')](_0x2410e8);}};}function respondWithFilteredResult(_0x1b2e54,_0x4cdae2){return function(_0x1525f3){if(_0x1525f3){var _0xd8e647=typeof _0x4cdae2[_0xc2bf('0x1d')]==='undefined'&&typeof _0x4cdae2[_0xc2bf('0x1e')]===_0xc2bf('0x1f');var _0x1cf683=_0x1525f3['count'];var _0x5d4678=_0xd8e647?0x0:_0x4cdae2[_0xc2bf('0x1d')];var _0x4eee97=_0xd8e647?_0x1525f3[_0xc2bf('0x20')]:_0x4cdae2[_0xc2bf('0x1d')]+_0x4cdae2[_0xc2bf('0x1e')];var _0x16efcc;if(_0x4eee97>=_0x1cf683){_0x4eee97=_0x1cf683;_0x16efcc=0xc8;}else{_0x16efcc=0xce;}_0x1b2e54[_0xc2bf('0x1b')](_0x16efcc);return _0x1b2e54[_0xc2bf('0x21')](_0xc2bf('0x22'),_0x5d4678+'-'+_0x4eee97+'/'+_0x1cf683)[_0xc2bf('0x1c')](_0x1525f3);}return null;};}function patchUpdates(_0x1e94a2){return function(_0x6bc1ce){try{jsonpatch['apply'](_0x6bc1ce,_0x1e94a2,!![]);}catch(_0xfffae2){return BPromise['reject'](_0xfffae2);}return _0x6bc1ce[_0xc2bf('0x23')]();};}function saveUpdates(_0x2e89ad,_0x1a95f5){return function(_0x450db6){if(_0x450db6){return _0x450db6['update'](_0x2e89ad)[_0xc2bf('0x24')](function(_0x154351){return _0x154351;});}return null;};}function removeEntity(_0x5e7625,_0x57d764){return function(_0x1344a3){if(_0x1344a3){return _0x1344a3[_0xc2bf('0x25')]()[_0xc2bf('0x24')](function(){_0x5e7625['status'](0xcc)[_0xc2bf('0x26')]();});}};}function handleEntityNotFound(_0x266540,_0x3476d1){return function(_0x2cb400){if(!_0x2cb400){_0x266540[_0xc2bf('0x1a')](0x194);}return _0x2cb400;};}function handleError(_0x10d252,_0x1e5877){_0x1e5877=_0x1e5877||0x1f4;return function(_0x4a37c8){logger['error'](_0x4a37c8[_0xc2bf('0x27')]);if(_0x4a37c8[_0xc2bf('0x28')]){delete _0x4a37c8[_0xc2bf('0x28')];}_0x10d252['status'](_0x1e5877)[_0xc2bf('0x29')](_0x4a37c8);};}exports['index']=function(_0x3eeb8e,_0x582105){var _0x51c6e1={},_0x2aa3e5={},_0x9d5867={'count':0x0,'rows':[]};var _0x39fc84=_[_0xc2bf('0x2a')](db[_0xc2bf('0x2b')][_0xc2bf('0x2c')],function(_0xc375a4){return{'name':_0xc375a4[_0xc2bf('0x2d')],'type':_0xc375a4['type'][_0xc2bf('0x2e')]};});_0x2aa3e5[_0xc2bf('0x2f')]=_[_0xc2bf('0x2a')](_0x39fc84,'name');_0x2aa3e5[_0xc2bf('0x30')]=_[_0xc2bf('0x31')](_0x3eeb8e['query']);_0x2aa3e5['filters']=_[_0xc2bf('0x32')](_0x2aa3e5[_0xc2bf('0x2f')],_0x2aa3e5['query']);_0x51c6e1[_0xc2bf('0x33')]=_['intersection'](_0x2aa3e5[_0xc2bf('0x2f')],qs[_0xc2bf('0x34')](_0x3eeb8e[_0xc2bf('0x30')][_0xc2bf('0x34')]));_0x51c6e1['attributes']=_0x51c6e1['attributes'][_0xc2bf('0x35')]?_0x51c6e1[_0xc2bf('0x33')]:_0x2aa3e5['model'];if(!_0x3eeb8e[_0xc2bf('0x30')][_0xc2bf('0x36')](_0xc2bf('0x37'))){_0x51c6e1['limit']=qs[_0xc2bf('0x1e')](_0x3eeb8e[_0xc2bf('0x30')]['limit']);_0x51c6e1['offset']=qs[_0xc2bf('0x1d')](_0x3eeb8e[_0xc2bf('0x30')][_0xc2bf('0x1d')]);}_0x51c6e1[_0xc2bf('0x38')]=qs[_0xc2bf('0x39')](_0x3eeb8e[_0xc2bf('0x30')][_0xc2bf('0x39')]);_0x51c6e1[_0xc2bf('0x3a')]=qs[_0xc2bf('0x3b')](_['pick'](_0x3eeb8e['query'],_0x2aa3e5[_0xc2bf('0x3b')]),_0x39fc84);if(_0x3eeb8e['query']['filter']){_0x51c6e1['where']=_[_0xc2bf('0x3c')](_0x51c6e1[_0xc2bf('0x3a')],{'$or':_[_0xc2bf('0x2a')](_0x39fc84,function(_0x309706){if(_0x309706[_0xc2bf('0x3d')]!==_0xc2bf('0x3e')){var _0x35eef9={};_0x35eef9[_0x309706[_0xc2bf('0x28')]]={'$like':'%'+_0x3eeb8e['query'][_0xc2bf('0x3f')]+'%'};return _0x35eef9;}})});}_0x51c6e1=_[_0xc2bf('0x3c')]({},_0x51c6e1,_0x3eeb8e['options']);var _0x441cd1={'where':_0x51c6e1['where']};return db['DeskAccount'][_0xc2bf('0x20')](_0x441cd1)[_0xc2bf('0x24')](function(_0x2286eb){_0x9d5867[_0xc2bf('0x20')]=_0x2286eb;if(_0x3eeb8e[_0xc2bf('0x30')][_0xc2bf('0x40')]){_0x51c6e1['include']=[{'all':!![]}];}return db[_0xc2bf('0x2b')][_0xc2bf('0x41')](_0x51c6e1);})[_0xc2bf('0x24')](function(_0x5f424c){_0x9d5867[_0xc2bf('0x42')]=_0x5f424c;return _0x9d5867;})[_0xc2bf('0x24')](respondWithFilteredResult(_0x582105,_0x51c6e1))[_0xc2bf('0x43')](handleError(_0x582105,null));};exports[_0xc2bf('0x44')]=function(_0x4d0e38,_0xa75a5f){var _0x1ed111={'raw':![],'where':{'id':_0x4d0e38[_0xc2bf('0x45')]['id']}},_0x225d4f={};_0x225d4f[_0xc2bf('0x2f')]=_[_0xc2bf('0x31')](db[_0xc2bf('0x2b')]['rawAttributes']);_0x225d4f[_0xc2bf('0x30')]=_[_0xc2bf('0x31')](_0x4d0e38[_0xc2bf('0x30')]);_0x225d4f['filters']=_[_0xc2bf('0x32')](_0x225d4f[_0xc2bf('0x2f')],_0x225d4f[_0xc2bf('0x30')]);_0x1ed111[_0xc2bf('0x33')]=_['intersection'](_0x225d4f[_0xc2bf('0x2f')],qs['fields'](_0x4d0e38[_0xc2bf('0x30')][_0xc2bf('0x34')]));_0x1ed111['attributes']=_0x1ed111[_0xc2bf('0x33')][_0xc2bf('0x35')]?_0x1ed111[_0xc2bf('0x33')]:_0x225d4f[_0xc2bf('0x2f')];if(_0x4d0e38[_0xc2bf('0x30')][_0xc2bf('0x40')]){_0x1ed111[_0xc2bf('0x46')]=[{'all':!![]}];}_0x1ed111=_['merge']({},_0x1ed111,_0x4d0e38[_0xc2bf('0x47')]);return db[_0xc2bf('0x2b')]['find'](_0x1ed111)[_0xc2bf('0x24')](handleEntityNotFound(_0xa75a5f,null))[_0xc2bf('0x24')](respondWithResult(_0xa75a5f,null))[_0xc2bf('0x43')](handleError(_0xa75a5f,null));};exports[_0xc2bf('0x48')]=function(_0x647ab9,_0x2010cc){return db[_0xc2bf('0x2b')][_0xc2bf('0x48')](_0x647ab9[_0xc2bf('0x49')],{})[_0xc2bf('0x24')](respondWithResult(_0x2010cc,0xc9))[_0xc2bf('0x43')](handleError(_0x2010cc,null));};exports[_0xc2bf('0x4a')]=function(_0x18f258,_0x2fbc1a){if(_0x18f258['body']['id']){delete _0x18f258[_0xc2bf('0x49')]['id'];}return db['DeskAccount'][_0xc2bf('0x4b')]({'where':{'id':_0x18f258['params']['id']}})[_0xc2bf('0x24')](handleEntityNotFound(_0x2fbc1a,null))[_0xc2bf('0x24')](saveUpdates(_0x18f258[_0xc2bf('0x49')],null))[_0xc2bf('0x24')](respondWithResult(_0x2fbc1a,null))[_0xc2bf('0x43')](handleError(_0x2fbc1a,null));};exports[_0xc2bf('0x25')]=function(_0x1ce623,_0x1b40e0){return db[_0xc2bf('0x2b')][_0xc2bf('0x4b')]({'where':{'id':_0x1ce623[_0xc2bf('0x45')]['id']}})[_0xc2bf('0x24')](handleEntityNotFound(_0x1b40e0,null))[_0xc2bf('0x24')](removeEntity(_0x1b40e0,null))[_0xc2bf('0x43')](handleError(_0x1b40e0,null));};exports['getConfigurations']=function(_0x50a814,_0x44a9f7,_0x283a6e){var _0x172a3a={};var _0x44b450={};var _0x4ebf51;var _0x182674;return db[_0xc2bf('0x2b')]['findOne']({'where':{'id':_0x50a814[_0xc2bf('0x45')]['id']}})[_0xc2bf('0x24')](handleEntityNotFound(_0x44a9f7,null))['then'](function(_0x442e0c){if(_0x442e0c){_0x4ebf51=_0x442e0c;_0x44b450[_0xc2bf('0x2f')]=_[_0xc2bf('0x31')](db['DeskConfiguration']['rawAttributes']);_0x44b450[_0xc2bf('0x30')]=_[_0xc2bf('0x31')](_0x50a814[_0xc2bf('0x30')]);_0x44b450[_0xc2bf('0x3b')]=_[_0xc2bf('0x32')](_0x44b450[_0xc2bf('0x2f')],_0x44b450['query']);_0x172a3a[_0xc2bf('0x33')]=_[_0xc2bf('0x32')](_0x44b450[_0xc2bf('0x2f')],qs['fields'](_0x50a814[_0xc2bf('0x30')][_0xc2bf('0x34')]));_0x172a3a[_0xc2bf('0x33')]=_0x172a3a[_0xc2bf('0x33')][_0xc2bf('0x35')]?_0x172a3a['attributes']:_0x44b450[_0xc2bf('0x2f')];_0x172a3a[_0xc2bf('0x38')]=qs[_0xc2bf('0x39')](_0x50a814[_0xc2bf('0x30')]['sort']);_0x172a3a[_0xc2bf('0x3a')]=qs[_0xc2bf('0x3b')](_[_0xc2bf('0x4c')](_0x50a814[_0xc2bf('0x30')],_0x44b450[_0xc2bf('0x3b')]));if(_0x50a814[_0xc2bf('0x30')][_0xc2bf('0x3f')]){_0x172a3a[_0xc2bf('0x3a')]=_['merge'](_0x172a3a[_0xc2bf('0x3a')],{'$or':_[_0xc2bf('0x2a')](_0x172a3a[_0xc2bf('0x33')],function(_0x3b97ec){var _0x3ef371={};_0x3ef371[_0x3b97ec]={'$like':'%'+_0x50a814[_0xc2bf('0x30')][_0xc2bf('0x3f')]+'%'};return _0x3ef371;})});}_0x172a3a=_[_0xc2bf('0x3c')]({},_0x172a3a,_0x50a814[_0xc2bf('0x47')]);return _0x4ebf51[_0xc2bf('0x4d')](_0x172a3a);}})[_0xc2bf('0x24')](function(_0x2e28f1){if(_0x2e28f1){_0x182674=_0x2e28f1[_0xc2bf('0x35')];if(!_0x50a814[_0xc2bf('0x30')]['hasOwnProperty']('nolimit')){_0x172a3a[_0xc2bf('0x1e')]=qs[_0xc2bf('0x1e')](_0x50a814['query'][_0xc2bf('0x1e')]);_0x172a3a[_0xc2bf('0x1d')]=qs['offset'](_0x50a814[_0xc2bf('0x30')][_0xc2bf('0x1d')]);}return _0x4ebf51[_0xc2bf('0x4d')](_0x172a3a);}})[_0xc2bf('0x24')](function(_0x272df6){if(_0x272df6){return _0x272df6?{'count':_0x182674,'rows':_0x272df6}:null;}})[_0xc2bf('0x24')](respondWithResult(_0x44a9f7,null))[_0xc2bf('0x43')](handleError(_0x44a9f7,null));};exports['addConfiguration']=function(_0xbc9a32,_0x3048a4,_0x95d47a){if(_0xbc9a32[_0xc2bf('0x49')]['id']){delete _0xbc9a32[_0xc2bf('0x49')]['id'];}return db[_0xc2bf('0x2b')][_0xc2bf('0x4e')]({'where':{'id':_0xbc9a32[_0xc2bf('0x45')]['id']}})[_0xc2bf('0x24')](handleEntityNotFound(_0x3048a4,null))['then'](function(_0x56769c){if(_0x56769c){_0xbc9a32['body']['AccountId']=_0x56769c['id'];_0xbc9a32[_0xc2bf('0x49')]['Subjects']=integrations[_0xc2bf('0x4f')](_0xbc9a32[_0xc2bf('0x49')][_0xc2bf('0x50')],_0xbc9a32[_0xc2bf('0x49')][_0xc2bf('0x3d')]);_0xbc9a32['body']['Descriptions']=integrations[_0xc2bf('0x51')](_0xbc9a32[_0xc2bf('0x49')][_0xc2bf('0x50')],_0xbc9a32[_0xc2bf('0x49')][_0xc2bf('0x3d')]);return db[_0xc2bf('0x52')]['create'](_0xbc9a32['body'],{'include':[{'model':db[_0xc2bf('0x53')],'as':_0xc2bf('0x54')},{'model':db[_0xc2bf('0x53')],'as':_0xc2bf('0x55')}]});}return null;})[_0xc2bf('0x24')](respondWithResult(_0x3048a4,null))[_0xc2bf('0x43')](handleError(_0x3048a4,null));};exports[_0xc2bf('0x56')]=function(_0x2207ee,_0x2c76a1,_0x458030){var _0x41e182=[{'name':_0xc2bf('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 _0x386dcc='';return db[_0xc2bf('0x2b')]['findOne']({'where':{'id':_0x2207ee[_0xc2bf('0x45')]['id']},'attributes':['id',_0xc2bf('0x58'),'authType',_0xc2bf('0x59'),_0xc2bf('0x5a'),_0xc2bf('0x5b'),'consumerSecret',_0xc2bf('0x5c'),_0xc2bf('0x5d')]})[_0xc2bf('0x24')](handleEntityNotFound(_0x2c76a1,null))[_0xc2bf('0x24')](function(_0x17f24a){if(_0x17f24a){_0x386dcc=_0x17f24a['remoteUri'];var _0x4a1836=_0x386dcc['slice'](-0x1);if(_0x4a1836==='/'){_0x386dcc=_0x386dcc['substring'](0x0,_0x386dcc[_0xc2bf('0x5e')](_0x4a1836));}var _0x3b4d44={'method':_0xc2bf('0x5f'),'uri':util[_0xc2bf('0x60')]('%s/custom_fields',_0x386dcc),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x17f24a[_0xc2bf('0x61')]===_0xc2bf('0x62')){_0x3b4d44[_0xc2bf('0x63')][_0xc2bf('0x64')]=util[_0xc2bf('0x60')]('Basic\x20%s',new Buffer(util[_0xc2bf('0x60')](_0xc2bf('0x65'),_0x17f24a[_0xc2bf('0x59')],_0x17f24a[_0xc2bf('0x5a')]))['toString']('base64'));}return rp(_0x3b4d44)[_0xc2bf('0x24')](function(_0x55c7fc){return _0x41e182[_0xc2bf('0x66')](_[_0xc2bf('0x2a')](_0x55c7fc[_0xc2bf('0x67')]['entries'],function(_0x229b0d){return{'id':_0x229b0d[_0xc2bf('0x28')],'name':_0x229b0d[_0xc2bf('0x28')],'type':_0x229b0d[_0xc2bf('0x3d')],'active':_0x229b0d['active'],'label':_0x229b0d[_0xc2bf('0x68')],'custom':!![]};}));});}})['then'](function(_0x1e615b){return{'count':_0x1e615b[_0xc2bf('0x35')],'rows':_0x1e615b};})['then'](respondWithResult(_0x2c76a1,null))[_0xc2bf('0x43')](function(_0x1312b3){var _0x2a1608=_0x2207ee['query']['test']?0x1f4:_0x1312b3['statusCode']||0x1f4;logger[_0xc2bf('0x69')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x2a1608,JSON[_0xc2bf('0x6a')](_0x1312b3));delete _0x1312b3['name'];if(_0x2a1608===0x191){_0x2a1608=0x190;}_0x2c76a1[_0xc2bf('0x1b')](_0x2a1608)[_0xc2bf('0x29')](_0x2207ee[_0xc2bf('0x30')][_0xc2bf('0x6b')]?{'message':_0xc2bf('0x6c'),'statusCode':_0x1312b3[_0xc2bf('0x6d')]}:_0x1312b3);});};
\ No newline at end of file