Built motion from commit 97153652.|2.6.26
[motion2.git] / server / api / intSalesforceAccount / intSalesforceAccount.controller.js
index bef1b93..538a065 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcf86=['ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../components/integrations/configuration','jayson/promise','client','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','SalesforceAccount,\x20%s,\x20%s','request\x20sent','debug','SalesforceAccount,\x20%s,\x20%s,\x20%s','error','message','catch','sendStatus','status','json','count','offset','set','Content-Range','apply','reject','save','update','destroy','end','stack','name','send','index','map','SalesforceAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','where','pick','VIRTUAL','filter','includeAll','findAll','rows','show','params','include','options','find','create','body','getConfigurations','findOne','SalesforceConfiguration','merge','nolimit','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','getDescriptions','SalesforceField','getFields','remoteUri','clientId','username','password','securityToken','slice','substring','lastIndexOf','Connection','clientSecret','login','concat','isNil','ticketType','sobject','CallDisposition','CallDurationInSeconds','CallObject','CallType','IsArchived','Priority','Status','Case','Type','Origin','Reason','IsEscalated','SuppliedName','SuppliedCompany','custom','label','picklistValues','True','true','test','stringify','Wrong\x20credentials','statusCode','html-pdf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','squel','crypto','desk.js','querystring','papaparse'];(function(_0x3e072f,_0x13c792){var _0x1db097=function(_0x12a66b){while(--_0x12a66b){_0x3e072f['push'](_0x3e072f['shift']());}};_0x1db097(++_0x13c792);}(_0xcf86,0x7a));var _0x6cf8=function(_0x166d93,_0x301f09){_0x166d93=_0x166d93-0x0;var _0xba708=_0xcf86[_0x166d93];return _0xba708;};'use strict';var pdf=require(_0x6cf8('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x6cf8('0x1'));var jsonpatch=require(_0x6cf8('0x2'));var rp=require('request-promise');var moment=require(_0x6cf8('0x3'));var BPromise=require(_0x6cf8('0x4'));var Mustache=require(_0x6cf8('0x5'));var util=require(_0x6cf8('0x6'));var path=require(_0x6cf8('0x7'));var sox=require(_0x6cf8('0x8'));var csv=require(_0x6cf8('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x6cf8('0xa'));var crypto=require(_0x6cf8('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x6cf8('0xc'));var toCsv=require(_0x6cf8('0x9'));var querystring=require(_0x6cf8('0xd'));var Papa=require(_0x6cf8('0xe'));var Redis=require(_0x6cf8('0xf'));var authService=require(_0x6cf8('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x6cf8('0x11'));var hardwareService=require(_0x6cf8('0x12'));var logger=require(_0x6cf8('0x13'))(_0x6cf8('0x14'));var utils=require(_0x6cf8('0x15'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];var integrations=require(_0x6cf8('0x16'));var jayson=require(_0x6cf8('0x17'));var client=jayson[_0x6cf8('0x18')]['http']({'port':0x232a});function checkPasswordPattern(_0x1b9ca3,_0x4fa774,_0x59e1b3){if(_0x59e1b3){var _0x2955fe=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x2955fe['test'](_0x4fa774)){return _0x1b9ca3;}else{throw new db['Sequelize']['ValidationError'](_0x6cf8('0x19'));}}else{return _0x1b9ca3;}}function respondWithRpcPromise(_0x200017,_0x41d649,_0x1cbbbd,_0x4e7823){return new BPromise(function(_0x358a14,_0x5a64cc){var _0x28d48d=_0x4e7823||client;return _0x28d48d[_0x6cf8('0x1a')](_0x200017,_0x1cbbbd)[_0x6cf8('0x1b')](function(_0x29cef1){logger[_0x6cf8('0x1c')](_0x6cf8('0x1d'),_0x41d649,_0x6cf8('0x1e'));logger[_0x6cf8('0x1f')](_0x6cf8('0x20'),_0x41d649,_0x6cf8('0x1e'),JSON['stringify'](_0x29cef1));if(_0x29cef1[_0x6cf8('0x21')]){if(_0x29cef1[_0x6cf8('0x21')]['code']===0x1f4){logger['error'](_0x6cf8('0x1d'),_0x41d649,_0x29cef1[_0x6cf8('0x21')][_0x6cf8('0x22')]);return _0x5a64cc(_0x29cef1['error'][_0x6cf8('0x22')]);}logger[_0x6cf8('0x21')](_0x6cf8('0x1d'),_0x41d649,_0x29cef1['error'][_0x6cf8('0x22')]);return _0x358a14(_0x29cef1[_0x6cf8('0x21')][_0x6cf8('0x22')]);}else{logger[_0x6cf8('0x1c')](_0x6cf8('0x1d'),_0x41d649,_0x6cf8('0x1e'));_0x358a14(_0x29cef1['result'][_0x6cf8('0x22')]);}})[_0x6cf8('0x23')](function(_0x2729b8){logger[_0x6cf8('0x21')](_0x6cf8('0x1d'),_0x41d649,_0x2729b8);_0x5a64cc(_0x2729b8);});});}function respondWithStatusCode(_0x42ea81,_0x328b4d){_0x328b4d=_0x328b4d||0xcc;return function(_0xede59f){if(_0xede59f){return _0x42ea81[_0x6cf8('0x24')](_0x328b4d);}return _0x42ea81[_0x6cf8('0x25')](_0x328b4d)['end']();};}function respondWithResult(_0x5cb891,_0x1545ec){_0x1545ec=_0x1545ec||0xc8;return function(_0x28b065){if(_0x28b065){return _0x5cb891[_0x6cf8('0x25')](_0x1545ec)[_0x6cf8('0x26')](_0x28b065);}};}function respondWithFilteredResult(_0xfe8dc5,_0x3f2dc6){return function(_0x5b2fc7){if(_0x5b2fc7){var _0x5b99ac=_0x5b2fc7[_0x6cf8('0x27')],_0xd26062=_0x3f2dc6[_0x6cf8('0x28')],_0x42c647=_0x3f2dc6[_0x6cf8('0x28')]+_0x3f2dc6['limit'],_0x34937a;if(_0x42c647>=_0x5b99ac){_0x42c647=_0x5b99ac;_0x34937a=0xc8;}else{_0x34937a=0xce;}_0xfe8dc5[_0x6cf8('0x25')](_0x34937a);return _0xfe8dc5[_0x6cf8('0x29')](_0x6cf8('0x2a'),_0xd26062+'-'+_0x42c647+'/'+_0x5b99ac)[_0x6cf8('0x26')](_0x5b2fc7);}return null;};}function patchUpdates(_0x239698){return function(_0x27ba5c){try{jsonpatch[_0x6cf8('0x2b')](_0x27ba5c,_0x239698,!![]);}catch(_0x503551){return BPromise[_0x6cf8('0x2c')](_0x503551);}return _0x27ba5c[_0x6cf8('0x2d')]();};}function saveUpdates(_0x24294c,_0xe84627){return function(_0x5b919d){if(_0x5b919d){return _0x5b919d[_0x6cf8('0x2e')](_0x24294c)['then'](function(_0x290779){return _0x290779;});}return null;};}function removeEntity(_0x342f36,_0x55d949){return function(_0x17d7dc){if(_0x17d7dc){return _0x17d7dc[_0x6cf8('0x2f')]()['then'](function(){_0x342f36[_0x6cf8('0x25')](0xcc)[_0x6cf8('0x30')]();});}};}function handleEntityNotFound(_0xb8ebbe,_0x88c0c4){return function(_0x575a41){if(!_0x575a41){_0xb8ebbe[_0x6cf8('0x24')](0x194);}return _0x575a41;};}function handleError(_0x5bcc11,_0x3a1e28){_0x3a1e28=_0x3a1e28||0x1f4;return function(_0x239462){logger['error'](_0x239462[_0x6cf8('0x31')]);if(_0x239462[_0x6cf8('0x32')]){delete _0x239462[_0x6cf8('0x32')];}_0x5bcc11[_0x6cf8('0x25')](_0x3a1e28)[_0x6cf8('0x33')](_0x239462);};}exports[_0x6cf8('0x34')]=function(_0x388def,_0x404a88){var _0x40d927={},_0x3343c8={},_0x117637={'count':0x0,'rows':[]};var _0x440585=_[_0x6cf8('0x35')](db[_0x6cf8('0x36')][_0x6cf8('0x37')],function(_0x383347){return{'name':_0x383347[_0x6cf8('0x38')],'type':_0x383347[_0x6cf8('0x39')][_0x6cf8('0x3a')]};});_0x3343c8[_0x6cf8('0x3b')]=_[_0x6cf8('0x35')](_0x440585,'name');_0x3343c8[_0x6cf8('0x3c')]=_[_0x6cf8('0x3d')](_0x388def[_0x6cf8('0x3c')]);_0x3343c8[_0x6cf8('0x3e')]=_[_0x6cf8('0x3f')](_0x3343c8[_0x6cf8('0x3b')],_0x3343c8['query']);_0x40d927[_0x6cf8('0x40')]=_[_0x6cf8('0x3f')](_0x3343c8[_0x6cf8('0x3b')],qs[_0x6cf8('0x41')](_0x388def[_0x6cf8('0x3c')][_0x6cf8('0x41')]));_0x40d927['attributes']=_0x40d927[_0x6cf8('0x40')][_0x6cf8('0x42')]?_0x40d927[_0x6cf8('0x40')]:_0x3343c8[_0x6cf8('0x3b')];if(!_0x388def[_0x6cf8('0x3c')][_0x6cf8('0x43')]('nolimit')){_0x40d927[_0x6cf8('0x44')]=qs[_0x6cf8('0x44')](_0x388def['query'][_0x6cf8('0x44')]);_0x40d927[_0x6cf8('0x28')]=qs[_0x6cf8('0x28')](_0x388def['query'][_0x6cf8('0x28')]);}_0x40d927[_0x6cf8('0x45')]=qs['sort'](_0x388def[_0x6cf8('0x3c')][_0x6cf8('0x46')]);_0x40d927[_0x6cf8('0x47')]=qs[_0x6cf8('0x3e')](_[_0x6cf8('0x48')](_0x388def[_0x6cf8('0x3c')],_0x3343c8[_0x6cf8('0x3e')]),_0x440585);if(_0x388def[_0x6cf8('0x3c')]['filter']){_0x40d927[_0x6cf8('0x47')]=_['merge'](_0x40d927[_0x6cf8('0x47')],{'$or':_[_0x6cf8('0x35')](_0x440585,function(_0x52194a){if(_0x52194a['type']!==_0x6cf8('0x49')){var _0x54b3a3={};_0x54b3a3[_0x52194a[_0x6cf8('0x32')]]={'$like':'%'+_0x388def[_0x6cf8('0x3c')][_0x6cf8('0x4a')]+'%'};return _0x54b3a3;}})});}_0x40d927=_['merge']({},_0x40d927,_0x388def['options']);var _0x399ef4={'where':_0x40d927[_0x6cf8('0x47')]};return db[_0x6cf8('0x36')][_0x6cf8('0x27')](_0x399ef4)[_0x6cf8('0x1b')](function(_0x1db895){_0x117637[_0x6cf8('0x27')]=_0x1db895;if(_0x388def[_0x6cf8('0x3c')][_0x6cf8('0x4b')]){_0x40d927['include']=[{'all':!![]}];}return db[_0x6cf8('0x36')][_0x6cf8('0x4c')](_0x40d927);})[_0x6cf8('0x1b')](function(_0x577462){_0x117637[_0x6cf8('0x4d')]=_0x577462;return _0x117637;})[_0x6cf8('0x1b')](respondWithFilteredResult(_0x404a88,_0x40d927))['catch'](handleError(_0x404a88,null));};exports[_0x6cf8('0x4e')]=function(_0x2db00e,_0x102832){var _0x94b833={'raw':![],'where':{'id':_0x2db00e[_0x6cf8('0x4f')]['id']}},_0x5bbc4e={};_0x5bbc4e[_0x6cf8('0x3b')]=_[_0x6cf8('0x3d')](db[_0x6cf8('0x36')][_0x6cf8('0x37')]);_0x5bbc4e[_0x6cf8('0x3c')]=_['keys'](_0x2db00e[_0x6cf8('0x3c')]);_0x5bbc4e[_0x6cf8('0x3e')]=_[_0x6cf8('0x3f')](_0x5bbc4e[_0x6cf8('0x3b')],_0x5bbc4e[_0x6cf8('0x3c')]);_0x94b833[_0x6cf8('0x40')]=_[_0x6cf8('0x3f')](_0x5bbc4e['model'],qs['fields'](_0x2db00e['query'][_0x6cf8('0x41')]));_0x94b833[_0x6cf8('0x40')]=_0x94b833[_0x6cf8('0x40')][_0x6cf8('0x42')]?_0x94b833['attributes']:_0x5bbc4e['model'];if(_0x2db00e[_0x6cf8('0x3c')][_0x6cf8('0x4b')]){_0x94b833[_0x6cf8('0x50')]=[{'all':!![]}];}_0x94b833=_['merge']({},_0x94b833,_0x2db00e[_0x6cf8('0x51')]);return db['SalesforceAccount'][_0x6cf8('0x52')](_0x94b833)[_0x6cf8('0x1b')](handleEntityNotFound(_0x102832,null))[_0x6cf8('0x1b')](respondWithResult(_0x102832,null))[_0x6cf8('0x23')](handleError(_0x102832,null));};exports[_0x6cf8('0x53')]=function(_0x21429e,_0x18cd53){return db['SalesforceAccount'][_0x6cf8('0x53')](_0x21429e[_0x6cf8('0x54')],{})[_0x6cf8('0x1b')](respondWithResult(_0x18cd53,0xc9))[_0x6cf8('0x23')](handleError(_0x18cd53,null));};exports[_0x6cf8('0x2e')]=function(_0x2ec923,_0x27d7e0){if(_0x2ec923[_0x6cf8('0x54')]['id']){delete _0x2ec923[_0x6cf8('0x54')]['id'];}return db[_0x6cf8('0x36')]['find']({'where':{'id':_0x2ec923['params']['id']}})['then'](handleEntityNotFound(_0x27d7e0,null))[_0x6cf8('0x1b')](saveUpdates(_0x2ec923[_0x6cf8('0x54')],null))[_0x6cf8('0x1b')](respondWithResult(_0x27d7e0,null))[_0x6cf8('0x23')](handleError(_0x27d7e0,null));};exports['destroy']=function(_0x253594,_0x463d60){return db[_0x6cf8('0x36')][_0x6cf8('0x52')]({'where':{'id':_0x253594[_0x6cf8('0x4f')]['id']}})['then'](handleEntityNotFound(_0x463d60,null))[_0x6cf8('0x1b')](removeEntity(_0x463d60,null))[_0x6cf8('0x23')](handleError(_0x463d60,null));};exports[_0x6cf8('0x55')]=function(_0x33be35,_0x3ee4b5,_0x2228a1){var _0x349618={};var _0xca271a={};var _0xcb790a;var _0x2ef07a;return db['SalesforceAccount'][_0x6cf8('0x56')]({'where':{'id':_0x33be35[_0x6cf8('0x4f')]['id']}})[_0x6cf8('0x1b')](handleEntityNotFound(_0x3ee4b5,null))['then'](function(_0x55914e){if(_0x55914e){_0xcb790a=_0x55914e;_0xca271a[_0x6cf8('0x3b')]=_['keys'](db[_0x6cf8('0x57')][_0x6cf8('0x37')]);_0xca271a[_0x6cf8('0x3c')]=_[_0x6cf8('0x3d')](_0x33be35[_0x6cf8('0x3c')]);_0xca271a[_0x6cf8('0x3e')]=_[_0x6cf8('0x3f')](_0xca271a[_0x6cf8('0x3b')],_0xca271a[_0x6cf8('0x3c')]);_0x349618['attributes']=_[_0x6cf8('0x3f')](_0xca271a['model'],qs[_0x6cf8('0x41')](_0x33be35[_0x6cf8('0x3c')][_0x6cf8('0x41')]));_0x349618[_0x6cf8('0x40')]=_0x349618['attributes'][_0x6cf8('0x42')]?_0x349618[_0x6cf8('0x40')]:_0xca271a[_0x6cf8('0x3b')];_0x349618[_0x6cf8('0x45')]=qs[_0x6cf8('0x46')](_0x33be35[_0x6cf8('0x3c')]['sort']);_0x349618[_0x6cf8('0x47')]=qs[_0x6cf8('0x3e')](_[_0x6cf8('0x48')](_0x33be35[_0x6cf8('0x3c')],_0xca271a[_0x6cf8('0x3e')]));if(_0x33be35[_0x6cf8('0x3c')]['filter']){_0x349618[_0x6cf8('0x47')]=_['merge'](_0x349618[_0x6cf8('0x47')],{'$or':_[_0x6cf8('0x35')](_0x349618[_0x6cf8('0x40')],function(_0x2834db){var _0x318fdb={};_0x318fdb[_0x2834db]={'$like':'%'+_0x33be35['query'][_0x6cf8('0x4a')]+'%'};return _0x318fdb;})});}_0x349618=_[_0x6cf8('0x58')]({},_0x349618,_0x33be35[_0x6cf8('0x51')]);return _0xcb790a[_0x6cf8('0x55')](_0x349618);}})[_0x6cf8('0x1b')](function(_0x10792a){if(_0x10792a){_0x2ef07a=_0x10792a['length'];if(!_0x33be35['query'][_0x6cf8('0x43')](_0x6cf8('0x59'))){_0x349618[_0x6cf8('0x44')]=qs['limit'](_0x33be35['query'][_0x6cf8('0x44')]);_0x349618['offset']=qs['offset'](_0x33be35['query'][_0x6cf8('0x28')]);}return _0xcb790a[_0x6cf8('0x55')](_0x349618);}})[_0x6cf8('0x1b')](function(_0x38e534){if(_0x38e534){return _0x38e534?{'count':_0x2ef07a,'rows':_0x38e534}:null;}})[_0x6cf8('0x1b')](respondWithResult(_0x3ee4b5,null))['catch'](handleError(_0x3ee4b5,null));};exports[_0x6cf8('0x5a')]=function(_0x5e22da,_0x843641,_0x5f4500){if(_0x5e22da[_0x6cf8('0x54')]['id']){delete _0x5e22da['body']['id'];}return db['SalesforceAccount'][_0x6cf8('0x56')]({'where':{'id':_0x5e22da['params']['id']}})['then'](handleEntityNotFound(_0x843641,null))[_0x6cf8('0x1b')](function(_0x3cbf5e){if(_0x3cbf5e){_0x5e22da['body'][_0x6cf8('0x5b')]=_0x3cbf5e['id'];_0x5e22da[_0x6cf8('0x54')][_0x6cf8('0x5c')]=integrations[_0x6cf8('0x5d')](_0x5e22da['body'][_0x6cf8('0x5e')],_0x5e22da[_0x6cf8('0x54')]['type']);_0x5e22da[_0x6cf8('0x54')][_0x6cf8('0x5f')]=integrations[_0x6cf8('0x60')](_0x5e22da['body'][_0x6cf8('0x5e')],_0x5e22da[_0x6cf8('0x54')][_0x6cf8('0x39')]);return db[_0x6cf8('0x57')][_0x6cf8('0x53')](_0x5e22da[_0x6cf8('0x54')],{'include':[{'model':db[_0x6cf8('0x61')],'as':_0x6cf8('0x5c')},{'model':db['SalesforceField'],'as':_0x6cf8('0x5f')}]});}return null;})[_0x6cf8('0x1b')](respondWithResult(_0x843641,null))[_0x6cf8('0x23')](handleError(_0x843641,null));};exports[_0x6cf8('0x62')]=function(_0x5d0bed,_0x5c76a4,_0x26388d){var _0xa3d4c7;var _0x281a03='';var _0x144b0d='Task';return db[_0x6cf8('0x36')][_0x6cf8('0x56')]({'where':{'id':_0x5d0bed[_0x6cf8('0x4f')]['id']},'attributes':['id',_0x6cf8('0x63'),_0x6cf8('0x64'),'clientSecret',_0x6cf8('0x65'),_0x6cf8('0x66'),_0x6cf8('0x67')]})[_0x6cf8('0x1b')](handleEntityNotFound(_0x5c76a4,null))['then'](function(_0x32b258){if(_0x32b258){_0x281a03=_0x32b258[_0x6cf8('0x63')];var _0x11f769=_0x281a03[_0x6cf8('0x68')](-0x1);if(_0x11f769==='/'){_0x281a03=_0x281a03[_0x6cf8('0x69')](0x0,_0x281a03[_0x6cf8('0x6a')](_0x11f769));}_0xa3d4c7=new jsforce[(_0x6cf8('0x6b'))]({'oauth2':{'loginUrl':_0x281a03,'clientId':_0x32b258[_0x6cf8('0x64')],'clientSecret':_0x32b258[_0x6cf8('0x6c')]}});return _0xa3d4c7[_0x6cf8('0x6d')](_0x32b258['username'],_0x32b258[_0x6cf8('0x66')][_0x6cf8('0x6e')](_0x32b258['securityToken']));}})[_0x6cf8('0x1b')](function(_0x568255){if(_0x568255){if(!_[_0x6cf8('0x6f')](_0x5d0bed[_0x6cf8('0x3c')][_0x6cf8('0x70')])){_0x144b0d=_0x5d0bed['query'][_0x6cf8('0x70')];}return _0xa3d4c7[_0x6cf8('0x71')](_0x144b0d)['describe']();}})[_0x6cf8('0x1b')](function(_0x4d0037){var _0xd28896=[_0x6cf8('0x72'),_0x6cf8('0x73'),_0x6cf8('0x74'),_0x6cf8('0x75'),_0x6cf8('0x76'),_0x6cf8('0x77'),_0x6cf8('0x78'),'Type'];if(!_[_0x6cf8('0x6f')](_0x5d0bed[_0x6cf8('0x3c')][_0x6cf8('0x70')])&&_0x5d0bed[_0x6cf8('0x3c')][_0x6cf8('0x70')]===_0x6cf8('0x79')){_0xd28896=[_0x6cf8('0x7a'),_0x6cf8('0x7b'),_0x6cf8('0x7c'),_0x6cf8('0x78'),_0x6cf8('0x77'),_0x6cf8('0x7d'),_0x6cf8('0x7e'),_0x6cf8('0x7f')];}if(_0x4d0037){_['remove'](_0x4d0037[_0x6cf8('0x41')],function(_0x3f202d){return _0x3f202d[_0x6cf8('0x80')]===![]&&!_0xd28896['includes'](_0x3f202d[_0x6cf8('0x32')]);});return{'count':_0x4d0037[_0x6cf8('0x41')]['length'],'rows':_[_0x6cf8('0x35')](_0x4d0037[_0x6cf8('0x41')],function(_0x433fa4){return{'id':_0x433fa4['name'],'name':_0x433fa4[_0x6cf8('0x81')],'custom':_0x433fa4['custom'],'options':_0x433fa4[_0x6cf8('0x82')]['length']>0x0?_[_0x6cf8('0x35')](_0x433fa4['picklistValues'],function(_0x306c0b){return{'name':_0x306c0b[_0x6cf8('0x81')],'value':_0x306c0b['value']};}):_0x433fa4[_0x6cf8('0x39')]=='boolean'?[{'name':_0x6cf8('0x83'),'value':_0x6cf8('0x84')},{'name':'False','value':'false'}]:[]};})};}})['then'](respondWithResult(_0x5c76a4,null))[_0x6cf8('0x23')](function(_0x5a4bf4){var _0x25a09d=_0x5d0bed[_0x6cf8('0x3c')][_0x6cf8('0x85')]?0x1f4:_0x5a4bf4['statusCode']||0x1f4;logger[_0x6cf8('0x21')]('getFields,\x20%s,\x20%s,\x20%s','getFields',_0x25a09d,JSON[_0x6cf8('0x86')](_0x5a4bf4));delete _0x5a4bf4[_0x6cf8('0x32')];if(_0x25a09d===0x191){_0x25a09d=0x190;}_0x5c76a4[_0x6cf8('0x25')](_0x25a09d)[_0x6cf8('0x33')](_0x5d0bed[_0x6cf8('0x3c')][_0x6cf8('0x85')]?{'message':_0x6cf8('0x87'),'statusCode':_0x5a4bf4[_0x6cf8('0x88')]}:_0x5a4bf4);});};
\ No newline at end of file
+var _0xa327=['label','custom','picklistValues','value','True','true','False','false','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','eml-format','zip-dir','fast-json-patch','moment','path','to-csv','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','set','Content-Range','apply','reject','update','then','error','stack','name','send','index','map','SalesforceAccount','type','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','catch','params','rawAttributes','options','create','body','destroy','getConfigurations','findOne','SalesforceConfiguration','addConfiguration','Subjects','getSubjects','channel','SalesforceField','getFields','Task','clientSecret','password','securityToken','remoteUri','slice','substring','lastIndexOf','Connection','login','ticketType','sobject','ActivityDate','IsReminderSet','IsRecurrence','Description','string','int','picklist','boolean','textarea','remove','includes'];(function(_0x7261e6,_0x3e3bf7){var _0x20d5ed=function(_0x522641){while(--_0x522641){_0x7261e6['push'](_0x7261e6['shift']());}};_0x20d5ed(++_0x3e3bf7);}(_0xa327,0x166));var _0x7a32=function(_0x139888,_0x186d9a){_0x139888=_0x139888-0x0;var _0x3fc0d6=_0xa327[_0x139888];return _0x3fc0d6;};'use strict';var emlformat=require(_0x7a32('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x7a32('0x1'));var jsonpatch=require(_0x7a32('0x2'));var rp=require('request-promise');var moment=require(_0x7a32('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x7a32('0x4'));var sox=require('sox');var csv=require(_0x7a32('0x5'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x7a32('0x6'));var _=require('lodash');var squel=require(_0x7a32('0x7'));var crypto=require(_0x7a32('0x8'));var jsforce=require(_0x7a32('0x9'));var deskjs=require(_0x7a32('0xa'));var toCsv=require(_0x7a32('0x5'));var querystring=require(_0x7a32('0xb'));var Papa=require(_0x7a32('0xc'));var Redis=require('ioredis');var authService=require(_0x7a32('0xd'));var qs=require(_0x7a32('0xe'));var as=require(_0x7a32('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7a32('0x10'))(_0x7a32('0x11'));var utils=require(_0x7a32('0x12'));var config=require(_0x7a32('0x13'));var licenseUtil=require(_0x7a32('0x14'));var db=require(_0x7a32('0x15'))['db'];var integrations=require('../../components/integrations/configuration');function respondWithStatusCode(_0x212ba4,_0x3cb622){_0x3cb622=_0x3cb622||0xcc;return function(_0x44e4a4){if(_0x44e4a4){return _0x212ba4[_0x7a32('0x16')](_0x3cb622);}return _0x212ba4[_0x7a32('0x17')](_0x3cb622)[_0x7a32('0x18')]();};}function respondWithResult(_0x248616,_0x3d8274){_0x3d8274=_0x3d8274||0xc8;return function(_0x482502){if(_0x482502){return _0x248616[_0x7a32('0x17')](_0x3d8274)[_0x7a32('0x19')](_0x482502);}};}function respondWithFilteredResult(_0x247425,_0x510f27){return function(_0x2270cb){if(_0x2270cb){var _0x191f8c=typeof _0x510f27[_0x7a32('0x1a')]==='undefined'&&typeof _0x510f27['limit']===_0x7a32('0x1b');var _0x4394c3=_0x2270cb[_0x7a32('0x1c')];var _0x206a83=_0x191f8c?0x0:_0x510f27['offset'];var _0x337971=_0x191f8c?_0x2270cb[_0x7a32('0x1c')]:_0x510f27[_0x7a32('0x1a')]+_0x510f27['limit'];var _0x52f070;if(_0x337971>=_0x4394c3){_0x337971=_0x4394c3;_0x52f070=0xc8;}else{_0x52f070=0xce;}_0x247425['status'](_0x52f070);return _0x247425[_0x7a32('0x1d')](_0x7a32('0x1e'),_0x206a83+'-'+_0x337971+'/'+_0x4394c3)[_0x7a32('0x19')](_0x2270cb);}return null;};}function patchUpdates(_0xf71cb5){return function(_0x5625c1){try{jsonpatch[_0x7a32('0x1f')](_0x5625c1,_0xf71cb5,!![]);}catch(_0xf66abb){return BPromise[_0x7a32('0x20')](_0xf66abb);}return _0x5625c1['save']();};}function saveUpdates(_0x41d3aa,_0x582a9a){return function(_0x297a6d){if(_0x297a6d){return _0x297a6d[_0x7a32('0x21')](_0x41d3aa)[_0x7a32('0x22')](function(_0x8acf3){return _0x8acf3;});}return null;};}function removeEntity(_0x288c4a,_0x1808ec){return function(_0x8d9418){if(_0x8d9418){return _0x8d9418['destroy']()['then'](function(){_0x288c4a[_0x7a32('0x17')](0xcc)[_0x7a32('0x18')]();});}};}function handleEntityNotFound(_0x2755f0,_0x43ecfc){return function(_0xeebc68){if(!_0xeebc68){_0x2755f0[_0x7a32('0x16')](0x194);}return _0xeebc68;};}function handleError(_0x34a898,_0x272a10){_0x272a10=_0x272a10||0x1f4;return function(_0x5ed400){logger[_0x7a32('0x23')](_0x5ed400[_0x7a32('0x24')]);if(_0x5ed400[_0x7a32('0x25')]){delete _0x5ed400[_0x7a32('0x25')];}_0x34a898[_0x7a32('0x17')](_0x272a10)[_0x7a32('0x26')](_0x5ed400);};}exports[_0x7a32('0x27')]=function(_0x571983,_0x1d02ce){var _0x4c27e5={},_0x2faf08={},_0x22cac4={'count':0x0,'rows':[]};var _0xc82021=_[_0x7a32('0x28')](db[_0x7a32('0x29')]['rawAttributes'],function(_0x17bd2a){return{'name':_0x17bd2a['fieldName'],'type':_0x17bd2a[_0x7a32('0x2a')]['key']};});_0x2faf08[_0x7a32('0x2b')]=_[_0x7a32('0x28')](_0xc82021,_0x7a32('0x25'));_0x2faf08[_0x7a32('0x2c')]=_[_0x7a32('0x2d')](_0x571983[_0x7a32('0x2c')]);_0x2faf08['filters']=_[_0x7a32('0x2e')](_0x2faf08[_0x7a32('0x2b')],_0x2faf08[_0x7a32('0x2c')]);_0x4c27e5['attributes']=_[_0x7a32('0x2e')](_0x2faf08[_0x7a32('0x2b')],qs[_0x7a32('0x2f')](_0x571983[_0x7a32('0x2c')][_0x7a32('0x2f')]));_0x4c27e5[_0x7a32('0x30')]=_0x4c27e5[_0x7a32('0x30')][_0x7a32('0x31')]?_0x4c27e5[_0x7a32('0x30')]:_0x2faf08[_0x7a32('0x2b')];if(!_0x571983[_0x7a32('0x2c')][_0x7a32('0x32')](_0x7a32('0x33'))){_0x4c27e5['limit']=qs['limit'](_0x571983['query'][_0x7a32('0x34')]);_0x4c27e5['offset']=qs[_0x7a32('0x1a')](_0x571983['query']['offset']);}_0x4c27e5[_0x7a32('0x35')]=qs[_0x7a32('0x36')](_0x571983['query'][_0x7a32('0x36')]);_0x4c27e5[_0x7a32('0x37')]=qs[_0x7a32('0x38')](_[_0x7a32('0x39')](_0x571983[_0x7a32('0x2c')],_0x2faf08[_0x7a32('0x38')]),_0xc82021);if(_0x571983[_0x7a32('0x2c')][_0x7a32('0x3a')]){_0x4c27e5[_0x7a32('0x37')]=_[_0x7a32('0x3b')](_0x4c27e5['where'],{'$or':_[_0x7a32('0x28')](_0xc82021,function(_0x50e433){if(_0x50e433[_0x7a32('0x2a')]!==_0x7a32('0x3c')){var _0x4f7ce2={};_0x4f7ce2[_0x50e433[_0x7a32('0x25')]]={'$like':'%'+_0x571983['query'][_0x7a32('0x3a')]+'%'};return _0x4f7ce2;}})});}_0x4c27e5=_[_0x7a32('0x3b')]({},_0x4c27e5,_0x571983['options']);var _0x9a471a={'where':_0x4c27e5['where']};return db[_0x7a32('0x29')][_0x7a32('0x1c')](_0x9a471a)['then'](function(_0x163c74){_0x22cac4['count']=_0x163c74;if(_0x571983[_0x7a32('0x2c')][_0x7a32('0x3d')]){_0x4c27e5[_0x7a32('0x3e')]=[{'all':!![]}];}return db[_0x7a32('0x29')]['findAll'](_0x4c27e5);})['then'](function(_0x26568f){_0x22cac4['rows']=_0x26568f;return _0x22cac4;})[_0x7a32('0x22')](respondWithFilteredResult(_0x1d02ce,_0x4c27e5))[_0x7a32('0x3f')](handleError(_0x1d02ce,null));};exports['show']=function(_0x3f0f2a,_0x455793){var _0x1a358c={'raw':![],'where':{'id':_0x3f0f2a[_0x7a32('0x40')]['id']}},_0x4f7c92={};_0x4f7c92[_0x7a32('0x2b')]=_[_0x7a32('0x2d')](db[_0x7a32('0x29')][_0x7a32('0x41')]);_0x4f7c92[_0x7a32('0x2c')]=_[_0x7a32('0x2d')](_0x3f0f2a[_0x7a32('0x2c')]);_0x4f7c92[_0x7a32('0x38')]=_[_0x7a32('0x2e')](_0x4f7c92['model'],_0x4f7c92[_0x7a32('0x2c')]);_0x1a358c[_0x7a32('0x30')]=_[_0x7a32('0x2e')](_0x4f7c92[_0x7a32('0x2b')],qs[_0x7a32('0x2f')](_0x3f0f2a[_0x7a32('0x2c')][_0x7a32('0x2f')]));_0x1a358c[_0x7a32('0x30')]=_0x1a358c[_0x7a32('0x30')][_0x7a32('0x31')]?_0x1a358c[_0x7a32('0x30')]:_0x4f7c92['model'];if(_0x3f0f2a['query'][_0x7a32('0x3d')]){_0x1a358c[_0x7a32('0x3e')]=[{'all':!![]}];}_0x1a358c=_['merge']({},_0x1a358c,_0x3f0f2a[_0x7a32('0x42')]);return db[_0x7a32('0x29')]['find'](_0x1a358c)[_0x7a32('0x22')](handleEntityNotFound(_0x455793,null))['then'](respondWithResult(_0x455793,null))['catch'](handleError(_0x455793,null));};exports[_0x7a32('0x43')]=function(_0x31ea14,_0x1f25d6){return db[_0x7a32('0x29')][_0x7a32('0x43')](_0x31ea14['body'],{})[_0x7a32('0x22')](respondWithResult(_0x1f25d6,0xc9))[_0x7a32('0x3f')](handleError(_0x1f25d6,null));};exports[_0x7a32('0x21')]=function(_0xed660a,_0x8ddc7e){if(_0xed660a[_0x7a32('0x44')]['id']){delete _0xed660a[_0x7a32('0x44')]['id'];}return db['SalesforceAccount']['find']({'where':{'id':_0xed660a[_0x7a32('0x40')]['id']}})['then'](handleEntityNotFound(_0x8ddc7e,null))[_0x7a32('0x22')](saveUpdates(_0xed660a[_0x7a32('0x44')],null))['then'](respondWithResult(_0x8ddc7e,null))[_0x7a32('0x3f')](handleError(_0x8ddc7e,null));};exports[_0x7a32('0x45')]=function(_0x1f6bb6,_0x4a9de5){return db[_0x7a32('0x29')]['find']({'where':{'id':_0x1f6bb6[_0x7a32('0x40')]['id']}})['then'](handleEntityNotFound(_0x4a9de5,null))[_0x7a32('0x22')](removeEntity(_0x4a9de5,null))[_0x7a32('0x3f')](handleError(_0x4a9de5,null));};exports[_0x7a32('0x46')]=function(_0x4fa56f,_0x41c643,_0x323c24){var _0x3656bd={};var _0x2c8518={};var _0x5441aa;var _0x4d90be;return db[_0x7a32('0x29')][_0x7a32('0x47')]({'where':{'id':_0x4fa56f[_0x7a32('0x40')]['id']}})['then'](handleEntityNotFound(_0x41c643,null))[_0x7a32('0x22')](function(_0xb07ac9){if(_0xb07ac9){_0x5441aa=_0xb07ac9;_0x2c8518[_0x7a32('0x2b')]=_[_0x7a32('0x2d')](db[_0x7a32('0x48')][_0x7a32('0x41')]);_0x2c8518[_0x7a32('0x2c')]=_[_0x7a32('0x2d')](_0x4fa56f['query']);_0x2c8518[_0x7a32('0x38')]=_['intersection'](_0x2c8518[_0x7a32('0x2b')],_0x2c8518['query']);_0x3656bd[_0x7a32('0x30')]=_[_0x7a32('0x2e')](_0x2c8518[_0x7a32('0x2b')],qs['fields'](_0x4fa56f[_0x7a32('0x2c')]['fields']));_0x3656bd['attributes']=_0x3656bd['attributes'][_0x7a32('0x31')]?_0x3656bd[_0x7a32('0x30')]:_0x2c8518[_0x7a32('0x2b')];_0x3656bd[_0x7a32('0x35')]=qs[_0x7a32('0x36')](_0x4fa56f[_0x7a32('0x2c')][_0x7a32('0x36')]);_0x3656bd[_0x7a32('0x37')]=qs[_0x7a32('0x38')](_[_0x7a32('0x39')](_0x4fa56f['query'],_0x2c8518[_0x7a32('0x38')]));if(_0x4fa56f['query'][_0x7a32('0x3a')]){_0x3656bd[_0x7a32('0x37')]=_[_0x7a32('0x3b')](_0x3656bd[_0x7a32('0x37')],{'$or':_[_0x7a32('0x28')](_0x3656bd[_0x7a32('0x30')],function(_0x534c6c){var _0x12f397={};_0x12f397[_0x534c6c]={'$like':'%'+_0x4fa56f['query'][_0x7a32('0x3a')]+'%'};return _0x12f397;})});}_0x3656bd=_[_0x7a32('0x3b')]({},_0x3656bd,_0x4fa56f['options']);return _0x5441aa['getConfigurations'](_0x3656bd);}})[_0x7a32('0x22')](function(_0x4b81d9){if(_0x4b81d9){_0x4d90be=_0x4b81d9[_0x7a32('0x31')];if(!_0x4fa56f[_0x7a32('0x2c')][_0x7a32('0x32')](_0x7a32('0x33'))){_0x3656bd[_0x7a32('0x34')]=qs[_0x7a32('0x34')](_0x4fa56f['query'][_0x7a32('0x34')]);_0x3656bd[_0x7a32('0x1a')]=qs[_0x7a32('0x1a')](_0x4fa56f['query'][_0x7a32('0x1a')]);}return _0x5441aa[_0x7a32('0x46')](_0x3656bd);}})[_0x7a32('0x22')](function(_0x4ca7bf){if(_0x4ca7bf){return _0x4ca7bf?{'count':_0x4d90be,'rows':_0x4ca7bf}:null;}})[_0x7a32('0x22')](respondWithResult(_0x41c643,null))[_0x7a32('0x3f')](handleError(_0x41c643,null));};exports[_0x7a32('0x49')]=function(_0x3d615c,_0x4e7aa1,_0x3b728e){if(_0x3d615c['body']['id']){delete _0x3d615c['body']['id'];}return db[_0x7a32('0x29')][_0x7a32('0x47')]({'where':{'id':_0x3d615c['params']['id']}})[_0x7a32('0x22')](handleEntityNotFound(_0x4e7aa1,null))['then'](function(_0x116e0d){if(_0x116e0d){_0x3d615c[_0x7a32('0x44')]['AccountId']=_0x116e0d['id'];_0x3d615c[_0x7a32('0x44')][_0x7a32('0x4a')]=integrations[_0x7a32('0x4b')](_0x3d615c[_0x7a32('0x44')]['channel'],_0x3d615c[_0x7a32('0x44')][_0x7a32('0x2a')]);_0x3d615c[_0x7a32('0x44')]['Descriptions']=integrations['getDescriptions'](_0x3d615c[_0x7a32('0x44')][_0x7a32('0x4c')],_0x3d615c['body'][_0x7a32('0x2a')]);return db[_0x7a32('0x48')][_0x7a32('0x43')](_0x3d615c[_0x7a32('0x44')],{'include':[{'model':db[_0x7a32('0x4d')],'as':'Subjects'},{'model':db[_0x7a32('0x4d')],'as':'Descriptions'}]});}return null;})[_0x7a32('0x22')](respondWithResult(_0x4e7aa1,null))[_0x7a32('0x3f')](handleError(_0x4e7aa1,null));};exports[_0x7a32('0x4e')]=function(_0x5193ef,_0x572e15,_0x31a158){var _0x30a47d;var _0x5e518d='';var _0x174808=_0x7a32('0x4f');return db[_0x7a32('0x29')][_0x7a32('0x47')]({'where':{'id':_0x5193ef[_0x7a32('0x40')]['id']},'attributes':['id','remoteUri','clientId',_0x7a32('0x50'),'username',_0x7a32('0x51'),_0x7a32('0x52')]})[_0x7a32('0x22')](handleEntityNotFound(_0x572e15,null))[_0x7a32('0x22')](function(_0x1c2f13){if(_0x1c2f13){_0x5e518d=_0x1c2f13[_0x7a32('0x53')];var _0x326452=_0x5e518d[_0x7a32('0x54')](-0x1);if(_0x326452==='/'){_0x5e518d=_0x5e518d[_0x7a32('0x55')](0x0,_0x5e518d[_0x7a32('0x56')](_0x326452));}_0x30a47d=new jsforce[(_0x7a32('0x57'))]({'oauth2':{'loginUrl':_0x5e518d,'clientId':_0x1c2f13['clientId'],'clientSecret':_0x1c2f13['clientSecret']}});return _0x30a47d[_0x7a32('0x58')](_0x1c2f13['username'],_0x1c2f13[_0x7a32('0x51')]['concat'](_0x1c2f13[_0x7a32('0x52')]));}})[_0x7a32('0x22')](function(_0x25afb){if(_0x25afb){if(!_['isNil'](_0x5193ef['query'][_0x7a32('0x59')])){_0x174808=_0x5193ef[_0x7a32('0x2c')][_0x7a32('0x59')];}return _0x30a47d[_0x7a32('0x5a')](_0x174808)['describe']();}})[_0x7a32('0x22')](function(_0xbdab85){var _0x2526a5=['OwnerId',_0x7a32('0x5b'),_0x7a32('0x5c'),_0x7a32('0x5d'),'Subject',_0x7a32('0x5e')];var _0x41eda7=[_0x7a32('0x5f'),_0x7a32('0x60'),_0x7a32('0x61'),_0x7a32('0x62'),'email',_0x7a32('0x63'),'phone'];if(_0xbdab85){_[_0x7a32('0x64')](_0xbdab85[_0x7a32('0x2f')],function(_0x1143e2){return _0x2526a5[_0x7a32('0x65')](_0x1143e2[_0x7a32('0x25')])||!_0x41eda7[_0x7a32('0x65')](_0x1143e2['type']);});return{'count':_0xbdab85[_0x7a32('0x2f')][_0x7a32('0x31')],'rows':_[_0x7a32('0x28')](_0xbdab85[_0x7a32('0x2f')],function(_0x4b5198){return{'id':_0x4b5198[_0x7a32('0x25')],'name':_0x4b5198[_0x7a32('0x66')],'custom':_0x4b5198[_0x7a32('0x67')],'options':_0x4b5198[_0x7a32('0x68')][_0x7a32('0x31')]>0x0?_[_0x7a32('0x28')](_0x4b5198['picklistValues'],function(_0x511ce4){return{'name':_0x511ce4[_0x7a32('0x66')],'value':_0x511ce4[_0x7a32('0x69')]};}):_0x4b5198['type']==_0x7a32('0x62')?[{'name':_0x7a32('0x6a'),'value':_0x7a32('0x6b')},{'name':_0x7a32('0x6c'),'value':_0x7a32('0x6d')}]:[]};})};}})[_0x7a32('0x22')](respondWithResult(_0x572e15,null))[_0x7a32('0x3f')](function(_0x4504d6){var _0x2594e6=_0x5193ef[_0x7a32('0x2c')][_0x7a32('0x6e')]?0x1f4:_0x4504d6[_0x7a32('0x6f')]||0x1f4;logger[_0x7a32('0x23')](_0x7a32('0x70'),_0x7a32('0x4e'),_0x2594e6,JSON[_0x7a32('0x71')](_0x4504d6));delete _0x4504d6[_0x7a32('0x25')];if(_0x2594e6===0x191){_0x2594e6=0x190;}_0x572e15['status'](_0x2594e6)[_0x7a32('0x26')](_0x5193ef['query'][_0x7a32('0x6e')]?{'message':_0x7a32('0x72'),'statusCode':_0x4504d6[_0x7a32('0x6f')]}:_0x4504d6);});};
\ No newline at end of file