Built motion from commit 13c3002c.|2.6.9
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index e597072..9007c61 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb29e=['length','addConfiguration','getSubjects','channel','type','SalesforceConfiguration','SalesforceField','Subjects','Descriptions','getFields','Task','remoteUri','clientId','clientSecret','password','slice','lastIndexOf','Connection','login','username','concat','securityToken','ticketType','sobject','ActivityDate','IsReminderSet','IsRecurrence','Subject','Description','string','int','picklist','boolean','email','textarea','phone','includes','name','label','custom','picklistValues','True','false','statusCode','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','offset','undefined','limit','count','Content-Range','json','apply','update','destroy','sendStatus','error','stack','send','index','SalesforceAccount','rawAttributes','fieldName','key','model','map','filters','intersection','query','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','then','rows','catch','params','keys','find','create','body','getConfigurations','findOne'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xb29e,0x129));var _0xeb29=function(_0x598e0e,_0x3607d3){_0x598e0e=_0x598e0e-0x0;var _0x11318c=_0xb29e[_0x598e0e];return _0x11318c;};'use strict';var emlformat=require(_0xeb29('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xeb29('0x1'));var jsonpatch=require(_0xeb29('0x2'));var rp=require(_0xeb29('0x3'));var moment=require(_0xeb29('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xeb29('0x5'));var util=require(_0xeb29('0x6'));var path=require(_0xeb29('0x7'));var sox=require(_0xeb29('0x8'));var csv=require(_0xeb29('0x9'));var ejs=require(_0xeb29('0xa'));var fs=require('fs');var fs_extra=require(_0xeb29('0xb'));var _=require(_0xeb29('0xc'));var squel=require(_0xeb29('0xd'));var crypto=require('crypto');var jsforce=require(_0xeb29('0xe'));var deskjs=require(_0xeb29('0xf'));var toCsv=require(_0xeb29('0x9'));var querystring=require(_0xeb29('0x10'));var Papa=require(_0xeb29('0x11'));var Redis=require(_0xeb29('0x12'));var authService=require(_0xeb29('0x13'));var qs=require(_0xeb29('0x14'));var as=require(_0xeb29('0x15'));var hardwareService=require(_0xeb29('0x16'));var logger=require(_0xeb29('0x17'))(_0xeb29('0x18'));var utils=require('../../config/utils');var config=require(_0xeb29('0x19'));var licenseUtil=require(_0xeb29('0x1a'));var db=require(_0xeb29('0x1b'))['db'];var integrations=require(_0xeb29('0x1c'));function respondWithStatusCode(_0x36cecd,_0x274369){_0x274369=_0x274369||0xcc;return function(_0x4881aa){if(_0x4881aa){return _0x36cecd['sendStatus'](_0x274369);}return _0x36cecd[_0xeb29('0x1d')](_0x274369)[_0xeb29('0x1e')]();};}function respondWithResult(_0x2be560,_0x4fd6e2){_0x4fd6e2=_0x4fd6e2||0xc8;return function(_0x3fe6f7){if(_0x3fe6f7){return _0x2be560[_0xeb29('0x1d')](_0x4fd6e2)['json'](_0x3fe6f7);}};}function respondWithFilteredResult(_0x5de4a0,_0x23e5d4){return function(_0x31aa8d){if(_0x31aa8d){var _0x46953f=typeof _0x23e5d4[_0xeb29('0x1f')]===_0xeb29('0x20')&&typeof _0x23e5d4[_0xeb29('0x21')]===_0xeb29('0x20');var _0x18b673=_0x31aa8d[_0xeb29('0x22')];var _0x493feb=_0x46953f?0x0:_0x23e5d4[_0xeb29('0x1f')];var _0x15b3e4=_0x46953f?_0x31aa8d[_0xeb29('0x22')]:_0x23e5d4[_0xeb29('0x1f')]+_0x23e5d4[_0xeb29('0x21')];var _0x40f08b;if(_0x15b3e4>=_0x18b673){_0x15b3e4=_0x18b673;_0x40f08b=0xc8;}else{_0x40f08b=0xce;}_0x5de4a0[_0xeb29('0x1d')](_0x40f08b);return _0x5de4a0['set'](_0xeb29('0x23'),_0x493feb+'-'+_0x15b3e4+'/'+_0x18b673)[_0xeb29('0x24')](_0x31aa8d);}return null;};}function patchUpdates(_0x3bd16e){return function(_0x2aea10){try{jsonpatch[_0xeb29('0x25')](_0x2aea10,_0x3bd16e,!![]);}catch(_0xc132bd){return BPromise['reject'](_0xc132bd);}return _0x2aea10['save']();};}function saveUpdates(_0x2b8556,_0x589d04){return function(_0x97ceb){if(_0x97ceb){return _0x97ceb[_0xeb29('0x26')](_0x2b8556)['then'](function(_0x3c4f33){return _0x3c4f33;});}return null;};}function removeEntity(_0x27ec50,_0xbb52fa){return function(_0x2c7224){if(_0x2c7224){return _0x2c7224[_0xeb29('0x27')]()['then'](function(){_0x27ec50[_0xeb29('0x1d')](0xcc)[_0xeb29('0x1e')]();});}};}function handleEntityNotFound(_0x27d66f,_0x482160){return function(_0x2197c5){if(!_0x2197c5){_0x27d66f[_0xeb29('0x28')](0x194);}return _0x2197c5;};}function handleError(_0x53bb05,_0x510a90){_0x510a90=_0x510a90||0x1f4;return function(_0x1fb3e0){logger[_0xeb29('0x29')](_0x1fb3e0[_0xeb29('0x2a')]);if(_0x1fb3e0['name']){delete _0x1fb3e0['name'];}_0x53bb05['status'](_0x510a90)[_0xeb29('0x2b')](_0x1fb3e0);};}exports[_0xeb29('0x2c')]=function(_0x4e452f,_0x1ed925){var _0x137d87={},_0x300c7c={},_0x55ca51={'count':0x0,'rows':[]};var _0x1a7d61=_['map'](db[_0xeb29('0x2d')][_0xeb29('0x2e')],function(_0xe6d87f){return{'name':_0xe6d87f[_0xeb29('0x2f')],'type':_0xe6d87f['type'][_0xeb29('0x30')]};});_0x300c7c[_0xeb29('0x31')]=_[_0xeb29('0x32')](_0x1a7d61,'name');_0x300c7c['query']=_['keys'](_0x4e452f['query']);_0x300c7c[_0xeb29('0x33')]=_[_0xeb29('0x34')](_0x300c7c['model'],_0x300c7c[_0xeb29('0x35')]);_0x137d87[_0xeb29('0x36')]=_['intersection'](_0x300c7c[_0xeb29('0x31')],qs[_0xeb29('0x37')](_0x4e452f[_0xeb29('0x35')]['fields']));_0x137d87[_0xeb29('0x36')]=_0x137d87[_0xeb29('0x36')]['length']?_0x137d87[_0xeb29('0x36')]:_0x300c7c['model'];if(!_0x4e452f[_0xeb29('0x35')][_0xeb29('0x38')](_0xeb29('0x39'))){_0x137d87[_0xeb29('0x21')]=qs[_0xeb29('0x21')](_0x4e452f['query'][_0xeb29('0x21')]);_0x137d87[_0xeb29('0x1f')]=qs[_0xeb29('0x1f')](_0x4e452f[_0xeb29('0x35')][_0xeb29('0x1f')]);}_0x137d87[_0xeb29('0x3a')]=qs[_0xeb29('0x3b')](_0x4e452f['query'][_0xeb29('0x3b')]);_0x137d87[_0xeb29('0x3c')]=qs['filters'](_[_0xeb29('0x3d')](_0x4e452f[_0xeb29('0x35')],_0x300c7c[_0xeb29('0x33')]),_0x1a7d61);if(_0x4e452f[_0xeb29('0x35')][_0xeb29('0x3e')]){_0x137d87['where']=_[_0xeb29('0x3f')](_0x137d87[_0xeb29('0x3c')],{'$or':_[_0xeb29('0x32')](_0x1a7d61,function(_0x3ab2ba){if(_0x3ab2ba['type']!=='VIRTUAL'){var _0x388f7d={};_0x388f7d[_0x3ab2ba['name']]={'$like':'%'+_0x4e452f[_0xeb29('0x35')][_0xeb29('0x3e')]+'%'};return _0x388f7d;}})});}_0x137d87=_[_0xeb29('0x3f')]({},_0x137d87,_0x4e452f[_0xeb29('0x40')]);var _0x563171={'where':_0x137d87[_0xeb29('0x3c')]};return db[_0xeb29('0x2d')][_0xeb29('0x22')](_0x563171)['then'](function(_0x4e5903){_0x55ca51[_0xeb29('0x22')]=_0x4e5903;if(_0x4e452f['query'][_0xeb29('0x41')]){_0x137d87[_0xeb29('0x42')]=[{'all':!![]}];}return db['SalesforceAccount'][_0xeb29('0x43')](_0x137d87);})[_0xeb29('0x44')](function(_0x2c6ad1){_0x55ca51[_0xeb29('0x45')]=_0x2c6ad1;return _0x55ca51;})['then'](respondWithFilteredResult(_0x1ed925,_0x137d87))[_0xeb29('0x46')](handleError(_0x1ed925,null));};exports['show']=function(_0x20f8f5,_0x4ce867){var _0x1e85a1={'raw':![],'where':{'id':_0x20f8f5[_0xeb29('0x47')]['id']}},_0x71415b={};_0x71415b['model']=_[_0xeb29('0x48')](db['SalesforceAccount'][_0xeb29('0x2e')]);_0x71415b[_0xeb29('0x35')]=_['keys'](_0x20f8f5['query']);_0x71415b['filters']=_[_0xeb29('0x34')](_0x71415b[_0xeb29('0x31')],_0x71415b[_0xeb29('0x35')]);_0x1e85a1[_0xeb29('0x36')]=_['intersection'](_0x71415b['model'],qs[_0xeb29('0x37')](_0x20f8f5[_0xeb29('0x35')][_0xeb29('0x37')]));_0x1e85a1[_0xeb29('0x36')]=_0x1e85a1[_0xeb29('0x36')]['length']?_0x1e85a1['attributes']:_0x71415b[_0xeb29('0x31')];if(_0x20f8f5[_0xeb29('0x35')]['includeAll']){_0x1e85a1['include']=[{'all':!![]}];}_0x1e85a1=_[_0xeb29('0x3f')]({},_0x1e85a1,_0x20f8f5[_0xeb29('0x40')]);return db['SalesforceAccount'][_0xeb29('0x49')](_0x1e85a1)[_0xeb29('0x44')](handleEntityNotFound(_0x4ce867,null))[_0xeb29('0x44')](respondWithResult(_0x4ce867,null))[_0xeb29('0x46')](handleError(_0x4ce867,null));};exports[_0xeb29('0x4a')]=function(_0x14a1be,_0x4aa553){return db[_0xeb29('0x2d')][_0xeb29('0x4a')](_0x14a1be[_0xeb29('0x4b')],{})[_0xeb29('0x44')](respondWithResult(_0x4aa553,0xc9))[_0xeb29('0x46')](handleError(_0x4aa553,null));};exports[_0xeb29('0x26')]=function(_0x3ca3f7,_0x4d19d0){if(_0x3ca3f7[_0xeb29('0x4b')]['id']){delete _0x3ca3f7[_0xeb29('0x4b')]['id'];}return db[_0xeb29('0x2d')][_0xeb29('0x49')]({'where':{'id':_0x3ca3f7[_0xeb29('0x47')]['id']}})[_0xeb29('0x44')](handleEntityNotFound(_0x4d19d0,null))[_0xeb29('0x44')](saveUpdates(_0x3ca3f7[_0xeb29('0x4b')],null))[_0xeb29('0x44')](respondWithResult(_0x4d19d0,null))[_0xeb29('0x46')](handleError(_0x4d19d0,null));};exports[_0xeb29('0x27')]=function(_0x5c4bbb,_0x4c2348){return db[_0xeb29('0x2d')][_0xeb29('0x49')]({'where':{'id':_0x5c4bbb[_0xeb29('0x47')]['id']}})[_0xeb29('0x44')](handleEntityNotFound(_0x4c2348,null))[_0xeb29('0x44')](removeEntity(_0x4c2348,null))[_0xeb29('0x46')](handleError(_0x4c2348,null));};exports[_0xeb29('0x4c')]=function(_0x353f20,_0x21f609,_0x1cfc1c){var _0x248b61={};var _0x9ab157={};var _0x3e4ddf;var _0x1714f6;return db['SalesforceAccount'][_0xeb29('0x4d')]({'where':{'id':_0x353f20[_0xeb29('0x47')]['id']}})[_0xeb29('0x44')](handleEntityNotFound(_0x21f609,null))[_0xeb29('0x44')](function(_0x42ca19){if(_0x42ca19){_0x3e4ddf=_0x42ca19;_0x9ab157['model']=_[_0xeb29('0x48')](db['SalesforceConfiguration'][_0xeb29('0x2e')]);_0x9ab157[_0xeb29('0x35')]=_['keys'](_0x353f20[_0xeb29('0x35')]);_0x9ab157[_0xeb29('0x33')]=_[_0xeb29('0x34')](_0x9ab157[_0xeb29('0x31')],_0x9ab157['query']);_0x248b61[_0xeb29('0x36')]=_['intersection'](_0x9ab157[_0xeb29('0x31')],qs[_0xeb29('0x37')](_0x353f20[_0xeb29('0x35')]['fields']));_0x248b61[_0xeb29('0x36')]=_0x248b61[_0xeb29('0x36')]['length']?_0x248b61[_0xeb29('0x36')]:_0x9ab157[_0xeb29('0x31')];_0x248b61[_0xeb29('0x3a')]=qs[_0xeb29('0x3b')](_0x353f20[_0xeb29('0x35')][_0xeb29('0x3b')]);_0x248b61[_0xeb29('0x3c')]=qs[_0xeb29('0x33')](_[_0xeb29('0x3d')](_0x353f20['query'],_0x9ab157['filters']));if(_0x353f20[_0xeb29('0x35')][_0xeb29('0x3e')]){_0x248b61[_0xeb29('0x3c')]=_[_0xeb29('0x3f')](_0x248b61['where'],{'$or':_[_0xeb29('0x32')](_0x248b61['attributes'],function(_0xe2af59){var _0x166646={};_0x166646[_0xe2af59]={'$like':'%'+_0x353f20['query'][_0xeb29('0x3e')]+'%'};return _0x166646;})});}_0x248b61=_[_0xeb29('0x3f')]({},_0x248b61,_0x353f20['options']);return _0x3e4ddf[_0xeb29('0x4c')](_0x248b61);}})[_0xeb29('0x44')](function(_0x5408c6){if(_0x5408c6){_0x1714f6=_0x5408c6[_0xeb29('0x4e')];if(!_0x353f20[_0xeb29('0x35')]['hasOwnProperty'](_0xeb29('0x39'))){_0x248b61[_0xeb29('0x21')]=qs[_0xeb29('0x21')](_0x353f20[_0xeb29('0x35')][_0xeb29('0x21')]);_0x248b61['offset']=qs['offset'](_0x353f20[_0xeb29('0x35')]['offset']);}return _0x3e4ddf[_0xeb29('0x4c')](_0x248b61);}})[_0xeb29('0x44')](function(_0x166992){if(_0x166992){return _0x166992?{'count':_0x1714f6,'rows':_0x166992}:null;}})[_0xeb29('0x44')](respondWithResult(_0x21f609,null))[_0xeb29('0x46')](handleError(_0x21f609,null));};exports[_0xeb29('0x4f')]=function(_0x343556,_0x3bfab1,_0x3bcab9){if(_0x343556[_0xeb29('0x4b')]['id']){delete _0x343556[_0xeb29('0x4b')]['id'];}return db[_0xeb29('0x2d')][_0xeb29('0x4d')]({'where':{'id':_0x343556[_0xeb29('0x47')]['id']}})[_0xeb29('0x44')](handleEntityNotFound(_0x3bfab1,null))[_0xeb29('0x44')](function(_0x5bac8d){if(_0x5bac8d){_0x343556[_0xeb29('0x4b')]['AccountId']=_0x5bac8d['id'];_0x343556[_0xeb29('0x4b')]['Subjects']=integrations[_0xeb29('0x50')](_0x343556[_0xeb29('0x4b')][_0xeb29('0x51')],_0x343556[_0xeb29('0x4b')]['type']);_0x343556['body']['Descriptions']=integrations['getDescriptions'](_0x343556['body'][_0xeb29('0x51')],_0x343556[_0xeb29('0x4b')][_0xeb29('0x52')]);return db[_0xeb29('0x53')]['create'](_0x343556[_0xeb29('0x4b')],{'include':[{'model':db[_0xeb29('0x54')],'as':_0xeb29('0x55')},{'model':db[_0xeb29('0x54')],'as':_0xeb29('0x56')}]});}return null;})[_0xeb29('0x44')](respondWithResult(_0x3bfab1,null))[_0xeb29('0x46')](handleError(_0x3bfab1,null));};exports[_0xeb29('0x57')]=function(_0x6a3f26,_0x26d978,_0x3db56a){var _0x3d37c7;var _0xc958c='';var _0x1d1ea9=_0xeb29('0x58');return db[_0xeb29('0x2d')]['findOne']({'where':{'id':_0x6a3f26['params']['id']},'attributes':['id',_0xeb29('0x59'),_0xeb29('0x5a'),_0xeb29('0x5b'),'username',_0xeb29('0x5c'),'securityToken']})[_0xeb29('0x44')](handleEntityNotFound(_0x26d978,null))[_0xeb29('0x44')](function(_0x59801a){if(_0x59801a){_0xc958c=_0x59801a[_0xeb29('0x59')];var _0x26fbe9=_0xc958c[_0xeb29('0x5d')](-0x1);if(_0x26fbe9==='/'){_0xc958c=_0xc958c['substring'](0x0,_0xc958c[_0xeb29('0x5e')](_0x26fbe9));}_0x3d37c7=new jsforce[(_0xeb29('0x5f'))]({'oauth2':{'loginUrl':_0xc958c,'clientId':_0x59801a[_0xeb29('0x5a')],'clientSecret':_0x59801a[_0xeb29('0x5b')]}});return _0x3d37c7[_0xeb29('0x60')](_0x59801a[_0xeb29('0x61')],_0x59801a['password'][_0xeb29('0x62')](_0x59801a[_0xeb29('0x63')]));}})['then'](function(_0x107988){if(_0x107988){if(!_['isNil'](_0x6a3f26[_0xeb29('0x35')][_0xeb29('0x64')])){_0x1d1ea9=_0x6a3f26[_0xeb29('0x35')]['ticketType'];}return _0x3d37c7[_0xeb29('0x65')](_0x1d1ea9)['describe']();}})[_0xeb29('0x44')](function(_0x2e48d0){var _0x122689=['OwnerId',_0xeb29('0x66'),_0xeb29('0x67'),_0xeb29('0x68'),_0xeb29('0x69'),_0xeb29('0x6a')];var _0x477b21=[_0xeb29('0x6b'),_0xeb29('0x6c'),_0xeb29('0x6d'),_0xeb29('0x6e'),_0xeb29('0x6f'),_0xeb29('0x70'),_0xeb29('0x71')];if(_0x2e48d0){_['remove'](_0x2e48d0[_0xeb29('0x37')],function(_0x33282c){return _0x122689[_0xeb29('0x72')](_0x33282c['name'])||!_0x477b21[_0xeb29('0x72')](_0x33282c['type']);});return{'count':_0x2e48d0[_0xeb29('0x37')]['length'],'rows':_[_0xeb29('0x32')](_0x2e48d0[_0xeb29('0x37')],function(_0x54e196){return{'id':_0x54e196[_0xeb29('0x73')],'name':_0x54e196[_0xeb29('0x74')],'custom':_0x54e196[_0xeb29('0x75')],'options':_0x54e196[_0xeb29('0x76')][_0xeb29('0x4e')]>0x0?_[_0xeb29('0x32')](_0x54e196[_0xeb29('0x76')],function(_0x132e54){return{'name':_0x132e54['label'],'value':_0x132e54['value']};}):_0x54e196[_0xeb29('0x52')]==_0xeb29('0x6e')?[{'name':_0xeb29('0x77'),'value':'true'},{'name':'False','value':_0xeb29('0x78')}]:[]};})};}})['then'](respondWithResult(_0x26d978,null))[_0xeb29('0x46')](function(_0x4e03f1){var _0x9c208e=_0x6a3f26[_0xeb29('0x35')]['test']?0x1f4:_0x4e03f1[_0xeb29('0x79')]||0x1f4;logger[_0xeb29('0x29')](_0xeb29('0x7a'),_0xeb29('0x57'),_0x9c208e,JSON['stringify'](_0x4e03f1));delete _0x4e03f1[_0xeb29('0x73')];if(_0x9c208e===0x191){_0x9c208e=0x190;}_0x26d978[_0xeb29('0x1d')](_0x9c208e)[_0xeb29('0x2b')](_0x6a3f26[_0xeb29('0x35')][_0xeb29('0x7b')]?{'message':_0xeb29('0x7c'),'statusCode':_0x4e03f1[_0xeb29('0x79')]}:_0x4e03f1);});};
\ No newline at end of file
+var _0x3fce=['rimraf','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','update','then','error','stack','name','send','index','map','SalesforceAccount','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','options','includeAll','include','rows','catch','show','params','find','create','destroy','getConfigurations','SalesforceConfiguration','addConfiguration','body','findOne','AccountId','channel','getDescriptions','SalesforceField','Subjects','Descriptions','getFields','clientSecret','password','securityToken','remoteUri','slice','substring','lastIndexOf','Connection','clientId','login','username','isNil','describe','OwnerId','IsRecurrence','Subject','Description','string','picklist','email','textarea','phone','includes','picklistValues','label','value','True','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials'];(function(_0x540a7b,_0x525bbf){var _0x5daff7=function(_0x5e7114){while(--_0x5e7114){_0x540a7b['push'](_0x540a7b['shift']());}};_0x5daff7(++_0x525bbf);}(_0x3fce,0x1e0));var _0xe3fc=function(_0x349367,_0x1cede2){_0x349367=_0x349367-0x0;var _0x14179b=_0x3fce[_0x349367];return _0x14179b;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xe3fc('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xe3fc('0x1'));var BPromise=require('bluebird');var Mustache=require(_0xe3fc('0x2'));var util=require(_0xe3fc('0x3'));var path=require(_0xe3fc('0x4'));var sox=require(_0xe3fc('0x5'));var csv=require(_0xe3fc('0x6'));var ejs=require(_0xe3fc('0x7'));var fs=require('fs');var fs_extra=require(_0xe3fc('0x8'));var _=require(_0xe3fc('0x9'));var squel=require('squel');var crypto=require(_0xe3fc('0xa'));var jsforce=require(_0xe3fc('0xb'));var deskjs=require(_0xe3fc('0xc'));var toCsv=require(_0xe3fc('0x6'));var querystring=require('querystring');var Papa=require(_0xe3fc('0xd'));var Redis=require(_0xe3fc('0xe'));var authService=require(_0xe3fc('0xf'));var qs=require(_0xe3fc('0x10'));var as=require(_0xe3fc('0x11'));var hardwareService=require(_0xe3fc('0x12'));var logger=require('../../config/logger')(_0xe3fc('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xe3fc('0x14'));var db=require(_0xe3fc('0x15'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x59b783,_0x1e610e){_0x1e610e=_0x1e610e||0xcc;return function(_0xfaef02){if(_0xfaef02){return _0x59b783[_0xe3fc('0x16')](_0x1e610e);}return _0x59b783[_0xe3fc('0x17')](_0x1e610e)[_0xe3fc('0x18')]();};}function respondWithResult(_0x56ff2f,_0x161cca){_0x161cca=_0x161cca||0xc8;return function(_0x505111){if(_0x505111){return _0x56ff2f[_0xe3fc('0x17')](_0x161cca)[_0xe3fc('0x19')](_0x505111);}};}function respondWithFilteredResult(_0x543be2,_0x5c8e7a){return function(_0x479c35){if(_0x479c35){var _0x4c4ae0=typeof _0x5c8e7a[_0xe3fc('0x1a')]==='undefined'&&typeof _0x5c8e7a[_0xe3fc('0x1b')]===_0xe3fc('0x1c');var _0x4a3b05=_0x479c35[_0xe3fc('0x1d')];var _0x2825a5=_0x4c4ae0?0x0:_0x5c8e7a[_0xe3fc('0x1a')];var _0x186b11=_0x4c4ae0?_0x479c35['count']:_0x5c8e7a[_0xe3fc('0x1a')]+_0x5c8e7a['limit'];var _0x2c87c5;if(_0x186b11>=_0x4a3b05){_0x186b11=_0x4a3b05;_0x2c87c5=0xc8;}else{_0x2c87c5=0xce;}_0x543be2[_0xe3fc('0x17')](_0x2c87c5);return _0x543be2[_0xe3fc('0x1e')](_0xe3fc('0x1f'),_0x2825a5+'-'+_0x186b11+'/'+_0x4a3b05)[_0xe3fc('0x19')](_0x479c35);}return null;};}function patchUpdates(_0x130427){return function(_0x16a5ef){try{jsonpatch[_0xe3fc('0x20')](_0x16a5ef,_0x130427,!![]);}catch(_0x1334dc){return BPromise[_0xe3fc('0x21')](_0x1334dc);}return _0x16a5ef['save']();};}function saveUpdates(_0x4ae30a,_0x1bf7e5){return function(_0x32347f){if(_0x32347f){return _0x32347f[_0xe3fc('0x22')](_0x4ae30a)[_0xe3fc('0x23')](function(_0x25fbb8){return _0x25fbb8;});}return null;};}function removeEntity(_0x3b9695,_0x23055b){return function(_0x146c39){if(_0x146c39){return _0x146c39['destroy']()['then'](function(){_0x3b9695[_0xe3fc('0x17')](0xcc)[_0xe3fc('0x18')]();});}};}function handleEntityNotFound(_0x28dfbc,_0x184557){return function(_0x1f946e){if(!_0x1f946e){_0x28dfbc[_0xe3fc('0x16')](0x194);}return _0x1f946e;};}function handleError(_0x410cf7,_0x44f8e4){_0x44f8e4=_0x44f8e4||0x1f4;return function(_0x1ab6bf){logger[_0xe3fc('0x24')](_0x1ab6bf[_0xe3fc('0x25')]);if(_0x1ab6bf[_0xe3fc('0x26')]){delete _0x1ab6bf['name'];}_0x410cf7['status'](_0x44f8e4)[_0xe3fc('0x27')](_0x1ab6bf);};}exports[_0xe3fc('0x28')]=function(_0x20b0b9,_0x17bf09){var _0x3039e9={},_0x43f4f5={},_0x34a25d={'count':0x0,'rows':[]};var _0xaf1d7e=_[_0xe3fc('0x29')](db[_0xe3fc('0x2a')][_0xe3fc('0x2b')],function(_0x526c8d){return{'name':_0x526c8d[_0xe3fc('0x2c')],'type':_0x526c8d[_0xe3fc('0x2d')][_0xe3fc('0x2e')]};});_0x43f4f5[_0xe3fc('0x2f')]=_['map'](_0xaf1d7e,_0xe3fc('0x26'));_0x43f4f5[_0xe3fc('0x30')]=_[_0xe3fc('0x31')](_0x20b0b9['query']);_0x43f4f5['filters']=_[_0xe3fc('0x32')](_0x43f4f5[_0xe3fc('0x2f')],_0x43f4f5['query']);_0x3039e9[_0xe3fc('0x33')]=_[_0xe3fc('0x32')](_0x43f4f5['model'],qs[_0xe3fc('0x34')](_0x20b0b9[_0xe3fc('0x30')][_0xe3fc('0x34')]));_0x3039e9[_0xe3fc('0x33')]=_0x3039e9[_0xe3fc('0x33')][_0xe3fc('0x35')]?_0x3039e9[_0xe3fc('0x33')]:_0x43f4f5['model'];if(!_0x20b0b9[_0xe3fc('0x30')][_0xe3fc('0x36')](_0xe3fc('0x37'))){_0x3039e9[_0xe3fc('0x1b')]=qs[_0xe3fc('0x1b')](_0x20b0b9[_0xe3fc('0x30')]['limit']);_0x3039e9['offset']=qs[_0xe3fc('0x1a')](_0x20b0b9['query']['offset']);}_0x3039e9[_0xe3fc('0x38')]=qs[_0xe3fc('0x39')](_0x20b0b9[_0xe3fc('0x30')][_0xe3fc('0x39')]);_0x3039e9[_0xe3fc('0x3a')]=qs[_0xe3fc('0x3b')](_[_0xe3fc('0x3c')](_0x20b0b9[_0xe3fc('0x30')],_0x43f4f5[_0xe3fc('0x3b')]),_0xaf1d7e);if(_0x20b0b9[_0xe3fc('0x30')][_0xe3fc('0x3d')]){_0x3039e9[_0xe3fc('0x3a')]=_[_0xe3fc('0x3e')](_0x3039e9['where'],{'$or':_[_0xe3fc('0x29')](_0xaf1d7e,function(_0x2368dc){if(_0x2368dc[_0xe3fc('0x2d')]!=='VIRTUAL'){var _0xadee8e={};_0xadee8e[_0x2368dc[_0xe3fc('0x26')]]={'$like':'%'+_0x20b0b9[_0xe3fc('0x30')]['filter']+'%'};return _0xadee8e;}})});}_0x3039e9=_[_0xe3fc('0x3e')]({},_0x3039e9,_0x20b0b9[_0xe3fc('0x3f')]);var _0x15993f={'where':_0x3039e9[_0xe3fc('0x3a')]};return db[_0xe3fc('0x2a')][_0xe3fc('0x1d')](_0x15993f)['then'](function(_0x4027e3){_0x34a25d['count']=_0x4027e3;if(_0x20b0b9[_0xe3fc('0x30')][_0xe3fc('0x40')]){_0x3039e9[_0xe3fc('0x41')]=[{'all':!![]}];}return db[_0xe3fc('0x2a')]['findAll'](_0x3039e9);})[_0xe3fc('0x23')](function(_0x43eb6b){_0x34a25d[_0xe3fc('0x42')]=_0x43eb6b;return _0x34a25d;})[_0xe3fc('0x23')](respondWithFilteredResult(_0x17bf09,_0x3039e9))[_0xe3fc('0x43')](handleError(_0x17bf09,null));};exports[_0xe3fc('0x44')]=function(_0x4a1955,_0x605587){var _0x4292b6={'raw':![],'where':{'id':_0x4a1955[_0xe3fc('0x45')]['id']}},_0x146c4a={};_0x146c4a[_0xe3fc('0x2f')]=_[_0xe3fc('0x31')](db[_0xe3fc('0x2a')][_0xe3fc('0x2b')]);_0x146c4a['query']=_[_0xe3fc('0x31')](_0x4a1955[_0xe3fc('0x30')]);_0x146c4a[_0xe3fc('0x3b')]=_[_0xe3fc('0x32')](_0x146c4a[_0xe3fc('0x2f')],_0x146c4a[_0xe3fc('0x30')]);_0x4292b6[_0xe3fc('0x33')]=_[_0xe3fc('0x32')](_0x146c4a[_0xe3fc('0x2f')],qs[_0xe3fc('0x34')](_0x4a1955[_0xe3fc('0x30')]['fields']));_0x4292b6[_0xe3fc('0x33')]=_0x4292b6['attributes'][_0xe3fc('0x35')]?_0x4292b6[_0xe3fc('0x33')]:_0x146c4a['model'];if(_0x4a1955[_0xe3fc('0x30')][_0xe3fc('0x40')]){_0x4292b6[_0xe3fc('0x41')]=[{'all':!![]}];}_0x4292b6=_[_0xe3fc('0x3e')]({},_0x4292b6,_0x4a1955['options']);return db[_0xe3fc('0x2a')][_0xe3fc('0x46')](_0x4292b6)[_0xe3fc('0x23')](handleEntityNotFound(_0x605587,null))[_0xe3fc('0x23')](respondWithResult(_0x605587,null))[_0xe3fc('0x43')](handleError(_0x605587,null));};exports[_0xe3fc('0x47')]=function(_0x38aa50,_0x31599b){return db[_0xe3fc('0x2a')][_0xe3fc('0x47')](_0x38aa50['body'],{})[_0xe3fc('0x23')](respondWithResult(_0x31599b,0xc9))[_0xe3fc('0x43')](handleError(_0x31599b,null));};exports[_0xe3fc('0x22')]=function(_0x39a5de,_0x4d1730){if(_0x39a5de['body']['id']){delete _0x39a5de['body']['id'];}return db[_0xe3fc('0x2a')][_0xe3fc('0x46')]({'where':{'id':_0x39a5de[_0xe3fc('0x45')]['id']}})['then'](handleEntityNotFound(_0x4d1730,null))[_0xe3fc('0x23')](saveUpdates(_0x39a5de['body'],null))[_0xe3fc('0x23')](respondWithResult(_0x4d1730,null))[_0xe3fc('0x43')](handleError(_0x4d1730,null));};exports[_0xe3fc('0x48')]=function(_0x5d2055,_0x5a3efc){return db[_0xe3fc('0x2a')][_0xe3fc('0x46')]({'where':{'id':_0x5d2055[_0xe3fc('0x45')]['id']}})['then'](handleEntityNotFound(_0x5a3efc,null))[_0xe3fc('0x23')](removeEntity(_0x5a3efc,null))[_0xe3fc('0x43')](handleError(_0x5a3efc,null));};exports[_0xe3fc('0x49')]=function(_0x38bdc6,_0x3734a5,_0x3136f3){var _0x2c6d7f={};var _0x52364f={};var _0x43830f;var _0xd3589e;return db[_0xe3fc('0x2a')]['findOne']({'where':{'id':_0x38bdc6['params']['id']}})[_0xe3fc('0x23')](handleEntityNotFound(_0x3734a5,null))[_0xe3fc('0x23')](function(_0x4d6993){if(_0x4d6993){_0x43830f=_0x4d6993;_0x52364f['model']=_[_0xe3fc('0x31')](db[_0xe3fc('0x4a')][_0xe3fc('0x2b')]);_0x52364f['query']=_['keys'](_0x38bdc6[_0xe3fc('0x30')]);_0x52364f[_0xe3fc('0x3b')]=_[_0xe3fc('0x32')](_0x52364f[_0xe3fc('0x2f')],_0x52364f['query']);_0x2c6d7f[_0xe3fc('0x33')]=_['intersection'](_0x52364f[_0xe3fc('0x2f')],qs[_0xe3fc('0x34')](_0x38bdc6[_0xe3fc('0x30')][_0xe3fc('0x34')]));_0x2c6d7f[_0xe3fc('0x33')]=_0x2c6d7f[_0xe3fc('0x33')][_0xe3fc('0x35')]?_0x2c6d7f[_0xe3fc('0x33')]:_0x52364f[_0xe3fc('0x2f')];_0x2c6d7f['order']=qs[_0xe3fc('0x39')](_0x38bdc6['query'][_0xe3fc('0x39')]);_0x2c6d7f[_0xe3fc('0x3a')]=qs['filters'](_['pick'](_0x38bdc6[_0xe3fc('0x30')],_0x52364f[_0xe3fc('0x3b')]));if(_0x38bdc6[_0xe3fc('0x30')]['filter']){_0x2c6d7f[_0xe3fc('0x3a')]=_[_0xe3fc('0x3e')](_0x2c6d7f[_0xe3fc('0x3a')],{'$or':_['map'](_0x2c6d7f[_0xe3fc('0x33')],function(_0xdc6e2c){var _0x764788={};_0x764788[_0xdc6e2c]={'$like':'%'+_0x38bdc6['query']['filter']+'%'};return _0x764788;})});}_0x2c6d7f=_['merge']({},_0x2c6d7f,_0x38bdc6[_0xe3fc('0x3f')]);return _0x43830f['getConfigurations'](_0x2c6d7f);}})[_0xe3fc('0x23')](function(_0x145bea){if(_0x145bea){_0xd3589e=_0x145bea['length'];if(!_0x38bdc6[_0xe3fc('0x30')][_0xe3fc('0x36')](_0xe3fc('0x37'))){_0x2c6d7f[_0xe3fc('0x1b')]=qs[_0xe3fc('0x1b')](_0x38bdc6[_0xe3fc('0x30')][_0xe3fc('0x1b')]);_0x2c6d7f[_0xe3fc('0x1a')]=qs[_0xe3fc('0x1a')](_0x38bdc6[_0xe3fc('0x30')][_0xe3fc('0x1a')]);}return _0x43830f[_0xe3fc('0x49')](_0x2c6d7f);}})[_0xe3fc('0x23')](function(_0x911960){if(_0x911960){return _0x911960?{'count':_0xd3589e,'rows':_0x911960}:null;}})[_0xe3fc('0x23')](respondWithResult(_0x3734a5,null))[_0xe3fc('0x43')](handleError(_0x3734a5,null));};exports[_0xe3fc('0x4b')]=function(_0x4afafe,_0x137ff3,_0x2f9b13){if(_0x4afafe[_0xe3fc('0x4c')]['id']){delete _0x4afafe[_0xe3fc('0x4c')]['id'];}return db[_0xe3fc('0x2a')][_0xe3fc('0x4d')]({'where':{'id':_0x4afafe[_0xe3fc('0x45')]['id']}})[_0xe3fc('0x23')](handleEntityNotFound(_0x137ff3,null))[_0xe3fc('0x23')](function(_0x2ecba3){if(_0x2ecba3){_0x4afafe[_0xe3fc('0x4c')][_0xe3fc('0x4e')]=_0x2ecba3['id'];_0x4afafe[_0xe3fc('0x4c')]['Subjects']=integrations['getSubjects'](_0x4afafe['body'][_0xe3fc('0x4f')],_0x4afafe['body'][_0xe3fc('0x2d')]);_0x4afafe[_0xe3fc('0x4c')]['Descriptions']=integrations[_0xe3fc('0x50')](_0x4afafe[_0xe3fc('0x4c')][_0xe3fc('0x4f')],_0x4afafe[_0xe3fc('0x4c')][_0xe3fc('0x2d')]);return db[_0xe3fc('0x4a')][_0xe3fc('0x47')](_0x4afafe[_0xe3fc('0x4c')],{'include':[{'model':db[_0xe3fc('0x51')],'as':_0xe3fc('0x52')},{'model':db[_0xe3fc('0x51')],'as':_0xe3fc('0x53')}]});}return null;})[_0xe3fc('0x23')](respondWithResult(_0x137ff3,null))[_0xe3fc('0x43')](handleError(_0x137ff3,null));};exports[_0xe3fc('0x54')]=function(_0x1173ab,_0x376e1f,_0x5396fd){var _0x48d4f2;var _0x5e096d='';var _0x2c86b2='Task';return db['SalesforceAccount'][_0xe3fc('0x4d')]({'where':{'id':_0x1173ab[_0xe3fc('0x45')]['id']},'attributes':['id','remoteUri','clientId',_0xe3fc('0x55'),'username',_0xe3fc('0x56'),_0xe3fc('0x57')]})['then'](handleEntityNotFound(_0x376e1f,null))[_0xe3fc('0x23')](function(_0x5b6ad0){if(_0x5b6ad0){_0x5e096d=_0x5b6ad0[_0xe3fc('0x58')];var _0x1132b1=_0x5e096d[_0xe3fc('0x59')](-0x1);if(_0x1132b1==='/'){_0x5e096d=_0x5e096d[_0xe3fc('0x5a')](0x0,_0x5e096d[_0xe3fc('0x5b')](_0x1132b1));}_0x48d4f2=new jsforce[(_0xe3fc('0x5c'))]({'oauth2':{'loginUrl':_0x5e096d,'clientId':_0x5b6ad0[_0xe3fc('0x5d')],'clientSecret':_0x5b6ad0[_0xe3fc('0x55')]}});return _0x48d4f2[_0xe3fc('0x5e')](_0x5b6ad0[_0xe3fc('0x5f')],_0x5b6ad0['password']['concat'](_0x5b6ad0['securityToken']));}})['then'](function(_0x35e30e){if(_0x35e30e){if(!_[_0xe3fc('0x60')](_0x1173ab[_0xe3fc('0x30')]['ticketType'])){_0x2c86b2=_0x1173ab[_0xe3fc('0x30')]['ticketType'];}return _0x48d4f2['sobject'](_0x2c86b2)[_0xe3fc('0x61')]();}})['then'](function(_0x4bb598){var _0x2a3268=[_0xe3fc('0x62'),'ActivityDate','IsReminderSet',_0xe3fc('0x63'),_0xe3fc('0x64'),_0xe3fc('0x65')];var _0x27ca5b=[_0xe3fc('0x66'),'int',_0xe3fc('0x67'),'boolean',_0xe3fc('0x68'),_0xe3fc('0x69'),_0xe3fc('0x6a')];if(_0x4bb598){_['remove'](_0x4bb598[_0xe3fc('0x34')],function(_0x33bb27){return _0x2a3268[_0xe3fc('0x6b')](_0x33bb27[_0xe3fc('0x26')])||!_0x27ca5b[_0xe3fc('0x6b')](_0x33bb27['type']);});return{'count':_0x4bb598[_0xe3fc('0x34')]['length'],'rows':_[_0xe3fc('0x29')](_0x4bb598['fields'],function(_0x7d19dd){return{'id':_0x7d19dd[_0xe3fc('0x26')],'name':_0x7d19dd['label'],'custom':_0x7d19dd['custom'],'options':_0x7d19dd['picklistValues'][_0xe3fc('0x35')]>0x0?_[_0xe3fc('0x29')](_0x7d19dd[_0xe3fc('0x6c')],function(_0x42d1b8){return{'name':_0x42d1b8[_0xe3fc('0x6d')],'value':_0x42d1b8[_0xe3fc('0x6e')]};}):_0x7d19dd[_0xe3fc('0x2d')]=='boolean'?[{'name':_0xe3fc('0x6f'),'value':_0xe3fc('0x70')},{'name':_0xe3fc('0x71'),'value':_0xe3fc('0x72')}]:[]};})};}})[_0xe3fc('0x23')](respondWithResult(_0x376e1f,null))[_0xe3fc('0x43')](function(_0x3bf5ad){var _0xad2b22=_0x1173ab[_0xe3fc('0x30')][_0xe3fc('0x73')]?0x1f4:_0x3bf5ad[_0xe3fc('0x74')]||0x1f4;logger['error'](_0xe3fc('0x75'),'getFields',_0xad2b22,JSON[_0xe3fc('0x76')](_0x3bf5ad));delete _0x3bf5ad['name'];if(_0xad2b22===0x191){_0xad2b22=0x190;}_0x376e1f[_0xe3fc('0x17')](_0xad2b22)['send'](_0x1173ab['query'][_0xe3fc('0x73')]?{'message':_0xe3fc('0x77'),'statusCode':_0x3bf5ad[_0xe3fc('0x74')]}:_0x3bf5ad);});};
\ No newline at end of file