Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index 8aba34c..2130e02 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf494=['addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','SalesforceField','getFields','Task','clientId','username','securityToken','remoteUri','substring','Connection','clientSecret','password','concat','isNil','ticketType','sobject','describe','CallDisposition','CallDurationInSeconds','CallObject','IsArchived','Priority','Status','Type','Case','Origin','Reason','SuppliedName','remove','custom','includes','picklistValues','label','value','boolean','True','true','false','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../components/integrations/configuration','jayson/promise','http','test','Sequelize','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','then','info','request\x20sent','stringify','error','SalesforceAccount,\x20%s,\x20%s','message','result','status','end','count','limit','set','json','apply','reject','save','update','destroy','sendStatus','stack','name','send','map','SalesforceAccount','rawAttributes','fieldName','type','key','model','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','offset','sort','where','pick','VIRTUAL','filter','merge','options','include','findAll','rows','catch','show','params','keys','find','create','body','getConfigurations','findOne','SalesforceConfiguration','order'];(function(_0x2d1cf4,_0x2ea9ee){var _0x554a7c=function(_0x55cc39){while(--_0x55cc39){_0x2d1cf4['push'](_0x2d1cf4['shift']());}};_0x554a7c(++_0x2ea9ee);}(_0xf494,0x1c6));var _0x4f49=function(_0x136301,_0xd06f76){_0x136301=_0x136301-0x0;var _0x4d0379=_0xf494[_0x136301];return _0x4d0379;};'use strict';var pdf=require(_0x4f49('0x0'));var emlformat=require(_0x4f49('0x1'));var rimraf=require(_0x4f49('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x4f49('0x3'));var rp=require(_0x4f49('0x4'));var moment=require(_0x4f49('0x5'));var BPromise=require(_0x4f49('0x6'));var Mustache=require(_0x4f49('0x7'));var util=require(_0x4f49('0x8'));var path=require(_0x4f49('0x9'));var sox=require(_0x4f49('0xa'));var csv=require(_0x4f49('0xb'));var ejs=require(_0x4f49('0xc'));var fs=require('fs');var _=require(_0x4f49('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x4f49('0xe'));var deskjs=require(_0x4f49('0xf'));var toCsv=require(_0x4f49('0xb'));var querystring=require(_0x4f49('0x10'));var Papa=require(_0x4f49('0x11'));var Redis=require(_0x4f49('0x12'));var authService=require(_0x4f49('0x13'));var qs=require(_0x4f49('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4f49('0x15'));var logger=require(_0x4f49('0x16'))('api');var utils=require(_0x4f49('0x17'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];var integrations=require(_0x4f49('0x18'));var jayson=require(_0x4f49('0x19'));var client=jayson['client'][_0x4f49('0x1a')]({'port':0x232a});function checkPasswordPattern(_0x111a8b,_0x1b9145,_0x2efe49){if(_0x2efe49){var _0x1a0f1e=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1a0f1e[_0x4f49('0x1b')](_0x1b9145)){return _0x111a8b;}else{throw new db[(_0x4f49('0x1c'))]['ValidationError'](_0x4f49('0x1d'));}}else{return _0x111a8b;}}function respondWithRpcPromise(_0x1f2d0d,_0x415e83,_0x5878f4,_0x5bdfaf){return new BPromise(function(_0x2f0a0d,_0x2ecaaa){var _0x74886e=_0x5bdfaf||client;return _0x74886e['request'](_0x1f2d0d,_0x5878f4)[_0x4f49('0x1e')](function(_0x399be7){logger[_0x4f49('0x1f')]('SalesforceAccount,\x20%s,\x20%s',_0x415e83,'request\x20sent');logger['debug']('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x415e83,_0x4f49('0x20'),JSON[_0x4f49('0x21')](_0x399be7));if(_0x399be7[_0x4f49('0x22')]){if(_0x399be7[_0x4f49('0x22')]['code']===0x1f4){logger[_0x4f49('0x22')](_0x4f49('0x23'),_0x415e83,_0x399be7[_0x4f49('0x22')][_0x4f49('0x24')]);return _0x2ecaaa(_0x399be7[_0x4f49('0x22')]['message']);}logger[_0x4f49('0x22')](_0x4f49('0x23'),_0x415e83,_0x399be7[_0x4f49('0x22')]['message']);return _0x2f0a0d(_0x399be7[_0x4f49('0x22')][_0x4f49('0x24')]);}else{logger[_0x4f49('0x1f')](_0x4f49('0x23'),_0x415e83,_0x4f49('0x20'));_0x2f0a0d(_0x399be7[_0x4f49('0x25')]['message']);}})['catch'](function(_0x3a947b){logger[_0x4f49('0x22')]('SalesforceAccount,\x20%s,\x20%s',_0x415e83,_0x3a947b);_0x2ecaaa(_0x3a947b);});});}function respondWithStatusCode(_0x408552,_0x2c1519){_0x2c1519=_0x2c1519||0xcc;return function(_0x35f8e0){if(_0x35f8e0){return _0x408552['sendStatus'](_0x2c1519);}return _0x408552[_0x4f49('0x26')](_0x2c1519)[_0x4f49('0x27')]();};}function respondWithResult(_0x298785,_0x148153){_0x148153=_0x148153||0xc8;return function(_0xfefbab){if(_0xfefbab){return _0x298785[_0x4f49('0x26')](_0x148153)['json'](_0xfefbab);}};}function respondWithFilteredResult(_0x50c571,_0x239f44){return function(_0x2c00ee){if(_0x2c00ee){var _0x605c91=_0x2c00ee[_0x4f49('0x28')],_0x560050=_0x239f44['offset'],_0x3cbfbd=_0x239f44['offset']+_0x239f44[_0x4f49('0x29')],_0x206203;if(_0x3cbfbd>=_0x605c91){_0x3cbfbd=_0x605c91;_0x206203=0xc8;}else{_0x206203=0xce;}_0x50c571[_0x4f49('0x26')](_0x206203);return _0x50c571[_0x4f49('0x2a')]('Content-Range',_0x560050+'-'+_0x3cbfbd+'/'+_0x605c91)[_0x4f49('0x2b')](_0x2c00ee);}return null;};}function patchUpdates(_0x35aa33){return function(_0x173657){try{jsonpatch[_0x4f49('0x2c')](_0x173657,_0x35aa33,!![]);}catch(_0x3e103b){return BPromise[_0x4f49('0x2d')](_0x3e103b);}return _0x173657[_0x4f49('0x2e')]();};}function saveUpdates(_0x45ae19,_0x1f38d3){return function(_0x310ee2){if(_0x310ee2){return _0x310ee2[_0x4f49('0x2f')](_0x45ae19)[_0x4f49('0x1e')](function(_0x29ff83){return _0x29ff83;});}return null;};}function removeEntity(_0x6625cd,_0x135d17){return function(_0x97ef98){if(_0x97ef98){return _0x97ef98[_0x4f49('0x30')]()[_0x4f49('0x1e')](function(){_0x6625cd[_0x4f49('0x26')](0xcc)['end']();});}};}function handleEntityNotFound(_0x45d0d2,_0x46b7ba){return function(_0x24f568){if(!_0x24f568){_0x45d0d2[_0x4f49('0x31')](0x194);}return _0x24f568;};}function handleError(_0x1c3af8,_0x15e82b){_0x15e82b=_0x15e82b||0x1f4;return function(_0x2cbe4e){logger[_0x4f49('0x22')](_0x2cbe4e[_0x4f49('0x32')]);if(_0x2cbe4e[_0x4f49('0x33')]){delete _0x2cbe4e[_0x4f49('0x33')];}_0x1c3af8[_0x4f49('0x26')](_0x15e82b)[_0x4f49('0x34')](_0x2cbe4e);};}exports['index']=function(_0x371282,_0x27b7a9){var _0x36000a={},_0x26014f={},_0x1c1e9b={'count':0x0,'rows':[]};var _0x3ee818=_[_0x4f49('0x35')](db[_0x4f49('0x36')][_0x4f49('0x37')],function(_0xf8c377){return{'name':_0xf8c377[_0x4f49('0x38')],'type':_0xf8c377[_0x4f49('0x39')][_0x4f49('0x3a')]};});_0x26014f[_0x4f49('0x3b')]=_['map'](_0x3ee818,_0x4f49('0x33'));_0x26014f[_0x4f49('0x3c')]=_['keys'](_0x371282[_0x4f49('0x3c')]);_0x26014f[_0x4f49('0x3d')]=_['intersection'](_0x26014f[_0x4f49('0x3b')],_0x26014f[_0x4f49('0x3c')]);_0x36000a[_0x4f49('0x3e')]=_[_0x4f49('0x3f')](_0x26014f[_0x4f49('0x3b')],qs[_0x4f49('0x40')](_0x371282[_0x4f49('0x3c')]['fields']));_0x36000a['attributes']=_0x36000a['attributes'][_0x4f49('0x41')]?_0x36000a[_0x4f49('0x3e')]:_0x26014f[_0x4f49('0x3b')];if(!_0x371282[_0x4f49('0x3c')][_0x4f49('0x42')](_0x4f49('0x43'))){_0x36000a[_0x4f49('0x29')]=qs[_0x4f49('0x29')](_0x371282[_0x4f49('0x3c')]['limit']);_0x36000a['offset']=qs[_0x4f49('0x44')](_0x371282[_0x4f49('0x3c')][_0x4f49('0x44')]);}_0x36000a['order']=qs[_0x4f49('0x45')](_0x371282['query']['sort']);_0x36000a[_0x4f49('0x46')]=qs[_0x4f49('0x3d')](_[_0x4f49('0x47')](_0x371282['query'],_0x26014f[_0x4f49('0x3d')]));if(_0x371282[_0x4f49('0x3c')]['filter']){_0x36000a[_0x4f49('0x46')]=_['merge'](_0x36000a[_0x4f49('0x46')],{'$or':_[_0x4f49('0x35')](_0x3ee818,function(_0x133f39){if(_0x133f39['type']!==_0x4f49('0x48')){var _0x1e5f0b={};_0x1e5f0b[_0x133f39[_0x4f49('0x33')]]={'$like':'%'+_0x371282[_0x4f49('0x3c')][_0x4f49('0x49')]+'%'};return _0x1e5f0b;}})});}_0x36000a=_[_0x4f49('0x4a')]({},_0x36000a,_0x371282[_0x4f49('0x4b')]);var _0x356785={'where':_0x36000a[_0x4f49('0x46')]};return db[_0x4f49('0x36')]['count'](_0x356785)[_0x4f49('0x1e')](function(_0x44bf1d){_0x1c1e9b['count']=_0x44bf1d;if(_0x371282[_0x4f49('0x3c')]['includeAll']){_0x36000a[_0x4f49('0x4c')]=[{'all':!![]}];}return db[_0x4f49('0x36')][_0x4f49('0x4d')](_0x36000a);})[_0x4f49('0x1e')](function(_0x4a91ec){_0x1c1e9b[_0x4f49('0x4e')]=_0x4a91ec;return _0x1c1e9b;})[_0x4f49('0x1e')](respondWithFilteredResult(_0x27b7a9,_0x36000a))[_0x4f49('0x4f')](handleError(_0x27b7a9,null));};exports[_0x4f49('0x50')]=function(_0x3ec266,_0x72ea05){var _0x37fdb7={'raw':![],'where':{'id':_0x3ec266[_0x4f49('0x51')]['id']}},_0xd282c={};_0xd282c[_0x4f49('0x3b')]=_[_0x4f49('0x52')](db[_0x4f49('0x36')][_0x4f49('0x37')]);_0xd282c[_0x4f49('0x3c')]=_[_0x4f49('0x52')](_0x3ec266[_0x4f49('0x3c')]);_0xd282c['filters']=_['intersection'](_0xd282c[_0x4f49('0x3b')],_0xd282c[_0x4f49('0x3c')]);_0x37fdb7[_0x4f49('0x3e')]=_[_0x4f49('0x3f')](_0xd282c[_0x4f49('0x3b')],qs[_0x4f49('0x40')](_0x3ec266[_0x4f49('0x3c')]['fields']));_0x37fdb7[_0x4f49('0x3e')]=_0x37fdb7['attributes'][_0x4f49('0x41')]?_0x37fdb7[_0x4f49('0x3e')]:_0xd282c[_0x4f49('0x3b')];if(_0x3ec266[_0x4f49('0x3c')]['includeAll']){_0x37fdb7[_0x4f49('0x4c')]=[{'all':!![]}];}_0x37fdb7=_['merge']({},_0x37fdb7,_0x3ec266['options']);return db[_0x4f49('0x36')][_0x4f49('0x53')](_0x37fdb7)[_0x4f49('0x1e')](handleEntityNotFound(_0x72ea05,null))[_0x4f49('0x1e')](respondWithResult(_0x72ea05,null))['catch'](handleError(_0x72ea05,null));};exports['create']=function(_0xd7f47b,_0x291a45){return db['SalesforceAccount'][_0x4f49('0x54')](_0xd7f47b['body'],{})['then'](respondWithResult(_0x291a45,0xc9))[_0x4f49('0x4f')](handleError(_0x291a45,null));};exports['update']=function(_0xfa7dd6,_0x492aaa){if(_0xfa7dd6[_0x4f49('0x55')]['id']){delete _0xfa7dd6[_0x4f49('0x55')]['id'];}return db[_0x4f49('0x36')][_0x4f49('0x53')]({'where':{'id':_0xfa7dd6[_0x4f49('0x51')]['id']}})[_0x4f49('0x1e')](handleEntityNotFound(_0x492aaa,null))[_0x4f49('0x1e')](saveUpdates(_0xfa7dd6[_0x4f49('0x55')],null))['then'](respondWithResult(_0x492aaa,null))[_0x4f49('0x4f')](handleError(_0x492aaa,null));};exports['destroy']=function(_0x213608,_0x1f640d){return db[_0x4f49('0x36')][_0x4f49('0x53')]({'where':{'id':_0x213608[_0x4f49('0x51')]['id']}})[_0x4f49('0x1e')](handleEntityNotFound(_0x1f640d,null))['then'](removeEntity(_0x1f640d,null))[_0x4f49('0x4f')](handleError(_0x1f640d,null));};exports[_0x4f49('0x56')]=function(_0x5e3568,_0x5d2b3c,_0x121c04){var _0x447dde={};var _0x2e0df5={};var _0x2409f1;var _0x19a788;return db['SalesforceAccount'][_0x4f49('0x57')]({'where':{'id':_0x5e3568['params']['id']}})[_0x4f49('0x1e')](handleEntityNotFound(_0x5d2b3c,null))[_0x4f49('0x1e')](function(_0x2a2b0d){if(_0x2a2b0d){_0x2409f1=_0x2a2b0d;_0x2e0df5['model']=_[_0x4f49('0x52')](db[_0x4f49('0x58')][_0x4f49('0x37')]);_0x2e0df5[_0x4f49('0x3c')]=_['keys'](_0x5e3568[_0x4f49('0x3c')]);_0x2e0df5[_0x4f49('0x3d')]=_['intersection'](_0x2e0df5[_0x4f49('0x3b')],_0x2e0df5[_0x4f49('0x3c')]);_0x447dde[_0x4f49('0x3e')]=_[_0x4f49('0x3f')](_0x2e0df5[_0x4f49('0x3b')],qs[_0x4f49('0x40')](_0x5e3568[_0x4f49('0x3c')][_0x4f49('0x40')]));_0x447dde['attributes']=_0x447dde[_0x4f49('0x3e')][_0x4f49('0x41')]?_0x447dde[_0x4f49('0x3e')]:_0x2e0df5[_0x4f49('0x3b')];_0x447dde[_0x4f49('0x59')]=qs[_0x4f49('0x45')](_0x5e3568[_0x4f49('0x3c')]['sort']);_0x447dde[_0x4f49('0x46')]=qs['filters'](_[_0x4f49('0x47')](_0x5e3568[_0x4f49('0x3c')],_0x2e0df5[_0x4f49('0x3d')]));if(_0x5e3568[_0x4f49('0x3c')][_0x4f49('0x49')]){_0x447dde[_0x4f49('0x46')]=_[_0x4f49('0x4a')](_0x447dde[_0x4f49('0x46')],{'$or':_[_0x4f49('0x35')](_0x447dde[_0x4f49('0x3e')],function(_0x545552){var _0x2f9f2e={};_0x2f9f2e[_0x545552]={'$like':'%'+_0x5e3568[_0x4f49('0x3c')][_0x4f49('0x49')]+'%'};return _0x2f9f2e;})});}_0x447dde=_[_0x4f49('0x4a')]({},_0x447dde,_0x5e3568['options']);return _0x2409f1['getConfigurations'](_0x447dde);}})[_0x4f49('0x1e')](function(_0x5e4879){if(_0x5e4879){_0x19a788=_0x5e4879[_0x4f49('0x41')];if(!_0x5e3568[_0x4f49('0x3c')][_0x4f49('0x42')](_0x4f49('0x43'))){_0x447dde[_0x4f49('0x29')]=qs[_0x4f49('0x29')](_0x5e3568[_0x4f49('0x3c')][_0x4f49('0x29')]);_0x447dde[_0x4f49('0x44')]=qs[_0x4f49('0x44')](_0x5e3568[_0x4f49('0x3c')][_0x4f49('0x44')]);}return _0x2409f1[_0x4f49('0x56')](_0x447dde);}})[_0x4f49('0x1e')](function(_0x234984){if(_0x234984){return _0x234984?{'count':_0x19a788,'rows':_0x234984}:null;}})[_0x4f49('0x1e')](respondWithResult(_0x5d2b3c,null))[_0x4f49('0x4f')](handleError(_0x5d2b3c,null));};exports[_0x4f49('0x5a')]=function(_0x1f9161,_0x1434ea,_0x2c3962){if(_0x1f9161[_0x4f49('0x55')]['id']){delete _0x1f9161[_0x4f49('0x55')]['id'];}return db[_0x4f49('0x36')][_0x4f49('0x57')]({'where':{'id':_0x1f9161['params']['id']}})[_0x4f49('0x1e')](handleEntityNotFound(_0x1434ea,null))['then'](function(_0x31df7f){if(_0x31df7f){_0x1f9161[_0x4f49('0x55')][_0x4f49('0x5b')]=_0x31df7f['id'];_0x1f9161[_0x4f49('0x55')][_0x4f49('0x5c')]=integrations[_0x4f49('0x5d')](_0x1f9161[_0x4f49('0x55')][_0x4f49('0x5e')],_0x1f9161[_0x4f49('0x55')]['type']);_0x1f9161['body'][_0x4f49('0x5f')]=integrations['getDescriptions'](_0x1f9161[_0x4f49('0x55')][_0x4f49('0x5e')],_0x1f9161[_0x4f49('0x55')][_0x4f49('0x39')]);return db[_0x4f49('0x58')]['create'](_0x1f9161['body'],{'include':[{'model':db[_0x4f49('0x60')],'as':_0x4f49('0x5c')},{'model':db['SalesforceField'],'as':_0x4f49('0x5f')}]});}return null;})[_0x4f49('0x1e')](respondWithResult(_0x1434ea,null))['catch'](handleError(_0x1434ea,null));};exports[_0x4f49('0x61')]=function(_0x5b88aa,_0x121972,_0x160cf8){var _0x544356;var _0x15ed6c='';var _0x4551d9=_0x4f49('0x62');return db[_0x4f49('0x36')][_0x4f49('0x57')]({'where':{'id':_0x5b88aa[_0x4f49('0x51')]['id']},'attributes':['id','remoteUri',_0x4f49('0x63'),'clientSecret',_0x4f49('0x64'),'password',_0x4f49('0x65')]})['then'](handleEntityNotFound(_0x121972,null))[_0x4f49('0x1e')](function(_0x16fad9){if(_0x16fad9){_0x15ed6c=_0x16fad9[_0x4f49('0x66')];var _0x2dbd0f=_0x15ed6c['slice'](-0x1);if(_0x2dbd0f==='/'){_0x15ed6c=_0x15ed6c[_0x4f49('0x67')](0x0,_0x15ed6c['lastIndexOf'](_0x2dbd0f));}_0x544356=new jsforce[(_0x4f49('0x68'))]({'oauth2':{'loginUrl':_0x15ed6c,'clientId':_0x16fad9['clientId'],'clientSecret':_0x16fad9[_0x4f49('0x69')]}});return _0x544356['login'](_0x16fad9['username'],_0x16fad9[_0x4f49('0x6a')][_0x4f49('0x6b')](_0x16fad9[_0x4f49('0x65')]));}})['then'](function(_0x289810){if(_0x289810){if(!_[_0x4f49('0x6c')](_0x5b88aa['query']['ticketType'])){_0x4551d9=_0x5b88aa['query'][_0x4f49('0x6d')];}return _0x544356[_0x4f49('0x6e')](_0x4551d9)[_0x4f49('0x6f')]();}})[_0x4f49('0x1e')](function(_0x1643fc){var _0x517144=[_0x4f49('0x70'),_0x4f49('0x71'),_0x4f49('0x72'),'CallType',_0x4f49('0x73'),_0x4f49('0x74'),_0x4f49('0x75'),_0x4f49('0x76')];if(!_['isNil'](_0x5b88aa[_0x4f49('0x3c')][_0x4f49('0x6d')])&&_0x5b88aa[_0x4f49('0x3c')][_0x4f49('0x6d')]===_0x4f49('0x77')){_0x517144=['Type',_0x4f49('0x78'),_0x4f49('0x79'),'Status',_0x4f49('0x74'),'IsEscalated',_0x4f49('0x7a'),'SuppliedCompany'];}if(_0x1643fc){_[_0x4f49('0x7b')](_0x1643fc[_0x4f49('0x40')],function(_0x2ef19e){return _0x2ef19e[_0x4f49('0x7c')]===![]&&!_0x517144[_0x4f49('0x7d')](_0x2ef19e['name']);});return{'count':_0x1643fc[_0x4f49('0x40')][_0x4f49('0x41')],'rows':_[_0x4f49('0x35')](_0x1643fc[_0x4f49('0x40')],function(_0x4b7c61){return{'id':_0x4b7c61[_0x4f49('0x33')],'name':_0x4b7c61['label'],'custom':_0x4b7c61[_0x4f49('0x7c')],'options':_0x4b7c61['picklistValues'][_0x4f49('0x41')]>0x0?_[_0x4f49('0x35')](_0x4b7c61[_0x4f49('0x7e')],function(_0x34fca3){return{'name':_0x34fca3[_0x4f49('0x7f')],'value':_0x34fca3[_0x4f49('0x80')]};}):_0x4b7c61[_0x4f49('0x39')]==_0x4f49('0x81')?[{'name':_0x4f49('0x82'),'value':_0x4f49('0x83')},{'name':'False','value':_0x4f49('0x84')}]:[]};})};}})[_0x4f49('0x1e')](respondWithResult(_0x121972,null))[_0x4f49('0x4f')](function(_0x299849){var _0x302861=_0x5b88aa[_0x4f49('0x3c')]['test']?0x1f4:_0x299849[_0x4f49('0x85')]||0x1f4;logger[_0x4f49('0x22')](_0x4f49('0x86'),_0x4f49('0x61'),_0x302861,JSON['stringify'](_0x299849));delete _0x299849[_0x4f49('0x33')];if(_0x302861===0x191){_0x302861=0x190;}_0x121972['status'](_0x302861)[_0x4f49('0x34')](_0x5b88aa[_0x4f49('0x3c')][_0x4f49('0x1b')]?{'message':_0x4f49('0x87'),'statusCode':_0x299849['statusCode']}:_0x299849);});};
\ No newline at end of file
+var _0xd53f=['../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','undefined','limit','offset','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','SalesforceAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','nolimit','sort','where','pick','VIRTUAL','merge','options','count','includeAll','include','findAll','catch','show','params','find','create','body','getConfigurations','findOne','SalesforceConfiguration','order','filter','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','SalesforceField','getFields','Task','clientId','clientSecret','username','password','securityToken','remoteUri','slice','lastIndexOf','Connection','login','concat','isNil','ticketType','describe','OwnerId','ActivityDate','IsReminderSet','Subject','string','int','picklist','boolean','email','phone','remove','includes','custom','picklistValues','label','value','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','rimraf','zip-dir','request-promise','bluebird','mustache','path','sox','to-csv','ejs','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api'];(function(_0x12cf7f,_0xfda4f5){var _0x316ca0=function(_0x243e0c){while(--_0x243e0c){_0x12cf7f['push'](_0x12cf7f['shift']());}};_0x316ca0(++_0xfda4f5);}(_0xd53f,0x162));var _0xfd53=function(_0x8efaf0,_0x46c3f2){_0x8efaf0=_0x8efaf0-0x0;var _0x4b46de=_0xd53f[_0x8efaf0];return _0x4b46de;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xfd53('0x0'));var zipdir=require(_0xfd53('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xfd53('0x2'));var moment=require('moment');var BPromise=require(_0xfd53('0x3'));var Mustache=require(_0xfd53('0x4'));var util=require('util');var path=require(_0xfd53('0x5'));var sox=require(_0xfd53('0x6'));var csv=require(_0xfd53('0x7'));var ejs=require(_0xfd53('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xfd53('0x9'));var crypto=require(_0xfd53('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xfd53('0xb'));var toCsv=require(_0xfd53('0x7'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xfd53('0xc'));var authService=require(_0xfd53('0xd'));var qs=require('../../components/parsers/qs');var as=require(_0xfd53('0xe'));var hardwareService=require(_0xfd53('0xf'));var logger=require(_0xfd53('0x10'))(_0xfd53('0x11'));var utils=require(_0xfd53('0x12'));var config=require('../../config/environment');var licenseUtil=require(_0xfd53('0x13'));var db=require(_0xfd53('0x14'))['db'];var integrations=require(_0xfd53('0x15'));function respondWithStatusCode(_0x1e6d81,_0x57be3b){_0x57be3b=_0x57be3b||0xcc;return function(_0x1e2d30){if(_0x1e2d30){return _0x1e6d81[_0xfd53('0x16')](_0x57be3b);}return _0x1e6d81[_0xfd53('0x17')](_0x57be3b)[_0xfd53('0x18')]();};}function respondWithResult(_0x41617b,_0x823cbb){_0x823cbb=_0x823cbb||0xc8;return function(_0x59c868){if(_0x59c868){return _0x41617b['status'](_0x823cbb)[_0xfd53('0x19')](_0x59c868);}};}function respondWithFilteredResult(_0x5641c1,_0x54d63b){return function(_0xe221c9){if(_0xe221c9){var _0x4d9cc9=typeof _0x54d63b['offset']===_0xfd53('0x1a')&&typeof _0x54d63b[_0xfd53('0x1b')]===_0xfd53('0x1a');var _0x427ffd=_0xe221c9['count'];var _0x472ba9=_0x4d9cc9?0x0:_0x54d63b['offset'];var _0x346022=_0x4d9cc9?_0xe221c9['count']:_0x54d63b[_0xfd53('0x1c')]+_0x54d63b['limit'];var _0x1f0015;if(_0x346022>=_0x427ffd){_0x346022=_0x427ffd;_0x1f0015=0xc8;}else{_0x1f0015=0xce;}_0x5641c1[_0xfd53('0x17')](_0x1f0015);return _0x5641c1['set'](_0xfd53('0x1d'),_0x472ba9+'-'+_0x346022+'/'+_0x427ffd)[_0xfd53('0x19')](_0xe221c9);}return null;};}function patchUpdates(_0x10a8be){return function(_0x532a69){try{jsonpatch[_0xfd53('0x1e')](_0x532a69,_0x10a8be,!![]);}catch(_0x1a34e9){return BPromise[_0xfd53('0x1f')](_0x1a34e9);}return _0x532a69[_0xfd53('0x20')]();};}function saveUpdates(_0x433a13,_0x151375){return function(_0x2396e2){if(_0x2396e2){return _0x2396e2[_0xfd53('0x21')](_0x433a13)[_0xfd53('0x22')](function(_0x1a6742){return _0x1a6742;});}return null;};}function removeEntity(_0x3d1ca6,_0x481e21){return function(_0x41ee8e){if(_0x41ee8e){return _0x41ee8e[_0xfd53('0x23')]()[_0xfd53('0x22')](function(){_0x3d1ca6[_0xfd53('0x17')](0xcc)[_0xfd53('0x18')]();});}};}function handleEntityNotFound(_0x10e3a,_0x5a1789){return function(_0x5d78a3){if(!_0x5d78a3){_0x10e3a['sendStatus'](0x194);}return _0x5d78a3;};}function handleError(_0x11ec35,_0x4a198b){_0x4a198b=_0x4a198b||0x1f4;return function(_0xab07){logger[_0xfd53('0x24')](_0xab07[_0xfd53('0x25')]);if(_0xab07[_0xfd53('0x26')]){delete _0xab07[_0xfd53('0x26')];}_0x11ec35['status'](_0x4a198b)[_0xfd53('0x27')](_0xab07);};}exports[_0xfd53('0x28')]=function(_0xeda3fc,_0x3f4652){var _0x1233b5={},_0x5506b4={},_0x5558ac={'count':0x0,'rows':[]};var _0x1bd885=_[_0xfd53('0x29')](db[_0xfd53('0x2a')][_0xfd53('0x2b')],function(_0x11cd28){return{'name':_0x11cd28[_0xfd53('0x2c')],'type':_0x11cd28[_0xfd53('0x2d')][_0xfd53('0x2e')]};});_0x5506b4[_0xfd53('0x2f')]=_[_0xfd53('0x29')](_0x1bd885,_0xfd53('0x26'));_0x5506b4[_0xfd53('0x30')]=_[_0xfd53('0x31')](_0xeda3fc[_0xfd53('0x30')]);_0x5506b4[_0xfd53('0x32')]=_[_0xfd53('0x33')](_0x5506b4[_0xfd53('0x2f')],_0x5506b4[_0xfd53('0x30')]);_0x1233b5[_0xfd53('0x34')]=_[_0xfd53('0x33')](_0x5506b4['model'],qs['fields'](_0xeda3fc[_0xfd53('0x30')][_0xfd53('0x35')]));_0x1233b5[_0xfd53('0x34')]=_0x1233b5[_0xfd53('0x34')][_0xfd53('0x36')]?_0x1233b5['attributes']:_0x5506b4[_0xfd53('0x2f')];if(!_0xeda3fc[_0xfd53('0x30')]['hasOwnProperty'](_0xfd53('0x37'))){_0x1233b5['limit']=qs[_0xfd53('0x1b')](_0xeda3fc[_0xfd53('0x30')][_0xfd53('0x1b')]);_0x1233b5[_0xfd53('0x1c')]=qs[_0xfd53('0x1c')](_0xeda3fc[_0xfd53('0x30')][_0xfd53('0x1c')]);}_0x1233b5['order']=qs[_0xfd53('0x38')](_0xeda3fc[_0xfd53('0x30')]['sort']);_0x1233b5[_0xfd53('0x39')]=qs[_0xfd53('0x32')](_[_0xfd53('0x3a')](_0xeda3fc[_0xfd53('0x30')],_0x5506b4[_0xfd53('0x32')]),_0x1bd885);if(_0xeda3fc[_0xfd53('0x30')]['filter']){_0x1233b5['where']=_['merge'](_0x1233b5[_0xfd53('0x39')],{'$or':_[_0xfd53('0x29')](_0x1bd885,function(_0x584b49){if(_0x584b49[_0xfd53('0x2d')]!==_0xfd53('0x3b')){var _0x49f042={};_0x49f042[_0x584b49[_0xfd53('0x26')]]={'$like':'%'+_0xeda3fc[_0xfd53('0x30')]['filter']+'%'};return _0x49f042;}})});}_0x1233b5=_[_0xfd53('0x3c')]({},_0x1233b5,_0xeda3fc[_0xfd53('0x3d')]);var _0x117484={'where':_0x1233b5[_0xfd53('0x39')]};return db[_0xfd53('0x2a')][_0xfd53('0x3e')](_0x117484)['then'](function(_0x22b47b){_0x5558ac[_0xfd53('0x3e')]=_0x22b47b;if(_0xeda3fc[_0xfd53('0x30')][_0xfd53('0x3f')]){_0x1233b5[_0xfd53('0x40')]=[{'all':!![]}];}return db['SalesforceAccount'][_0xfd53('0x41')](_0x1233b5);})['then'](function(_0x1d77fa){_0x5558ac['rows']=_0x1d77fa;return _0x5558ac;})[_0xfd53('0x22')](respondWithFilteredResult(_0x3f4652,_0x1233b5))[_0xfd53('0x42')](handleError(_0x3f4652,null));};exports[_0xfd53('0x43')]=function(_0x3f015e,_0x3be12b){var _0x2f1531={'raw':![],'where':{'id':_0x3f015e[_0xfd53('0x44')]['id']}},_0x3b44fc={};_0x3b44fc['model']=_[_0xfd53('0x31')](db[_0xfd53('0x2a')][_0xfd53('0x2b')]);_0x3b44fc[_0xfd53('0x30')]=_[_0xfd53('0x31')](_0x3f015e['query']);_0x3b44fc['filters']=_['intersection'](_0x3b44fc[_0xfd53('0x2f')],_0x3b44fc[_0xfd53('0x30')]);_0x2f1531[_0xfd53('0x34')]=_[_0xfd53('0x33')](_0x3b44fc[_0xfd53('0x2f')],qs[_0xfd53('0x35')](_0x3f015e[_0xfd53('0x30')]['fields']));_0x2f1531['attributes']=_0x2f1531[_0xfd53('0x34')]['length']?_0x2f1531[_0xfd53('0x34')]:_0x3b44fc['model'];if(_0x3f015e[_0xfd53('0x30')][_0xfd53('0x3f')]){_0x2f1531[_0xfd53('0x40')]=[{'all':!![]}];}_0x2f1531=_[_0xfd53('0x3c')]({},_0x2f1531,_0x3f015e['options']);return db[_0xfd53('0x2a')][_0xfd53('0x45')](_0x2f1531)[_0xfd53('0x22')](handleEntityNotFound(_0x3be12b,null))['then'](respondWithResult(_0x3be12b,null))[_0xfd53('0x42')](handleError(_0x3be12b,null));};exports[_0xfd53('0x46')]=function(_0x5e704f,_0x1d8288){return db['SalesforceAccount']['create'](_0x5e704f[_0xfd53('0x47')],{})[_0xfd53('0x22')](respondWithResult(_0x1d8288,0xc9))[_0xfd53('0x42')](handleError(_0x1d8288,null));};exports[_0xfd53('0x21')]=function(_0x533d4f,_0x4f755f){if(_0x533d4f['body']['id']){delete _0x533d4f[_0xfd53('0x47')]['id'];}return db[_0xfd53('0x2a')][_0xfd53('0x45')]({'where':{'id':_0x533d4f[_0xfd53('0x44')]['id']}})[_0xfd53('0x22')](handleEntityNotFound(_0x4f755f,null))[_0xfd53('0x22')](saveUpdates(_0x533d4f[_0xfd53('0x47')],null))[_0xfd53('0x22')](respondWithResult(_0x4f755f,null))[_0xfd53('0x42')](handleError(_0x4f755f,null));};exports[_0xfd53('0x23')]=function(_0x57bbde,_0x5e051e){return db[_0xfd53('0x2a')][_0xfd53('0x45')]({'where':{'id':_0x57bbde['params']['id']}})[_0xfd53('0x22')](handleEntityNotFound(_0x5e051e,null))[_0xfd53('0x22')](removeEntity(_0x5e051e,null))[_0xfd53('0x42')](handleError(_0x5e051e,null));};exports[_0xfd53('0x48')]=function(_0x28d5e1,_0x1b2ddd,_0x206351){var _0xf4bc07={};var _0x274632={};var _0x313398;var _0x57f665;return db[_0xfd53('0x2a')][_0xfd53('0x49')]({'where':{'id':_0x28d5e1[_0xfd53('0x44')]['id']}})[_0xfd53('0x22')](handleEntityNotFound(_0x1b2ddd,null))['then'](function(_0x5b911a){if(_0x5b911a){_0x313398=_0x5b911a;_0x274632['model']=_[_0xfd53('0x31')](db[_0xfd53('0x4a')][_0xfd53('0x2b')]);_0x274632['query']=_['keys'](_0x28d5e1['query']);_0x274632[_0xfd53('0x32')]=_[_0xfd53('0x33')](_0x274632[_0xfd53('0x2f')],_0x274632[_0xfd53('0x30')]);_0xf4bc07[_0xfd53('0x34')]=_['intersection'](_0x274632[_0xfd53('0x2f')],qs['fields'](_0x28d5e1[_0xfd53('0x30')][_0xfd53('0x35')]));_0xf4bc07[_0xfd53('0x34')]=_0xf4bc07[_0xfd53('0x34')][_0xfd53('0x36')]?_0xf4bc07[_0xfd53('0x34')]:_0x274632['model'];_0xf4bc07[_0xfd53('0x4b')]=qs[_0xfd53('0x38')](_0x28d5e1[_0xfd53('0x30')][_0xfd53('0x38')]);_0xf4bc07['where']=qs[_0xfd53('0x32')](_[_0xfd53('0x3a')](_0x28d5e1[_0xfd53('0x30')],_0x274632[_0xfd53('0x32')]));if(_0x28d5e1[_0xfd53('0x30')][_0xfd53('0x4c')]){_0xf4bc07[_0xfd53('0x39')]=_[_0xfd53('0x3c')](_0xf4bc07[_0xfd53('0x39')],{'$or':_[_0xfd53('0x29')](_0xf4bc07['attributes'],function(_0x2c1d75){var _0x39954c={};_0x39954c[_0x2c1d75]={'$like':'%'+_0x28d5e1['query'][_0xfd53('0x4c')]+'%'};return _0x39954c;})});}_0xf4bc07=_[_0xfd53('0x3c')]({},_0xf4bc07,_0x28d5e1[_0xfd53('0x3d')]);return _0x313398[_0xfd53('0x48')](_0xf4bc07);}})['then'](function(_0xbe622a){if(_0xbe622a){_0x57f665=_0xbe622a[_0xfd53('0x36')];if(!_0x28d5e1[_0xfd53('0x30')][_0xfd53('0x4d')](_0xfd53('0x37'))){_0xf4bc07[_0xfd53('0x1b')]=qs['limit'](_0x28d5e1[_0xfd53('0x30')]['limit']);_0xf4bc07[_0xfd53('0x1c')]=qs[_0xfd53('0x1c')](_0x28d5e1[_0xfd53('0x30')]['offset']);}return _0x313398[_0xfd53('0x48')](_0xf4bc07);}})[_0xfd53('0x22')](function(_0x2f6c0f){if(_0x2f6c0f){return _0x2f6c0f?{'count':_0x57f665,'rows':_0x2f6c0f}:null;}})[_0xfd53('0x22')](respondWithResult(_0x1b2ddd,null))[_0xfd53('0x42')](handleError(_0x1b2ddd,null));};exports[_0xfd53('0x4e')]=function(_0x2d5d76,_0x19644e,_0x14fa5c){if(_0x2d5d76[_0xfd53('0x47')]['id']){delete _0x2d5d76['body']['id'];}return db[_0xfd53('0x2a')]['findOne']({'where':{'id':_0x2d5d76[_0xfd53('0x44')]['id']}})[_0xfd53('0x22')](handleEntityNotFound(_0x19644e,null))[_0xfd53('0x22')](function(_0x49bbe7){if(_0x49bbe7){_0x2d5d76['body'][_0xfd53('0x4f')]=_0x49bbe7['id'];_0x2d5d76[_0xfd53('0x47')][_0xfd53('0x50')]=integrations[_0xfd53('0x51')](_0x2d5d76['body'][_0xfd53('0x52')],_0x2d5d76[_0xfd53('0x47')]['type']);_0x2d5d76['body'][_0xfd53('0x53')]=integrations['getDescriptions'](_0x2d5d76[_0xfd53('0x47')][_0xfd53('0x52')],_0x2d5d76[_0xfd53('0x47')]['type']);return db[_0xfd53('0x4a')][_0xfd53('0x46')](_0x2d5d76[_0xfd53('0x47')],{'include':[{'model':db[_0xfd53('0x54')],'as':_0xfd53('0x50')},{'model':db[_0xfd53('0x54')],'as':_0xfd53('0x53')}]});}return null;})['then'](respondWithResult(_0x19644e,null))['catch'](handleError(_0x19644e,null));};exports[_0xfd53('0x55')]=function(_0x6b6ae7,_0x1b83b4,_0xa5e325){var _0x344769;var _0xfac9fc='';var _0x38195f=_0xfd53('0x56');return db['SalesforceAccount'][_0xfd53('0x49')]({'where':{'id':_0x6b6ae7['params']['id']},'attributes':['id','remoteUri',_0xfd53('0x57'),_0xfd53('0x58'),_0xfd53('0x59'),_0xfd53('0x5a'),_0xfd53('0x5b')]})[_0xfd53('0x22')](handleEntityNotFound(_0x1b83b4,null))[_0xfd53('0x22')](function(_0x3827a7){if(_0x3827a7){_0xfac9fc=_0x3827a7[_0xfd53('0x5c')];var _0x247943=_0xfac9fc[_0xfd53('0x5d')](-0x1);if(_0x247943==='/'){_0xfac9fc=_0xfac9fc['substring'](0x0,_0xfac9fc[_0xfd53('0x5e')](_0x247943));}_0x344769=new jsforce[(_0xfd53('0x5f'))]({'oauth2':{'loginUrl':_0xfac9fc,'clientId':_0x3827a7['clientId'],'clientSecret':_0x3827a7[_0xfd53('0x58')]}});return _0x344769[_0xfd53('0x60')](_0x3827a7['username'],_0x3827a7['password'][_0xfd53('0x61')](_0x3827a7[_0xfd53('0x5b')]));}})[_0xfd53('0x22')](function(_0x58e090){if(_0x58e090){if(!_[_0xfd53('0x62')](_0x6b6ae7['query'][_0xfd53('0x63')])){_0x38195f=_0x6b6ae7[_0xfd53('0x30')][_0xfd53('0x63')];}return _0x344769['sobject'](_0x38195f)[_0xfd53('0x64')]();}})[_0xfd53('0x22')](function(_0x2fe601){var _0x2224eb=[_0xfd53('0x65'),_0xfd53('0x66'),_0xfd53('0x67'),'IsRecurrence',_0xfd53('0x68'),'Description'];var _0x164544=[_0xfd53('0x69'),_0xfd53('0x6a'),_0xfd53('0x6b'),_0xfd53('0x6c'),_0xfd53('0x6d'),'textarea',_0xfd53('0x6e')];if(_0x2fe601){_[_0xfd53('0x6f')](_0x2fe601[_0xfd53('0x35')],function(_0x3bbdc7){return _0x2224eb[_0xfd53('0x70')](_0x3bbdc7['name'])||!_0x164544['includes'](_0x3bbdc7['type']);});return{'count':_0x2fe601[_0xfd53('0x35')][_0xfd53('0x36')],'rows':_[_0xfd53('0x29')](_0x2fe601[_0xfd53('0x35')],function(_0x577060){return{'id':_0x577060['name'],'name':_0x577060['label'],'custom':_0x577060[_0xfd53('0x71')],'options':_0x577060[_0xfd53('0x72')][_0xfd53('0x36')]>0x0?_[_0xfd53('0x29')](_0x577060['picklistValues'],function(_0x130539){return{'name':_0x130539[_0xfd53('0x73')],'value':_0x130539[_0xfd53('0x74')]};}):_0x577060[_0xfd53('0x2d')]==_0xfd53('0x6c')?[{'name':'True','value':_0xfd53('0x75')},{'name':_0xfd53('0x76'),'value':_0xfd53('0x77')}]:[]};})};}})[_0xfd53('0x22')](respondWithResult(_0x1b83b4,null))[_0xfd53('0x42')](function(_0x31ea74){var _0x3115d2=_0x6b6ae7[_0xfd53('0x30')][_0xfd53('0x78')]?0x1f4:_0x31ea74[_0xfd53('0x79')]||0x1f4;logger[_0xfd53('0x24')](_0xfd53('0x7a'),'getFields',_0x3115d2,JSON[_0xfd53('0x7b')](_0x31ea74));delete _0x31ea74['name'];if(_0x3115d2===0x191){_0x3115d2=0x190;}_0x1b83b4[_0xfd53('0x17')](_0x3115d2)[_0xfd53('0x27')](_0x6b6ae7[_0xfd53('0x30')][_0xfd53('0x78')]?{'message':'Wrong\x20credentials','statusCode':_0x31ea74[_0xfd53('0x79')]}:_0x31ea74);});};
\ No newline at end of file