Built motion from commit 25580385.|2.6.2
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index bddf780..337adea 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5eb8=['Task','remoteUri','username','password','securityToken','slice','substring','lastIndexOf','Connection','clientId','login','concat','isNil','ticketType','sobject','describe','CallDurationInSeconds','CallType','Priority','Status','Case','Type','Reason','IsEscalated','SuppliedName','remove','includes','label','custom','picklistValues','value','True','true','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','request','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','sendStatus','status','end','json','count','limit','set','apply','reject','save','then','destroy','name','send','index','map','SalesforceAccount','rawAttributes','fieldName','type','keys','filters','model','attributes','fields','length','nolimit','query','offset','sort','where','filter','merge','VIRTUAL','options','includeAll','include','rows','show','params','intersection','create','body','update','find','getConfigurations','findOne','SalesforceConfiguration','order','pick','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','SalesforceField','getFields'];(function(_0x4a8932,_0x51d924){var _0x50b1dd=function(_0x260ef6){while(--_0x260ef6){_0x4a8932['push'](_0x4a8932['shift']());}};_0x50b1dd(++_0x51d924);}(_0x5eb8,0xb0));var _0x85eb=function(_0x584b9d,_0x1cb5c5){_0x584b9d=_0x584b9d-0x0;var _0x172053=_0x5eb8[_0x584b9d];return _0x172053;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x85eb('0x0'));var zipdir=require(_0x85eb('0x1'));var jsonpatch=require(_0x85eb('0x2'));var rp=require(_0x85eb('0x3'));var moment=require(_0x85eb('0x4'));var BPromise=require(_0x85eb('0x5'));var Mustache=require(_0x85eb('0x6'));var util=require(_0x85eb('0x7'));var path=require(_0x85eb('0x8'));var sox=require(_0x85eb('0x9'));var csv=require(_0x85eb('0xa'));var ejs=require(_0x85eb('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x85eb('0xc'));var crypto=require(_0x85eb('0xd'));var jsforce=require(_0x85eb('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x85eb('0xa'));var querystring=require('querystring');var Papa=require(_0x85eb('0xf'));var Redis=require(_0x85eb('0x10'));var authService=require(_0x85eb('0x11'));var qs=require(_0x85eb('0x12'));var as=require(_0x85eb('0x13'));var hardwareService=require(_0x85eb('0x14'));var logger=require(_0x85eb('0x15'))('api');var utils=require(_0x85eb('0x16'));var config=require(_0x85eb('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0x85eb('0x18'))['db'];var integrations=require(_0x85eb('0x19'));var jayson=require(_0x85eb('0x1a'));var client=jayson[_0x85eb('0x1b')]['http']({'port':0x232a});function respondWithRpcPromise(_0x548628,_0x394c74,_0x5c760a,_0x18ca53){return new BPromise(function(_0x23a82a,_0x600a7f){var _0x1604ba=_0x18ca53||client;return _0x1604ba[_0x85eb('0x1c')](_0x548628,_0x5c760a)['then'](function(_0x2e5c0a){logger['info'](_0x85eb('0x1d'),_0x394c74,_0x85eb('0x1e'));logger[_0x85eb('0x1f')](_0x85eb('0x20'),_0x394c74,'request\x20sent',JSON['stringify'](_0x2e5c0a));if(_0x2e5c0a['error']){if(_0x2e5c0a[_0x85eb('0x21')][_0x85eb('0x22')]===0x1f4){logger[_0x85eb('0x21')](_0x85eb('0x1d'),_0x394c74,_0x2e5c0a[_0x85eb('0x21')][_0x85eb('0x23')]);return _0x600a7f(_0x2e5c0a['error'][_0x85eb('0x23')]);}logger[_0x85eb('0x21')](_0x85eb('0x1d'),_0x394c74,_0x2e5c0a['error']['message']);return _0x23a82a(_0x2e5c0a['error']['message']);}else{logger[_0x85eb('0x24')](_0x85eb('0x1d'),_0x394c74,_0x85eb('0x1e'));_0x23a82a(_0x2e5c0a[_0x85eb('0x25')][_0x85eb('0x23')]);}})[_0x85eb('0x26')](function(_0x5c9895){logger['error']('SalesforceAccount,\x20%s,\x20%s',_0x394c74,_0x5c9895);_0x600a7f(_0x5c9895);});});}function respondWithStatusCode(_0x298e84,_0x1426c8){_0x1426c8=_0x1426c8||0xcc;return function(_0x3f7a4d){if(_0x3f7a4d){return _0x298e84[_0x85eb('0x27')](_0x1426c8);}return _0x298e84[_0x85eb('0x28')](_0x1426c8)[_0x85eb('0x29')]();};}function respondWithResult(_0x5dfc96,_0x39d3fe){_0x39d3fe=_0x39d3fe||0xc8;return function(_0x3453cd){if(_0x3453cd){return _0x5dfc96[_0x85eb('0x28')](_0x39d3fe)[_0x85eb('0x2a')](_0x3453cd);}};}function respondWithFilteredResult(_0x3e2326,_0x57a03c){return function(_0x2e5aa3){if(_0x2e5aa3){var _0x792d3a=_0x2e5aa3[_0x85eb('0x2b')],_0x291557=_0x57a03c['offset'],_0x3e7eb9=_0x57a03c['offset']+_0x57a03c[_0x85eb('0x2c')],_0x40f13e;if(_0x3e7eb9>=_0x792d3a){_0x3e7eb9=_0x792d3a;_0x40f13e=0xc8;}else{_0x40f13e=0xce;}_0x3e2326['status'](_0x40f13e);return _0x3e2326[_0x85eb('0x2d')]('Content-Range',_0x291557+'-'+_0x3e7eb9+'/'+_0x792d3a)[_0x85eb('0x2a')](_0x2e5aa3);}return null;};}function patchUpdates(_0x3570f7){return function(_0x1ba904){try{jsonpatch[_0x85eb('0x2e')](_0x1ba904,_0x3570f7,!![]);}catch(_0xa67e1c){return BPromise[_0x85eb('0x2f')](_0xa67e1c);}return _0x1ba904[_0x85eb('0x30')]();};}function saveUpdates(_0x5decd5,_0x237f19){return function(_0xcbcf2b){if(_0xcbcf2b){return _0xcbcf2b['update'](_0x5decd5)[_0x85eb('0x31')](function(_0x5af2de){return _0x5af2de;});}return null;};}function removeEntity(_0x5439aa,_0x3c5ecc){return function(_0x3a533c){if(_0x3a533c){return _0x3a533c[_0x85eb('0x32')]()[_0x85eb('0x31')](function(){_0x5439aa[_0x85eb('0x28')](0xcc)[_0x85eb('0x29')]();});}};}function handleEntityNotFound(_0x39b574,_0x3858e6){return function(_0xa3fe68){if(!_0xa3fe68){_0x39b574[_0x85eb('0x27')](0x194);}return _0xa3fe68;};}function handleError(_0x4cbee0,_0x14fe58){_0x14fe58=_0x14fe58||0x1f4;return function(_0x3a5b87){logger['error'](_0x3a5b87['stack']);if(_0x3a5b87[_0x85eb('0x33')]){delete _0x3a5b87[_0x85eb('0x33')];}_0x4cbee0[_0x85eb('0x28')](_0x14fe58)[_0x85eb('0x34')](_0x3a5b87);};}exports[_0x85eb('0x35')]=function(_0x3c2686,_0xf4d0e4){var _0x35f092={},_0x272a99={},_0x373e5f={'count':0x0,'rows':[]};var _0x424053=_[_0x85eb('0x36')](db[_0x85eb('0x37')][_0x85eb('0x38')],function(_0x4b69a7){return{'name':_0x4b69a7[_0x85eb('0x39')],'type':_0x4b69a7[_0x85eb('0x3a')]['key']};});_0x272a99['model']=_[_0x85eb('0x36')](_0x424053,_0x85eb('0x33'));_0x272a99['query']=_[_0x85eb('0x3b')](_0x3c2686['query']);_0x272a99[_0x85eb('0x3c')]=_['intersection'](_0x272a99[_0x85eb('0x3d')],_0x272a99['query']);_0x35f092[_0x85eb('0x3e')]=_['intersection'](_0x272a99[_0x85eb('0x3d')],qs[_0x85eb('0x3f')](_0x3c2686['query'][_0x85eb('0x3f')]));_0x35f092['attributes']=_0x35f092[_0x85eb('0x3e')][_0x85eb('0x40')]?_0x35f092['attributes']:_0x272a99[_0x85eb('0x3d')];if(!_0x3c2686['query']['hasOwnProperty'](_0x85eb('0x41'))){_0x35f092['limit']=qs[_0x85eb('0x2c')](_0x3c2686[_0x85eb('0x42')]['limit']);_0x35f092['offset']=qs[_0x85eb('0x43')](_0x3c2686[_0x85eb('0x42')]['offset']);}_0x35f092['order']=qs[_0x85eb('0x44')](_0x3c2686[_0x85eb('0x42')][_0x85eb('0x44')]);_0x35f092[_0x85eb('0x45')]=qs[_0x85eb('0x3c')](_['pick'](_0x3c2686[_0x85eb('0x42')],_0x272a99[_0x85eb('0x3c')]),_0x424053);if(_0x3c2686[_0x85eb('0x42')][_0x85eb('0x46')]){_0x35f092[_0x85eb('0x45')]=_[_0x85eb('0x47')](_0x35f092[_0x85eb('0x45')],{'$or':_[_0x85eb('0x36')](_0x424053,function(_0x469639){if(_0x469639['type']!==_0x85eb('0x48')){var _0x1cabcb={};_0x1cabcb[_0x469639['name']]={'$like':'%'+_0x3c2686[_0x85eb('0x42')][_0x85eb('0x46')]+'%'};return _0x1cabcb;}})});}_0x35f092=_[_0x85eb('0x47')]({},_0x35f092,_0x3c2686[_0x85eb('0x49')]);var _0x1b1559={'where':_0x35f092[_0x85eb('0x45')]};return db['SalesforceAccount'][_0x85eb('0x2b')](_0x1b1559)[_0x85eb('0x31')](function(_0x1ead1d){_0x373e5f[_0x85eb('0x2b')]=_0x1ead1d;if(_0x3c2686[_0x85eb('0x42')][_0x85eb('0x4a')]){_0x35f092[_0x85eb('0x4b')]=[{'all':!![]}];}return db[_0x85eb('0x37')]['findAll'](_0x35f092);})[_0x85eb('0x31')](function(_0x26b226){_0x373e5f[_0x85eb('0x4c')]=_0x26b226;return _0x373e5f;})[_0x85eb('0x31')](respondWithFilteredResult(_0xf4d0e4,_0x35f092))[_0x85eb('0x26')](handleError(_0xf4d0e4,null));};exports[_0x85eb('0x4d')]=function(_0x3c387a,_0x77fdc4){var _0x8cf8c4={'raw':![],'where':{'id':_0x3c387a[_0x85eb('0x4e')]['id']}},_0x14ebda={};_0x14ebda[_0x85eb('0x3d')]=_['keys'](db[_0x85eb('0x37')][_0x85eb('0x38')]);_0x14ebda[_0x85eb('0x42')]=_['keys'](_0x3c387a[_0x85eb('0x42')]);_0x14ebda[_0x85eb('0x3c')]=_[_0x85eb('0x4f')](_0x14ebda[_0x85eb('0x3d')],_0x14ebda[_0x85eb('0x42')]);_0x8cf8c4['attributes']=_[_0x85eb('0x4f')](_0x14ebda[_0x85eb('0x3d')],qs[_0x85eb('0x3f')](_0x3c387a['query'][_0x85eb('0x3f')]));_0x8cf8c4[_0x85eb('0x3e')]=_0x8cf8c4[_0x85eb('0x3e')]['length']?_0x8cf8c4['attributes']:_0x14ebda[_0x85eb('0x3d')];if(_0x3c387a['query']['includeAll']){_0x8cf8c4[_0x85eb('0x4b')]=[{'all':!![]}];}_0x8cf8c4=_['merge']({},_0x8cf8c4,_0x3c387a[_0x85eb('0x49')]);return db[_0x85eb('0x37')]['find'](_0x8cf8c4)['then'](handleEntityNotFound(_0x77fdc4,null))[_0x85eb('0x31')](respondWithResult(_0x77fdc4,null))[_0x85eb('0x26')](handleError(_0x77fdc4,null));};exports[_0x85eb('0x50')]=function(_0x40d64d,_0xf63998){return db['SalesforceAccount'][_0x85eb('0x50')](_0x40d64d[_0x85eb('0x51')],{})[_0x85eb('0x31')](respondWithResult(_0xf63998,0xc9))[_0x85eb('0x26')](handleError(_0xf63998,null));};exports[_0x85eb('0x52')]=function(_0x5318d3,_0x140919){if(_0x5318d3['body']['id']){delete _0x5318d3[_0x85eb('0x51')]['id'];}return db[_0x85eb('0x37')]['find']({'where':{'id':_0x5318d3[_0x85eb('0x4e')]['id']}})[_0x85eb('0x31')](handleEntityNotFound(_0x140919,null))[_0x85eb('0x31')](saveUpdates(_0x5318d3[_0x85eb('0x51')],null))[_0x85eb('0x31')](respondWithResult(_0x140919,null))[_0x85eb('0x26')](handleError(_0x140919,null));};exports['destroy']=function(_0x38d68a,_0x51368c){return db[_0x85eb('0x37')][_0x85eb('0x53')]({'where':{'id':_0x38d68a['params']['id']}})[_0x85eb('0x31')](handleEntityNotFound(_0x51368c,null))[_0x85eb('0x31')](removeEntity(_0x51368c,null))['catch'](handleError(_0x51368c,null));};exports[_0x85eb('0x54')]=function(_0x51125a,_0x452e7e,_0x3f6985){var _0x105bf8={};var _0x13c0b3={};var _0x45a201;var _0x15d4a7;return db['SalesforceAccount'][_0x85eb('0x55')]({'where':{'id':_0x51125a[_0x85eb('0x4e')]['id']}})[_0x85eb('0x31')](handleEntityNotFound(_0x452e7e,null))[_0x85eb('0x31')](function(_0x18f739){if(_0x18f739){_0x45a201=_0x18f739;_0x13c0b3[_0x85eb('0x3d')]=_[_0x85eb('0x3b')](db[_0x85eb('0x56')][_0x85eb('0x38')]);_0x13c0b3[_0x85eb('0x42')]=_[_0x85eb('0x3b')](_0x51125a['query']);_0x13c0b3[_0x85eb('0x3c')]=_[_0x85eb('0x4f')](_0x13c0b3[_0x85eb('0x3d')],_0x13c0b3[_0x85eb('0x42')]);_0x105bf8[_0x85eb('0x3e')]=_[_0x85eb('0x4f')](_0x13c0b3['model'],qs[_0x85eb('0x3f')](_0x51125a['query'][_0x85eb('0x3f')]));_0x105bf8[_0x85eb('0x3e')]=_0x105bf8[_0x85eb('0x3e')][_0x85eb('0x40')]?_0x105bf8[_0x85eb('0x3e')]:_0x13c0b3['model'];_0x105bf8[_0x85eb('0x57')]=qs[_0x85eb('0x44')](_0x51125a[_0x85eb('0x42')][_0x85eb('0x44')]);_0x105bf8[_0x85eb('0x45')]=qs[_0x85eb('0x3c')](_[_0x85eb('0x58')](_0x51125a[_0x85eb('0x42')],_0x13c0b3['filters']));if(_0x51125a[_0x85eb('0x42')]['filter']){_0x105bf8[_0x85eb('0x45')]=_[_0x85eb('0x47')](_0x105bf8[_0x85eb('0x45')],{'$or':_[_0x85eb('0x36')](_0x105bf8[_0x85eb('0x3e')],function(_0x547ccb){var _0x34ecea={};_0x34ecea[_0x547ccb]={'$like':'%'+_0x51125a[_0x85eb('0x42')][_0x85eb('0x46')]+'%'};return _0x34ecea;})});}_0x105bf8=_[_0x85eb('0x47')]({},_0x105bf8,_0x51125a[_0x85eb('0x49')]);return _0x45a201[_0x85eb('0x54')](_0x105bf8);}})['then'](function(_0x5f4113){if(_0x5f4113){_0x15d4a7=_0x5f4113[_0x85eb('0x40')];if(!_0x51125a['query'][_0x85eb('0x59')](_0x85eb('0x41'))){_0x105bf8[_0x85eb('0x2c')]=qs[_0x85eb('0x2c')](_0x51125a[_0x85eb('0x42')][_0x85eb('0x2c')]);_0x105bf8['offset']=qs[_0x85eb('0x43')](_0x51125a[_0x85eb('0x42')][_0x85eb('0x43')]);}return _0x45a201[_0x85eb('0x54')](_0x105bf8);}})['then'](function(_0x1d513c){if(_0x1d513c){return _0x1d513c?{'count':_0x15d4a7,'rows':_0x1d513c}:null;}})[_0x85eb('0x31')](respondWithResult(_0x452e7e,null))[_0x85eb('0x26')](handleError(_0x452e7e,null));};exports[_0x85eb('0x5a')]=function(_0x5037c7,_0x459317,_0x2e6734){if(_0x5037c7[_0x85eb('0x51')]['id']){delete _0x5037c7[_0x85eb('0x51')]['id'];}return db[_0x85eb('0x37')][_0x85eb('0x55')]({'where':{'id':_0x5037c7[_0x85eb('0x4e')]['id']}})[_0x85eb('0x31')](handleEntityNotFound(_0x459317,null))[_0x85eb('0x31')](function(_0x1db157){if(_0x1db157){_0x5037c7[_0x85eb('0x51')][_0x85eb('0x5b')]=_0x1db157['id'];_0x5037c7[_0x85eb('0x51')][_0x85eb('0x5c')]=integrations[_0x85eb('0x5d')](_0x5037c7[_0x85eb('0x51')][_0x85eb('0x5e')],_0x5037c7[_0x85eb('0x51')][_0x85eb('0x3a')]);_0x5037c7['body'][_0x85eb('0x5f')]=integrations['getDescriptions'](_0x5037c7[_0x85eb('0x51')][_0x85eb('0x5e')],_0x5037c7[_0x85eb('0x51')][_0x85eb('0x3a')]);return db[_0x85eb('0x56')][_0x85eb('0x50')](_0x5037c7[_0x85eb('0x51')],{'include':[{'model':db[_0x85eb('0x60')],'as':_0x85eb('0x5c')},{'model':db['SalesforceField'],'as':_0x85eb('0x5f')}]});}return null;})[_0x85eb('0x31')](respondWithResult(_0x459317,null))[_0x85eb('0x26')](handleError(_0x459317,null));};exports[_0x85eb('0x61')]=function(_0x440968,_0x496216,_0x2b4a71){var _0x589702;var _0x24e609='';var _0x330c2b=_0x85eb('0x62');return db['SalesforceAccount'][_0x85eb('0x55')]({'where':{'id':_0x440968[_0x85eb('0x4e')]['id']},'attributes':['id',_0x85eb('0x63'),'clientId','clientSecret',_0x85eb('0x64'),_0x85eb('0x65'),_0x85eb('0x66')]})[_0x85eb('0x31')](handleEntityNotFound(_0x496216,null))['then'](function(_0x8cb47){if(_0x8cb47){_0x24e609=_0x8cb47['remoteUri'];var _0x11a3bd=_0x24e609[_0x85eb('0x67')](-0x1);if(_0x11a3bd==='/'){_0x24e609=_0x24e609[_0x85eb('0x68')](0x0,_0x24e609[_0x85eb('0x69')](_0x11a3bd));}_0x589702=new jsforce[(_0x85eb('0x6a'))]({'oauth2':{'loginUrl':_0x24e609,'clientId':_0x8cb47[_0x85eb('0x6b')],'clientSecret':_0x8cb47['clientSecret']}});return _0x589702[_0x85eb('0x6c')](_0x8cb47['username'],_0x8cb47[_0x85eb('0x65')][_0x85eb('0x6d')](_0x8cb47[_0x85eb('0x66')]));}})[_0x85eb('0x31')](function(_0xcfe307){if(_0xcfe307){if(!_[_0x85eb('0x6e')](_0x440968[_0x85eb('0x42')][_0x85eb('0x6f')])){_0x330c2b=_0x440968[_0x85eb('0x42')]['ticketType'];}return _0x589702[_0x85eb('0x70')](_0x330c2b)[_0x85eb('0x71')]();}})['then'](function(_0x4bb9b7){var _0x2de4f5=['CallDisposition',_0x85eb('0x72'),'CallObject',_0x85eb('0x73'),'IsArchived',_0x85eb('0x74'),_0x85eb('0x75'),'Type'];if(!_[_0x85eb('0x6e')](_0x440968[_0x85eb('0x42')]['ticketType'])&&_0x440968[_0x85eb('0x42')][_0x85eb('0x6f')]===_0x85eb('0x76')){_0x2de4f5=[_0x85eb('0x77'),'Origin',_0x85eb('0x78'),'Status',_0x85eb('0x74'),_0x85eb('0x79'),_0x85eb('0x7a'),'SuppliedCompany'];}if(_0x4bb9b7){_[_0x85eb('0x7b')](_0x4bb9b7[_0x85eb('0x3f')],function(_0x760d65){return _0x760d65['custom']===![]&&!_0x2de4f5[_0x85eb('0x7c')](_0x760d65['name']);});return{'count':_0x4bb9b7[_0x85eb('0x3f')][_0x85eb('0x40')],'rows':_[_0x85eb('0x36')](_0x4bb9b7['fields'],function(_0x4a7184){return{'id':_0x4a7184['name'],'name':_0x4a7184[_0x85eb('0x7d')],'custom':_0x4a7184[_0x85eb('0x7e')],'options':_0x4a7184[_0x85eb('0x7f')]['length']>0x0?_[_0x85eb('0x36')](_0x4a7184[_0x85eb('0x7f')],function(_0x45d6af){return{'name':_0x45d6af[_0x85eb('0x7d')],'value':_0x45d6af[_0x85eb('0x80')]};}):_0x4a7184['type']=='boolean'?[{'name':_0x85eb('0x81'),'value':_0x85eb('0x82')},{'name':'False','value':_0x85eb('0x83')}]:[]};})};}})[_0x85eb('0x31')](respondWithResult(_0x496216,null))[_0x85eb('0x26')](function(_0x107f31){var _0x2f2475=_0x440968[_0x85eb('0x42')][_0x85eb('0x84')]?0x1f4:_0x107f31[_0x85eb('0x85')]||0x1f4;logger[_0x85eb('0x21')](_0x85eb('0x86'),_0x85eb('0x61'),_0x2f2475,JSON[_0x85eb('0x87')](_0x107f31));delete _0x107f31[_0x85eb('0x33')];if(_0x2f2475===0x191){_0x2f2475=0x190;}_0x496216[_0x85eb('0x28')](_0x2f2475)[_0x85eb('0x34')](_0x440968['query'][_0x85eb('0x84')]?{'message':_0x85eb('0x88'),'statusCode':_0x107f31[_0x85eb('0x85')]}:_0x107f31);});};
\ No newline at end of file
+var _0x473a=['slice','substring','lastIndexOf','Connection','clientSecret','login','isNil','ticketType','sobject','describe','OwnerId','ActivityDate','IsReminderSet','IsRecurrence','Subject','string','int','picklist','boolean','email','textarea','phone','remove','includes','label','custom','picklistValues','value','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','send','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','path','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','index','map','SalesforceAccount','type','key','model','query','keys','filters','attributes','intersection','fields','hasOwnProperty','nolimit','sort','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','rawAttributes','length','find','create','body','getConfigurations','findOne','SalesforceConfiguration','order','AccountId','Subjects','getSubjects','getDescriptions','channel','SalesforceField','getFields','Task','remoteUri','clientId','username','password','securityToken'];(function(_0x257c45,_0x3555b3){var _0x24454c=function(_0x2faea1){while(--_0x2faea1){_0x257c45['push'](_0x257c45['shift']());}};_0x24454c(++_0x3555b3);}(_0x473a,0x1a4));var _0xa473=function(_0x329d5b,_0x146ff1){_0x329d5b=_0x329d5b-0x0;var _0x250c0e=_0x473a[_0x329d5b];return _0x250c0e;};'use strict';var emlformat=require(_0xa473('0x0'));var rimraf=require(_0xa473('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xa473('0x2'));var moment=require(_0xa473('0x3'));var BPromise=require(_0xa473('0x4'));var Mustache=require(_0xa473('0x5'));var util=require(_0xa473('0x6'));var path=require(_0xa473('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa473('0x8'));var _=require(_0xa473('0x9'));var squel=require(_0xa473('0xa'));var crypto=require(_0xa473('0xb'));var jsforce=require(_0xa473('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xa473('0xd'));var Papa=require('papaparse');var Redis=require(_0xa473('0xe'));var authService=require(_0xa473('0xf'));var qs=require(_0xa473('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xa473('0x11'))(_0xa473('0x12'));var utils=require(_0xa473('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xa473('0x14'));var db=require(_0xa473('0x15'))['db'];var integrations=require(_0xa473('0x16'));function respondWithStatusCode(_0x388235,_0x3cc8e5){_0x3cc8e5=_0x3cc8e5||0xcc;return function(_0x5e8ed1){if(_0x5e8ed1){return _0x388235[_0xa473('0x17')](_0x3cc8e5);}return _0x388235[_0xa473('0x18')](_0x3cc8e5)[_0xa473('0x19')]();};}function respondWithResult(_0x161fe1,_0x6baabe){_0x6baabe=_0x6baabe||0xc8;return function(_0x2f920c){if(_0x2f920c){return _0x161fe1[_0xa473('0x18')](_0x6baabe)[_0xa473('0x1a')](_0x2f920c);}};}function respondWithFilteredResult(_0x4408e5,_0x4a765e){return function(_0x6a4e){if(_0x6a4e){var _0x1a773f=typeof _0x4a765e[_0xa473('0x1b')]==='undefined'&&typeof _0x4a765e[_0xa473('0x1c')]===_0xa473('0x1d');var _0x5a4bf2=_0x6a4e['count'];var _0x3f11f6=_0x1a773f?0x0:_0x4a765e['offset'];var _0x2e5a83=_0x1a773f?_0x6a4e[_0xa473('0x1e')]:_0x4a765e['offset']+_0x4a765e[_0xa473('0x1c')];var _0xbd2321;if(_0x2e5a83>=_0x5a4bf2){_0x2e5a83=_0x5a4bf2;_0xbd2321=0xc8;}else{_0xbd2321=0xce;}_0x4408e5[_0xa473('0x18')](_0xbd2321);return _0x4408e5[_0xa473('0x1f')](_0xa473('0x20'),_0x3f11f6+'-'+_0x2e5a83+'/'+_0x5a4bf2)[_0xa473('0x1a')](_0x6a4e);}return null;};}function patchUpdates(_0x178bfa){return function(_0x4309e3){try{jsonpatch[_0xa473('0x21')](_0x4309e3,_0x178bfa,!![]);}catch(_0x395213){return BPromise[_0xa473('0x22')](_0x395213);}return _0x4309e3[_0xa473('0x23')]();};}function saveUpdates(_0x324337,_0x2ff691){return function(_0x3c8043){if(_0x3c8043){return _0x3c8043[_0xa473('0x24')](_0x324337)[_0xa473('0x25')](function(_0x3cb9c4){return _0x3cb9c4;});}return null;};}function removeEntity(_0xec543f,_0x19604e){return function(_0x5a679f){if(_0x5a679f){return _0x5a679f[_0xa473('0x26')]()[_0xa473('0x25')](function(){_0xec543f[_0xa473('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x500bba,_0x356c16){return function(_0x290905){if(!_0x290905){_0x500bba[_0xa473('0x17')](0x194);}return _0x290905;};}function handleError(_0x14c6a5,_0xc5bd1){_0xc5bd1=_0xc5bd1||0x1f4;return function(_0x57cac4){logger[_0xa473('0x27')](_0x57cac4[_0xa473('0x28')]);if(_0x57cac4[_0xa473('0x29')]){delete _0x57cac4[_0xa473('0x29')];}_0x14c6a5[_0xa473('0x18')](_0xc5bd1)['send'](_0x57cac4);};}exports[_0xa473('0x2a')]=function(_0x37efcd,_0x56c28c){var _0x4b39cc={},_0x105551={},_0x529c06={'count':0x0,'rows':[]};var _0x3d4895=_[_0xa473('0x2b')](db[_0xa473('0x2c')]['rawAttributes'],function(_0x5bbb82){return{'name':_0x5bbb82['fieldName'],'type':_0x5bbb82[_0xa473('0x2d')][_0xa473('0x2e')]};});_0x105551[_0xa473('0x2f')]=_[_0xa473('0x2b')](_0x3d4895,_0xa473('0x29'));_0x105551[_0xa473('0x30')]=_[_0xa473('0x31')](_0x37efcd[_0xa473('0x30')]);_0x105551[_0xa473('0x32')]=_['intersection'](_0x105551[_0xa473('0x2f')],_0x105551[_0xa473('0x30')]);_0x4b39cc[_0xa473('0x33')]=_[_0xa473('0x34')](_0x105551[_0xa473('0x2f')],qs['fields'](_0x37efcd[_0xa473('0x30')][_0xa473('0x35')]));_0x4b39cc['attributes']=_0x4b39cc[_0xa473('0x33')]['length']?_0x4b39cc[_0xa473('0x33')]:_0x105551[_0xa473('0x2f')];if(!_0x37efcd['query'][_0xa473('0x36')](_0xa473('0x37'))){_0x4b39cc[_0xa473('0x1c')]=qs[_0xa473('0x1c')](_0x37efcd['query']['limit']);_0x4b39cc[_0xa473('0x1b')]=qs['offset'](_0x37efcd[_0xa473('0x30')][_0xa473('0x1b')]);}_0x4b39cc['order']=qs[_0xa473('0x38')](_0x37efcd['query'][_0xa473('0x38')]);_0x4b39cc['where']=qs[_0xa473('0x32')](_[_0xa473('0x39')](_0x37efcd['query'],_0x105551[_0xa473('0x32')]),_0x3d4895);if(_0x37efcd[_0xa473('0x30')]['filter']){_0x4b39cc[_0xa473('0x3a')]=_[_0xa473('0x3b')](_0x4b39cc[_0xa473('0x3a')],{'$or':_[_0xa473('0x2b')](_0x3d4895,function(_0x1b1c95){if(_0x1b1c95[_0xa473('0x2d')]!==_0xa473('0x3c')){var _0x19afe2={};_0x19afe2[_0x1b1c95['name']]={'$like':'%'+_0x37efcd[_0xa473('0x30')][_0xa473('0x3d')]+'%'};return _0x19afe2;}})});}_0x4b39cc=_[_0xa473('0x3b')]({},_0x4b39cc,_0x37efcd[_0xa473('0x3e')]);var _0xa99024={'where':_0x4b39cc[_0xa473('0x3a')]};return db[_0xa473('0x2c')]['count'](_0xa99024)[_0xa473('0x25')](function(_0x41066f){_0x529c06[_0xa473('0x1e')]=_0x41066f;if(_0x37efcd[_0xa473('0x30')][_0xa473('0x3f')]){_0x4b39cc[_0xa473('0x40')]=[{'all':!![]}];}return db[_0xa473('0x2c')][_0xa473('0x41')](_0x4b39cc);})[_0xa473('0x25')](function(_0x17d4ff){_0x529c06[_0xa473('0x42')]=_0x17d4ff;return _0x529c06;})[_0xa473('0x25')](respondWithFilteredResult(_0x56c28c,_0x4b39cc))[_0xa473('0x43')](handleError(_0x56c28c,null));};exports[_0xa473('0x44')]=function(_0xc39fe5,_0x477bf5){var _0xa61bf2={'raw':![],'where':{'id':_0xc39fe5[_0xa473('0x45')]['id']}},_0x43465b={};_0x43465b['model']=_['keys'](db[_0xa473('0x2c')][_0xa473('0x46')]);_0x43465b[_0xa473('0x30')]=_[_0xa473('0x31')](_0xc39fe5[_0xa473('0x30')]);_0x43465b['filters']=_['intersection'](_0x43465b[_0xa473('0x2f')],_0x43465b[_0xa473('0x30')]);_0xa61bf2['attributes']=_['intersection'](_0x43465b[_0xa473('0x2f')],qs[_0xa473('0x35')](_0xc39fe5[_0xa473('0x30')]['fields']));_0xa61bf2['attributes']=_0xa61bf2[_0xa473('0x33')][_0xa473('0x47')]?_0xa61bf2[_0xa473('0x33')]:_0x43465b[_0xa473('0x2f')];if(_0xc39fe5[_0xa473('0x30')][_0xa473('0x3f')]){_0xa61bf2[_0xa473('0x40')]=[{'all':!![]}];}_0xa61bf2=_[_0xa473('0x3b')]({},_0xa61bf2,_0xc39fe5[_0xa473('0x3e')]);return db['SalesforceAccount'][_0xa473('0x48')](_0xa61bf2)[_0xa473('0x25')](handleEntityNotFound(_0x477bf5,null))[_0xa473('0x25')](respondWithResult(_0x477bf5,null))[_0xa473('0x43')](handleError(_0x477bf5,null));};exports[_0xa473('0x49')]=function(_0x47e7b5,_0x2e7279){return db['SalesforceAccount']['create'](_0x47e7b5['body'],{})[_0xa473('0x25')](respondWithResult(_0x2e7279,0xc9))[_0xa473('0x43')](handleError(_0x2e7279,null));};exports[_0xa473('0x24')]=function(_0x56151e,_0xc980f8){if(_0x56151e[_0xa473('0x4a')]['id']){delete _0x56151e['body']['id'];}return db['SalesforceAccount'][_0xa473('0x48')]({'where':{'id':_0x56151e[_0xa473('0x45')]['id']}})[_0xa473('0x25')](handleEntityNotFound(_0xc980f8,null))[_0xa473('0x25')](saveUpdates(_0x56151e[_0xa473('0x4a')],null))['then'](respondWithResult(_0xc980f8,null))['catch'](handleError(_0xc980f8,null));};exports[_0xa473('0x26')]=function(_0xc36dbb,_0x51044c){return db[_0xa473('0x2c')][_0xa473('0x48')]({'where':{'id':_0xc36dbb[_0xa473('0x45')]['id']}})[_0xa473('0x25')](handleEntityNotFound(_0x51044c,null))['then'](removeEntity(_0x51044c,null))[_0xa473('0x43')](handleError(_0x51044c,null));};exports[_0xa473('0x4b')]=function(_0x2ff673,_0x2d787a,_0x129722){var _0x374044={};var _0x553c71={};var _0x5f289f;var _0x5c9a04;return db[_0xa473('0x2c')][_0xa473('0x4c')]({'where':{'id':_0x2ff673[_0xa473('0x45')]['id']}})[_0xa473('0x25')](handleEntityNotFound(_0x2d787a,null))[_0xa473('0x25')](function(_0xf64824){if(_0xf64824){_0x5f289f=_0xf64824;_0x553c71[_0xa473('0x2f')]=_[_0xa473('0x31')](db[_0xa473('0x4d')]['rawAttributes']);_0x553c71['query']=_[_0xa473('0x31')](_0x2ff673[_0xa473('0x30')]);_0x553c71[_0xa473('0x32')]=_[_0xa473('0x34')](_0x553c71[_0xa473('0x2f')],_0x553c71[_0xa473('0x30')]);_0x374044[_0xa473('0x33')]=_[_0xa473('0x34')](_0x553c71['model'],qs[_0xa473('0x35')](_0x2ff673[_0xa473('0x30')]['fields']));_0x374044[_0xa473('0x33')]=_0x374044['attributes']['length']?_0x374044['attributes']:_0x553c71[_0xa473('0x2f')];_0x374044[_0xa473('0x4e')]=qs[_0xa473('0x38')](_0x2ff673[_0xa473('0x30')][_0xa473('0x38')]);_0x374044[_0xa473('0x3a')]=qs['filters'](_['pick'](_0x2ff673[_0xa473('0x30')],_0x553c71[_0xa473('0x32')]));if(_0x2ff673[_0xa473('0x30')][_0xa473('0x3d')]){_0x374044[_0xa473('0x3a')]=_[_0xa473('0x3b')](_0x374044[_0xa473('0x3a')],{'$or':_[_0xa473('0x2b')](_0x374044[_0xa473('0x33')],function(_0x2eea3a){var _0x17f5a9={};_0x17f5a9[_0x2eea3a]={'$like':'%'+_0x2ff673[_0xa473('0x30')]['filter']+'%'};return _0x17f5a9;})});}_0x374044=_[_0xa473('0x3b')]({},_0x374044,_0x2ff673[_0xa473('0x3e')]);return _0x5f289f[_0xa473('0x4b')](_0x374044);}})[_0xa473('0x25')](function(_0x3c7b00){if(_0x3c7b00){_0x5c9a04=_0x3c7b00[_0xa473('0x47')];if(!_0x2ff673['query'][_0xa473('0x36')](_0xa473('0x37'))){_0x374044['limit']=qs[_0xa473('0x1c')](_0x2ff673['query'][_0xa473('0x1c')]);_0x374044[_0xa473('0x1b')]=qs[_0xa473('0x1b')](_0x2ff673['query'][_0xa473('0x1b')]);}return _0x5f289f['getConfigurations'](_0x374044);}})['then'](function(_0x3be8db){if(_0x3be8db){return _0x3be8db?{'count':_0x5c9a04,'rows':_0x3be8db}:null;}})[_0xa473('0x25')](respondWithResult(_0x2d787a,null))[_0xa473('0x43')](handleError(_0x2d787a,null));};exports['addConfiguration']=function(_0x39d954,_0x36550f,_0x2050d0){if(_0x39d954[_0xa473('0x4a')]['id']){delete _0x39d954[_0xa473('0x4a')]['id'];}return db[_0xa473('0x2c')]['findOne']({'where':{'id':_0x39d954[_0xa473('0x45')]['id']}})['then'](handleEntityNotFound(_0x36550f,null))[_0xa473('0x25')](function(_0x5e0cb0){if(_0x5e0cb0){_0x39d954[_0xa473('0x4a')][_0xa473('0x4f')]=_0x5e0cb0['id'];_0x39d954['body'][_0xa473('0x50')]=integrations[_0xa473('0x51')](_0x39d954[_0xa473('0x4a')]['channel'],_0x39d954[_0xa473('0x4a')][_0xa473('0x2d')]);_0x39d954[_0xa473('0x4a')]['Descriptions']=integrations[_0xa473('0x52')](_0x39d954[_0xa473('0x4a')][_0xa473('0x53')],_0x39d954[_0xa473('0x4a')][_0xa473('0x2d')]);return db['SalesforceConfiguration'][_0xa473('0x49')](_0x39d954['body'],{'include':[{'model':db[_0xa473('0x54')],'as':_0xa473('0x50')},{'model':db[_0xa473('0x54')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x36550f,null))[_0xa473('0x43')](handleError(_0x36550f,null));};exports[_0xa473('0x55')]=function(_0x23aaf3,_0x1ff886,_0x46a0ef){var _0x6224e5;var _0x2a4ef4='';var _0xcfd5f5=_0xa473('0x56');return db[_0xa473('0x2c')][_0xa473('0x4c')]({'where':{'id':_0x23aaf3[_0xa473('0x45')]['id']},'attributes':['id',_0xa473('0x57'),_0xa473('0x58'),'clientSecret',_0xa473('0x59'),_0xa473('0x5a'),_0xa473('0x5b')]})[_0xa473('0x25')](handleEntityNotFound(_0x1ff886,null))[_0xa473('0x25')](function(_0x3206a0){if(_0x3206a0){_0x2a4ef4=_0x3206a0[_0xa473('0x57')];var _0x2e831d=_0x2a4ef4[_0xa473('0x5c')](-0x1);if(_0x2e831d==='/'){_0x2a4ef4=_0x2a4ef4[_0xa473('0x5d')](0x0,_0x2a4ef4[_0xa473('0x5e')](_0x2e831d));}_0x6224e5=new jsforce[(_0xa473('0x5f'))]({'oauth2':{'loginUrl':_0x2a4ef4,'clientId':_0x3206a0[_0xa473('0x58')],'clientSecret':_0x3206a0[_0xa473('0x60')]}});return _0x6224e5[_0xa473('0x61')](_0x3206a0[_0xa473('0x59')],_0x3206a0[_0xa473('0x5a')]['concat'](_0x3206a0[_0xa473('0x5b')]));}})['then'](function(_0x3fe78c){if(_0x3fe78c){if(!_[_0xa473('0x62')](_0x23aaf3[_0xa473('0x30')][_0xa473('0x63')])){_0xcfd5f5=_0x23aaf3[_0xa473('0x30')][_0xa473('0x63')];}return _0x6224e5[_0xa473('0x64')](_0xcfd5f5)[_0xa473('0x65')]();}})[_0xa473('0x25')](function(_0x3a3c32){var _0x52e227=[_0xa473('0x66'),_0xa473('0x67'),_0xa473('0x68'),_0xa473('0x69'),_0xa473('0x6a'),'Description'];var _0xdcae30=[_0xa473('0x6b'),_0xa473('0x6c'),_0xa473('0x6d'),_0xa473('0x6e'),_0xa473('0x6f'),_0xa473('0x70'),_0xa473('0x71')];if(_0x3a3c32){_[_0xa473('0x72')](_0x3a3c32[_0xa473('0x35')],function(_0x47f9e0){return _0x52e227[_0xa473('0x73')](_0x47f9e0[_0xa473('0x29')])||!_0xdcae30[_0xa473('0x73')](_0x47f9e0[_0xa473('0x2d')]);});return{'count':_0x3a3c32[_0xa473('0x35')][_0xa473('0x47')],'rows':_['map'](_0x3a3c32[_0xa473('0x35')],function(_0x3628ae){return{'id':_0x3628ae['name'],'name':_0x3628ae[_0xa473('0x74')],'custom':_0x3628ae[_0xa473('0x75')],'options':_0x3628ae[_0xa473('0x76')][_0xa473('0x47')]>0x0?_[_0xa473('0x2b')](_0x3628ae['picklistValues'],function(_0x5b3b30){return{'name':_0x5b3b30[_0xa473('0x74')],'value':_0x5b3b30[_0xa473('0x77')]};}):_0x3628ae[_0xa473('0x2d')]=='boolean'?[{'name':'True','value':_0xa473('0x78')},{'name':_0xa473('0x79'),'value':_0xa473('0x7a')}]:[]};})};}})[_0xa473('0x25')](respondWithResult(_0x1ff886,null))[_0xa473('0x43')](function(_0x24a274){var _0x33ab25=_0x23aaf3[_0xa473('0x30')][_0xa473('0x7b')]?0x1f4:_0x24a274[_0xa473('0x7c')]||0x1f4;logger['error'](_0xa473('0x7d'),_0xa473('0x55'),_0x33ab25,JSON[_0xa473('0x7e')](_0x24a274));delete _0x24a274['name'];if(_0x33ab25===0x191){_0x33ab25=0x190;}_0x1ff886[_0xa473('0x18')](_0x33ab25)[_0xa473('0x7f')](_0x23aaf3[_0xa473('0x30')]['test']?{'message':'Wrong\x20credentials','statusCode':_0x24a274[_0xa473('0x7c')]}:_0x24a274);});};
\ No newline at end of file