Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 0ae5290..eb87028 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8ec9=['Subjects','getSubjects','Descriptions','getDescriptions','channel','DeskConfiguration','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','tokenSecret','substring','lastIndexOf','%s/custom_fields','application/json','headers','Authorization','format','Basic\x20%s','%s:%s','base64','concat','entries','active','label','test','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','zip-dir','request-promise','bluebird','mustache','util','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/advancedSearch','api','../../config/environment','../../config/license/util','../../components/integrations/configuration','end','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','stack','name','send','index','map','DeskAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','rows','show','include','find','catch','create','body','params','getConfigurations','findOne','hasOwnProperty','addConfiguration'];(function(_0x208961,_0x5e6cf6){var _0x4236f5=function(_0x28856f){while(--_0x28856f){_0x208961['push'](_0x208961['shift']());}};_0x4236f5(++_0x5e6cf6);}(_0x8ec9,0xfc));var _0x98ec=function(_0x1f32a4,_0x4dc5b0){_0x1f32a4=_0x1f32a4-0x0;var _0x5936e5=_0x8ec9[_0x1f32a4];return _0x5936e5;};'use strict';var emlformat=require(_0x98ec('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x98ec('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x98ec('0x2'));var moment=require('moment');var BPromise=require(_0x98ec('0x3'));var Mustache=require(_0x98ec('0x4'));var util=require(_0x98ec('0x5'));var path=require('path');var sox=require(_0x98ec('0x6'));var csv=require(_0x98ec('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x98ec('0x8'));var _=require(_0x98ec('0x9'));var squel=require(_0x98ec('0xa'));var crypto=require('crypto');var jsforce=require(_0x98ec('0xb'));var deskjs=require(_0x98ec('0xc'));var toCsv=require(_0x98ec('0x7'));var querystring=require(_0x98ec('0xd'));var Papa=require('papaparse');var Redis=require(_0x98ec('0xe'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x98ec('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x98ec('0x10'));var utils=require('../../config/utils');var config=require(_0x98ec('0x11'));var licenseUtil=require(_0x98ec('0x12'));var db=require('../../mysqldb')['db'];var integrations=require(_0x98ec('0x13'));function respondWithStatusCode(_0x234056,_0x45513c){_0x45513c=_0x45513c||0xcc;return function(_0x1ca49c){if(_0x1ca49c){return _0x234056['sendStatus'](_0x45513c);}return _0x234056['status'](_0x45513c)[_0x98ec('0x14')]();};}function respondWithResult(_0x287bc8,_0x5d29e6){_0x5d29e6=_0x5d29e6||0xc8;return function(_0x149ae0){if(_0x149ae0){return _0x287bc8[_0x98ec('0x15')](_0x5d29e6)[_0x98ec('0x16')](_0x149ae0);}};}function respondWithFilteredResult(_0x265074,_0x56502d){return function(_0x347882){if(_0x347882){var _0x1e731a=typeof _0x56502d[_0x98ec('0x17')]===_0x98ec('0x18')&&typeof _0x56502d[_0x98ec('0x19')]===_0x98ec('0x18');var _0x166be7=_0x347882[_0x98ec('0x1a')];var _0x1fa56a=_0x1e731a?0x0:_0x56502d[_0x98ec('0x17')];var _0x5758ab=_0x1e731a?_0x347882[_0x98ec('0x1a')]:_0x56502d[_0x98ec('0x17')]+_0x56502d[_0x98ec('0x19')];var _0x455b75;if(_0x5758ab>=_0x166be7){_0x5758ab=_0x166be7;_0x455b75=0xc8;}else{_0x455b75=0xce;}_0x265074[_0x98ec('0x15')](_0x455b75);return _0x265074[_0x98ec('0x1b')](_0x98ec('0x1c'),_0x1fa56a+'-'+_0x5758ab+'/'+_0x166be7)['json'](_0x347882);}return null;};}function patchUpdates(_0x4582a8){return function(_0x121e06){try{jsonpatch['apply'](_0x121e06,_0x4582a8,!![]);}catch(_0x8b0146){return BPromise[_0x98ec('0x1d')](_0x8b0146);}return _0x121e06[_0x98ec('0x1e')]();};}function saveUpdates(_0x160b8b,_0x359a48){return function(_0x25c706){if(_0x25c706){return _0x25c706[_0x98ec('0x1f')](_0x160b8b)[_0x98ec('0x20')](function(_0x42390a){return _0x42390a;});}return null;};}function removeEntity(_0x16fe8b,_0x1689c9){return function(_0x2c595c){if(_0x2c595c){return _0x2c595c[_0x98ec('0x21')]()[_0x98ec('0x20')](function(){_0x16fe8b[_0x98ec('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4e432f,_0x5d91bd){return function(_0x38ca52){if(!_0x38ca52){_0x4e432f['sendStatus'](0x194);}return _0x38ca52;};}function handleError(_0x3700c2,_0x3f1fd1){_0x3f1fd1=_0x3f1fd1||0x1f4;return function(_0x35406e){logger['error'](_0x35406e[_0x98ec('0x22')]);if(_0x35406e[_0x98ec('0x23')]){delete _0x35406e[_0x98ec('0x23')];}_0x3700c2[_0x98ec('0x15')](_0x3f1fd1)[_0x98ec('0x24')](_0x35406e);};}exports[_0x98ec('0x25')]=function(_0x3b883f,_0xf684a1){var _0x190ead={},_0x1f9a56={},_0x251808={'count':0x0,'rows':[]};var _0x58b9e3=_[_0x98ec('0x26')](db[_0x98ec('0x27')][_0x98ec('0x28')],function(_0x2d1bb2){return{'name':_0x2d1bb2[_0x98ec('0x29')],'type':_0x2d1bb2[_0x98ec('0x2a')]['key']};});_0x1f9a56[_0x98ec('0x2b')]=_[_0x98ec('0x26')](_0x58b9e3,_0x98ec('0x23'));_0x1f9a56[_0x98ec('0x2c')]=_[_0x98ec('0x2d')](_0x3b883f['query']);_0x1f9a56[_0x98ec('0x2e')]=_[_0x98ec('0x2f')](_0x1f9a56[_0x98ec('0x2b')],_0x1f9a56['query']);_0x190ead[_0x98ec('0x30')]=_[_0x98ec('0x2f')](_0x1f9a56[_0x98ec('0x2b')],qs[_0x98ec('0x31')](_0x3b883f[_0x98ec('0x2c')]['fields']));_0x190ead[_0x98ec('0x30')]=_0x190ead[_0x98ec('0x30')][_0x98ec('0x32')]?_0x190ead['attributes']:_0x1f9a56[_0x98ec('0x2b')];if(!_0x3b883f['query']['hasOwnProperty']('nolimit')){_0x190ead[_0x98ec('0x19')]=qs['limit'](_0x3b883f[_0x98ec('0x2c')][_0x98ec('0x19')]);_0x190ead[_0x98ec('0x17')]=qs[_0x98ec('0x17')](_0x3b883f[_0x98ec('0x2c')][_0x98ec('0x17')]);}_0x190ead[_0x98ec('0x33')]=qs[_0x98ec('0x34')](_0x3b883f[_0x98ec('0x2c')][_0x98ec('0x34')]);_0x190ead['where']=qs['filters'](_[_0x98ec('0x35')](_0x3b883f[_0x98ec('0x2c')],_0x1f9a56[_0x98ec('0x2e')]),_0x58b9e3);if(_0x3b883f['query'][_0x98ec('0x36')]){_0x190ead[_0x98ec('0x37')]=_[_0x98ec('0x38')](_0x190ead[_0x98ec('0x37')],{'$or':_[_0x98ec('0x26')](_0x58b9e3,function(_0x392c53){if(_0x392c53[_0x98ec('0x2a')]!==_0x98ec('0x39')){var _0x37b8f8={};_0x37b8f8[_0x392c53[_0x98ec('0x23')]]={'$like':'%'+_0x3b883f[_0x98ec('0x2c')][_0x98ec('0x36')]+'%'};return _0x37b8f8;}})});}_0x190ead=_[_0x98ec('0x38')]({},_0x190ead,_0x3b883f[_0x98ec('0x3a')]);var _0x47b6df={'where':_0x190ead[_0x98ec('0x37')]};return db[_0x98ec('0x27')][_0x98ec('0x1a')](_0x47b6df)[_0x98ec('0x20')](function(_0x210716){_0x251808[_0x98ec('0x1a')]=_0x210716;if(_0x3b883f[_0x98ec('0x2c')][_0x98ec('0x3b')]){_0x190ead['include']=[{'all':!![]}];}return db[_0x98ec('0x27')]['findAll'](_0x190ead);})[_0x98ec('0x20')](function(_0x2f87c2){_0x251808[_0x98ec('0x3c')]=_0x2f87c2;return _0x251808;})[_0x98ec('0x20')](respondWithFilteredResult(_0xf684a1,_0x190ead))['catch'](handleError(_0xf684a1,null));};exports[_0x98ec('0x3d')]=function(_0x7b7935,_0x394ead){var _0x4d1909={'raw':![],'where':{'id':_0x7b7935['params']['id']}},_0x41d100={};_0x41d100['model']=_[_0x98ec('0x2d')](db[_0x98ec('0x27')]['rawAttributes']);_0x41d100['query']=_[_0x98ec('0x2d')](_0x7b7935[_0x98ec('0x2c')]);_0x41d100[_0x98ec('0x2e')]=_['intersection'](_0x41d100[_0x98ec('0x2b')],_0x41d100['query']);_0x4d1909[_0x98ec('0x30')]=_[_0x98ec('0x2f')](_0x41d100['model'],qs[_0x98ec('0x31')](_0x7b7935[_0x98ec('0x2c')][_0x98ec('0x31')]));_0x4d1909['attributes']=_0x4d1909[_0x98ec('0x30')]['length']?_0x4d1909['attributes']:_0x41d100[_0x98ec('0x2b')];if(_0x7b7935[_0x98ec('0x2c')][_0x98ec('0x3b')]){_0x4d1909[_0x98ec('0x3e')]=[{'all':!![]}];}_0x4d1909=_[_0x98ec('0x38')]({},_0x4d1909,_0x7b7935[_0x98ec('0x3a')]);return db['DeskAccount'][_0x98ec('0x3f')](_0x4d1909)[_0x98ec('0x20')](handleEntityNotFound(_0x394ead,null))[_0x98ec('0x20')](respondWithResult(_0x394ead,null))[_0x98ec('0x40')](handleError(_0x394ead,null));};exports[_0x98ec('0x41')]=function(_0x1b22e0,_0xb66736){return db[_0x98ec('0x27')][_0x98ec('0x41')](_0x1b22e0[_0x98ec('0x42')],{})[_0x98ec('0x20')](respondWithResult(_0xb66736,0xc9))[_0x98ec('0x40')](handleError(_0xb66736,null));};exports['update']=function(_0x2822d1,_0x4663df){if(_0x2822d1[_0x98ec('0x42')]['id']){delete _0x2822d1[_0x98ec('0x42')]['id'];}return db[_0x98ec('0x27')][_0x98ec('0x3f')]({'where':{'id':_0x2822d1[_0x98ec('0x43')]['id']}})[_0x98ec('0x20')](handleEntityNotFound(_0x4663df,null))['then'](saveUpdates(_0x2822d1[_0x98ec('0x42')],null))[_0x98ec('0x20')](respondWithResult(_0x4663df,null))[_0x98ec('0x40')](handleError(_0x4663df,null));};exports['destroy']=function(_0x13875e,_0x548378){return db[_0x98ec('0x27')][_0x98ec('0x3f')]({'where':{'id':_0x13875e[_0x98ec('0x43')]['id']}})[_0x98ec('0x20')](handleEntityNotFound(_0x548378,null))[_0x98ec('0x20')](removeEntity(_0x548378,null))[_0x98ec('0x40')](handleError(_0x548378,null));};exports[_0x98ec('0x44')]=function(_0x5a65c8,_0x5ac6a1,_0x2c6028){var _0x4ae659={};var _0x14aa50={};var _0x5f7979;var _0x1a1956;return db[_0x98ec('0x27')][_0x98ec('0x45')]({'where':{'id':_0x5a65c8[_0x98ec('0x43')]['id']}})['then'](handleEntityNotFound(_0x5ac6a1,null))[_0x98ec('0x20')](function(_0x325208){if(_0x325208){_0x5f7979=_0x325208;_0x14aa50['model']=_[_0x98ec('0x2d')](db['DeskConfiguration'][_0x98ec('0x28')]);_0x14aa50[_0x98ec('0x2c')]=_[_0x98ec('0x2d')](_0x5a65c8['query']);_0x14aa50[_0x98ec('0x2e')]=_[_0x98ec('0x2f')](_0x14aa50['model'],_0x14aa50[_0x98ec('0x2c')]);_0x4ae659['attributes']=_[_0x98ec('0x2f')](_0x14aa50['model'],qs['fields'](_0x5a65c8[_0x98ec('0x2c')][_0x98ec('0x31')]));_0x4ae659[_0x98ec('0x30')]=_0x4ae659[_0x98ec('0x30')][_0x98ec('0x32')]?_0x4ae659[_0x98ec('0x30')]:_0x14aa50[_0x98ec('0x2b')];_0x4ae659[_0x98ec('0x33')]=qs[_0x98ec('0x34')](_0x5a65c8[_0x98ec('0x2c')]['sort']);_0x4ae659[_0x98ec('0x37')]=qs[_0x98ec('0x2e')](_['pick'](_0x5a65c8[_0x98ec('0x2c')],_0x14aa50['filters']));if(_0x5a65c8[_0x98ec('0x2c')]['filter']){_0x4ae659[_0x98ec('0x37')]=_[_0x98ec('0x38')](_0x4ae659[_0x98ec('0x37')],{'$or':_[_0x98ec('0x26')](_0x4ae659[_0x98ec('0x30')],function(_0x47bf6e){var _0x1415c4={};_0x1415c4[_0x47bf6e]={'$like':'%'+_0x5a65c8[_0x98ec('0x2c')][_0x98ec('0x36')]+'%'};return _0x1415c4;})});}_0x4ae659=_[_0x98ec('0x38')]({},_0x4ae659,_0x5a65c8[_0x98ec('0x3a')]);return _0x5f7979[_0x98ec('0x44')](_0x4ae659);}})[_0x98ec('0x20')](function(_0x1c6777){if(_0x1c6777){_0x1a1956=_0x1c6777[_0x98ec('0x32')];if(!_0x5a65c8['query'][_0x98ec('0x46')]('nolimit')){_0x4ae659[_0x98ec('0x19')]=qs[_0x98ec('0x19')](_0x5a65c8['query'][_0x98ec('0x19')]);_0x4ae659[_0x98ec('0x17')]=qs[_0x98ec('0x17')](_0x5a65c8[_0x98ec('0x2c')]['offset']);}return _0x5f7979[_0x98ec('0x44')](_0x4ae659);}})[_0x98ec('0x20')](function(_0x4949d3){if(_0x4949d3){return _0x4949d3?{'count':_0x1a1956,'rows':_0x4949d3}:null;}})[_0x98ec('0x20')](respondWithResult(_0x5ac6a1,null))['catch'](handleError(_0x5ac6a1,null));};exports[_0x98ec('0x47')]=function(_0x362db5,_0x20dd02,_0x106372){if(_0x362db5[_0x98ec('0x42')]['id']){delete _0x362db5[_0x98ec('0x42')]['id'];}return db[_0x98ec('0x27')]['findOne']({'where':{'id':_0x362db5[_0x98ec('0x43')]['id']}})['then'](handleEntityNotFound(_0x20dd02,null))['then'](function(_0x1b0ac3){if(_0x1b0ac3){_0x362db5[_0x98ec('0x42')]['AccountId']=_0x1b0ac3['id'];_0x362db5[_0x98ec('0x42')][_0x98ec('0x48')]=integrations[_0x98ec('0x49')](_0x362db5['body']['channel'],_0x362db5[_0x98ec('0x42')]['type']);_0x362db5[_0x98ec('0x42')][_0x98ec('0x4a')]=integrations[_0x98ec('0x4b')](_0x362db5['body'][_0x98ec('0x4c')],_0x362db5[_0x98ec('0x42')][_0x98ec('0x2a')]);return db[_0x98ec('0x4d')][_0x98ec('0x41')](_0x362db5[_0x98ec('0x42')],{'include':[{'model':db[_0x98ec('0x4e')],'as':'Subjects'},{'model':db['DeskField'],'as':_0x98ec('0x4a')}]});}return null;})[_0x98ec('0x20')](respondWithResult(_0x20dd02,null))[_0x98ec('0x40')](handleError(_0x20dd02,null));};exports[_0x98ec('0x4f')]=function(_0xe95ef9,_0xc37afd,_0x3587f1){var _0x454a85=[{'name':_0x98ec('0x50'),'label':_0x98ec('0x50'),'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 _0x480523='';return db[_0x98ec('0x27')][_0x98ec('0x45')]({'where':{'id':_0xe95ef9['params']['id']},'attributes':['id',_0x98ec('0x51'),_0x98ec('0x52'),_0x98ec('0x53'),_0x98ec('0x54'),_0x98ec('0x55'),_0x98ec('0x56'),'token',_0x98ec('0x57')]})[_0x98ec('0x20')](handleEntityNotFound(_0xc37afd,null))[_0x98ec('0x20')](function(_0x194cce){if(_0x194cce){_0x480523=_0x194cce[_0x98ec('0x51')];var _0xafe90f=_0x480523['slice'](-0x1);if(_0xafe90f==='/'){_0x480523=_0x480523[_0x98ec('0x58')](0x0,_0x480523[_0x98ec('0x59')](_0xafe90f));}var _0x57aba2={'method':'GET','uri':util['format'](_0x98ec('0x5a'),_0x480523),'headers':{'Content-Type':'application/json','Accept':_0x98ec('0x5b')},'json':!![]};if(_0x194cce[_0x98ec('0x52')]==='basic'){_0x57aba2[_0x98ec('0x5c')][_0x98ec('0x5d')]=util[_0x98ec('0x5e')](_0x98ec('0x5f'),new Buffer(util[_0x98ec('0x5e')](_0x98ec('0x60'),_0x194cce[_0x98ec('0x53')],_0x194cce[_0x98ec('0x54')]))['toString'](_0x98ec('0x61')));}return rp(_0x57aba2)['then'](function(_0xa0ca27){return _0x454a85[_0x98ec('0x62')](_['map'](_0xa0ca27['_embedded'][_0x98ec('0x63')],function(_0x19a0b5){return{'id':_0x19a0b5[_0x98ec('0x23')],'name':_0x19a0b5[_0x98ec('0x23')],'type':_0x19a0b5['type'],'active':_0x19a0b5[_0x98ec('0x64')],'label':_0x19a0b5[_0x98ec('0x65')],'custom':!![]};}));});}})[_0x98ec('0x20')](function(_0x236fcf){return{'count':_0x236fcf['length'],'rows':_0x236fcf};})[_0x98ec('0x20')](respondWithResult(_0xc37afd,null))[_0x98ec('0x40')](function(_0x9d1783){var _0x42431a=_0xe95ef9['query'][_0x98ec('0x66')]?0x1f4:_0x9d1783[_0x98ec('0x67')]||0x1f4;logger[_0x98ec('0x68')](_0x98ec('0x69'),_0x98ec('0x4f'),_0x42431a,JSON[_0x98ec('0x6a')](_0x9d1783));delete _0x9d1783[_0x98ec('0x23')];if(_0x42431a===0x191){_0x42431a=0x190;}_0xc37afd[_0x98ec('0x15')](_0x42431a)[_0x98ec('0x24')](_0xe95ef9[_0x98ec('0x2c')][_0x98ec('0x66')]?{'message':_0x98ec('0x6b'),'statusCode':_0x9d1783[_0x98ec('0x67')]}:_0x9d1783);});};
\ No newline at end of file
+var _0xaa8e=['filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','rows','catch','show','params','find','create','body','getConfigurations','findOne','length','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','DeskConfiguration','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','token','tokenSecret','slice','substring','lastIndexOf','GET','format','%s/custom_fields','basic','headers','toString','base64','concat','_embedded','entries','active','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','send','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','end','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','error','stack','name','index','map','DeskAccount','rawAttributes','type','model','query','keys'];(function(_0x22f53f,_0x14ef66){var _0x57bc67=function(_0x375f18){while(--_0x375f18){_0x22f53f['push'](_0x22f53f['shift']());}};_0x57bc67(++_0x14ef66);}(_0xaa8e,0x126));var _0xeaa8=function(_0x391fc3,_0x2aa361){_0x391fc3=_0x391fc3-0x0;var _0x684b49=_0xaa8e[_0x391fc3];return _0x684b49;};'use strict';var emlformat=require(_0xeaa8('0x0'));var rimraf=require(_0xeaa8('0x1'));var zipdir=require(_0xeaa8('0x2'));var jsonpatch=require(_0xeaa8('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xeaa8('0x4'));var Mustache=require('mustache');var util=require(_0xeaa8('0x5'));var path=require(_0xeaa8('0x6'));var sox=require(_0xeaa8('0x7'));var csv=require(_0xeaa8('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xeaa8('0x9'));var _=require(_0xeaa8('0xa'));var squel=require(_0xeaa8('0xb'));var crypto=require(_0xeaa8('0xc'));var jsforce=require(_0xeaa8('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xeaa8('0x8'));var querystring=require(_0xeaa8('0xe'));var Papa=require('papaparse');var Redis=require(_0xeaa8('0xf'));var authService=require(_0xeaa8('0x10'));var qs=require(_0xeaa8('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xeaa8('0x12'));var logger=require(_0xeaa8('0x13'))(_0xeaa8('0x14'));var utils=require(_0xeaa8('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xeaa8('0x16'));var db=require(_0xeaa8('0x17'))['db'];var integrations=require(_0xeaa8('0x18'));function respondWithStatusCode(_0x427efe,_0x83795d){_0x83795d=_0x83795d||0xcc;return function(_0x55857a){if(_0x55857a){return _0x427efe[_0xeaa8('0x19')](_0x83795d);}return _0x427efe['status'](_0x83795d)[_0xeaa8('0x1a')]();};}function respondWithResult(_0x20e6a6,_0x6585b){_0x6585b=_0x6585b||0xc8;return function(_0xd8fb19){if(_0xd8fb19){return _0x20e6a6[_0xeaa8('0x1b')](_0x6585b)[_0xeaa8('0x1c')](_0xd8fb19);}};}function respondWithFilteredResult(_0x37f52b,_0x531e37){return function(_0x3923e2){if(_0x3923e2){var _0x109f5f=typeof _0x531e37['offset']===_0xeaa8('0x1d')&&typeof _0x531e37[_0xeaa8('0x1e')]===_0xeaa8('0x1d');var _0x1d9388=_0x3923e2[_0xeaa8('0x1f')];var _0xa6e8d2=_0x109f5f?0x0:_0x531e37[_0xeaa8('0x20')];var _0x2d2ed3=_0x109f5f?_0x3923e2[_0xeaa8('0x1f')]:_0x531e37[_0xeaa8('0x20')]+_0x531e37[_0xeaa8('0x1e')];var _0x4924ee;if(_0x2d2ed3>=_0x1d9388){_0x2d2ed3=_0x1d9388;_0x4924ee=0xc8;}else{_0x4924ee=0xce;}_0x37f52b[_0xeaa8('0x1b')](_0x4924ee);return _0x37f52b[_0xeaa8('0x21')](_0xeaa8('0x22'),_0xa6e8d2+'-'+_0x2d2ed3+'/'+_0x1d9388)[_0xeaa8('0x1c')](_0x3923e2);}return null;};}function patchUpdates(_0x56033e){return function(_0x4f5450){try{jsonpatch[_0xeaa8('0x23')](_0x4f5450,_0x56033e,!![]);}catch(_0x55883a){return BPromise[_0xeaa8('0x24')](_0x55883a);}return _0x4f5450[_0xeaa8('0x25')]();};}function saveUpdates(_0x209f04,_0x777a8b){return function(_0x551ecb){if(_0x551ecb){return _0x551ecb[_0xeaa8('0x26')](_0x209f04)[_0xeaa8('0x27')](function(_0x5441f9){return _0x5441f9;});}return null;};}function removeEntity(_0x1f0139,_0x543cd8){return function(_0x596271){if(_0x596271){return _0x596271['destroy']()[_0xeaa8('0x27')](function(){_0x1f0139[_0xeaa8('0x1b')](0xcc)[_0xeaa8('0x1a')]();});}};}function handleEntityNotFound(_0x4eb633,_0x15d1ee){return function(_0x49a8cb){if(!_0x49a8cb){_0x4eb633[_0xeaa8('0x19')](0x194);}return _0x49a8cb;};}function handleError(_0x2a7a0a,_0x43f053){_0x43f053=_0x43f053||0x1f4;return function(_0x24eb40){logger[_0xeaa8('0x28')](_0x24eb40[_0xeaa8('0x29')]);if(_0x24eb40[_0xeaa8('0x2a')]){delete _0x24eb40[_0xeaa8('0x2a')];}_0x2a7a0a['status'](_0x43f053)['send'](_0x24eb40);};}exports[_0xeaa8('0x2b')]=function(_0x5d8650,_0x60b6e4){var _0x425271={},_0x41ece8={},_0x1950ae={'count':0x0,'rows':[]};var _0x3d5c82=_[_0xeaa8('0x2c')](db[_0xeaa8('0x2d')][_0xeaa8('0x2e')],function(_0x5471c5){return{'name':_0x5471c5['fieldName'],'type':_0x5471c5[_0xeaa8('0x2f')]['key']};});_0x41ece8[_0xeaa8('0x30')]=_['map'](_0x3d5c82,_0xeaa8('0x2a'));_0x41ece8[_0xeaa8('0x31')]=_[_0xeaa8('0x32')](_0x5d8650['query']);_0x41ece8[_0xeaa8('0x33')]=_[_0xeaa8('0x34')](_0x41ece8[_0xeaa8('0x30')],_0x41ece8[_0xeaa8('0x31')]);_0x425271['attributes']=_['intersection'](_0x41ece8[_0xeaa8('0x30')],qs[_0xeaa8('0x35')](_0x5d8650['query'][_0xeaa8('0x35')]));_0x425271[_0xeaa8('0x36')]=_0x425271[_0xeaa8('0x36')]['length']?_0x425271[_0xeaa8('0x36')]:_0x41ece8[_0xeaa8('0x30')];if(!_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x37')](_0xeaa8('0x38'))){_0x425271[_0xeaa8('0x1e')]=qs[_0xeaa8('0x1e')](_0x5d8650[_0xeaa8('0x31')]['limit']);_0x425271['offset']=qs['offset'](_0x5d8650['query'][_0xeaa8('0x20')]);}_0x425271[_0xeaa8('0x39')]=qs[_0xeaa8('0x3a')](_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x3a')]);_0x425271[_0xeaa8('0x3b')]=qs[_0xeaa8('0x33')](_[_0xeaa8('0x3c')](_0x5d8650['query'],_0x41ece8[_0xeaa8('0x33')]),_0x3d5c82);if(_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x3d')]){_0x425271[_0xeaa8('0x3b')]=_[_0xeaa8('0x3e')](_0x425271[_0xeaa8('0x3b')],{'$or':_['map'](_0x3d5c82,function(_0x3c17f3){if(_0x3c17f3[_0xeaa8('0x2f')]!=='VIRTUAL'){var _0x4ea3a4={};_0x4ea3a4[_0x3c17f3[_0xeaa8('0x2a')]]={'$like':'%'+_0x5d8650[_0xeaa8('0x31')]['filter']+'%'};return _0x4ea3a4;}})});}_0x425271=_[_0xeaa8('0x3e')]({},_0x425271,_0x5d8650[_0xeaa8('0x3f')]);var _0x5b0a5f={'where':_0x425271['where']};return db[_0xeaa8('0x2d')][_0xeaa8('0x1f')](_0x5b0a5f)[_0xeaa8('0x27')](function(_0xfb43e4){_0x1950ae['count']=_0xfb43e4;if(_0x5d8650[_0xeaa8('0x31')][_0xeaa8('0x40')]){_0x425271[_0xeaa8('0x41')]=[{'all':!![]}];}return db[_0xeaa8('0x2d')]['findAll'](_0x425271);})[_0xeaa8('0x27')](function(_0x2b3bd5){_0x1950ae[_0xeaa8('0x42')]=_0x2b3bd5;return _0x1950ae;})[_0xeaa8('0x27')](respondWithFilteredResult(_0x60b6e4,_0x425271))[_0xeaa8('0x43')](handleError(_0x60b6e4,null));};exports[_0xeaa8('0x44')]=function(_0x1581aa,_0x3f63b7){var _0x1b4447={'raw':![],'where':{'id':_0x1581aa[_0xeaa8('0x45')]['id']}},_0x283b04={};_0x283b04[_0xeaa8('0x30')]=_[_0xeaa8('0x32')](db['DeskAccount']['rawAttributes']);_0x283b04[_0xeaa8('0x31')]=_[_0xeaa8('0x32')](_0x1581aa['query']);_0x283b04['filters']=_[_0xeaa8('0x34')](_0x283b04[_0xeaa8('0x30')],_0x283b04[_0xeaa8('0x31')]);_0x1b4447[_0xeaa8('0x36')]=_[_0xeaa8('0x34')](_0x283b04[_0xeaa8('0x30')],qs['fields'](_0x1581aa['query'][_0xeaa8('0x35')]));_0x1b4447[_0xeaa8('0x36')]=_0x1b4447[_0xeaa8('0x36')]['length']?_0x1b4447[_0xeaa8('0x36')]:_0x283b04[_0xeaa8('0x30')];if(_0x1581aa['query'][_0xeaa8('0x40')]){_0x1b4447['include']=[{'all':!![]}];}_0x1b4447=_['merge']({},_0x1b4447,_0x1581aa[_0xeaa8('0x3f')]);return db[_0xeaa8('0x2d')][_0xeaa8('0x46')](_0x1b4447)[_0xeaa8('0x27')](handleEntityNotFound(_0x3f63b7,null))[_0xeaa8('0x27')](respondWithResult(_0x3f63b7,null))[_0xeaa8('0x43')](handleError(_0x3f63b7,null));};exports['create']=function(_0x4f8a1c,_0x1ac592){return db['DeskAccount'][_0xeaa8('0x47')](_0x4f8a1c[_0xeaa8('0x48')],{})[_0xeaa8('0x27')](respondWithResult(_0x1ac592,0xc9))[_0xeaa8('0x43')](handleError(_0x1ac592,null));};exports['update']=function(_0x51a5d9,_0x1f4e8e){if(_0x51a5d9[_0xeaa8('0x48')]['id']){delete _0x51a5d9[_0xeaa8('0x48')]['id'];}return db[_0xeaa8('0x2d')][_0xeaa8('0x46')]({'where':{'id':_0x51a5d9[_0xeaa8('0x45')]['id']}})[_0xeaa8('0x27')](handleEntityNotFound(_0x1f4e8e,null))[_0xeaa8('0x27')](saveUpdates(_0x51a5d9[_0xeaa8('0x48')],null))[_0xeaa8('0x27')](respondWithResult(_0x1f4e8e,null))[_0xeaa8('0x43')](handleError(_0x1f4e8e,null));};exports['destroy']=function(_0x4e6489,_0x25dfa0){return db[_0xeaa8('0x2d')][_0xeaa8('0x46')]({'where':{'id':_0x4e6489[_0xeaa8('0x45')]['id']}})['then'](handleEntityNotFound(_0x25dfa0,null))[_0xeaa8('0x27')](removeEntity(_0x25dfa0,null))[_0xeaa8('0x43')](handleError(_0x25dfa0,null));};exports[_0xeaa8('0x49')]=function(_0x57f40d,_0xf7578,_0x54f0e0){var _0x1619f3={};var _0x1ad662={};var _0x3e303d;var _0x18c0f9;return db[_0xeaa8('0x2d')][_0xeaa8('0x4a')]({'where':{'id':_0x57f40d[_0xeaa8('0x45')]['id']}})[_0xeaa8('0x27')](handleEntityNotFound(_0xf7578,null))['then'](function(_0x4bda2a){if(_0x4bda2a){_0x3e303d=_0x4bda2a;_0x1ad662[_0xeaa8('0x30')]=_[_0xeaa8('0x32')](db['DeskConfiguration'][_0xeaa8('0x2e')]);_0x1ad662[_0xeaa8('0x31')]=_[_0xeaa8('0x32')](_0x57f40d[_0xeaa8('0x31')]);_0x1ad662[_0xeaa8('0x33')]=_[_0xeaa8('0x34')](_0x1ad662[_0xeaa8('0x30')],_0x1ad662[_0xeaa8('0x31')]);_0x1619f3[_0xeaa8('0x36')]=_[_0xeaa8('0x34')](_0x1ad662['model'],qs[_0xeaa8('0x35')](_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x35')]));_0x1619f3[_0xeaa8('0x36')]=_0x1619f3[_0xeaa8('0x36')][_0xeaa8('0x4b')]?_0x1619f3[_0xeaa8('0x36')]:_0x1ad662['model'];_0x1619f3[_0xeaa8('0x39')]=qs[_0xeaa8('0x3a')](_0x57f40d['query']['sort']);_0x1619f3[_0xeaa8('0x3b')]=qs['filters'](_[_0xeaa8('0x3c')](_0x57f40d[_0xeaa8('0x31')],_0x1ad662[_0xeaa8('0x33')]));if(_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x3d')]){_0x1619f3[_0xeaa8('0x3b')]=_[_0xeaa8('0x3e')](_0x1619f3['where'],{'$or':_['map'](_0x1619f3[_0xeaa8('0x36')],function(_0x30b632){var _0x53a49a={};_0x53a49a[_0x30b632]={'$like':'%'+_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x3d')]+'%'};return _0x53a49a;})});}_0x1619f3=_[_0xeaa8('0x3e')]({},_0x1619f3,_0x57f40d[_0xeaa8('0x3f')]);return _0x3e303d[_0xeaa8('0x49')](_0x1619f3);}})[_0xeaa8('0x27')](function(_0x2bb5be){if(_0x2bb5be){_0x18c0f9=_0x2bb5be['length'];if(!_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x37')](_0xeaa8('0x38'))){_0x1619f3['limit']=qs[_0xeaa8('0x1e')](_0x57f40d[_0xeaa8('0x31')]['limit']);_0x1619f3['offset']=qs['offset'](_0x57f40d[_0xeaa8('0x31')][_0xeaa8('0x20')]);}return _0x3e303d[_0xeaa8('0x49')](_0x1619f3);}})[_0xeaa8('0x27')](function(_0x1eafdd){if(_0x1eafdd){return _0x1eafdd?{'count':_0x18c0f9,'rows':_0x1eafdd}:null;}})[_0xeaa8('0x27')](respondWithResult(_0xf7578,null))[_0xeaa8('0x43')](handleError(_0xf7578,null));};exports[_0xeaa8('0x4c')]=function(_0xb5f8f9,_0x1ef259,_0x15defd){if(_0xb5f8f9[_0xeaa8('0x48')]['id']){delete _0xb5f8f9[_0xeaa8('0x48')]['id'];}return db[_0xeaa8('0x2d')][_0xeaa8('0x4a')]({'where':{'id':_0xb5f8f9[_0xeaa8('0x45')]['id']}})[_0xeaa8('0x27')](handleEntityNotFound(_0x1ef259,null))[_0xeaa8('0x27')](function(_0x1e4af4){if(_0x1e4af4){_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4d')]=_0x1e4af4['id'];_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4e')]=integrations['getSubjects'](_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4f')],_0xb5f8f9[_0xeaa8('0x48')]['type']);_0xb5f8f9['body'][_0xeaa8('0x50')]=integrations[_0xeaa8('0x51')](_0xb5f8f9[_0xeaa8('0x48')][_0xeaa8('0x4f')],_0xb5f8f9[_0xeaa8('0x48')]['type']);return db[_0xeaa8('0x52')][_0xeaa8('0x47')](_0xb5f8f9['body'],{'include':[{'model':db[_0xeaa8('0x53')],'as':_0xeaa8('0x4e')},{'model':db['DeskField'],'as':_0xeaa8('0x50')}]});}return null;})[_0xeaa8('0x27')](respondWithResult(_0x1ef259,null))[_0xeaa8('0x43')](handleError(_0x1ef259,null));};exports[_0xeaa8('0x54')]=function(_0x3d3a09,_0x33afef,_0x474bd9){var _0x2836b4=[{'name':_0xeaa8('0x55'),'label':_0xeaa8('0x55'),'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 _0x330660='';return db['DeskAccount'][_0xeaa8('0x4a')]({'where':{'id':_0x3d3a09[_0xeaa8('0x45')]['id']},'attributes':['id',_0xeaa8('0x56'),_0xeaa8('0x57'),_0xeaa8('0x58'),_0xeaa8('0x59'),_0xeaa8('0x5a'),_0xeaa8('0x5b'),_0xeaa8('0x5c'),_0xeaa8('0x5d')]})[_0xeaa8('0x27')](handleEntityNotFound(_0x33afef,null))['then'](function(_0x3d22fe){if(_0x3d22fe){_0x330660=_0x3d22fe[_0xeaa8('0x56')];var _0x2726c0=_0x330660[_0xeaa8('0x5e')](-0x1);if(_0x2726c0==='/'){_0x330660=_0x330660[_0xeaa8('0x5f')](0x0,_0x330660[_0xeaa8('0x60')](_0x2726c0));}var _0x4c70f4={'method':_0xeaa8('0x61'),'uri':util[_0xeaa8('0x62')](_0xeaa8('0x63'),_0x330660),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x3d22fe[_0xeaa8('0x57')]===_0xeaa8('0x64')){_0x4c70f4[_0xeaa8('0x65')]['Authorization']=util[_0xeaa8('0x62')]('Basic\x20%s',new Buffer(util['format']('%s:%s',_0x3d22fe[_0xeaa8('0x58')],_0x3d22fe['password']))[_0xeaa8('0x66')](_0xeaa8('0x67')));}return rp(_0x4c70f4)[_0xeaa8('0x27')](function(_0x58bb05){return _0x2836b4[_0xeaa8('0x68')](_[_0xeaa8('0x2c')](_0x58bb05[_0xeaa8('0x69')][_0xeaa8('0x6a')],function(_0x53fb6c){return{'id':_0x53fb6c[_0xeaa8('0x2a')],'name':_0x53fb6c['name'],'type':_0x53fb6c['type'],'active':_0x53fb6c[_0xeaa8('0x6b')],'label':_0x53fb6c[_0xeaa8('0x6c')],'custom':!![]};}));});}})[_0xeaa8('0x27')](function(_0x3f3ef9){return{'count':_0x3f3ef9['length'],'rows':_0x3f3ef9};})[_0xeaa8('0x27')](respondWithResult(_0x33afef,null))[_0xeaa8('0x43')](function(_0x514c0e){var _0x13e4e3=_0x3d3a09[_0xeaa8('0x31')]['test']?0x1f4:_0x514c0e[_0xeaa8('0x6d')]||0x1f4;logger[_0xeaa8('0x28')](_0xeaa8('0x6e'),_0xeaa8('0x54'),_0x13e4e3,JSON[_0xeaa8('0x6f')](_0x514c0e));delete _0x514c0e[_0xeaa8('0x2a')];if(_0x13e4e3===0x191){_0x13e4e3=0x190;}_0x33afef[_0xeaa8('0x1b')](_0x13e4e3)[_0xeaa8('0x70')](_0x3d3a09[_0xeaa8('0x31')][_0xeaa8('0x71')]?{'message':_0xeaa8('0x72'),'statusCode':_0x514c0e['statusCode']}:_0x514c0e);});};
\ No newline at end of file