Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 70257c3..5e57ca9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf419=['find','create','body','update','params','getConfigurations','findOne','nolimit','addConfiguration','AccountId','getSubjects','channel','Descriptions','getDescriptions','DeskField','Subjects','getFields','priority','remoteUri','username','password','consumerKey','consumerSecret','token','tokenSecret','substring','lastIndexOf','GET','format','%s/custom_fields','application/json','authType','Authorization','toString','base64','_embedded','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','to-csv','ejs','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','client','ValidationError','then','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','DeskAccount,\x20%s,\x20%s','message','info','result','catch','sendStatus','status','end','offset','limit','set','Content-Range','destroy','stack','name','send','map','DeskAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','count','includeAll','include','rows','attributes'];(function(_0x81b6d,_0x370ac1){var _0x181867=function(_0x352e3b){while(--_0x352e3b){_0x81b6d['push'](_0x81b6d['shift']());}};_0x181867(++_0x370ac1);}(_0xf419,0x10f));var _0x9f41=function(_0x48cd42,_0x27de33){_0x48cd42=_0x48cd42-0x0;var _0x127686=_0xf419[_0x48cd42];return _0x127686;};'use strict';var pdf=require(_0x9f41('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x9f41('0x1'));var jsonpatch=require(_0x9f41('0x2'));var rp=require(_0x9f41('0x3'));var moment=require(_0x9f41('0x4'));var BPromise=require(_0x9f41('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x9f41('0x6'));var sox=require('sox');var csv=require(_0x9f41('0x7'));var ejs=require(_0x9f41('0x8'));var fs=require('fs');var _=require(_0x9f41('0x9'));var squel=require('squel');var crypto=require(_0x9f41('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x9f41('0xb'));var toCsv=require(_0x9f41('0x7'));var querystring=require(_0x9f41('0xc'));var Papa=require(_0x9f41('0xd'));var Redis=require(_0x9f41('0xe'));var authService=require(_0x9f41('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x9f41('0x10'));var hardwareService=require(_0x9f41('0x11'));var logger=require(_0x9f41('0x12'))(_0x9f41('0x13'));var utils=require(_0x9f41('0x14'));var config=require(_0x9f41('0x15'));var db=require(_0x9f41('0x16'))['db'];var integrations=require(_0x9f41('0x17'));var jayson=require('jayson/promise');var client=jayson[_0x9f41('0x18')]['http']({'port':0x232a});function checkPasswordPattern(_0x296c0b,_0x54cab1,_0xa146c3){if(_0xa146c3){var _0x2102c9=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x2102c9['test'](_0x54cab1)){return _0x296c0b;}else{throw new db['Sequelize'][(_0x9f41('0x19'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x296c0b;}}function respondWithRpcPromise(_0x3d600b,_0xb3e41c,_0x270ff1,_0xf6177b){return new BPromise(function(_0xde6b20,_0xc80f8f){var _0x446199=_0xf6177b||client;return _0x446199['request'](_0x3d600b,_0x270ff1)[_0x9f41('0x1a')](function(_0x4e66df){logger['info']('DeskAccount,\x20%s,\x20%s',_0xb3e41c,_0x9f41('0x1b'));logger[_0x9f41('0x1c')](_0x9f41('0x1d'),_0xb3e41c,_0x9f41('0x1b'),JSON[_0x9f41('0x1e')](_0x4e66df));if(_0x4e66df[_0x9f41('0x1f')]){if(_0x4e66df['error']['code']===0x1f4){logger['error'](_0x9f41('0x20'),_0xb3e41c,_0x4e66df['error'][_0x9f41('0x21')]);return _0xc80f8f(_0x4e66df[_0x9f41('0x1f')][_0x9f41('0x21')]);}logger[_0x9f41('0x1f')](_0x9f41('0x20'),_0xb3e41c,_0x4e66df[_0x9f41('0x1f')][_0x9f41('0x21')]);return _0xde6b20(_0x4e66df[_0x9f41('0x1f')]['message']);}else{logger[_0x9f41('0x22')](_0x9f41('0x20'),_0xb3e41c,'request\x20sent');_0xde6b20(_0x4e66df[_0x9f41('0x23')]['message']);}})[_0x9f41('0x24')](function(_0x48e4ea){logger['error'](_0x9f41('0x20'),_0xb3e41c,_0x48e4ea);_0xc80f8f(_0x48e4ea);});});}function respondWithStatusCode(_0x5ebf57,_0x186594){_0x186594=_0x186594||0xcc;return function(_0x2abe87){if(_0x2abe87){return _0x5ebf57[_0x9f41('0x25')](_0x186594);}return _0x5ebf57[_0x9f41('0x26')](_0x186594)[_0x9f41('0x27')]();};}function respondWithResult(_0xc1efc8,_0x5267e8){_0x5267e8=_0x5267e8||0xc8;return function(_0x4dbd6e){if(_0x4dbd6e){return _0xc1efc8[_0x9f41('0x26')](_0x5267e8)['json'](_0x4dbd6e);}};}function respondWithFilteredResult(_0x558f0f,_0x1d3955){return function(_0xc02194){if(_0xc02194){var _0x3f92e1=_0xc02194['count'],_0x2daa5a=_0x1d3955[_0x9f41('0x28')],_0x189ae5=_0x1d3955[_0x9f41('0x28')]+_0x1d3955[_0x9f41('0x29')],_0x2f1c91;if(_0x189ae5>=_0x3f92e1){_0x189ae5=_0x3f92e1;_0x2f1c91=0xc8;}else{_0x2f1c91=0xce;}_0x558f0f[_0x9f41('0x26')](_0x2f1c91);return _0x558f0f[_0x9f41('0x2a')](_0x9f41('0x2b'),_0x2daa5a+'-'+_0x189ae5+'/'+_0x3f92e1)['json'](_0xc02194);}return null;};}function patchUpdates(_0x3ff00b){return function(_0x45956b){try{jsonpatch['apply'](_0x45956b,_0x3ff00b,!![]);}catch(_0x527630){return BPromise['reject'](_0x527630);}return _0x45956b['save']();};}function saveUpdates(_0x1dad01,_0x3d5955){return function(_0x335e08){if(_0x335e08){return _0x335e08['update'](_0x1dad01)[_0x9f41('0x1a')](function(_0x2f0afc){return _0x2f0afc;});}return null;};}function removeEntity(_0x3fbfdf,_0x1efd98){return function(_0x1b2139){if(_0x1b2139){return _0x1b2139[_0x9f41('0x2c')]()['then'](function(){_0x3fbfdf[_0x9f41('0x26')](0xcc)[_0x9f41('0x27')]();});}};}function handleEntityNotFound(_0x29c3cf,_0x1ad488){return function(_0x28e5ba){if(!_0x28e5ba){_0x29c3cf[_0x9f41('0x25')](0x194);}return _0x28e5ba;};}function handleError(_0x219c8c,_0x4ebe6b){_0x4ebe6b=_0x4ebe6b||0x1f4;return function(_0x474545){logger[_0x9f41('0x1f')](_0x474545[_0x9f41('0x2d')]);if(_0x474545[_0x9f41('0x2e')]){delete _0x474545['name'];}_0x219c8c[_0x9f41('0x26')](_0x4ebe6b)[_0x9f41('0x2f')](_0x474545);};}exports['index']=function(_0xb2493c,_0x2f8806){var _0x5cea45={},_0x32969e={},_0x331024={'count':0x0,'rows':[]};var _0x918bf0=_[_0x9f41('0x30')](db[_0x9f41('0x31')][_0x9f41('0x32')],function(_0x2265de){return{'name':_0x2265de[_0x9f41('0x33')],'type':_0x2265de[_0x9f41('0x34')]['key']};});_0x32969e[_0x9f41('0x35')]=_[_0x9f41('0x30')](_0x918bf0,_0x9f41('0x2e'));_0x32969e[_0x9f41('0x36')]=_[_0x9f41('0x37')](_0xb2493c['query']);_0x32969e[_0x9f41('0x38')]=_[_0x9f41('0x39')](_0x32969e[_0x9f41('0x35')],_0x32969e[_0x9f41('0x36')]);_0x5cea45['attributes']=_['intersection'](_0x32969e[_0x9f41('0x35')],qs[_0x9f41('0x3a')](_0xb2493c[_0x9f41('0x36')][_0x9f41('0x3a')]));_0x5cea45['attributes']=_0x5cea45['attributes'][_0x9f41('0x3b')]?_0x5cea45['attributes']:_0x32969e[_0x9f41('0x35')];if(!_0xb2493c[_0x9f41('0x36')][_0x9f41('0x3c')]('nolimit')){_0x5cea45[_0x9f41('0x29')]=qs[_0x9f41('0x29')](_0xb2493c[_0x9f41('0x36')][_0x9f41('0x29')]);_0x5cea45[_0x9f41('0x28')]=qs[_0x9f41('0x28')](_0xb2493c[_0x9f41('0x36')][_0x9f41('0x28')]);}_0x5cea45[_0x9f41('0x3d')]=qs[_0x9f41('0x3e')](_0xb2493c[_0x9f41('0x36')][_0x9f41('0x3e')]);_0x5cea45[_0x9f41('0x3f')]=qs[_0x9f41('0x38')](_[_0x9f41('0x40')](_0xb2493c[_0x9f41('0x36')],_0x32969e['filters']),_0x918bf0);if(_0xb2493c[_0x9f41('0x36')][_0x9f41('0x41')]){_0x5cea45[_0x9f41('0x3f')]=_[_0x9f41('0x42')](_0x5cea45[_0x9f41('0x3f')],{'$or':_[_0x9f41('0x30')](_0x918bf0,function(_0x2e5419){if(_0x2e5419['type']!==_0x9f41('0x43')){var _0x1c6c9a={};_0x1c6c9a[_0x2e5419[_0x9f41('0x2e')]]={'$like':'%'+_0xb2493c[_0x9f41('0x36')][_0x9f41('0x41')]+'%'};return _0x1c6c9a;}})});}_0x5cea45=_[_0x9f41('0x42')]({},_0x5cea45,_0xb2493c[_0x9f41('0x44')]);var _0x2b6e0f={'where':_0x5cea45[_0x9f41('0x3f')]};return db['DeskAccount'][_0x9f41('0x45')](_0x2b6e0f)['then'](function(_0xb365ae){_0x331024[_0x9f41('0x45')]=_0xb365ae;if(_0xb2493c[_0x9f41('0x36')][_0x9f41('0x46')]){_0x5cea45[_0x9f41('0x47')]=[{'all':!![]}];}return db[_0x9f41('0x31')]['findAll'](_0x5cea45);})[_0x9f41('0x1a')](function(_0x3c43b3){_0x331024[_0x9f41('0x48')]=_0x3c43b3;return _0x331024;})['then'](respondWithFilteredResult(_0x2f8806,_0x5cea45))[_0x9f41('0x24')](handleError(_0x2f8806,null));};exports['show']=function(_0xe5d72,_0x52770c){var _0x2cf13f={'raw':![],'where':{'id':_0xe5d72['params']['id']}},_0x1b2afa={};_0x1b2afa['model']=_[_0x9f41('0x37')](db[_0x9f41('0x31')][_0x9f41('0x32')]);_0x1b2afa['query']=_[_0x9f41('0x37')](_0xe5d72[_0x9f41('0x36')]);_0x1b2afa[_0x9f41('0x38')]=_[_0x9f41('0x39')](_0x1b2afa[_0x9f41('0x35')],_0x1b2afa['query']);_0x2cf13f['attributes']=_[_0x9f41('0x39')](_0x1b2afa[_0x9f41('0x35')],qs['fields'](_0xe5d72[_0x9f41('0x36')]['fields']));_0x2cf13f[_0x9f41('0x49')]=_0x2cf13f[_0x9f41('0x49')][_0x9f41('0x3b')]?_0x2cf13f[_0x9f41('0x49')]:_0x1b2afa[_0x9f41('0x35')];if(_0xe5d72[_0x9f41('0x36')][_0x9f41('0x46')]){_0x2cf13f[_0x9f41('0x47')]=[{'all':!![]}];}_0x2cf13f=_[_0x9f41('0x42')]({},_0x2cf13f,_0xe5d72['options']);return db['DeskAccount'][_0x9f41('0x4a')](_0x2cf13f)[_0x9f41('0x1a')](handleEntityNotFound(_0x52770c,null))[_0x9f41('0x1a')](respondWithResult(_0x52770c,null))['catch'](handleError(_0x52770c,null));};exports[_0x9f41('0x4b')]=function(_0x3545ca,_0x2f5075){return db[_0x9f41('0x31')][_0x9f41('0x4b')](_0x3545ca[_0x9f41('0x4c')],{})[_0x9f41('0x1a')](respondWithResult(_0x2f5075,0xc9))[_0x9f41('0x24')](handleError(_0x2f5075,null));};exports[_0x9f41('0x4d')]=function(_0x7a6ffb,_0x36813f){if(_0x7a6ffb[_0x9f41('0x4c')]['id']){delete _0x7a6ffb[_0x9f41('0x4c')]['id'];}return db[_0x9f41('0x31')][_0x9f41('0x4a')]({'where':{'id':_0x7a6ffb[_0x9f41('0x4e')]['id']}})[_0x9f41('0x1a')](handleEntityNotFound(_0x36813f,null))[_0x9f41('0x1a')](saveUpdates(_0x7a6ffb[_0x9f41('0x4c')],null))[_0x9f41('0x1a')](respondWithResult(_0x36813f,null))[_0x9f41('0x24')](handleError(_0x36813f,null));};exports['destroy']=function(_0xc83b57,_0xd1e2e8){return db['DeskAccount']['find']({'where':{'id':_0xc83b57[_0x9f41('0x4e')]['id']}})[_0x9f41('0x1a')](handleEntityNotFound(_0xd1e2e8,null))[_0x9f41('0x1a')](removeEntity(_0xd1e2e8,null))[_0x9f41('0x24')](handleError(_0xd1e2e8,null));};exports[_0x9f41('0x4f')]=function(_0x57e67c,_0x262d0e,_0x3e6c02){var _0x14ef9c={};var _0x1df8b5={};var _0x2e1944;var _0x38b05d;return db['DeskAccount'][_0x9f41('0x50')]({'where':{'id':_0x57e67c[_0x9f41('0x4e')]['id']}})['then'](handleEntityNotFound(_0x262d0e,null))['then'](function(_0x48a4bd){if(_0x48a4bd){_0x2e1944=_0x48a4bd;_0x1df8b5[_0x9f41('0x35')]=_['keys'](db['DeskConfiguration'][_0x9f41('0x32')]);_0x1df8b5['query']=_['keys'](_0x57e67c[_0x9f41('0x36')]);_0x1df8b5['filters']=_[_0x9f41('0x39')](_0x1df8b5[_0x9f41('0x35')],_0x1df8b5[_0x9f41('0x36')]);_0x14ef9c[_0x9f41('0x49')]=_[_0x9f41('0x39')](_0x1df8b5['model'],qs[_0x9f41('0x3a')](_0x57e67c['query']['fields']));_0x14ef9c[_0x9f41('0x49')]=_0x14ef9c[_0x9f41('0x49')][_0x9f41('0x3b')]?_0x14ef9c[_0x9f41('0x49')]:_0x1df8b5['model'];_0x14ef9c[_0x9f41('0x3d')]=qs[_0x9f41('0x3e')](_0x57e67c[_0x9f41('0x36')][_0x9f41('0x3e')]);_0x14ef9c['where']=qs[_0x9f41('0x38')](_[_0x9f41('0x40')](_0x57e67c[_0x9f41('0x36')],_0x1df8b5[_0x9f41('0x38')]));if(_0x57e67c['query'][_0x9f41('0x41')]){_0x14ef9c[_0x9f41('0x3f')]=_['merge'](_0x14ef9c[_0x9f41('0x3f')],{'$or':_[_0x9f41('0x30')](_0x14ef9c['attributes'],function(_0x5a88ce){var _0x50d409={};_0x50d409[_0x5a88ce]={'$like':'%'+_0x57e67c[_0x9f41('0x36')][_0x9f41('0x41')]+'%'};return _0x50d409;})});}_0x14ef9c=_[_0x9f41('0x42')]({},_0x14ef9c,_0x57e67c['options']);return _0x2e1944[_0x9f41('0x4f')](_0x14ef9c);}})[_0x9f41('0x1a')](function(_0x153d47){if(_0x153d47){_0x38b05d=_0x153d47['length'];if(!_0x57e67c[_0x9f41('0x36')]['hasOwnProperty'](_0x9f41('0x51'))){_0x14ef9c[_0x9f41('0x29')]=qs['limit'](_0x57e67c['query'][_0x9f41('0x29')]);_0x14ef9c[_0x9f41('0x28')]=qs['offset'](_0x57e67c[_0x9f41('0x36')][_0x9f41('0x28')]);}return _0x2e1944[_0x9f41('0x4f')](_0x14ef9c);}})['then'](function(_0x2f72ab){if(_0x2f72ab){return _0x2f72ab?{'count':_0x38b05d,'rows':_0x2f72ab}:null;}})[_0x9f41('0x1a')](respondWithResult(_0x262d0e,null))[_0x9f41('0x24')](handleError(_0x262d0e,null));};exports[_0x9f41('0x52')]=function(_0x146d20,_0x4c821c,_0x43038e){if(_0x146d20[_0x9f41('0x4c')]['id']){delete _0x146d20[_0x9f41('0x4c')]['id'];}return db[_0x9f41('0x31')]['findOne']({'where':{'id':_0x146d20['params']['id']}})[_0x9f41('0x1a')](handleEntityNotFound(_0x4c821c,null))[_0x9f41('0x1a')](function(_0x221361){if(_0x221361){_0x146d20[_0x9f41('0x4c')][_0x9f41('0x53')]=_0x221361['id'];_0x146d20[_0x9f41('0x4c')]['Subjects']=integrations[_0x9f41('0x54')](_0x146d20[_0x9f41('0x4c')][_0x9f41('0x55')],_0x146d20[_0x9f41('0x4c')][_0x9f41('0x34')]);_0x146d20[_0x9f41('0x4c')][_0x9f41('0x56')]=integrations[_0x9f41('0x57')](_0x146d20[_0x9f41('0x4c')][_0x9f41('0x55')],_0x146d20[_0x9f41('0x4c')][_0x9f41('0x34')]);return db['DeskConfiguration'][_0x9f41('0x4b')](_0x146d20[_0x9f41('0x4c')],{'include':[{'model':db[_0x9f41('0x58')],'as':_0x9f41('0x59')},{'model':db['DeskField'],'as':'Descriptions'}]});}return null;})[_0x9f41('0x1a')](respondWithResult(_0x4c821c,null))['catch'](handleError(_0x4c821c,null));};exports[_0x9f41('0x5a')]=function(_0x401003,_0x48177d,_0x1fa77b){var _0x55660f=[{'name':_0x9f41('0x5b'),'label':_0x9f41('0x5b'),'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 _0x3a1002='';return db[_0x9f41('0x31')][_0x9f41('0x50')]({'where':{'id':_0x401003['params']['id']},'attributes':['id',_0x9f41('0x5c'),'authType',_0x9f41('0x5d'),_0x9f41('0x5e'),_0x9f41('0x5f'),_0x9f41('0x60'),_0x9f41('0x61'),_0x9f41('0x62')]})[_0x9f41('0x1a')](handleEntityNotFound(_0x48177d,null))[_0x9f41('0x1a')](function(_0x473a4b){if(_0x473a4b){_0x3a1002=_0x473a4b['remoteUri'];var _0x4eae34=_0x3a1002['slice'](-0x1);if(_0x4eae34==='/'){_0x3a1002=_0x3a1002[_0x9f41('0x63')](0x0,_0x3a1002[_0x9f41('0x64')](_0x4eae34));}var _0x173c3e={'method':_0x9f41('0x65'),'uri':util[_0x9f41('0x66')](_0x9f41('0x67'),_0x3a1002),'headers':{'Content-Type':_0x9f41('0x68'),'Accept':_0x9f41('0x68')},'json':!![]};if(_0x473a4b[_0x9f41('0x69')]==='basic'){_0x173c3e['headers'][_0x9f41('0x6a')]=util[_0x9f41('0x66')]('Basic\x20%s',new Buffer(util[_0x9f41('0x66')]('%s:%s',_0x473a4b[_0x9f41('0x5d')],_0x473a4b[_0x9f41('0x5e')]))[_0x9f41('0x6b')](_0x9f41('0x6c')));}return rp(_0x173c3e)[_0x9f41('0x1a')](function(_0x35e651){return _0x55660f['concat'](_[_0x9f41('0x30')](_0x35e651[_0x9f41('0x6d')]['entries'],function(_0x52216c){return{'id':_0x52216c[_0x9f41('0x2e')],'name':_0x52216c[_0x9f41('0x2e')],'type':_0x52216c['type'],'active':_0x52216c['active'],'label':_0x52216c[_0x9f41('0x6e')],'custom':!![]};}));});}})[_0x9f41('0x1a')](function(_0x35b8d9){return{'count':_0x35b8d9['length'],'rows':_0x35b8d9};})[_0x9f41('0x1a')](respondWithResult(_0x48177d,null))[_0x9f41('0x24')](function(_0xe7dda){var _0x847895=_0x401003[_0x9f41('0x36')]['test']?0x1f4:_0xe7dda[_0x9f41('0x6f')]||0x1f4;logger['error'](_0x9f41('0x70'),_0x9f41('0x5a'),_0x847895,JSON['stringify'](_0xe7dda));delete _0xe7dda[_0x9f41('0x2e')];if(_0x847895===0x191){_0x847895=0x190;}_0x48177d[_0x9f41('0x26')](_0x847895)[_0x9f41('0x2f')](_0x401003['query'][_0x9f41('0x71')]?{'message':_0x9f41('0x72'),'statusCode':_0xe7dda['statusCode']}:_0xe7dda);});};
\ 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