Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index e74da61..62d0876 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3b94=['lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','end','status','undefined','count','offset','limit','set','apply','save','update','destroy','then','sendStatus','name','send','index','map','SalesforceAccount','fieldName','type','model','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','include','findAll','show','params','rawAttributes','length','includeAll','find','catch','create','body','getConfigurations','findOne','nolimit','addConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','SalesforceConfiguration','SalesforceField','getFields','Task','remoteUri','clientId','username','password','slice','substring','lastIndexOf','clientSecret','securityToken','isNil','ticketType','sobject','describe','ActivityDate','IsReminderSet','Subject','Description','string','int','picklist','textarea','phone','includes','label','picklistValues','value','True','true','false','test','statusCode','error','getFields,\x20%s,\x20%s,\x20%s','eml-format','zip-dir','moment','bluebird','mustache','path','sox','to-csv','ejs'];(function(_0x2a703a,_0x4bbe04){var _0x5921ee=function(_0x199b0c){while(--_0x199b0c){_0x2a703a['push'](_0x2a703a['shift']());}};_0x5921ee(++_0x4bbe04);}(_0x3b94,0x1d3));var _0x43b9=function(_0x49bb01,_0x5402ee){_0x49bb01=_0x49bb01-0x0;var _0x2df424=_0x3b94[_0x49bb01];return _0x2df424;};'use strict';var emlformat=require(_0x43b9('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x43b9('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x43b9('0x2'));var BPromise=require(_0x43b9('0x3'));var Mustache=require(_0x43b9('0x4'));var util=require('util');var path=require(_0x43b9('0x5'));var sox=require(_0x43b9('0x6'));var csv=require(_0x43b9('0x7'));var ejs=require(_0x43b9('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x43b9('0x9'));var squel=require(_0x43b9('0xa'));var crypto=require(_0x43b9('0xb'));var jsforce=require(_0x43b9('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x43b9('0xd'));var Papa=require('papaparse');var Redis=require(_0x43b9('0xe'));var authService=require(_0x43b9('0xf'));var qs=require(_0x43b9('0x10'));var as=require(_0x43b9('0x11'));var hardwareService=require(_0x43b9('0x12'));var logger=require(_0x43b9('0x13'))(_0x43b9('0x14'));var utils=require(_0x43b9('0x15'));var config=require(_0x43b9('0x16'));var licenseUtil=require(_0x43b9('0x17'));var db=require(_0x43b9('0x18'))['db'];var integrations=require(_0x43b9('0x19'));function respondWithStatusCode(_0x56b62a,_0x187c72){_0x187c72=_0x187c72||0xcc;return function(_0x2f0d01){if(_0x2f0d01){return _0x56b62a['sendStatus'](_0x187c72);}return _0x56b62a['status'](_0x187c72)[_0x43b9('0x1a')]();};}function respondWithResult(_0x5adf1f,_0x9b52aa){_0x9b52aa=_0x9b52aa||0xc8;return function(_0x12c9ca){if(_0x12c9ca){return _0x5adf1f[_0x43b9('0x1b')](_0x9b52aa)['json'](_0x12c9ca);}};}function respondWithFilteredResult(_0x5b4f8b,_0x4dad46){return function(_0x432bd0){if(_0x432bd0){var _0x8521ff=typeof _0x4dad46['offset']===_0x43b9('0x1c')&&typeof _0x4dad46['limit']==='undefined';var _0x38c27f=_0x432bd0[_0x43b9('0x1d')];var _0x5d5c43=_0x8521ff?0x0:_0x4dad46['offset'];var _0x5bdf05=_0x8521ff?_0x432bd0['count']:_0x4dad46[_0x43b9('0x1e')]+_0x4dad46[_0x43b9('0x1f')];var _0x25681d;if(_0x5bdf05>=_0x38c27f){_0x5bdf05=_0x38c27f;_0x25681d=0xc8;}else{_0x25681d=0xce;}_0x5b4f8b[_0x43b9('0x1b')](_0x25681d);return _0x5b4f8b[_0x43b9('0x20')]('Content-Range',_0x5d5c43+'-'+_0x5bdf05+'/'+_0x38c27f)['json'](_0x432bd0);}return null;};}function patchUpdates(_0x49eddb){return function(_0x469ac5){try{jsonpatch[_0x43b9('0x21')](_0x469ac5,_0x49eddb,!![]);}catch(_0x237996){return BPromise['reject'](_0x237996);}return _0x469ac5[_0x43b9('0x22')]();};}function saveUpdates(_0x5bf320,_0x16e369){return function(_0x144f44){if(_0x144f44){return _0x144f44[_0x43b9('0x23')](_0x5bf320)['then'](function(_0x85fcd1){return _0x85fcd1;});}return null;};}function removeEntity(_0x507fac,_0x5e1bcc){return function(_0x219a9d){if(_0x219a9d){return _0x219a9d[_0x43b9('0x24')]()[_0x43b9('0x25')](function(){_0x507fac['status'](0xcc)[_0x43b9('0x1a')]();});}};}function handleEntityNotFound(_0x5eb44d,_0x2bc245){return function(_0x4110ef){if(!_0x4110ef){_0x5eb44d[_0x43b9('0x26')](0x194);}return _0x4110ef;};}function handleError(_0x14105b,_0x1fec3c){_0x1fec3c=_0x1fec3c||0x1f4;return function(_0x47d69c){logger['error'](_0x47d69c['stack']);if(_0x47d69c[_0x43b9('0x27')]){delete _0x47d69c[_0x43b9('0x27')];}_0x14105b[_0x43b9('0x1b')](_0x1fec3c)[_0x43b9('0x28')](_0x47d69c);};}exports[_0x43b9('0x29')]=function(_0x570a46,_0x53907e){var _0x2c004c={},_0x35410d={},_0x29f58e={'count':0x0,'rows':[]};var _0xbca20=_[_0x43b9('0x2a')](db[_0x43b9('0x2b')]['rawAttributes'],function(_0x25099b){return{'name':_0x25099b[_0x43b9('0x2c')],'type':_0x25099b[_0x43b9('0x2d')]['key']};});_0x35410d[_0x43b9('0x2e')]=_[_0x43b9('0x2a')](_0xbca20,_0x43b9('0x27'));_0x35410d[_0x43b9('0x2f')]=_[_0x43b9('0x30')](_0x570a46['query']);_0x35410d['filters']=_[_0x43b9('0x31')](_0x35410d['model'],_0x35410d[_0x43b9('0x2f')]);_0x2c004c[_0x43b9('0x32')]=_[_0x43b9('0x31')](_0x35410d[_0x43b9('0x2e')],qs[_0x43b9('0x33')](_0x570a46[_0x43b9('0x2f')]['fields']));_0x2c004c[_0x43b9('0x32')]=_0x2c004c[_0x43b9('0x32')]['length']?_0x2c004c[_0x43b9('0x32')]:_0x35410d['model'];if(!_0x570a46[_0x43b9('0x2f')][_0x43b9('0x34')]('nolimit')){_0x2c004c[_0x43b9('0x1f')]=qs[_0x43b9('0x1f')](_0x570a46[_0x43b9('0x2f')][_0x43b9('0x1f')]);_0x2c004c[_0x43b9('0x1e')]=qs[_0x43b9('0x1e')](_0x570a46[_0x43b9('0x2f')][_0x43b9('0x1e')]);}_0x2c004c[_0x43b9('0x35')]=qs[_0x43b9('0x36')](_0x570a46[_0x43b9('0x2f')]['sort']);_0x2c004c[_0x43b9('0x37')]=qs[_0x43b9('0x38')](_[_0x43b9('0x39')](_0x570a46[_0x43b9('0x2f')],_0x35410d[_0x43b9('0x38')]),_0xbca20);if(_0x570a46[_0x43b9('0x2f')][_0x43b9('0x3a')]){_0x2c004c[_0x43b9('0x37')]=_['merge'](_0x2c004c[_0x43b9('0x37')],{'$or':_[_0x43b9('0x2a')](_0xbca20,function(_0x1c16f6){if(_0x1c16f6[_0x43b9('0x2d')]!==_0x43b9('0x3b')){var _0x55ae82={};_0x55ae82[_0x1c16f6['name']]={'$like':'%'+_0x570a46[_0x43b9('0x2f')][_0x43b9('0x3a')]+'%'};return _0x55ae82;}})});}_0x2c004c=_[_0x43b9('0x3c')]({},_0x2c004c,_0x570a46[_0x43b9('0x3d')]);var _0x55d461={'where':_0x2c004c['where']};return db['SalesforceAccount'][_0x43b9('0x1d')](_0x55d461)[_0x43b9('0x25')](function(_0x106506){_0x29f58e['count']=_0x106506;if(_0x570a46[_0x43b9('0x2f')]['includeAll']){_0x2c004c[_0x43b9('0x3e')]=[{'all':!![]}];}return db['SalesforceAccount'][_0x43b9('0x3f')](_0x2c004c);})[_0x43b9('0x25')](function(_0x204c50){_0x29f58e['rows']=_0x204c50;return _0x29f58e;})[_0x43b9('0x25')](respondWithFilteredResult(_0x53907e,_0x2c004c))['catch'](handleError(_0x53907e,null));};exports[_0x43b9('0x40')]=function(_0x440ce7,_0x1d0e75){var _0x2448c1={'raw':![],'where':{'id':_0x440ce7[_0x43b9('0x41')]['id']}},_0x5b5981={};_0x5b5981['model']=_[_0x43b9('0x30')](db['SalesforceAccount'][_0x43b9('0x42')]);_0x5b5981[_0x43b9('0x2f')]=_[_0x43b9('0x30')](_0x440ce7['query']);_0x5b5981['filters']=_['intersection'](_0x5b5981['model'],_0x5b5981[_0x43b9('0x2f')]);_0x2448c1[_0x43b9('0x32')]=_[_0x43b9('0x31')](_0x5b5981[_0x43b9('0x2e')],qs[_0x43b9('0x33')](_0x440ce7[_0x43b9('0x2f')][_0x43b9('0x33')]));_0x2448c1[_0x43b9('0x32')]=_0x2448c1[_0x43b9('0x32')][_0x43b9('0x43')]?_0x2448c1[_0x43b9('0x32')]:_0x5b5981[_0x43b9('0x2e')];if(_0x440ce7[_0x43b9('0x2f')][_0x43b9('0x44')]){_0x2448c1[_0x43b9('0x3e')]=[{'all':!![]}];}_0x2448c1=_['merge']({},_0x2448c1,_0x440ce7[_0x43b9('0x3d')]);return db[_0x43b9('0x2b')][_0x43b9('0x45')](_0x2448c1)['then'](handleEntityNotFound(_0x1d0e75,null))[_0x43b9('0x25')](respondWithResult(_0x1d0e75,null))[_0x43b9('0x46')](handleError(_0x1d0e75,null));};exports[_0x43b9('0x47')]=function(_0x266753,_0x323dd8){return db[_0x43b9('0x2b')][_0x43b9('0x47')](_0x266753[_0x43b9('0x48')],{})['then'](respondWithResult(_0x323dd8,0xc9))['catch'](handleError(_0x323dd8,null));};exports['update']=function(_0x31902b,_0x31e8d6){if(_0x31902b[_0x43b9('0x48')]['id']){delete _0x31902b[_0x43b9('0x48')]['id'];}return db[_0x43b9('0x2b')][_0x43b9('0x45')]({'where':{'id':_0x31902b['params']['id']}})[_0x43b9('0x25')](handleEntityNotFound(_0x31e8d6,null))[_0x43b9('0x25')](saveUpdates(_0x31902b['body'],null))[_0x43b9('0x25')](respondWithResult(_0x31e8d6,null))[_0x43b9('0x46')](handleError(_0x31e8d6,null));};exports[_0x43b9('0x24')]=function(_0x58789b,_0x5df306){return db[_0x43b9('0x2b')][_0x43b9('0x45')]({'where':{'id':_0x58789b['params']['id']}})[_0x43b9('0x25')](handleEntityNotFound(_0x5df306,null))[_0x43b9('0x25')](removeEntity(_0x5df306,null))[_0x43b9('0x46')](handleError(_0x5df306,null));};exports[_0x43b9('0x49')]=function(_0x58a9a8,_0x3b69b4,_0x3934a8){var _0x32f73a={};var _0x270bbc={};var _0x58be5f;var _0xf76796;return db[_0x43b9('0x2b')][_0x43b9('0x4a')]({'where':{'id':_0x58a9a8[_0x43b9('0x41')]['id']}})[_0x43b9('0x25')](handleEntityNotFound(_0x3b69b4,null))['then'](function(_0x4c0695){if(_0x4c0695){_0x58be5f=_0x4c0695;_0x270bbc['model']=_[_0x43b9('0x30')](db['SalesforceConfiguration']['rawAttributes']);_0x270bbc['query']=_[_0x43b9('0x30')](_0x58a9a8[_0x43b9('0x2f')]);_0x270bbc[_0x43b9('0x38')]=_['intersection'](_0x270bbc['model'],_0x270bbc[_0x43b9('0x2f')]);_0x32f73a[_0x43b9('0x32')]=_['intersection'](_0x270bbc[_0x43b9('0x2e')],qs[_0x43b9('0x33')](_0x58a9a8['query']['fields']));_0x32f73a[_0x43b9('0x32')]=_0x32f73a[_0x43b9('0x32')][_0x43b9('0x43')]?_0x32f73a[_0x43b9('0x32')]:_0x270bbc['model'];_0x32f73a[_0x43b9('0x35')]=qs[_0x43b9('0x36')](_0x58a9a8[_0x43b9('0x2f')]['sort']);_0x32f73a['where']=qs['filters'](_[_0x43b9('0x39')](_0x58a9a8['query'],_0x270bbc[_0x43b9('0x38')]));if(_0x58a9a8[_0x43b9('0x2f')][_0x43b9('0x3a')]){_0x32f73a[_0x43b9('0x37')]=_['merge'](_0x32f73a[_0x43b9('0x37')],{'$or':_[_0x43b9('0x2a')](_0x32f73a['attributes'],function(_0x5e6ec7){var _0x1e24f4={};_0x1e24f4[_0x5e6ec7]={'$like':'%'+_0x58a9a8['query']['filter']+'%'};return _0x1e24f4;})});}_0x32f73a=_[_0x43b9('0x3c')]({},_0x32f73a,_0x58a9a8['options']);return _0x58be5f['getConfigurations'](_0x32f73a);}})[_0x43b9('0x25')](function(_0x1eadd1){if(_0x1eadd1){_0xf76796=_0x1eadd1[_0x43b9('0x43')];if(!_0x58a9a8[_0x43b9('0x2f')][_0x43b9('0x34')](_0x43b9('0x4b'))){_0x32f73a['limit']=qs[_0x43b9('0x1f')](_0x58a9a8['query'][_0x43b9('0x1f')]);_0x32f73a[_0x43b9('0x1e')]=qs[_0x43b9('0x1e')](_0x58a9a8[_0x43b9('0x2f')][_0x43b9('0x1e')]);}return _0x58be5f[_0x43b9('0x49')](_0x32f73a);}})[_0x43b9('0x25')](function(_0x6c4f65){if(_0x6c4f65){return _0x6c4f65?{'count':_0xf76796,'rows':_0x6c4f65}:null;}})[_0x43b9('0x25')](respondWithResult(_0x3b69b4,null))[_0x43b9('0x46')](handleError(_0x3b69b4,null));};exports[_0x43b9('0x4c')]=function(_0x38e8c8,_0x4cb1e6,_0x2661f3){if(_0x38e8c8[_0x43b9('0x48')]['id']){delete _0x38e8c8[_0x43b9('0x48')]['id'];}return db[_0x43b9('0x2b')][_0x43b9('0x4a')]({'where':{'id':_0x38e8c8['params']['id']}})['then'](handleEntityNotFound(_0x4cb1e6,null))[_0x43b9('0x25')](function(_0x4fca56){if(_0x4fca56){_0x38e8c8[_0x43b9('0x48')][_0x43b9('0x4d')]=_0x4fca56['id'];_0x38e8c8['body'][_0x43b9('0x4e')]=integrations[_0x43b9('0x4f')](_0x38e8c8['body'][_0x43b9('0x50')],_0x38e8c8[_0x43b9('0x48')][_0x43b9('0x2d')]);_0x38e8c8[_0x43b9('0x48')]['Descriptions']=integrations[_0x43b9('0x51')](_0x38e8c8[_0x43b9('0x48')][_0x43b9('0x50')],_0x38e8c8[_0x43b9('0x48')][_0x43b9('0x2d')]);return db[_0x43b9('0x52')][_0x43b9('0x47')](_0x38e8c8['body'],{'include':[{'model':db[_0x43b9('0x53')],'as':'Subjects'},{'model':db[_0x43b9('0x53')],'as':'Descriptions'}]});}return null;})[_0x43b9('0x25')](respondWithResult(_0x4cb1e6,null))[_0x43b9('0x46')](handleError(_0x4cb1e6,null));};exports[_0x43b9('0x54')]=function(_0x22fa7a,_0x4924e5,_0x628e76){var _0x5c1e8c;var _0x5addbe='';var _0x4b248b=_0x43b9('0x55');return db['SalesforceAccount'][_0x43b9('0x4a')]({'where':{'id':_0x22fa7a['params']['id']},'attributes':['id',_0x43b9('0x56'),_0x43b9('0x57'),'clientSecret',_0x43b9('0x58'),_0x43b9('0x59'),'securityToken']})[_0x43b9('0x25')](handleEntityNotFound(_0x4924e5,null))[_0x43b9('0x25')](function(_0x54b1e8){if(_0x54b1e8){_0x5addbe=_0x54b1e8[_0x43b9('0x56')];var _0x4329bc=_0x5addbe[_0x43b9('0x5a')](-0x1);if(_0x4329bc==='/'){_0x5addbe=_0x5addbe[_0x43b9('0x5b')](0x0,_0x5addbe[_0x43b9('0x5c')](_0x4329bc));}_0x5c1e8c=new jsforce['Connection']({'oauth2':{'loginUrl':_0x5addbe,'clientId':_0x54b1e8['clientId'],'clientSecret':_0x54b1e8[_0x43b9('0x5d')]}});return _0x5c1e8c['login'](_0x54b1e8[_0x43b9('0x58')],_0x54b1e8[_0x43b9('0x59')]['concat'](_0x54b1e8[_0x43b9('0x5e')]));}})[_0x43b9('0x25')](function(_0x369672){if(_0x369672){if(!_[_0x43b9('0x5f')](_0x22fa7a[_0x43b9('0x2f')][_0x43b9('0x60')])){_0x4b248b=_0x22fa7a[_0x43b9('0x2f')][_0x43b9('0x60')];}return _0x5c1e8c[_0x43b9('0x61')](_0x4b248b)[_0x43b9('0x62')]();}})['then'](function(_0x546953){var _0x36eb2a=['OwnerId',_0x43b9('0x63'),_0x43b9('0x64'),'IsRecurrence',_0x43b9('0x65'),_0x43b9('0x66')];var _0x64a854=[_0x43b9('0x67'),_0x43b9('0x68'),_0x43b9('0x69'),'boolean','email',_0x43b9('0x6a'),_0x43b9('0x6b')];if(_0x546953){_['remove'](_0x546953[_0x43b9('0x33')],function(_0x2cfaa6){return _0x36eb2a[_0x43b9('0x6c')](_0x2cfaa6[_0x43b9('0x27')])||!_0x64a854['includes'](_0x2cfaa6[_0x43b9('0x2d')]);});return{'count':_0x546953['fields'][_0x43b9('0x43')],'rows':_['map'](_0x546953[_0x43b9('0x33')],function(_0x3bed88){return{'id':_0x3bed88[_0x43b9('0x27')],'name':_0x3bed88[_0x43b9('0x6d')],'custom':_0x3bed88['custom'],'options':_0x3bed88['picklistValues'][_0x43b9('0x43')]>0x0?_[_0x43b9('0x2a')](_0x3bed88[_0x43b9('0x6e')],function(_0x544fa3){return{'name':_0x544fa3[_0x43b9('0x6d')],'value':_0x544fa3[_0x43b9('0x6f')]};}):_0x3bed88[_0x43b9('0x2d')]=='boolean'?[{'name':_0x43b9('0x70'),'value':_0x43b9('0x71')},{'name':'False','value':_0x43b9('0x72')}]:[]};})};}})[_0x43b9('0x25')](respondWithResult(_0x4924e5,null))['catch'](function(_0x4d3897){var _0x5771a2=_0x22fa7a[_0x43b9('0x2f')][_0x43b9('0x73')]?0x1f4:_0x4d3897[_0x43b9('0x74')]||0x1f4;logger[_0x43b9('0x75')](_0x43b9('0x76'),_0x43b9('0x54'),_0x5771a2,JSON['stringify'](_0x4d3897));delete _0x4d3897[_0x43b9('0x27')];if(_0x5771a2===0x191){_0x5771a2=0x190;}_0x4924e5[_0x43b9('0x1b')](_0x5771a2)[_0x43b9('0x28')](_0x22fa7a[_0x43b9('0x2f')][_0x43b9('0x73')]?{'message':'Wrong\x20credentials','statusCode':_0x4d3897[_0x43b9('0x74')]}:_0x4d3897);});};
\ No newline at end of file
+var _0x85fc=['test','Wrong\x20credentials','eml-format','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/environment','../../components/integrations/configuration','sendStatus','status','end','offset','undefined','limit','count','json','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','options','SalesforceAccount','includeAll','findAll','rows','catch','show','length','find','create','body','params','getConfigurations','findOne','SalesforceConfiguration','filter','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','SalesforceField','getFields','Task','remoteUri','clientSecret','username','password','securityToken','substring','lastIndexOf','Connection','concat','isNil','ticketType','describe','OwnerId','ActivityDate','IsRecurrence','Subject','Description','string','int','picklist','email','textarea','phone','remove','includes','label','custom','picklistValues','value','boolean','true','False','false','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x457e20,_0x3985ac){var _0x1f920b=function(_0x3804e4){while(--_0x3804e4){_0x457e20['push'](_0x457e20['shift']());}};_0x1f920b(++_0x3985ac);}(_0x85fc,0x7b));var _0xc85f=function(_0x52f3,_0x1ac14f){_0x52f3=_0x52f3-0x0;var _0x266655=_0x85fc[_0x52f3];return _0x266655;};'use strict';var emlformat=require(_0xc85f('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xc85f('0x1'));var rp=require(_0xc85f('0x2'));var moment=require(_0xc85f('0x3'));var BPromise=require(_0xc85f('0x4'));var Mustache=require('mustache');var util=require(_0xc85f('0x5'));var path=require(_0xc85f('0x6'));var sox=require('sox');var csv=require(_0xc85f('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xc85f('0x8'));var crypto=require('crypto');var jsforce=require(_0xc85f('0x9'));var deskjs=require(_0xc85f('0xa'));var toCsv=require(_0xc85f('0x7'));var querystring=require(_0xc85f('0xb'));var Papa=require(_0xc85f('0xc'));var Redis=require(_0xc85f('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xc85f('0xe'));var as=require(_0xc85f('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xc85f('0x10'));var utils=require('../../config/utils');var config=require(_0xc85f('0x11'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0xc85f('0x12'));function respondWithStatusCode(_0x2b0fc1,_0x467812){_0x467812=_0x467812||0xcc;return function(_0x17da98){if(_0x17da98){return _0x2b0fc1[_0xc85f('0x13')](_0x467812);}return _0x2b0fc1[_0xc85f('0x14')](_0x467812)[_0xc85f('0x15')]();};}function respondWithResult(_0x43e98e,_0x1878d0){_0x1878d0=_0x1878d0||0xc8;return function(_0x27dc90){if(_0x27dc90){return _0x43e98e[_0xc85f('0x14')](_0x1878d0)['json'](_0x27dc90);}};}function respondWithFilteredResult(_0x4d0964,_0x419e6b){return function(_0x305246){if(_0x305246){var _0x2d1bec=typeof _0x419e6b[_0xc85f('0x16')]===_0xc85f('0x17')&&typeof _0x419e6b[_0xc85f('0x18')]==='undefined';var _0x4bad59=_0x305246[_0xc85f('0x19')];var _0x32f15f=_0x2d1bec?0x0:_0x419e6b[_0xc85f('0x16')];var _0x25d89c=_0x2d1bec?_0x305246[_0xc85f('0x19')]:_0x419e6b[_0xc85f('0x16')]+_0x419e6b[_0xc85f('0x18')];var _0x5281f6;if(_0x25d89c>=_0x4bad59){_0x25d89c=_0x4bad59;_0x5281f6=0xc8;}else{_0x5281f6=0xce;}_0x4d0964[_0xc85f('0x14')](_0x5281f6);return _0x4d0964['set']('Content-Range',_0x32f15f+'-'+_0x25d89c+'/'+_0x4bad59)[_0xc85f('0x1a')](_0x305246);}return null;};}function patchUpdates(_0x316bac){return function(_0x4f7404){try{jsonpatch[_0xc85f('0x1b')](_0x4f7404,_0x316bac,!![]);}catch(_0x4868f1){return BPromise[_0xc85f('0x1c')](_0x4868f1);}return _0x4f7404[_0xc85f('0x1d')]();};}function saveUpdates(_0x5768d2,_0x836571){return function(_0x13647c){if(_0x13647c){return _0x13647c[_0xc85f('0x1e')](_0x5768d2)[_0xc85f('0x1f')](function(_0x1ac15d){return _0x1ac15d;});}return null;};}function removeEntity(_0xfcbf2e,_0x1c2749){return function(_0x579b1c){if(_0x579b1c){return _0x579b1c[_0xc85f('0x20')]()['then'](function(){_0xfcbf2e[_0xc85f('0x14')](0xcc)[_0xc85f('0x15')]();});}};}function handleEntityNotFound(_0x240e92,_0x379160){return function(_0x528fd0){if(!_0x528fd0){_0x240e92['sendStatus'](0x194);}return _0x528fd0;};}function handleError(_0x2bdb8b,_0x9c7b9c){_0x9c7b9c=_0x9c7b9c||0x1f4;return function(_0x464225){logger[_0xc85f('0x21')](_0x464225[_0xc85f('0x22')]);if(_0x464225[_0xc85f('0x23')]){delete _0x464225['name'];}_0x2bdb8b[_0xc85f('0x14')](_0x9c7b9c)[_0xc85f('0x24')](_0x464225);};}exports[_0xc85f('0x25')]=function(_0x23894c,_0x1af152){var _0x3ec423={},_0x50699c={},_0x5f43ff={'count':0x0,'rows':[]};var _0x2e41fe=_[_0xc85f('0x26')](db['SalesforceAccount'][_0xc85f('0x27')],function(_0x520c37){return{'name':_0x520c37[_0xc85f('0x28')],'type':_0x520c37[_0xc85f('0x29')][_0xc85f('0x2a')]};});_0x50699c['model']=_['map'](_0x2e41fe,_0xc85f('0x23'));_0x50699c['query']=_[_0xc85f('0x2b')](_0x23894c[_0xc85f('0x2c')]);_0x50699c[_0xc85f('0x2d')]=_[_0xc85f('0x2e')](_0x50699c[_0xc85f('0x2f')],_0x50699c[_0xc85f('0x2c')]);_0x3ec423[_0xc85f('0x30')]=_[_0xc85f('0x2e')](_0x50699c[_0xc85f('0x2f')],qs[_0xc85f('0x31')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x31')]));_0x3ec423['attributes']=_0x3ec423[_0xc85f('0x30')]['length']?_0x3ec423[_0xc85f('0x30')]:_0x50699c[_0xc85f('0x2f')];if(!_0x23894c[_0xc85f('0x2c')][_0xc85f('0x32')](_0xc85f('0x33'))){_0x3ec423[_0xc85f('0x18')]=qs[_0xc85f('0x18')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x18')]);_0x3ec423['offset']=qs[_0xc85f('0x16')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x16')]);}_0x3ec423[_0xc85f('0x34')]=qs[_0xc85f('0x35')](_0x23894c[_0xc85f('0x2c')][_0xc85f('0x35')]);_0x3ec423[_0xc85f('0x36')]=qs['filters'](_['pick'](_0x23894c[_0xc85f('0x2c')],_0x50699c[_0xc85f('0x2d')]),_0x2e41fe);if(_0x23894c[_0xc85f('0x2c')]['filter']){_0x3ec423[_0xc85f('0x36')]=_[_0xc85f('0x37')](_0x3ec423[_0xc85f('0x36')],{'$or':_['map'](_0x2e41fe,function(_0x71fb8c){if(_0x71fb8c[_0xc85f('0x29')]!==_0xc85f('0x38')){var _0x45df31={};_0x45df31[_0x71fb8c[_0xc85f('0x23')]]={'$like':'%'+_0x23894c[_0xc85f('0x2c')]['filter']+'%'};return _0x45df31;}})});}_0x3ec423=_[_0xc85f('0x37')]({},_0x3ec423,_0x23894c[_0xc85f('0x39')]);var _0x44b4b0={'where':_0x3ec423[_0xc85f('0x36')]};return db[_0xc85f('0x3a')][_0xc85f('0x19')](_0x44b4b0)[_0xc85f('0x1f')](function(_0x59f45d){_0x5f43ff['count']=_0x59f45d;if(_0x23894c[_0xc85f('0x2c')][_0xc85f('0x3b')]){_0x3ec423['include']=[{'all':!![]}];}return db[_0xc85f('0x3a')][_0xc85f('0x3c')](_0x3ec423);})[_0xc85f('0x1f')](function(_0x3ab966){_0x5f43ff[_0xc85f('0x3d')]=_0x3ab966;return _0x5f43ff;})[_0xc85f('0x1f')](respondWithFilteredResult(_0x1af152,_0x3ec423))[_0xc85f('0x3e')](handleError(_0x1af152,null));};exports[_0xc85f('0x3f')]=function(_0x5ab810,_0x2d4307){var _0x47b1f8={'raw':![],'where':{'id':_0x5ab810['params']['id']}},_0x1842ae={};_0x1842ae[_0xc85f('0x2f')]=_[_0xc85f('0x2b')](db['SalesforceAccount'][_0xc85f('0x27')]);_0x1842ae[_0xc85f('0x2c')]=_[_0xc85f('0x2b')](_0x5ab810[_0xc85f('0x2c')]);_0x1842ae[_0xc85f('0x2d')]=_['intersection'](_0x1842ae[_0xc85f('0x2f')],_0x1842ae[_0xc85f('0x2c')]);_0x47b1f8['attributes']=_[_0xc85f('0x2e')](_0x1842ae[_0xc85f('0x2f')],qs['fields'](_0x5ab810['query']['fields']));_0x47b1f8[_0xc85f('0x30')]=_0x47b1f8[_0xc85f('0x30')][_0xc85f('0x40')]?_0x47b1f8['attributes']:_0x1842ae[_0xc85f('0x2f')];if(_0x5ab810[_0xc85f('0x2c')]['includeAll']){_0x47b1f8['include']=[{'all':!![]}];}_0x47b1f8=_[_0xc85f('0x37')]({},_0x47b1f8,_0x5ab810[_0xc85f('0x39')]);return db[_0xc85f('0x3a')][_0xc85f('0x41')](_0x47b1f8)[_0xc85f('0x1f')](handleEntityNotFound(_0x2d4307,null))[_0xc85f('0x1f')](respondWithResult(_0x2d4307,null))[_0xc85f('0x3e')](handleError(_0x2d4307,null));};exports[_0xc85f('0x42')]=function(_0x3a118f,_0x171677){return db[_0xc85f('0x3a')][_0xc85f('0x42')](_0x3a118f['body'],{})[_0xc85f('0x1f')](respondWithResult(_0x171677,0xc9))[_0xc85f('0x3e')](handleError(_0x171677,null));};exports['update']=function(_0x17c280,_0x3e0c00){if(_0x17c280[_0xc85f('0x43')]['id']){delete _0x17c280[_0xc85f('0x43')]['id'];}return db[_0xc85f('0x3a')]['find']({'where':{'id':_0x17c280[_0xc85f('0x44')]['id']}})[_0xc85f('0x1f')](handleEntityNotFound(_0x3e0c00,null))['then'](saveUpdates(_0x17c280['body'],null))[_0xc85f('0x1f')](respondWithResult(_0x3e0c00,null))[_0xc85f('0x3e')](handleError(_0x3e0c00,null));};exports[_0xc85f('0x20')]=function(_0x263a9a,_0x191d04){return db['SalesforceAccount'][_0xc85f('0x41')]({'where':{'id':_0x263a9a[_0xc85f('0x44')]['id']}})[_0xc85f('0x1f')](handleEntityNotFound(_0x191d04,null))[_0xc85f('0x1f')](removeEntity(_0x191d04,null))[_0xc85f('0x3e')](handleError(_0x191d04,null));};exports[_0xc85f('0x45')]=function(_0x4e2290,_0x598e73,_0x148e30){var _0x19add8={};var _0x5ce7e2={};var _0x19968c;var _0x282afc;return db['SalesforceAccount'][_0xc85f('0x46')]({'where':{'id':_0x4e2290[_0xc85f('0x44')]['id']}})['then'](handleEntityNotFound(_0x598e73,null))[_0xc85f('0x1f')](function(_0x17b44c){if(_0x17b44c){_0x19968c=_0x17b44c;_0x5ce7e2[_0xc85f('0x2f')]=_['keys'](db[_0xc85f('0x47')]['rawAttributes']);_0x5ce7e2['query']=_[_0xc85f('0x2b')](_0x4e2290[_0xc85f('0x2c')]);_0x5ce7e2[_0xc85f('0x2d')]=_[_0xc85f('0x2e')](_0x5ce7e2[_0xc85f('0x2f')],_0x5ce7e2['query']);_0x19add8[_0xc85f('0x30')]=_[_0xc85f('0x2e')](_0x5ce7e2[_0xc85f('0x2f')],qs[_0xc85f('0x31')](_0x4e2290['query'][_0xc85f('0x31')]));_0x19add8[_0xc85f('0x30')]=_0x19add8[_0xc85f('0x30')][_0xc85f('0x40')]?_0x19add8[_0xc85f('0x30')]:_0x5ce7e2[_0xc85f('0x2f')];_0x19add8[_0xc85f('0x34')]=qs[_0xc85f('0x35')](_0x4e2290['query'][_0xc85f('0x35')]);_0x19add8['where']=qs['filters'](_['pick'](_0x4e2290[_0xc85f('0x2c')],_0x5ce7e2[_0xc85f('0x2d')]));if(_0x4e2290['query'][_0xc85f('0x48')]){_0x19add8[_0xc85f('0x36')]=_[_0xc85f('0x37')](_0x19add8[_0xc85f('0x36')],{'$or':_[_0xc85f('0x26')](_0x19add8[_0xc85f('0x30')],function(_0x33317a){var _0x3244ad={};_0x3244ad[_0x33317a]={'$like':'%'+_0x4e2290[_0xc85f('0x2c')][_0xc85f('0x48')]+'%'};return _0x3244ad;})});}_0x19add8=_[_0xc85f('0x37')]({},_0x19add8,_0x4e2290[_0xc85f('0x39')]);return _0x19968c[_0xc85f('0x45')](_0x19add8);}})[_0xc85f('0x1f')](function(_0x14c9b6){if(_0x14c9b6){_0x282afc=_0x14c9b6[_0xc85f('0x40')];if(!_0x4e2290['query'][_0xc85f('0x32')](_0xc85f('0x33'))){_0x19add8['limit']=qs[_0xc85f('0x18')](_0x4e2290[_0xc85f('0x2c')]['limit']);_0x19add8[_0xc85f('0x16')]=qs[_0xc85f('0x16')](_0x4e2290[_0xc85f('0x2c')][_0xc85f('0x16')]);}return _0x19968c[_0xc85f('0x45')](_0x19add8);}})[_0xc85f('0x1f')](function(_0x8cf4cf){if(_0x8cf4cf){return _0x8cf4cf?{'count':_0x282afc,'rows':_0x8cf4cf}:null;}})[_0xc85f('0x1f')](respondWithResult(_0x598e73,null))[_0xc85f('0x3e')](handleError(_0x598e73,null));};exports[_0xc85f('0x49')]=function(_0xe28fe,_0x3f248a,_0x50c0f5){if(_0xe28fe['body']['id']){delete _0xe28fe['body']['id'];}return db[_0xc85f('0x3a')][_0xc85f('0x46')]({'where':{'id':_0xe28fe[_0xc85f('0x44')]['id']}})['then'](handleEntityNotFound(_0x3f248a,null))[_0xc85f('0x1f')](function(_0x4df548){if(_0x4df548){_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4a')]=_0x4df548['id'];_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4b')]=integrations[_0xc85f('0x4c')](_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4d')],_0xe28fe[_0xc85f('0x43')]['type']);_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4e')]=integrations[_0xc85f('0x4f')](_0xe28fe[_0xc85f('0x43')][_0xc85f('0x4d')],_0xe28fe[_0xc85f('0x43')][_0xc85f('0x29')]);return db[_0xc85f('0x47')][_0xc85f('0x42')](_0xe28fe[_0xc85f('0x43')],{'include':[{'model':db[_0xc85f('0x50')],'as':_0xc85f('0x4b')},{'model':db[_0xc85f('0x50')],'as':_0xc85f('0x4e')}]});}return null;})[_0xc85f('0x1f')](respondWithResult(_0x3f248a,null))[_0xc85f('0x3e')](handleError(_0x3f248a,null));};exports[_0xc85f('0x51')]=function(_0x7ff56d,_0x3c19e6,_0x2f0ba7){var _0x5e60bb;var _0x231332='';var _0x514de9=_0xc85f('0x52');return db[_0xc85f('0x3a')][_0xc85f('0x46')]({'where':{'id':_0x7ff56d['params']['id']},'attributes':['id',_0xc85f('0x53'),'clientId',_0xc85f('0x54'),_0xc85f('0x55'),_0xc85f('0x56'),_0xc85f('0x57')]})[_0xc85f('0x1f')](handleEntityNotFound(_0x3c19e6,null))[_0xc85f('0x1f')](function(_0x3d979e){if(_0x3d979e){_0x231332=_0x3d979e[_0xc85f('0x53')];var _0x5e4399=_0x231332['slice'](-0x1);if(_0x5e4399==='/'){_0x231332=_0x231332[_0xc85f('0x58')](0x0,_0x231332[_0xc85f('0x59')](_0x5e4399));}_0x5e60bb=new jsforce[(_0xc85f('0x5a'))]({'oauth2':{'loginUrl':_0x231332,'clientId':_0x3d979e['clientId'],'clientSecret':_0x3d979e[_0xc85f('0x54')]}});return _0x5e60bb['login'](_0x3d979e['username'],_0x3d979e[_0xc85f('0x56')][_0xc85f('0x5b')](_0x3d979e[_0xc85f('0x57')]));}})[_0xc85f('0x1f')](function(_0x1eb1f1){if(_0x1eb1f1){if(!_[_0xc85f('0x5c')](_0x7ff56d[_0xc85f('0x2c')][_0xc85f('0x5d')])){_0x514de9=_0x7ff56d[_0xc85f('0x2c')]['ticketType'];}return _0x5e60bb['sobject'](_0x514de9)[_0xc85f('0x5e')]();}})['then'](function(_0x1c49b2){var _0x493e3b=[_0xc85f('0x5f'),_0xc85f('0x60'),'IsReminderSet',_0xc85f('0x61'),_0xc85f('0x62'),_0xc85f('0x63')];var _0x35b002=[_0xc85f('0x64'),_0xc85f('0x65'),_0xc85f('0x66'),'boolean',_0xc85f('0x67'),_0xc85f('0x68'),_0xc85f('0x69')];if(_0x1c49b2){_[_0xc85f('0x6a')](_0x1c49b2[_0xc85f('0x31')],function(_0x46228f){return _0x493e3b['includes'](_0x46228f[_0xc85f('0x23')])||!_0x35b002[_0xc85f('0x6b')](_0x46228f[_0xc85f('0x29')]);});return{'count':_0x1c49b2['fields'][_0xc85f('0x40')],'rows':_['map'](_0x1c49b2[_0xc85f('0x31')],function(_0x426dc1){return{'id':_0x426dc1['name'],'name':_0x426dc1[_0xc85f('0x6c')],'custom':_0x426dc1[_0xc85f('0x6d')],'options':_0x426dc1[_0xc85f('0x6e')][_0xc85f('0x40')]>0x0?_['map'](_0x426dc1[_0xc85f('0x6e')],function(_0x252e49){return{'name':_0x252e49[_0xc85f('0x6c')],'value':_0x252e49[_0xc85f('0x6f')]};}):_0x426dc1[_0xc85f('0x29')]==_0xc85f('0x70')?[{'name':'True','value':_0xc85f('0x71')},{'name':_0xc85f('0x72'),'value':_0xc85f('0x73')}]:[]};})};}})[_0xc85f('0x1f')](respondWithResult(_0x3c19e6,null))[_0xc85f('0x3e')](function(_0x4346b8){var _0x1f3f03=_0x7ff56d[_0xc85f('0x2c')]['test']?0x1f4:_0x4346b8[_0xc85f('0x74')]||0x1f4;logger[_0xc85f('0x21')](_0xc85f('0x75'),_0xc85f('0x51'),_0x1f3f03,JSON[_0xc85f('0x76')](_0x4346b8));delete _0x4346b8['name'];if(_0x1f3f03===0x191){_0x1f3f03=0x190;}_0x3c19e6[_0xc85f('0x14')](_0x1f3f03)[_0xc85f('0x24')](_0x7ff56d['query'][_0xc85f('0x77')]?{'message':_0xc85f('0x78'),'statusCode':_0x4346b8['statusCode']}:_0x4346b8);});};
\ No newline at end of file