Built motion from commit 25580385.|2.6.2
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index 027a764..337adea 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1eba=['merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','create','body','getConfigurations','findOne','SalesforceConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','SalesforceField','getFields','Task','clientSecret','username','password','securityToken','remoteUri','slice','substring','lastIndexOf','Connection','clientId','login','concat','isNil','ticketType','sobject','CallDisposition','CallDurationInSeconds','CallType','IsArchived','Status','Type','Case','Origin','Reason','Priority','IsEscalated','SuppliedName','SuppliedCompany','custom','label','picklistValues','value','boolean','True','true','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','../../components/integrations/configuration','client','request','then','info','SalesforceAccount,\x20%s,\x20%s','debug','request\x20sent','stringify','error','message','catch','sendStatus','status','end','json','count','offset','limit','Content-Range','apply','reject','save','update','destroy','stack','name','send','map','SalesforceAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter'];(function(_0x5175fa,_0xdad90c){var _0x188ee1=function(_0x23a8be){while(--_0x23a8be){_0x5175fa['push'](_0x5175fa['shift']());}};_0x188ee1(++_0xdad90c);}(_0x1eba,0x1d7));var _0xa1eb=function(_0x246f0c,_0x39f734){_0x246f0c=_0x246f0c-0x0;var _0x30fe50=_0x1eba[_0x246f0c];return _0x30fe50;};'use strict';var pdf=require(_0xa1eb('0x0'));var emlformat=require(_0xa1eb('0x1'));var rimraf=require(_0xa1eb('0x2'));var zipdir=require(_0xa1eb('0x3'));var jsonpatch=require(_0xa1eb('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xa1eb('0x5'));var Mustache=require(_0xa1eb('0x6'));var util=require(_0xa1eb('0x7'));var path=require(_0xa1eb('0x8'));var sox=require(_0xa1eb('0x9'));var csv=require(_0xa1eb('0xa'));var ejs=require(_0xa1eb('0xb'));var fs=require('fs');var _=require(_0xa1eb('0xc'));var squel=require(_0xa1eb('0xd'));var crypto=require(_0xa1eb('0xe'));var jsforce=require(_0xa1eb('0xf'));var deskjs=require(_0xa1eb('0x10'));var toCsv=require('to-csv');var querystring=require(_0xa1eb('0x11'));var Papa=require('papaparse');var Redis=require(_0xa1eb('0x12'));var authService=require('../../components/auth/service');var qs=require(_0xa1eb('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa1eb('0x14'));var logger=require('../../config/logger')(_0xa1eb('0x15'));var utils=require(_0xa1eb('0x16'));var config=require(_0xa1eb('0x17'));var licenseUtil=require('../../config/license/util');var db=require(_0xa1eb('0x18'))['db'];var integrations=require(_0xa1eb('0x19'));var jayson=require('jayson/promise');var client=jayson[_0xa1eb('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4e65dc,_0x35a353,_0x4c7983,_0x25d058){return new BPromise(function(_0x2178e2,_0x14e048){var _0x2877cb=_0x25d058||client;return _0x2877cb[_0xa1eb('0x1b')](_0x4e65dc,_0x4c7983)[_0xa1eb('0x1c')](function(_0x1c858c){logger[_0xa1eb('0x1d')](_0xa1eb('0x1e'),_0x35a353,'request\x20sent');logger[_0xa1eb('0x1f')]('SalesforceAccount,\x20%s,\x20%s,\x20%s',_0x35a353,_0xa1eb('0x20'),JSON[_0xa1eb('0x21')](_0x1c858c));if(_0x1c858c[_0xa1eb('0x22')]){if(_0x1c858c[_0xa1eb('0x22')]['code']===0x1f4){logger[_0xa1eb('0x22')](_0xa1eb('0x1e'),_0x35a353,_0x1c858c[_0xa1eb('0x22')][_0xa1eb('0x23')]);return _0x14e048(_0x1c858c[_0xa1eb('0x22')][_0xa1eb('0x23')]);}logger[_0xa1eb('0x22')](_0xa1eb('0x1e'),_0x35a353,_0x1c858c['error'][_0xa1eb('0x23')]);return _0x2178e2(_0x1c858c['error'][_0xa1eb('0x23')]);}else{logger[_0xa1eb('0x1d')](_0xa1eb('0x1e'),_0x35a353,_0xa1eb('0x20'));_0x2178e2(_0x1c858c['result']['message']);}})[_0xa1eb('0x24')](function(_0xc64cb9){logger['error'](_0xa1eb('0x1e'),_0x35a353,_0xc64cb9);_0x14e048(_0xc64cb9);});});}function respondWithStatusCode(_0x250728,_0x258d3a){_0x258d3a=_0x258d3a||0xcc;return function(_0xa6b20c){if(_0xa6b20c){return _0x250728[_0xa1eb('0x25')](_0x258d3a);}return _0x250728[_0xa1eb('0x26')](_0x258d3a)[_0xa1eb('0x27')]();};}function respondWithResult(_0x364b1c,_0xd7bb88){_0xd7bb88=_0xd7bb88||0xc8;return function(_0x352796){if(_0x352796){return _0x364b1c[_0xa1eb('0x26')](_0xd7bb88)[_0xa1eb('0x28')](_0x352796);}};}function respondWithFilteredResult(_0x57d089,_0x7c617e){return function(_0xbd5517){if(_0xbd5517){var _0x491f37=_0xbd5517[_0xa1eb('0x29')],_0x2680c0=_0x7c617e['offset'],_0x4e2aa7=_0x7c617e[_0xa1eb('0x2a')]+_0x7c617e[_0xa1eb('0x2b')],_0x3aae71;if(_0x4e2aa7>=_0x491f37){_0x4e2aa7=_0x491f37;_0x3aae71=0xc8;}else{_0x3aae71=0xce;}_0x57d089[_0xa1eb('0x26')](_0x3aae71);return _0x57d089['set'](_0xa1eb('0x2c'),_0x2680c0+'-'+_0x4e2aa7+'/'+_0x491f37)[_0xa1eb('0x28')](_0xbd5517);}return null;};}function patchUpdates(_0x55f5cc){return function(_0x273a42){try{jsonpatch[_0xa1eb('0x2d')](_0x273a42,_0x55f5cc,!![]);}catch(_0x401510){return BPromise[_0xa1eb('0x2e')](_0x401510);}return _0x273a42[_0xa1eb('0x2f')]();};}function saveUpdates(_0x52f9c7,_0x9d49d8){return function(_0x316b02){if(_0x316b02){return _0x316b02[_0xa1eb('0x30')](_0x52f9c7)[_0xa1eb('0x1c')](function(_0x383e26){return _0x383e26;});}return null;};}function removeEntity(_0xcd9efd,_0x1d5b64){return function(_0xcfda64){if(_0xcfda64){return _0xcfda64[_0xa1eb('0x31')]()[_0xa1eb('0x1c')](function(){_0xcd9efd[_0xa1eb('0x26')](0xcc)['end']();});}};}function handleEntityNotFound(_0x563b11,_0x126d50){return function(_0xb267e0){if(!_0xb267e0){_0x563b11[_0xa1eb('0x25')](0x194);}return _0xb267e0;};}function handleError(_0x36cc2a,_0x2b345a){_0x2b345a=_0x2b345a||0x1f4;return function(_0x58d336){logger['error'](_0x58d336[_0xa1eb('0x32')]);if(_0x58d336[_0xa1eb('0x33')]){delete _0x58d336['name'];}_0x36cc2a['status'](_0x2b345a)[_0xa1eb('0x34')](_0x58d336);};}exports['index']=function(_0x1f33dc,_0x534fe4){var _0x47737d={},_0x3ad54b={},_0x229931={'count':0x0,'rows':[]};var _0x57355f=_[_0xa1eb('0x35')](db[_0xa1eb('0x36')][_0xa1eb('0x37')],function(_0x481405){return{'name':_0x481405[_0xa1eb('0x38')],'type':_0x481405[_0xa1eb('0x39')][_0xa1eb('0x3a')]};});_0x3ad54b[_0xa1eb('0x3b')]=_[_0xa1eb('0x35')](_0x57355f,'name');_0x3ad54b[_0xa1eb('0x3c')]=_[_0xa1eb('0x3d')](_0x1f33dc[_0xa1eb('0x3c')]);_0x3ad54b[_0xa1eb('0x3e')]=_[_0xa1eb('0x3f')](_0x3ad54b[_0xa1eb('0x3b')],_0x3ad54b[_0xa1eb('0x3c')]);_0x47737d[_0xa1eb('0x40')]=_['intersection'](_0x3ad54b[_0xa1eb('0x3b')],qs[_0xa1eb('0x41')](_0x1f33dc[_0xa1eb('0x3c')][_0xa1eb('0x41')]));_0x47737d[_0xa1eb('0x40')]=_0x47737d['attributes'][_0xa1eb('0x42')]?_0x47737d[_0xa1eb('0x40')]:_0x3ad54b[_0xa1eb('0x3b')];if(!_0x1f33dc['query'][_0xa1eb('0x43')](_0xa1eb('0x44'))){_0x47737d[_0xa1eb('0x2b')]=qs[_0xa1eb('0x2b')](_0x1f33dc[_0xa1eb('0x3c')][_0xa1eb('0x2b')]);_0x47737d[_0xa1eb('0x2a')]=qs['offset'](_0x1f33dc[_0xa1eb('0x3c')][_0xa1eb('0x2a')]);}_0x47737d['order']=qs[_0xa1eb('0x45')](_0x1f33dc['query'][_0xa1eb('0x45')]);_0x47737d[_0xa1eb('0x46')]=qs[_0xa1eb('0x3e')](_[_0xa1eb('0x47')](_0x1f33dc[_0xa1eb('0x3c')],_0x3ad54b[_0xa1eb('0x3e')]),_0x57355f);if(_0x1f33dc[_0xa1eb('0x3c')][_0xa1eb('0x48')]){_0x47737d[_0xa1eb('0x46')]=_[_0xa1eb('0x49')](_0x47737d[_0xa1eb('0x46')],{'$or':_[_0xa1eb('0x35')](_0x57355f,function(_0x459a02){if(_0x459a02[_0xa1eb('0x39')]!==_0xa1eb('0x4a')){var _0x2ee961={};_0x2ee961[_0x459a02['name']]={'$like':'%'+_0x1f33dc[_0xa1eb('0x3c')]['filter']+'%'};return _0x2ee961;}})});}_0x47737d=_[_0xa1eb('0x49')]({},_0x47737d,_0x1f33dc[_0xa1eb('0x4b')]);var _0x54a29f={'where':_0x47737d['where']};return db[_0xa1eb('0x36')][_0xa1eb('0x29')](_0x54a29f)[_0xa1eb('0x1c')](function(_0x55c770){_0x229931[_0xa1eb('0x29')]=_0x55c770;if(_0x1f33dc[_0xa1eb('0x3c')][_0xa1eb('0x4c')]){_0x47737d[_0xa1eb('0x4d')]=[{'all':!![]}];}return db[_0xa1eb('0x36')][_0xa1eb('0x4e')](_0x47737d);})[_0xa1eb('0x1c')](function(_0x3f66a9){_0x229931[_0xa1eb('0x4f')]=_0x3f66a9;return _0x229931;})[_0xa1eb('0x1c')](respondWithFilteredResult(_0x534fe4,_0x47737d))[_0xa1eb('0x24')](handleError(_0x534fe4,null));};exports[_0xa1eb('0x50')]=function(_0x39d3c6,_0x10e15a){var _0x50df09={'raw':![],'where':{'id':_0x39d3c6[_0xa1eb('0x51')]['id']}},_0x41b65a={};_0x41b65a[_0xa1eb('0x3b')]=_[_0xa1eb('0x3d')](db[_0xa1eb('0x36')][_0xa1eb('0x37')]);_0x41b65a[_0xa1eb('0x3c')]=_['keys'](_0x39d3c6[_0xa1eb('0x3c')]);_0x41b65a[_0xa1eb('0x3e')]=_[_0xa1eb('0x3f')](_0x41b65a[_0xa1eb('0x3b')],_0x41b65a[_0xa1eb('0x3c')]);_0x50df09[_0xa1eb('0x40')]=_[_0xa1eb('0x3f')](_0x41b65a[_0xa1eb('0x3b')],qs[_0xa1eb('0x41')](_0x39d3c6['query'][_0xa1eb('0x41')]));_0x50df09['attributes']=_0x50df09[_0xa1eb('0x40')]['length']?_0x50df09[_0xa1eb('0x40')]:_0x41b65a[_0xa1eb('0x3b')];if(_0x39d3c6[_0xa1eb('0x3c')]['includeAll']){_0x50df09[_0xa1eb('0x4d')]=[{'all':!![]}];}_0x50df09=_[_0xa1eb('0x49')]({},_0x50df09,_0x39d3c6['options']);return db[_0xa1eb('0x36')][_0xa1eb('0x52')](_0x50df09)[_0xa1eb('0x1c')](handleEntityNotFound(_0x10e15a,null))[_0xa1eb('0x1c')](respondWithResult(_0x10e15a,null))[_0xa1eb('0x24')](handleError(_0x10e15a,null));};exports[_0xa1eb('0x53')]=function(_0x305202,_0x247b08){return db[_0xa1eb('0x36')][_0xa1eb('0x53')](_0x305202[_0xa1eb('0x54')],{})[_0xa1eb('0x1c')](respondWithResult(_0x247b08,0xc9))[_0xa1eb('0x24')](handleError(_0x247b08,null));};exports[_0xa1eb('0x30')]=function(_0x40f119,_0x2ba6c0){if(_0x40f119[_0xa1eb('0x54')]['id']){delete _0x40f119['body']['id'];}return db[_0xa1eb('0x36')][_0xa1eb('0x52')]({'where':{'id':_0x40f119[_0xa1eb('0x51')]['id']}})[_0xa1eb('0x1c')](handleEntityNotFound(_0x2ba6c0,null))[_0xa1eb('0x1c')](saveUpdates(_0x40f119[_0xa1eb('0x54')],null))['then'](respondWithResult(_0x2ba6c0,null))[_0xa1eb('0x24')](handleError(_0x2ba6c0,null));};exports[_0xa1eb('0x31')]=function(_0x217ecb,_0xf9d185){return db[_0xa1eb('0x36')][_0xa1eb('0x52')]({'where':{'id':_0x217ecb[_0xa1eb('0x51')]['id']}})['then'](handleEntityNotFound(_0xf9d185,null))[_0xa1eb('0x1c')](removeEntity(_0xf9d185,null))[_0xa1eb('0x24')](handleError(_0xf9d185,null));};exports[_0xa1eb('0x55')]=function(_0x1c8fd0,_0x4c30ad,_0x5af1e6){var _0x58ca4e={};var _0x5673fa={};var _0x1b3c33;var _0x1e1e5d;return db['SalesforceAccount'][_0xa1eb('0x56')]({'where':{'id':_0x1c8fd0[_0xa1eb('0x51')]['id']}})[_0xa1eb('0x1c')](handleEntityNotFound(_0x4c30ad,null))[_0xa1eb('0x1c')](function(_0x4edf8e){if(_0x4edf8e){_0x1b3c33=_0x4edf8e;_0x5673fa['model']=_[_0xa1eb('0x3d')](db[_0xa1eb('0x57')][_0xa1eb('0x37')]);_0x5673fa[_0xa1eb('0x3c')]=_[_0xa1eb('0x3d')](_0x1c8fd0[_0xa1eb('0x3c')]);_0x5673fa['filters']=_['intersection'](_0x5673fa[_0xa1eb('0x3b')],_0x5673fa['query']);_0x58ca4e[_0xa1eb('0x40')]=_['intersection'](_0x5673fa[_0xa1eb('0x3b')],qs[_0xa1eb('0x41')](_0x1c8fd0['query'][_0xa1eb('0x41')]));_0x58ca4e[_0xa1eb('0x40')]=_0x58ca4e['attributes'][_0xa1eb('0x42')]?_0x58ca4e[_0xa1eb('0x40')]:_0x5673fa[_0xa1eb('0x3b')];_0x58ca4e['order']=qs[_0xa1eb('0x45')](_0x1c8fd0[_0xa1eb('0x3c')]['sort']);_0x58ca4e[_0xa1eb('0x46')]=qs[_0xa1eb('0x3e')](_[_0xa1eb('0x47')](_0x1c8fd0['query'],_0x5673fa[_0xa1eb('0x3e')]));if(_0x1c8fd0['query'][_0xa1eb('0x48')]){_0x58ca4e[_0xa1eb('0x46')]=_[_0xa1eb('0x49')](_0x58ca4e[_0xa1eb('0x46')],{'$or':_[_0xa1eb('0x35')](_0x58ca4e['attributes'],function(_0x2aba03){var _0x401800={};_0x401800[_0x2aba03]={'$like':'%'+_0x1c8fd0[_0xa1eb('0x3c')]['filter']+'%'};return _0x401800;})});}_0x58ca4e=_[_0xa1eb('0x49')]({},_0x58ca4e,_0x1c8fd0['options']);return _0x1b3c33['getConfigurations'](_0x58ca4e);}})['then'](function(_0x555ded){if(_0x555ded){_0x1e1e5d=_0x555ded[_0xa1eb('0x42')];if(!_0x1c8fd0[_0xa1eb('0x3c')][_0xa1eb('0x43')](_0xa1eb('0x44'))){_0x58ca4e[_0xa1eb('0x2b')]=qs[_0xa1eb('0x2b')](_0x1c8fd0[_0xa1eb('0x3c')][_0xa1eb('0x2b')]);_0x58ca4e[_0xa1eb('0x2a')]=qs[_0xa1eb('0x2a')](_0x1c8fd0['query'][_0xa1eb('0x2a')]);}return _0x1b3c33[_0xa1eb('0x55')](_0x58ca4e);}})[_0xa1eb('0x1c')](function(_0x1f9418){if(_0x1f9418){return _0x1f9418?{'count':_0x1e1e5d,'rows':_0x1f9418}:null;}})[_0xa1eb('0x1c')](respondWithResult(_0x4c30ad,null))[_0xa1eb('0x24')](handleError(_0x4c30ad,null));};exports['addConfiguration']=function(_0x113a3a,_0x2b6996,_0x16c5a3){if(_0x113a3a['body']['id']){delete _0x113a3a[_0xa1eb('0x54')]['id'];}return db[_0xa1eb('0x36')][_0xa1eb('0x56')]({'where':{'id':_0x113a3a[_0xa1eb('0x51')]['id']}})[_0xa1eb('0x1c')](handleEntityNotFound(_0x2b6996,null))['then'](function(_0x2eca4e){if(_0x2eca4e){_0x113a3a['body'][_0xa1eb('0x58')]=_0x2eca4e['id'];_0x113a3a['body'][_0xa1eb('0x59')]=integrations[_0xa1eb('0x5a')](_0x113a3a[_0xa1eb('0x54')][_0xa1eb('0x5b')],_0x113a3a['body'][_0xa1eb('0x39')]);_0x113a3a[_0xa1eb('0x54')][_0xa1eb('0x5c')]=integrations[_0xa1eb('0x5d')](_0x113a3a['body'][_0xa1eb('0x5b')],_0x113a3a[_0xa1eb('0x54')][_0xa1eb('0x39')]);return db[_0xa1eb('0x57')][_0xa1eb('0x53')](_0x113a3a[_0xa1eb('0x54')],{'include':[{'model':db[_0xa1eb('0x5e')],'as':_0xa1eb('0x59')},{'model':db[_0xa1eb('0x5e')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x2b6996,null))['catch'](handleError(_0x2b6996,null));};exports[_0xa1eb('0x5f')]=function(_0x5b7785,_0xa5810,_0x3ec094){var _0x492325;var _0x52522a='';var _0xdcaac3=_0xa1eb('0x60');return db[_0xa1eb('0x36')][_0xa1eb('0x56')]({'where':{'id':_0x5b7785[_0xa1eb('0x51')]['id']},'attributes':['id','remoteUri','clientId',_0xa1eb('0x61'),_0xa1eb('0x62'),_0xa1eb('0x63'),_0xa1eb('0x64')]})['then'](handleEntityNotFound(_0xa5810,null))[_0xa1eb('0x1c')](function(_0x28b3de){if(_0x28b3de){_0x52522a=_0x28b3de[_0xa1eb('0x65')];var _0x4050d6=_0x52522a[_0xa1eb('0x66')](-0x1);if(_0x4050d6==='/'){_0x52522a=_0x52522a[_0xa1eb('0x67')](0x0,_0x52522a[_0xa1eb('0x68')](_0x4050d6));}_0x492325=new jsforce[(_0xa1eb('0x69'))]({'oauth2':{'loginUrl':_0x52522a,'clientId':_0x28b3de[_0xa1eb('0x6a')],'clientSecret':_0x28b3de[_0xa1eb('0x61')]}});return _0x492325[_0xa1eb('0x6b')](_0x28b3de['username'],_0x28b3de[_0xa1eb('0x63')][_0xa1eb('0x6c')](_0x28b3de[_0xa1eb('0x64')]));}})[_0xa1eb('0x1c')](function(_0x3fe7ef){if(_0x3fe7ef){if(!_[_0xa1eb('0x6d')](_0x5b7785['query'][_0xa1eb('0x6e')])){_0xdcaac3=_0x5b7785[_0xa1eb('0x3c')][_0xa1eb('0x6e')];}return _0x492325[_0xa1eb('0x6f')](_0xdcaac3)['describe']();}})['then'](function(_0xff1843){var _0x5e0cd5=[_0xa1eb('0x70'),_0xa1eb('0x71'),'CallObject',_0xa1eb('0x72'),_0xa1eb('0x73'),'Priority',_0xa1eb('0x74'),_0xa1eb('0x75')];if(!_[_0xa1eb('0x6d')](_0x5b7785[_0xa1eb('0x3c')][_0xa1eb('0x6e')])&&_0x5b7785[_0xa1eb('0x3c')][_0xa1eb('0x6e')]===_0xa1eb('0x76')){_0x5e0cd5=[_0xa1eb('0x75'),_0xa1eb('0x77'),_0xa1eb('0x78'),'Status',_0xa1eb('0x79'),_0xa1eb('0x7a'),_0xa1eb('0x7b'),_0xa1eb('0x7c')];}if(_0xff1843){_['remove'](_0xff1843[_0xa1eb('0x41')],function(_0x2ff08e){return _0x2ff08e[_0xa1eb('0x7d')]===![]&&!_0x5e0cd5['includes'](_0x2ff08e[_0xa1eb('0x33')]);});return{'count':_0xff1843[_0xa1eb('0x41')][_0xa1eb('0x42')],'rows':_['map'](_0xff1843[_0xa1eb('0x41')],function(_0x4fb7a7){return{'id':_0x4fb7a7[_0xa1eb('0x33')],'name':_0x4fb7a7[_0xa1eb('0x7e')],'custom':_0x4fb7a7[_0xa1eb('0x7d')],'options':_0x4fb7a7[_0xa1eb('0x7f')][_0xa1eb('0x42')]>0x0?_[_0xa1eb('0x35')](_0x4fb7a7[_0xa1eb('0x7f')],function(_0xc16d28){return{'name':_0xc16d28['label'],'value':_0xc16d28[_0xa1eb('0x80')]};}):_0x4fb7a7[_0xa1eb('0x39')]==_0xa1eb('0x81')?[{'name':_0xa1eb('0x82'),'value':_0xa1eb('0x83')},{'name':'False','value':_0xa1eb('0x84')}]:[]};})};}})[_0xa1eb('0x1c')](respondWithResult(_0xa5810,null))['catch'](function(_0x1e7ce7){var _0x4be2e5=_0x5b7785['query'][_0xa1eb('0x85')]?0x1f4:_0x1e7ce7[_0xa1eb('0x86')]||0x1f4;logger['error'](_0xa1eb('0x87'),_0xa1eb('0x5f'),_0x4be2e5,JSON['stringify'](_0x1e7ce7));delete _0x1e7ce7[_0xa1eb('0x33')];if(_0x4be2e5===0x191){_0x4be2e5=0x190;}_0xa5810[_0xa1eb('0x26')](_0x4be2e5)['send'](_0x5b7785['query'][_0xa1eb('0x85')]?{'message':'Wrong\x20credentials','statusCode':_0x1e7ce7[_0xa1eb('0x86')]}:_0x1e7ce7);});};
\ 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