Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 5f30138..ee792ca 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xad77=['info','catch','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','then','sendStatus','stack','name','send','map','DeskAccount','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','show','find','create','body','params','getConfigurations','findOne','addConfiguration','Subjects','getSubjects','channel','Descriptions','getDescriptions','DeskConfiguration','DeskField','getFields','priority','remoteUri','authType','username','password','consumerKey','consumerSecret','token','tokenSecret','slice','substring','GET','%s/custom_fields','basic','headers','Authorization','format','%s:%s','base64','concat','entries','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','http','DeskAccount,\x20%s,\x20%s','request\x20sent','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x279285,_0x222d40){var _0x571299=function(_0x2c7551){while(--_0x2c7551){_0x279285['push'](_0x279285['shift']());}};_0x571299(++_0x222d40);}(_0xad77,0xd7));var _0x7ad7=function(_0x493fe2,_0xb64d6c){_0x493fe2=_0x493fe2-0x0;var _0x24e309=_0xad77[_0x493fe2];return _0x24e309;};'use strict';var pdf=require(_0x7ad7('0x0'));var emlformat=require(_0x7ad7('0x1'));var rimraf=require(_0x7ad7('0x2'));var zipdir=require(_0x7ad7('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7ad7('0x4'));var moment=require(_0x7ad7('0x5'));var BPromise=require(_0x7ad7('0x6'));var Mustache=require(_0x7ad7('0x7'));var util=require(_0x7ad7('0x8'));var path=require(_0x7ad7('0x9'));var sox=require(_0x7ad7('0xa'));var csv=require(_0x7ad7('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x7ad7('0xc'));var squel=require('squel');var crypto=require(_0x7ad7('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x7ad7('0xe'));var Papa=require(_0x7ad7('0xf'));var Redis=require(_0x7ad7('0x10'));var authService=require(_0x7ad7('0x11'));var qs=require(_0x7ad7('0x12'));var as=require(_0x7ad7('0x13'));var hardwareService=require(_0x7ad7('0x14'));var logger=require('../../config/logger')(_0x7ad7('0x15'));var utils=require(_0x7ad7('0x16'));var config=require(_0x7ad7('0x17'));var licenseUtil=require(_0x7ad7('0x18'));var db=require(_0x7ad7('0x19'))['db'];var integrations=require(_0x7ad7('0x1a'));var jayson=require(_0x7ad7('0x1b'));var client=jayson[_0x7ad7('0x1c')][_0x7ad7('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x225e4b,_0x22d80b,_0x15e53d,_0x141f0a){return new BPromise(function(_0x5cba11,_0x508bdb){var _0x2d196f=_0x141f0a||client;return _0x2d196f['request'](_0x225e4b,_0x15e53d)['then'](function(_0x12ef15){logger['info'](_0x7ad7('0x1e'),_0x22d80b,_0x7ad7('0x1f'));logger['debug'](_0x7ad7('0x20'),_0x22d80b,_0x7ad7('0x1f'),JSON[_0x7ad7('0x21')](_0x12ef15));if(_0x12ef15[_0x7ad7('0x22')]){if(_0x12ef15[_0x7ad7('0x22')][_0x7ad7('0x23')]===0x1f4){logger[_0x7ad7('0x22')](_0x7ad7('0x1e'),_0x22d80b,_0x12ef15[_0x7ad7('0x22')]['message']);return _0x508bdb(_0x12ef15['error'][_0x7ad7('0x24')]);}logger[_0x7ad7('0x22')]('DeskAccount,\x20%s,\x20%s',_0x22d80b,_0x12ef15['error']['message']);return _0x5cba11(_0x12ef15[_0x7ad7('0x22')][_0x7ad7('0x24')]);}else{logger[_0x7ad7('0x25')](_0x7ad7('0x1e'),_0x22d80b,_0x7ad7('0x1f'));_0x5cba11(_0x12ef15['result'][_0x7ad7('0x24')]);}})[_0x7ad7('0x26')](function(_0x174ca1){logger[_0x7ad7('0x22')]('DeskAccount,\x20%s,\x20%s',_0x22d80b,_0x174ca1);_0x508bdb(_0x174ca1);});});}function respondWithStatusCode(_0xf1458d,_0x1b684a){_0x1b684a=_0x1b684a||0xcc;return function(_0x3daa50){if(_0x3daa50){return _0xf1458d['sendStatus'](_0x1b684a);}return _0xf1458d[_0x7ad7('0x27')](_0x1b684a)[_0x7ad7('0x28')]();};}function respondWithResult(_0x4b41ce,_0x1d5fd1){_0x1d5fd1=_0x1d5fd1||0xc8;return function(_0x1b861b){if(_0x1b861b){return _0x4b41ce[_0x7ad7('0x27')](_0x1d5fd1)[_0x7ad7('0x29')](_0x1b861b);}};}function respondWithFilteredResult(_0x2ff65d,_0x3740bc){return function(_0x43b612){if(_0x43b612){var _0x5c5f76=_0x43b612[_0x7ad7('0x2a')],_0x4cdc4e=_0x3740bc[_0x7ad7('0x2b')],_0x2d8798=_0x3740bc[_0x7ad7('0x2b')]+_0x3740bc[_0x7ad7('0x2c')],_0x58b77b;if(_0x2d8798>=_0x5c5f76){_0x2d8798=_0x5c5f76;_0x58b77b=0xc8;}else{_0x58b77b=0xce;}_0x2ff65d[_0x7ad7('0x27')](_0x58b77b);return _0x2ff65d[_0x7ad7('0x2d')](_0x7ad7('0x2e'),_0x4cdc4e+'-'+_0x2d8798+'/'+_0x5c5f76)[_0x7ad7('0x29')](_0x43b612);}return null;};}function patchUpdates(_0xfffca8){return function(_0x90bba5){try{jsonpatch[_0x7ad7('0x2f')](_0x90bba5,_0xfffca8,!![]);}catch(_0x3516e9){return BPromise[_0x7ad7('0x30')](_0x3516e9);}return _0x90bba5[_0x7ad7('0x31')]();};}function saveUpdates(_0x2fa3da,_0x86b4d){return function(_0x543c09){if(_0x543c09){return _0x543c09[_0x7ad7('0x32')](_0x2fa3da)['then'](function(_0x3bd71d){return _0x3bd71d;});}return null;};}function removeEntity(_0x41e195,_0x1555bd){return function(_0x583427){if(_0x583427){return _0x583427[_0x7ad7('0x33')]()[_0x7ad7('0x34')](function(){_0x41e195[_0x7ad7('0x27')](0xcc)[_0x7ad7('0x28')]();});}};}function handleEntityNotFound(_0x4df251,_0x129f3a){return function(_0x80e448){if(!_0x80e448){_0x4df251[_0x7ad7('0x35')](0x194);}return _0x80e448;};}function handleError(_0x124de5,_0x2e8272){_0x2e8272=_0x2e8272||0x1f4;return function(_0x3a429b){logger[_0x7ad7('0x22')](_0x3a429b[_0x7ad7('0x36')]);if(_0x3a429b[_0x7ad7('0x37')]){delete _0x3a429b[_0x7ad7('0x37')];}_0x124de5[_0x7ad7('0x27')](_0x2e8272)[_0x7ad7('0x38')](_0x3a429b);};}exports['index']=function(_0xeb28ae,_0x2b494a){var _0x486534={},_0x1fb1d2={},_0x385dac={'count':0x0,'rows':[]};var _0xb08d44=_[_0x7ad7('0x39')](db[_0x7ad7('0x3a')][_0x7ad7('0x3b')],function(_0x300958){return{'name':_0x300958[_0x7ad7('0x3c')],'type':_0x300958[_0x7ad7('0x3d')][_0x7ad7('0x3e')]};});_0x1fb1d2['model']=_[_0x7ad7('0x39')](_0xb08d44,_0x7ad7('0x37'));_0x1fb1d2['query']=_[_0x7ad7('0x3f')](_0xeb28ae[_0x7ad7('0x40')]);_0x1fb1d2[_0x7ad7('0x41')]=_[_0x7ad7('0x42')](_0x1fb1d2[_0x7ad7('0x43')],_0x1fb1d2['query']);_0x486534[_0x7ad7('0x44')]=_['intersection'](_0x1fb1d2[_0x7ad7('0x43')],qs[_0x7ad7('0x45')](_0xeb28ae['query'][_0x7ad7('0x45')]));_0x486534['attributes']=_0x486534[_0x7ad7('0x44')][_0x7ad7('0x46')]?_0x486534['attributes']:_0x1fb1d2[_0x7ad7('0x43')];if(!_0xeb28ae[_0x7ad7('0x40')][_0x7ad7('0x47')](_0x7ad7('0x48'))){_0x486534[_0x7ad7('0x2c')]=qs['limit'](_0xeb28ae['query'][_0x7ad7('0x2c')]);_0x486534[_0x7ad7('0x2b')]=qs[_0x7ad7('0x2b')](_0xeb28ae[_0x7ad7('0x40')]['offset']);}_0x486534[_0x7ad7('0x49')]=qs[_0x7ad7('0x4a')](_0xeb28ae[_0x7ad7('0x40')]['sort']);_0x486534[_0x7ad7('0x4b')]=qs['filters'](_[_0x7ad7('0x4c')](_0xeb28ae[_0x7ad7('0x40')],_0x1fb1d2[_0x7ad7('0x41')]),_0xb08d44);if(_0xeb28ae[_0x7ad7('0x40')][_0x7ad7('0x4d')]){_0x486534['where']=_['merge'](_0x486534['where'],{'$or':_['map'](_0xb08d44,function(_0x1ca3ac){if(_0x1ca3ac[_0x7ad7('0x3d')]!==_0x7ad7('0x4e')){var _0x3f99c8={};_0x3f99c8[_0x1ca3ac['name']]={'$like':'%'+_0xeb28ae[_0x7ad7('0x40')][_0x7ad7('0x4d')]+'%'};return _0x3f99c8;}})});}_0x486534=_[_0x7ad7('0x4f')]({},_0x486534,_0xeb28ae[_0x7ad7('0x50')]);var _0x4841cf={'where':_0x486534[_0x7ad7('0x4b')]};return db[_0x7ad7('0x3a')][_0x7ad7('0x2a')](_0x4841cf)[_0x7ad7('0x34')](function(_0x3789d3){_0x385dac[_0x7ad7('0x2a')]=_0x3789d3;if(_0xeb28ae[_0x7ad7('0x40')][_0x7ad7('0x51')]){_0x486534[_0x7ad7('0x52')]=[{'all':!![]}];}return db[_0x7ad7('0x3a')][_0x7ad7('0x53')](_0x486534);})['then'](function(_0x34d77f){_0x385dac[_0x7ad7('0x54')]=_0x34d77f;return _0x385dac;})['then'](respondWithFilteredResult(_0x2b494a,_0x486534))[_0x7ad7('0x26')](handleError(_0x2b494a,null));};exports[_0x7ad7('0x55')]=function(_0x56e052,_0x5dc96d){var _0x32cf99={'raw':![],'where':{'id':_0x56e052['params']['id']}},_0x18c2d4={};_0x18c2d4[_0x7ad7('0x43')]=_[_0x7ad7('0x3f')](db['DeskAccount'][_0x7ad7('0x3b')]);_0x18c2d4[_0x7ad7('0x40')]=_[_0x7ad7('0x3f')](_0x56e052[_0x7ad7('0x40')]);_0x18c2d4[_0x7ad7('0x41')]=_[_0x7ad7('0x42')](_0x18c2d4[_0x7ad7('0x43')],_0x18c2d4[_0x7ad7('0x40')]);_0x32cf99['attributes']=_['intersection'](_0x18c2d4[_0x7ad7('0x43')],qs[_0x7ad7('0x45')](_0x56e052[_0x7ad7('0x40')][_0x7ad7('0x45')]));_0x32cf99['attributes']=_0x32cf99['attributes']['length']?_0x32cf99[_0x7ad7('0x44')]:_0x18c2d4[_0x7ad7('0x43')];if(_0x56e052['query'][_0x7ad7('0x51')]){_0x32cf99['include']=[{'all':!![]}];}_0x32cf99=_[_0x7ad7('0x4f')]({},_0x32cf99,_0x56e052[_0x7ad7('0x50')]);return db[_0x7ad7('0x3a')][_0x7ad7('0x56')](_0x32cf99)['then'](handleEntityNotFound(_0x5dc96d,null))[_0x7ad7('0x34')](respondWithResult(_0x5dc96d,null))['catch'](handleError(_0x5dc96d,null));};exports[_0x7ad7('0x57')]=function(_0x149686,_0x627606){return db[_0x7ad7('0x3a')][_0x7ad7('0x57')](_0x149686['body'],{})[_0x7ad7('0x34')](respondWithResult(_0x627606,0xc9))[_0x7ad7('0x26')](handleError(_0x627606,null));};exports[_0x7ad7('0x32')]=function(_0x4e2c5b,_0x12f94e){if(_0x4e2c5b[_0x7ad7('0x58')]['id']){delete _0x4e2c5b['body']['id'];}return db[_0x7ad7('0x3a')]['find']({'where':{'id':_0x4e2c5b[_0x7ad7('0x59')]['id']}})['then'](handleEntityNotFound(_0x12f94e,null))[_0x7ad7('0x34')](saveUpdates(_0x4e2c5b[_0x7ad7('0x58')],null))[_0x7ad7('0x34')](respondWithResult(_0x12f94e,null))[_0x7ad7('0x26')](handleError(_0x12f94e,null));};exports[_0x7ad7('0x33')]=function(_0x50c44d,_0x52c995){return db[_0x7ad7('0x3a')][_0x7ad7('0x56')]({'where':{'id':_0x50c44d['params']['id']}})[_0x7ad7('0x34')](handleEntityNotFound(_0x52c995,null))[_0x7ad7('0x34')](removeEntity(_0x52c995,null))[_0x7ad7('0x26')](handleError(_0x52c995,null));};exports[_0x7ad7('0x5a')]=function(_0x5f2e0d,_0x43d347,_0x2ca8fd){var _0x3d6dda={};var _0x579152={};var _0x275312;var _0x247a29;return db['DeskAccount'][_0x7ad7('0x5b')]({'where':{'id':_0x5f2e0d[_0x7ad7('0x59')]['id']}})['then'](handleEntityNotFound(_0x43d347,null))['then'](function(_0x4d2c88){if(_0x4d2c88){_0x275312=_0x4d2c88;_0x579152[_0x7ad7('0x43')]=_[_0x7ad7('0x3f')](db['DeskConfiguration'][_0x7ad7('0x3b')]);_0x579152[_0x7ad7('0x40')]=_[_0x7ad7('0x3f')](_0x5f2e0d['query']);_0x579152[_0x7ad7('0x41')]=_[_0x7ad7('0x42')](_0x579152[_0x7ad7('0x43')],_0x579152['query']);_0x3d6dda['attributes']=_[_0x7ad7('0x42')](_0x579152[_0x7ad7('0x43')],qs[_0x7ad7('0x45')](_0x5f2e0d[_0x7ad7('0x40')][_0x7ad7('0x45')]));_0x3d6dda[_0x7ad7('0x44')]=_0x3d6dda[_0x7ad7('0x44')][_0x7ad7('0x46')]?_0x3d6dda[_0x7ad7('0x44')]:_0x579152['model'];_0x3d6dda[_0x7ad7('0x49')]=qs[_0x7ad7('0x4a')](_0x5f2e0d[_0x7ad7('0x40')][_0x7ad7('0x4a')]);_0x3d6dda[_0x7ad7('0x4b')]=qs[_0x7ad7('0x41')](_[_0x7ad7('0x4c')](_0x5f2e0d[_0x7ad7('0x40')],_0x579152[_0x7ad7('0x41')]));if(_0x5f2e0d[_0x7ad7('0x40')][_0x7ad7('0x4d')]){_0x3d6dda[_0x7ad7('0x4b')]=_['merge'](_0x3d6dda[_0x7ad7('0x4b')],{'$or':_[_0x7ad7('0x39')](_0x3d6dda[_0x7ad7('0x44')],function(_0x1c2eab){var _0x1a4e54={};_0x1a4e54[_0x1c2eab]={'$like':'%'+_0x5f2e0d[_0x7ad7('0x40')][_0x7ad7('0x4d')]+'%'};return _0x1a4e54;})});}_0x3d6dda=_[_0x7ad7('0x4f')]({},_0x3d6dda,_0x5f2e0d['options']);return _0x275312['getConfigurations'](_0x3d6dda);}})[_0x7ad7('0x34')](function(_0x308ee6){if(_0x308ee6){_0x247a29=_0x308ee6[_0x7ad7('0x46')];if(!_0x5f2e0d[_0x7ad7('0x40')][_0x7ad7('0x47')]('nolimit')){_0x3d6dda[_0x7ad7('0x2c')]=qs[_0x7ad7('0x2c')](_0x5f2e0d[_0x7ad7('0x40')]['limit']);_0x3d6dda[_0x7ad7('0x2b')]=qs['offset'](_0x5f2e0d[_0x7ad7('0x40')][_0x7ad7('0x2b')]);}return _0x275312[_0x7ad7('0x5a')](_0x3d6dda);}})[_0x7ad7('0x34')](function(_0x465c0c){if(_0x465c0c){return _0x465c0c?{'count':_0x247a29,'rows':_0x465c0c}:null;}})[_0x7ad7('0x34')](respondWithResult(_0x43d347,null))[_0x7ad7('0x26')](handleError(_0x43d347,null));};exports[_0x7ad7('0x5c')]=function(_0x1cb75f,_0x1c5acd,_0x434676){if(_0x1cb75f[_0x7ad7('0x58')]['id']){delete _0x1cb75f[_0x7ad7('0x58')]['id'];}return db[_0x7ad7('0x3a')][_0x7ad7('0x5b')]({'where':{'id':_0x1cb75f['params']['id']}})[_0x7ad7('0x34')](handleEntityNotFound(_0x1c5acd,null))[_0x7ad7('0x34')](function(_0x396dbd){if(_0x396dbd){_0x1cb75f['body']['AccountId']=_0x396dbd['id'];_0x1cb75f[_0x7ad7('0x58')][_0x7ad7('0x5d')]=integrations[_0x7ad7('0x5e')](_0x1cb75f[_0x7ad7('0x58')][_0x7ad7('0x5f')],_0x1cb75f[_0x7ad7('0x58')][_0x7ad7('0x3d')]);_0x1cb75f['body'][_0x7ad7('0x60')]=integrations[_0x7ad7('0x61')](_0x1cb75f['body'][_0x7ad7('0x5f')],_0x1cb75f['body'][_0x7ad7('0x3d')]);return db[_0x7ad7('0x62')][_0x7ad7('0x57')](_0x1cb75f[_0x7ad7('0x58')],{'include':[{'model':db[_0x7ad7('0x63')],'as':_0x7ad7('0x5d')},{'model':db[_0x7ad7('0x63')],'as':'Descriptions'}]});}return null;})[_0x7ad7('0x34')](respondWithResult(_0x1c5acd,null))['catch'](handleError(_0x1c5acd,null));};exports[_0x7ad7('0x64')]=function(_0x1e48b9,_0x19b1fa,_0x1cbbc3){var _0x34cc19=[{'name':_0x7ad7('0x65'),'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 _0x3a1989='';return db[_0x7ad7('0x3a')][_0x7ad7('0x5b')]({'where':{'id':_0x1e48b9['params']['id']},'attributes':['id',_0x7ad7('0x66'),_0x7ad7('0x67'),_0x7ad7('0x68'),_0x7ad7('0x69'),_0x7ad7('0x6a'),_0x7ad7('0x6b'),_0x7ad7('0x6c'),_0x7ad7('0x6d')]})[_0x7ad7('0x34')](handleEntityNotFound(_0x19b1fa,null))[_0x7ad7('0x34')](function(_0x227eb4){if(_0x227eb4){_0x3a1989=_0x227eb4[_0x7ad7('0x66')];var _0x10785d=_0x3a1989[_0x7ad7('0x6e')](-0x1);if(_0x10785d==='/'){_0x3a1989=_0x3a1989[_0x7ad7('0x6f')](0x0,_0x3a1989['lastIndexOf'](_0x10785d));}var _0xfa6ef3={'method':_0x7ad7('0x70'),'uri':util['format'](_0x7ad7('0x71'),_0x3a1989),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x227eb4[_0x7ad7('0x67')]===_0x7ad7('0x72')){_0xfa6ef3[_0x7ad7('0x73')][_0x7ad7('0x74')]=util[_0x7ad7('0x75')]('Basic\x20%s',new Buffer(util[_0x7ad7('0x75')](_0x7ad7('0x76'),_0x227eb4[_0x7ad7('0x68')],_0x227eb4[_0x7ad7('0x69')]))['toString'](_0x7ad7('0x77')));}return rp(_0xfa6ef3)[_0x7ad7('0x34')](function(_0x44b673){return _0x34cc19[_0x7ad7('0x78')](_[_0x7ad7('0x39')](_0x44b673['_embedded'][_0x7ad7('0x79')],function(_0x563007){return{'id':_0x563007[_0x7ad7('0x37')],'name':_0x563007['name'],'type':_0x563007[_0x7ad7('0x3d')],'active':_0x563007['active'],'label':_0x563007['label'],'custom':!![]};}));});}})[_0x7ad7('0x34')](function(_0x563e40){return{'count':_0x563e40[_0x7ad7('0x46')],'rows':_0x563e40};})[_0x7ad7('0x34')](respondWithResult(_0x19b1fa,null))['catch'](function(_0x147e16){var _0x29c7e1=_0x1e48b9[_0x7ad7('0x40')][_0x7ad7('0x7a')]?0x1f4:_0x147e16[_0x7ad7('0x7b')]||0x1f4;logger[_0x7ad7('0x22')](_0x7ad7('0x7c'),'getFields',_0x29c7e1,JSON[_0x7ad7('0x21')](_0x147e16));delete _0x147e16['name'];if(_0x29c7e1===0x191){_0x29c7e1=0x190;}_0x19b1fa[_0x7ad7('0x27')](_0x29c7e1)['send'](_0x1e48b9[_0x7ad7('0x40')][_0x7ad7('0x7a')]?{'message':_0x7ad7('0x7d'),'statusCode':_0x147e16[_0x7ad7('0x7b')]}:_0x147e16);});};
\ No newline at end of file
+var _0x554c=['DeskAccount','rawAttributes','type','key','keys','query','filters','intersection','fields','attributes','length','model','sort','merge','options','includeAll','findAll','rows','catch','show','params','include','find','create','body','getConfigurations','findOne','DeskConfiguration','order','where','pick','hasOwnProperty','nolimit','addConfiguration','AccountId','Subjects','channel','Descriptions','getDescriptions','DeskField','getFields','priority','authType','username','password','consumerKey','consumerSecret','token','tokenSecret','substring','lastIndexOf','GET','format','basic','headers','Authorization','toString','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','moment','mustache','util','path','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','destroy','then','error','name','send','map'];(function(_0x3743e5,_0x4b6bb9){var _0x370603=function(_0x1d8df1){while(--_0x1d8df1){_0x3743e5['push'](_0x3743e5['shift']());}};_0x370603(++_0x4b6bb9);}(_0x554c,0x127));var _0xc554=function(_0x2dbae6,_0x424afb){_0x2dbae6=_0x2dbae6-0x0;var _0x37f9ae=_0x554c[_0x2dbae6];return _0x37f9ae;};'use strict';var emlformat=require(_0xc554('0x0'));var rimraf=require(_0xc554('0x1'));var zipdir=require(_0xc554('0x2'));var jsonpatch=require(_0xc554('0x3'));var rp=require('request-promise');var moment=require(_0xc554('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xc554('0x5'));var util=require(_0xc554('0x6'));var path=require(_0xc554('0x7'));var sox=require('sox');var csv=require(_0xc554('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc554('0x9'));var squel=require(_0xc554('0xa'));var crypto=require(_0xc554('0xb'));var jsforce=require(_0xc554('0xc'));var deskjs=require(_0xc554('0xd'));var toCsv=require(_0xc554('0x8'));var querystring=require(_0xc554('0xe'));var Papa=require(_0xc554('0xf'));var Redis=require(_0xc554('0x10'));var authService=require(_0xc554('0x11'));var qs=require(_0xc554('0x12'));var as=require(_0xc554('0x13'));var hardwareService=require(_0xc554('0x14'));var logger=require(_0xc554('0x15'))(_0xc554('0x16'));var utils=require(_0xc554('0x17'));var config=require(_0xc554('0x18'));var licenseUtil=require(_0xc554('0x19'));var db=require(_0xc554('0x1a'))['db'];var integrations=require(_0xc554('0x1b'));function respondWithStatusCode(_0x11ac26,_0x7ff077){_0x7ff077=_0x7ff077||0xcc;return function(_0x493c68){if(_0x493c68){return _0x11ac26[_0xc554('0x1c')](_0x7ff077);}return _0x11ac26[_0xc554('0x1d')](_0x7ff077)[_0xc554('0x1e')]();};}function respondWithResult(_0x1fc61c,_0x44df8){_0x44df8=_0x44df8||0xc8;return function(_0x4937bb){if(_0x4937bb){return _0x1fc61c[_0xc554('0x1d')](_0x44df8)[_0xc554('0x1f')](_0x4937bb);}};}function respondWithFilteredResult(_0x173f63,_0x2e99c5){return function(_0x54a34b){if(_0x54a34b){var _0x5b98d6=typeof _0x2e99c5[_0xc554('0x20')]===_0xc554('0x21')&&typeof _0x2e99c5[_0xc554('0x22')]===_0xc554('0x21');var _0x51c89b=_0x54a34b['count'];var _0x5009df=_0x5b98d6?0x0:_0x2e99c5[_0xc554('0x20')];var _0x6b2cf5=_0x5b98d6?_0x54a34b[_0xc554('0x23')]:_0x2e99c5[_0xc554('0x20')]+_0x2e99c5[_0xc554('0x22')];var _0x35bf8a;if(_0x6b2cf5>=_0x51c89b){_0x6b2cf5=_0x51c89b;_0x35bf8a=0xc8;}else{_0x35bf8a=0xce;}_0x173f63[_0xc554('0x1d')](_0x35bf8a);return _0x173f63[_0xc554('0x24')](_0xc554('0x25'),_0x5009df+'-'+_0x6b2cf5+'/'+_0x51c89b)[_0xc554('0x1f')](_0x54a34b);}return null;};}function patchUpdates(_0x3197e3){return function(_0x351f54){try{jsonpatch[_0xc554('0x26')](_0x351f54,_0x3197e3,!![]);}catch(_0x5633e1){return BPromise[_0xc554('0x27')](_0x5633e1);}return _0x351f54['save']();};}function saveUpdates(_0x1506ef,_0x4c9b3b){return function(_0x45624b){if(_0x45624b){return _0x45624b[_0xc554('0x28')](_0x1506ef)['then'](function(_0x433e9b){return _0x433e9b;});}return null;};}function removeEntity(_0x32a1fd,_0x1c80fb){return function(_0xb171bb){if(_0xb171bb){return _0xb171bb[_0xc554('0x29')]()[_0xc554('0x2a')](function(){_0x32a1fd[_0xc554('0x1d')](0xcc)[_0xc554('0x1e')]();});}};}function handleEntityNotFound(_0x4a6384,_0x176efe){return function(_0x53edcc){if(!_0x53edcc){_0x4a6384[_0xc554('0x1c')](0x194);}return _0x53edcc;};}function handleError(_0x5e636d,_0x7ed7ca){_0x7ed7ca=_0x7ed7ca||0x1f4;return function(_0x7f1ebc){logger[_0xc554('0x2b')](_0x7f1ebc['stack']);if(_0x7f1ebc[_0xc554('0x2c')]){delete _0x7f1ebc[_0xc554('0x2c')];}_0x5e636d[_0xc554('0x1d')](_0x7ed7ca)[_0xc554('0x2d')](_0x7f1ebc);};}exports['index']=function(_0x1287f4,_0x58cde9){var _0x6fef5a={},_0x4fc458={},_0x22fd71={'count':0x0,'rows':[]};var _0x50d3f3=_[_0xc554('0x2e')](db[_0xc554('0x2f')][_0xc554('0x30')],function(_0xe05459){return{'name':_0xe05459['fieldName'],'type':_0xe05459[_0xc554('0x31')][_0xc554('0x32')]};});_0x4fc458['model']=_['map'](_0x50d3f3,_0xc554('0x2c'));_0x4fc458['query']=_[_0xc554('0x33')](_0x1287f4[_0xc554('0x34')]);_0x4fc458[_0xc554('0x35')]=_[_0xc554('0x36')](_0x4fc458['model'],_0x4fc458['query']);_0x6fef5a['attributes']=_[_0xc554('0x36')](_0x4fc458['model'],qs['fields'](_0x1287f4[_0xc554('0x34')][_0xc554('0x37')]));_0x6fef5a[_0xc554('0x38')]=_0x6fef5a[_0xc554('0x38')][_0xc554('0x39')]?_0x6fef5a[_0xc554('0x38')]:_0x4fc458[_0xc554('0x3a')];if(!_0x1287f4[_0xc554('0x34')]['hasOwnProperty']('nolimit')){_0x6fef5a[_0xc554('0x22')]=qs[_0xc554('0x22')](_0x1287f4[_0xc554('0x34')][_0xc554('0x22')]);_0x6fef5a[_0xc554('0x20')]=qs[_0xc554('0x20')](_0x1287f4[_0xc554('0x34')]['offset']);}_0x6fef5a['order']=qs[_0xc554('0x3b')](_0x1287f4[_0xc554('0x34')][_0xc554('0x3b')]);_0x6fef5a['where']=qs[_0xc554('0x35')](_['pick'](_0x1287f4[_0xc554('0x34')],_0x4fc458[_0xc554('0x35')]),_0x50d3f3);if(_0x1287f4[_0xc554('0x34')]['filter']){_0x6fef5a['where']=_[_0xc554('0x3c')](_0x6fef5a['where'],{'$or':_[_0xc554('0x2e')](_0x50d3f3,function(_0x2cdcb0){if(_0x2cdcb0['type']!=='VIRTUAL'){var _0x3902fb={};_0x3902fb[_0x2cdcb0[_0xc554('0x2c')]]={'$like':'%'+_0x1287f4[_0xc554('0x34')]['filter']+'%'};return _0x3902fb;}})});}_0x6fef5a=_[_0xc554('0x3c')]({},_0x6fef5a,_0x1287f4[_0xc554('0x3d')]);var _0x4e26c4={'where':_0x6fef5a['where']};return db[_0xc554('0x2f')][_0xc554('0x23')](_0x4e26c4)[_0xc554('0x2a')](function(_0x5c33ea){_0x22fd71[_0xc554('0x23')]=_0x5c33ea;if(_0x1287f4[_0xc554('0x34')][_0xc554('0x3e')]){_0x6fef5a['include']=[{'all':!![]}];}return db[_0xc554('0x2f')][_0xc554('0x3f')](_0x6fef5a);})['then'](function(_0x5c2b57){_0x22fd71[_0xc554('0x40')]=_0x5c2b57;return _0x22fd71;})[_0xc554('0x2a')](respondWithFilteredResult(_0x58cde9,_0x6fef5a))[_0xc554('0x41')](handleError(_0x58cde9,null));};exports[_0xc554('0x42')]=function(_0x5168e5,_0x3d49fd){var _0x23e5f3={'raw':![],'where':{'id':_0x5168e5[_0xc554('0x43')]['id']}},_0x53bdff={};_0x53bdff[_0xc554('0x3a')]=_[_0xc554('0x33')](db[_0xc554('0x2f')][_0xc554('0x30')]);_0x53bdff['query']=_['keys'](_0x5168e5[_0xc554('0x34')]);_0x53bdff[_0xc554('0x35')]=_[_0xc554('0x36')](_0x53bdff[_0xc554('0x3a')],_0x53bdff[_0xc554('0x34')]);_0x23e5f3[_0xc554('0x38')]=_[_0xc554('0x36')](_0x53bdff['model'],qs[_0xc554('0x37')](_0x5168e5[_0xc554('0x34')][_0xc554('0x37')]));_0x23e5f3['attributes']=_0x23e5f3['attributes'][_0xc554('0x39')]?_0x23e5f3[_0xc554('0x38')]:_0x53bdff[_0xc554('0x3a')];if(_0x5168e5['query']['includeAll']){_0x23e5f3[_0xc554('0x44')]=[{'all':!![]}];}_0x23e5f3=_['merge']({},_0x23e5f3,_0x5168e5[_0xc554('0x3d')]);return db[_0xc554('0x2f')][_0xc554('0x45')](_0x23e5f3)[_0xc554('0x2a')](handleEntityNotFound(_0x3d49fd,null))[_0xc554('0x2a')](respondWithResult(_0x3d49fd,null))[_0xc554('0x41')](handleError(_0x3d49fd,null));};exports[_0xc554('0x46')]=function(_0x3173b8,_0x241f68){return db[_0xc554('0x2f')]['create'](_0x3173b8[_0xc554('0x47')],{})[_0xc554('0x2a')](respondWithResult(_0x241f68,0xc9))[_0xc554('0x41')](handleError(_0x241f68,null));};exports['update']=function(_0x3592aa,_0x130126){if(_0x3592aa[_0xc554('0x47')]['id']){delete _0x3592aa[_0xc554('0x47')]['id'];}return db[_0xc554('0x2f')][_0xc554('0x45')]({'where':{'id':_0x3592aa['params']['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x130126,null))[_0xc554('0x2a')](saveUpdates(_0x3592aa[_0xc554('0x47')],null))[_0xc554('0x2a')](respondWithResult(_0x130126,null))[_0xc554('0x41')](handleError(_0x130126,null));};exports['destroy']=function(_0x4c2b14,_0x4c7603){return db['DeskAccount'][_0xc554('0x45')]({'where':{'id':_0x4c2b14[_0xc554('0x43')]['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x4c7603,null))[_0xc554('0x2a')](removeEntity(_0x4c7603,null))[_0xc554('0x41')](handleError(_0x4c7603,null));};exports[_0xc554('0x48')]=function(_0x276161,_0x4e77aa,_0x31cc47){var _0x1214d6={};var _0x1f1309={};var _0xb95fb1;var _0x2595aa;return db[_0xc554('0x2f')][_0xc554('0x49')]({'where':{'id':_0x276161[_0xc554('0x43')]['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x4e77aa,null))[_0xc554('0x2a')](function(_0xc33439){if(_0xc33439){_0xb95fb1=_0xc33439;_0x1f1309[_0xc554('0x3a')]=_[_0xc554('0x33')](db[_0xc554('0x4a')]['rawAttributes']);_0x1f1309[_0xc554('0x34')]=_[_0xc554('0x33')](_0x276161['query']);_0x1f1309[_0xc554('0x35')]=_[_0xc554('0x36')](_0x1f1309[_0xc554('0x3a')],_0x1f1309['query']);_0x1214d6['attributes']=_[_0xc554('0x36')](_0x1f1309[_0xc554('0x3a')],qs[_0xc554('0x37')](_0x276161[_0xc554('0x34')][_0xc554('0x37')]));_0x1214d6[_0xc554('0x38')]=_0x1214d6[_0xc554('0x38')][_0xc554('0x39')]?_0x1214d6[_0xc554('0x38')]:_0x1f1309[_0xc554('0x3a')];_0x1214d6[_0xc554('0x4b')]=qs[_0xc554('0x3b')](_0x276161[_0xc554('0x34')][_0xc554('0x3b')]);_0x1214d6[_0xc554('0x4c')]=qs[_0xc554('0x35')](_[_0xc554('0x4d')](_0x276161[_0xc554('0x34')],_0x1f1309[_0xc554('0x35')]));if(_0x276161[_0xc554('0x34')]['filter']){_0x1214d6[_0xc554('0x4c')]=_[_0xc554('0x3c')](_0x1214d6['where'],{'$or':_[_0xc554('0x2e')](_0x1214d6[_0xc554('0x38')],function(_0x60abe9){var _0xfbf9fd={};_0xfbf9fd[_0x60abe9]={'$like':'%'+_0x276161[_0xc554('0x34')]['filter']+'%'};return _0xfbf9fd;})});}_0x1214d6=_[_0xc554('0x3c')]({},_0x1214d6,_0x276161['options']);return _0xb95fb1['getConfigurations'](_0x1214d6);}})[_0xc554('0x2a')](function(_0x363ca0){if(_0x363ca0){_0x2595aa=_0x363ca0[_0xc554('0x39')];if(!_0x276161['query'][_0xc554('0x4e')](_0xc554('0x4f'))){_0x1214d6[_0xc554('0x22')]=qs[_0xc554('0x22')](_0x276161[_0xc554('0x34')][_0xc554('0x22')]);_0x1214d6[_0xc554('0x20')]=qs[_0xc554('0x20')](_0x276161[_0xc554('0x34')][_0xc554('0x20')]);}return _0xb95fb1[_0xc554('0x48')](_0x1214d6);}})[_0xc554('0x2a')](function(_0x5c27b0){if(_0x5c27b0){return _0x5c27b0?{'count':_0x2595aa,'rows':_0x5c27b0}:null;}})[_0xc554('0x2a')](respondWithResult(_0x4e77aa,null))[_0xc554('0x41')](handleError(_0x4e77aa,null));};exports[_0xc554('0x50')]=function(_0x2e5a49,_0x35e61c,_0x3904b3){if(_0x2e5a49[_0xc554('0x47')]['id']){delete _0x2e5a49['body']['id'];}return db[_0xc554('0x2f')][_0xc554('0x49')]({'where':{'id':_0x2e5a49[_0xc554('0x43')]['id']}})[_0xc554('0x2a')](handleEntityNotFound(_0x35e61c,null))[_0xc554('0x2a')](function(_0x52d12c){if(_0x52d12c){_0x2e5a49[_0xc554('0x47')][_0xc554('0x51')]=_0x52d12c['id'];_0x2e5a49[_0xc554('0x47')][_0xc554('0x52')]=integrations['getSubjects'](_0x2e5a49[_0xc554('0x47')][_0xc554('0x53')],_0x2e5a49[_0xc554('0x47')][_0xc554('0x31')]);_0x2e5a49[_0xc554('0x47')][_0xc554('0x54')]=integrations[_0xc554('0x55')](_0x2e5a49['body'][_0xc554('0x53')],_0x2e5a49['body'][_0xc554('0x31')]);return db[_0xc554('0x4a')][_0xc554('0x46')](_0x2e5a49[_0xc554('0x47')],{'include':[{'model':db['DeskField'],'as':_0xc554('0x52')},{'model':db[_0xc554('0x56')],'as':_0xc554('0x54')}]});}return null;})[_0xc554('0x2a')](respondWithResult(_0x35e61c,null))[_0xc554('0x41')](handleError(_0x35e61c,null));};exports[_0xc554('0x57')]=function(_0x2ea0d5,_0x3f4cfb,_0x293da1){var _0x2af638=[{'name':_0xc554('0x58'),'label':_0xc554('0x58'),'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 _0x301584='';return db[_0xc554('0x2f')][_0xc554('0x49')]({'where':{'id':_0x2ea0d5[_0xc554('0x43')]['id']},'attributes':['id','remoteUri',_0xc554('0x59'),_0xc554('0x5a'),_0xc554('0x5b'),_0xc554('0x5c'),_0xc554('0x5d'),_0xc554('0x5e'),_0xc554('0x5f')]})['then'](handleEntityNotFound(_0x3f4cfb,null))[_0xc554('0x2a')](function(_0x479575){if(_0x479575){_0x301584=_0x479575['remoteUri'];var _0xf23b3f=_0x301584['slice'](-0x1);if(_0xf23b3f==='/'){_0x301584=_0x301584[_0xc554('0x60')](0x0,_0x301584[_0xc554('0x61')](_0xf23b3f));}var _0x14c837={'method':_0xc554('0x62'),'uri':util[_0xc554('0x63')]('%s/custom_fields',_0x301584),'headers':{'Content-Type':'application/json','Accept':'application/json'},'json':!![]};if(_0x479575['authType']===_0xc554('0x64')){_0x14c837[_0xc554('0x65')][_0xc554('0x66')]=util[_0xc554('0x63')]('Basic\x20%s',new Buffer(util[_0xc554('0x63')]('%s:%s',_0x479575[_0xc554('0x5a')],_0x479575[_0xc554('0x5b')]))[_0xc554('0x67')]('base64'));}return rp(_0x14c837)[_0xc554('0x2a')](function(_0x1d6bf4){return _0x2af638[_0xc554('0x68')](_[_0xc554('0x2e')](_0x1d6bf4[_0xc554('0x69')][_0xc554('0x6a')],function(_0x1ffd01){return{'id':_0x1ffd01['name'],'name':_0x1ffd01[_0xc554('0x2c')],'type':_0x1ffd01[_0xc554('0x31')],'active':_0x1ffd01[_0xc554('0x6b')],'label':_0x1ffd01[_0xc554('0x6c')],'custom':!![]};}));});}})[_0xc554('0x2a')](function(_0x4ea1d5){return{'count':_0x4ea1d5[_0xc554('0x39')],'rows':_0x4ea1d5};})[_0xc554('0x2a')](respondWithResult(_0x3f4cfb,null))[_0xc554('0x41')](function(_0x22f1da){var _0x5285ba=_0x2ea0d5[_0xc554('0x34')]['test']?0x1f4:_0x22f1da[_0xc554('0x6d')]||0x1f4;logger[_0xc554('0x2b')](_0xc554('0x6e'),_0xc554('0x57'),_0x5285ba,JSON[_0xc554('0x6f')](_0x22f1da));delete _0x22f1da['name'];if(_0x5285ba===0x191){_0x5285ba=0x190;}_0x3f4cfb['status'](_0x5285ba)[_0xc554('0x2d')](_0x2ea0d5[_0xc554('0x34')][_0xc554('0x70')]?{'message':_0xc554('0x71'),'statusCode':_0x22f1da[_0xc554('0x6d')]}:_0x22f1da);});};
\ No newline at end of file