Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 8a7482d..8008278 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb792=['api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','SugarcrmAccount,\x20%s,\x20%s','message','result','sendStatus','end','status','offset','limit','set','Content-Range','json','save','destroy','stack','name','send','map','SugarcrmAccount','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','nolimit','sort','where','merge','filter','count','includeAll','include','findAll','rows','catch','show','params','length','options','find','create','body','update','getConfigurations','findOne','pick','hasOwnProperty','addConfiguration','channel','Descriptions','getDescriptions','SugarcrmConfiguration','SugarcrmField','Subjects','getFields','created_by','description','date_start','duration_minutes','parent_id','parent_name','username','remoteUri','slice','substring','lastIndexOf','POST','format','/service/v4_1/rest.php','login','JSON','password','PLAIN','xCALLY\x20Motion\x20Integration','Invalid\x20Login','Password\x20Expired','%s%s','module_fields','remove','includes','label','endsWith','value','getFields,\x20%s,\x20%s,\x20%s','statusCode','Wrong\x20credentials','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger'];(function(_0x30b942,_0x5198f0){var _0x3d486d=function(_0x429cc7){while(--_0x429cc7){_0x30b942['push'](_0x30b942['shift']());}};_0x3d486d(++_0x5198f0);}(_0xb792,0xef));var _0x2b79=function(_0x578ebe,_0x5b6b8f){_0x578ebe=_0x578ebe-0x0;var _0x1a93b8=_0xb792[_0x578ebe];return _0x1a93b8;};'use strict';var pdf=require(_0x2b79('0x0'));var emlformat=require(_0x2b79('0x1'));var rimraf=require(_0x2b79('0x2'));var zipdir=require(_0x2b79('0x3'));var jsonpatch=require(_0x2b79('0x4'));var rp=require('request-promise');var moment=require(_0x2b79('0x5'));var BPromise=require(_0x2b79('0x6'));var Mustache=require(_0x2b79('0x7'));var util=require(_0x2b79('0x8'));var path=require(_0x2b79('0x9'));var sox=require(_0x2b79('0xa'));var csv=require('to-csv');var ejs=require(_0x2b79('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x2b79('0xc'));var crypto=require('crypto');var jsforce=require(_0x2b79('0xd'));var deskjs=require(_0x2b79('0xe'));var toCsv=require(_0x2b79('0xf'));var querystring=require(_0x2b79('0x10'));var Papa=require(_0x2b79('0x11'));var Redis=require(_0x2b79('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x2b79('0x13'));var as=require(_0x2b79('0x14'));var hardwareService=require(_0x2b79('0x15'));var logger=require(_0x2b79('0x16'))(_0x2b79('0x17'));var utils=require(_0x2b79('0x18'));var config=require(_0x2b79('0x19'));var licenseUtil=require(_0x2b79('0x1a'));var db=require(_0x2b79('0x1b'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require(_0x2b79('0x1c'));var client=jayson[_0x2b79('0x1d')][_0x2b79('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x5f1bd7,_0x53f9dc,_0x56ab59,_0x391493){return new BPromise(function(_0x2b29f1,_0x4251f1){var _0x39c8d3=_0x391493||client;return _0x39c8d3[_0x2b79('0x1f')](_0x5f1bd7,_0x56ab59)[_0x2b79('0x20')](function(_0x4e832c){logger[_0x2b79('0x21')]('SugarcrmAccount,\x20%s,\x20%s',_0x53f9dc,'request\x20sent');logger[_0x2b79('0x22')](_0x2b79('0x23'),_0x53f9dc,_0x2b79('0x24'),JSON[_0x2b79('0x25')](_0x4e832c));if(_0x4e832c[_0x2b79('0x26')]){if(_0x4e832c['error'][_0x2b79('0x27')]===0x1f4){logger[_0x2b79('0x26')](_0x2b79('0x28'),_0x53f9dc,_0x4e832c[_0x2b79('0x26')]['message']);return _0x4251f1(_0x4e832c[_0x2b79('0x26')][_0x2b79('0x29')]);}logger[_0x2b79('0x26')](_0x2b79('0x28'),_0x53f9dc,_0x4e832c['error'][_0x2b79('0x29')]);return _0x2b29f1(_0x4e832c['error'][_0x2b79('0x29')]);}else{logger[_0x2b79('0x21')](_0x2b79('0x28'),_0x53f9dc,'request\x20sent');_0x2b29f1(_0x4e832c[_0x2b79('0x2a')][_0x2b79('0x29')]);}})['catch'](function(_0x21e076){logger[_0x2b79('0x26')](_0x2b79('0x28'),_0x53f9dc,_0x21e076);_0x4251f1(_0x21e076);});});}function respondWithStatusCode(_0x2bc961,_0x2fc2a7){_0x2fc2a7=_0x2fc2a7||0xcc;return function(_0x2a1e9e){if(_0x2a1e9e){return _0x2bc961[_0x2b79('0x2b')](_0x2fc2a7);}return _0x2bc961['status'](_0x2fc2a7)[_0x2b79('0x2c')]();};}function respondWithResult(_0x2f5140,_0x4c8094){_0x4c8094=_0x4c8094||0xc8;return function(_0x52a1a4){if(_0x52a1a4){return _0x2f5140[_0x2b79('0x2d')](_0x4c8094)['json'](_0x52a1a4);}};}function respondWithFilteredResult(_0x54521c,_0x260172){return function(_0xed557c){if(_0xed557c){var _0x41866d=_0xed557c['count'],_0x51a552=_0x260172[_0x2b79('0x2e')],_0x1b74cd=_0x260172[_0x2b79('0x2e')]+_0x260172[_0x2b79('0x2f')],_0x33f301;if(_0x1b74cd>=_0x41866d){_0x1b74cd=_0x41866d;_0x33f301=0xc8;}else{_0x33f301=0xce;}_0x54521c[_0x2b79('0x2d')](_0x33f301);return _0x54521c[_0x2b79('0x30')](_0x2b79('0x31'),_0x51a552+'-'+_0x1b74cd+'/'+_0x41866d)[_0x2b79('0x32')](_0xed557c);}return null;};}function patchUpdates(_0x109c0f){return function(_0x1b7079){try{jsonpatch['apply'](_0x1b7079,_0x109c0f,!![]);}catch(_0x14b1c7){return BPromise['reject'](_0x14b1c7);}return _0x1b7079[_0x2b79('0x33')]();};}function saveUpdates(_0x27b83e,_0x41eb36){return function(_0x22ccb0){if(_0x22ccb0){return _0x22ccb0['update'](_0x27b83e)[_0x2b79('0x20')](function(_0x32be9d){return _0x32be9d;});}return null;};}function removeEntity(_0xfbaa45,_0x2f1987){return function(_0x1d1b85){if(_0x1d1b85){return _0x1d1b85[_0x2b79('0x34')]()[_0x2b79('0x20')](function(){_0xfbaa45[_0x2b79('0x2d')](0xcc)['end']();});}};}function handleEntityNotFound(_0xfa1412,_0x20bb1c){return function(_0x1fe1f6){if(!_0x1fe1f6){_0xfa1412[_0x2b79('0x2b')](0x194);}return _0x1fe1f6;};}function handleError(_0x3958f5,_0x3b2853){_0x3b2853=_0x3b2853||0x1f4;return function(_0x510f85){logger[_0x2b79('0x26')](_0x510f85[_0x2b79('0x35')]);if(_0x510f85[_0x2b79('0x36')]){delete _0x510f85[_0x2b79('0x36')];}_0x3958f5['status'](_0x3b2853)[_0x2b79('0x37')](_0x510f85);};}exports['index']=function(_0x769f3a,_0x37472e){var _0x41ff1a={},_0x4ef994={},_0x5761cd={'count':0x0,'rows':[]};var _0x2656b2=_[_0x2b79('0x38')](db[_0x2b79('0x39')][_0x2b79('0x3a')],function(_0x4544fe){return{'name':_0x4544fe[_0x2b79('0x3b')],'type':_0x4544fe[_0x2b79('0x3c')][_0x2b79('0x3d')]};});_0x4ef994[_0x2b79('0x3e')]=_[_0x2b79('0x38')](_0x2656b2,_0x2b79('0x36'));_0x4ef994[_0x2b79('0x3f')]=_[_0x2b79('0x40')](_0x769f3a[_0x2b79('0x3f')]);_0x4ef994[_0x2b79('0x41')]=_[_0x2b79('0x42')](_0x4ef994[_0x2b79('0x3e')],_0x4ef994[_0x2b79('0x3f')]);_0x41ff1a['attributes']=_[_0x2b79('0x42')](_0x4ef994[_0x2b79('0x3e')],qs['fields'](_0x769f3a[_0x2b79('0x3f')][_0x2b79('0x43')]));_0x41ff1a[_0x2b79('0x44')]=_0x41ff1a[_0x2b79('0x44')]['length']?_0x41ff1a['attributes']:_0x4ef994[_0x2b79('0x3e')];if(!_0x769f3a['query']['hasOwnProperty'](_0x2b79('0x45'))){_0x41ff1a['limit']=qs['limit'](_0x769f3a[_0x2b79('0x3f')][_0x2b79('0x2f')]);_0x41ff1a[_0x2b79('0x2e')]=qs[_0x2b79('0x2e')](_0x769f3a[_0x2b79('0x3f')][_0x2b79('0x2e')]);}_0x41ff1a['order']=qs[_0x2b79('0x46')](_0x769f3a[_0x2b79('0x3f')][_0x2b79('0x46')]);_0x41ff1a[_0x2b79('0x47')]=qs[_0x2b79('0x41')](_['pick'](_0x769f3a[_0x2b79('0x3f')],_0x4ef994[_0x2b79('0x41')]),_0x2656b2);if(_0x769f3a[_0x2b79('0x3f')]['filter']){_0x41ff1a[_0x2b79('0x47')]=_[_0x2b79('0x48')](_0x41ff1a[_0x2b79('0x47')],{'$or':_['map'](_0x2656b2,function(_0x4abbb1){if(_0x4abbb1['type']!=='VIRTUAL'){var _0x48d57e={};_0x48d57e[_0x4abbb1[_0x2b79('0x36')]]={'$like':'%'+_0x769f3a['query'][_0x2b79('0x49')]+'%'};return _0x48d57e;}})});}_0x41ff1a=_['merge']({},_0x41ff1a,_0x769f3a['options']);var _0x536c72={'where':_0x41ff1a[_0x2b79('0x47')]};return db['SugarcrmAccount'][_0x2b79('0x4a')](_0x536c72)[_0x2b79('0x20')](function(_0x4d2948){_0x5761cd[_0x2b79('0x4a')]=_0x4d2948;if(_0x769f3a[_0x2b79('0x3f')][_0x2b79('0x4b')]){_0x41ff1a[_0x2b79('0x4c')]=[{'all':!![]}];}return db[_0x2b79('0x39')][_0x2b79('0x4d')](_0x41ff1a);})[_0x2b79('0x20')](function(_0x9edd7a){_0x5761cd[_0x2b79('0x4e')]=_0x9edd7a;return _0x5761cd;})[_0x2b79('0x20')](respondWithFilteredResult(_0x37472e,_0x41ff1a))[_0x2b79('0x4f')](handleError(_0x37472e,null));};exports[_0x2b79('0x50')]=function(_0x1418b2,_0x20f692){var _0x2eb975={'raw':![],'where':{'id':_0x1418b2[_0x2b79('0x51')]['id']}},_0xd718e0={};_0xd718e0[_0x2b79('0x3e')]=_['keys'](db[_0x2b79('0x39')][_0x2b79('0x3a')]);_0xd718e0[_0x2b79('0x3f')]=_[_0x2b79('0x40')](_0x1418b2[_0x2b79('0x3f')]);_0xd718e0[_0x2b79('0x41')]=_['intersection'](_0xd718e0[_0x2b79('0x3e')],_0xd718e0[_0x2b79('0x3f')]);_0x2eb975[_0x2b79('0x44')]=_[_0x2b79('0x42')](_0xd718e0[_0x2b79('0x3e')],qs[_0x2b79('0x43')](_0x1418b2[_0x2b79('0x3f')][_0x2b79('0x43')]));_0x2eb975['attributes']=_0x2eb975[_0x2b79('0x44')][_0x2b79('0x52')]?_0x2eb975[_0x2b79('0x44')]:_0xd718e0[_0x2b79('0x3e')];if(_0x1418b2[_0x2b79('0x3f')]['includeAll']){_0x2eb975['include']=[{'all':!![]}];}_0x2eb975=_[_0x2b79('0x48')]({},_0x2eb975,_0x1418b2[_0x2b79('0x53')]);return db[_0x2b79('0x39')][_0x2b79('0x54')](_0x2eb975)[_0x2b79('0x20')](handleEntityNotFound(_0x20f692,null))[_0x2b79('0x20')](respondWithResult(_0x20f692,null))[_0x2b79('0x4f')](handleError(_0x20f692,null));};exports['create']=function(_0x1164d,_0x51df90){return db[_0x2b79('0x39')][_0x2b79('0x55')](_0x1164d[_0x2b79('0x56')],{})['then'](respondWithResult(_0x51df90,0xc9))[_0x2b79('0x4f')](handleError(_0x51df90,null));};exports[_0x2b79('0x57')]=function(_0x280219,_0x10d0dd){if(_0x280219[_0x2b79('0x56')]['id']){delete _0x280219[_0x2b79('0x56')]['id'];}return db['SugarcrmAccount'][_0x2b79('0x54')]({'where':{'id':_0x280219['params']['id']}})[_0x2b79('0x20')](handleEntityNotFound(_0x10d0dd,null))[_0x2b79('0x20')](saveUpdates(_0x280219[_0x2b79('0x56')],null))[_0x2b79('0x20')](respondWithResult(_0x10d0dd,null))[_0x2b79('0x4f')](handleError(_0x10d0dd,null));};exports['destroy']=function(_0x38268b,_0x9f1b1a){return db['SugarcrmAccount']['find']({'where':{'id':_0x38268b[_0x2b79('0x51')]['id']}})['then'](handleEntityNotFound(_0x9f1b1a,null))[_0x2b79('0x20')](removeEntity(_0x9f1b1a,null))['catch'](handleError(_0x9f1b1a,null));};exports[_0x2b79('0x58')]=function(_0x32c484,_0x59d068,_0x4ec768){var _0x593a83={};var _0x4feef3={};var _0x3dc4a0;var _0x34b0e5;return db['SugarcrmAccount'][_0x2b79('0x59')]({'where':{'id':_0x32c484['params']['id']}})[_0x2b79('0x20')](handleEntityNotFound(_0x59d068,null))[_0x2b79('0x20')](function(_0x19fd32){if(_0x19fd32){_0x3dc4a0=_0x19fd32;_0x4feef3['model']=_[_0x2b79('0x40')](db['SugarcrmConfiguration'][_0x2b79('0x3a')]);_0x4feef3[_0x2b79('0x3f')]=_[_0x2b79('0x40')](_0x32c484[_0x2b79('0x3f')]);_0x4feef3[_0x2b79('0x41')]=_[_0x2b79('0x42')](_0x4feef3[_0x2b79('0x3e')],_0x4feef3[_0x2b79('0x3f')]);_0x593a83[_0x2b79('0x44')]=_[_0x2b79('0x42')](_0x4feef3['model'],qs[_0x2b79('0x43')](_0x32c484[_0x2b79('0x3f')][_0x2b79('0x43')]));_0x593a83[_0x2b79('0x44')]=_0x593a83[_0x2b79('0x44')][_0x2b79('0x52')]?_0x593a83[_0x2b79('0x44')]:_0x4feef3[_0x2b79('0x3e')];_0x593a83['order']=qs[_0x2b79('0x46')](_0x32c484[_0x2b79('0x3f')][_0x2b79('0x46')]);_0x593a83[_0x2b79('0x47')]=qs['filters'](_[_0x2b79('0x5a')](_0x32c484[_0x2b79('0x3f')],_0x4feef3[_0x2b79('0x41')]));if(_0x32c484['query'][_0x2b79('0x49')]){_0x593a83[_0x2b79('0x47')]=_[_0x2b79('0x48')](_0x593a83['where'],{'$or':_['map'](_0x593a83[_0x2b79('0x44')],function(_0x432f09){var _0x5a31eb={};_0x5a31eb[_0x432f09]={'$like':'%'+_0x32c484[_0x2b79('0x3f')][_0x2b79('0x49')]+'%'};return _0x5a31eb;})});}_0x593a83=_[_0x2b79('0x48')]({},_0x593a83,_0x32c484[_0x2b79('0x53')]);return _0x3dc4a0[_0x2b79('0x58')](_0x593a83);}})['then'](function(_0x2ce77b){if(_0x2ce77b){_0x34b0e5=_0x2ce77b['length'];if(!_0x32c484[_0x2b79('0x3f')][_0x2b79('0x5b')](_0x2b79('0x45'))){_0x593a83[_0x2b79('0x2f')]=qs['limit'](_0x32c484['query']['limit']);_0x593a83[_0x2b79('0x2e')]=qs[_0x2b79('0x2e')](_0x32c484[_0x2b79('0x3f')][_0x2b79('0x2e')]);}return _0x3dc4a0['getConfigurations'](_0x593a83);}})[_0x2b79('0x20')](function(_0x287348){if(_0x287348){return _0x287348?{'count':_0x34b0e5,'rows':_0x287348}:null;}})[_0x2b79('0x20')](respondWithResult(_0x59d068,null))['catch'](handleError(_0x59d068,null));};exports[_0x2b79('0x5c')]=function(_0x2c1bdb,_0x3e1936,_0x5aa23f){if(_0x2c1bdb[_0x2b79('0x56')]['id']){delete _0x2c1bdb['body']['id'];}return db[_0x2b79('0x39')][_0x2b79('0x59')]({'where':{'id':_0x2c1bdb[_0x2b79('0x51')]['id']}})[_0x2b79('0x20')](handleEntityNotFound(_0x3e1936,null))['then'](function(_0x5c0b5c){if(_0x5c0b5c){_0x2c1bdb[_0x2b79('0x56')]['AccountId']=_0x5c0b5c['id'];_0x2c1bdb[_0x2b79('0x56')]['Subjects']=integrations['getSubjects'](_0x2c1bdb[_0x2b79('0x56')][_0x2b79('0x5d')],_0x2c1bdb[_0x2b79('0x56')][_0x2b79('0x3c')]);_0x2c1bdb['body'][_0x2b79('0x5e')]=integrations[_0x2b79('0x5f')](_0x2c1bdb[_0x2b79('0x56')]['channel'],_0x2c1bdb[_0x2b79('0x56')][_0x2b79('0x3c')]);return db[_0x2b79('0x60')][_0x2b79('0x55')](_0x2c1bdb[_0x2b79('0x56')],{'include':[{'model':db[_0x2b79('0x61')],'as':_0x2b79('0x62')},{'model':db[_0x2b79('0x61')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x3e1936,null))[_0x2b79('0x4f')](handleError(_0x3e1936,null));};exports[_0x2b79('0x63')]=function(_0x9a6201,_0x3e7f94,_0x12bcca){var _0x2e23be='';var _0x3a9a6e=['id','name','assigned_user_id',_0x2b79('0x64'),_0x2b79('0x65'),_0x2b79('0x66'),'duration_hours',_0x2b79('0x67'),_0x2b79('0x68'),'parent_type',_0x2b79('0x69'),'direction'];return db[_0x2b79('0x39')][_0x2b79('0x59')]({'where':{'id':_0x9a6201[_0x2b79('0x51')]['id']},'attributes':['id',_0x2b79('0x6a'),'password',_0x2b79('0x6b')]})[_0x2b79('0x20')](handleEntityNotFound(_0x3e7f94,null))[_0x2b79('0x20')](function(_0x16da41){if(_0x16da41){_0x2e23be=_0x16da41['remoteUri'];var _0x3f8a57=_0x2e23be[_0x2b79('0x6c')](-0x1);if(_0x3f8a57==='/'){_0x2e23be=_0x2e23be[_0x2b79('0x6d')](0x0,_0x2e23be[_0x2b79('0x6e')](_0x3f8a57));}return rp({'method':_0x2b79('0x6f'),'uri':util[_0x2b79('0x70')]('%s%s',_0x2e23be,_0x2b79('0x71')),'json':!![],'form':{'method':_0x2b79('0x72'),'input_type':_0x2b79('0x73'),'response_type':_0x2b79('0x73'),'rest_data':JSON[_0x2b79('0x25')]({'user_auth':{'user_name':_0x16da41[_0x2b79('0x6a')],'password':_0x16da41[_0x2b79('0x74')],'encryption':_0x2b79('0x75')},'application':_0x2b79('0x76')})}});}})[_0x2b79('0x20')](function(_0x1328ab){if(_0x1328ab&&_0x1328ab[_0x2b79('0x36')]!==_0x2b79('0x77')&&_0x1328ab[_0x2b79('0x36')]!==_0x2b79('0x78')){return rp({'method':_0x2b79('0x6f'),'uri':util[_0x2b79('0x70')](_0x2b79('0x79'),_0x2e23be,_0x2b79('0x71')),'json':!![],'form':{'method':'get_module_fields','input_type':_0x2b79('0x73'),'response_type':'JSON','rest_data':JSON[_0x2b79('0x25')]({'session':_0x1328ab['id'],'module_name':'Calls'})}})[_0x2b79('0x20')](function(_0x363f2a){if(_0x363f2a){var _0x176bd4=_['values'](_0x363f2a[_0x2b79('0x7a')]);_[_0x2b79('0x7b')](_0x176bd4,function(_0xd7f9bb){return _0x3a9a6e[_0x2b79('0x7c')](_0xd7f9bb[_0x2b79('0x36')]);});return{'count':_0x176bd4[_0x2b79('0x52')],'rows':_[_0x2b79('0x38')](_0x176bd4,function(_0x33e473){return{'id':_0x33e473['name'],'name':_0x33e473[_0x2b79('0x7d')],'custom':_[_0x2b79('0x7e')](_0x33e473['name'],'_c')?!![]:![],'options':_0x33e473[_0x2b79('0x53')]?_[_0x2b79('0x38')](_['values'](_0x33e473[_0x2b79('0x53')]),function(_0x3b4708){return{'name':_0x3b4708[_0x2b79('0x7f')],'value':_0x3b4708[_0x2b79('0x36')]};}):[]};})};}})[_0x2b79('0x20')](respondWithResult(_0x3e7f94,null))['catch'](function(_0x81f5bf){var _0x3d6b86=_0x9a6201[_0x2b79('0x3f')]['test']?0x1f4:_0x81f5bf['statusCode']||0x1f4;logger[_0x2b79('0x26')](_0x2b79('0x80'),'getFields',_0x3d6b86,JSON[_0x2b79('0x25')](_0x81f5bf));delete _0x81f5bf[_0x2b79('0x36')];if(_0x3d6b86===0x191){_0x3d6b86=0x190;}_0x3e7f94[_0x2b79('0x2d')](_0x3d6b86)['send'](_0x9a6201[_0x2b79('0x3f')]['test']?{'message':'Wrong\x20credentials','statusCode':_0x81f5bf[_0x2b79('0x81')]}:_0x81f5bf);});}else{var _0x4ed12a=0x1f4;_0x3e7f94['status'](_0x4ed12a)[_0x2b79('0x37')]({'message':_0x2b79('0x82'),'statusCode':0x190});}});};
\ No newline at end of file
+var _0x2ac1=['parent_id','parent_name','direction','remoteUri','slice','substring','lastIndexOf','POST','format','%s%s','/service/v4_1/rest.php','login','JSON','stringify','username','password','xCALLY\x20Motion\x20Integration','Invalid\x20Login','Password\x20Expired','get_module_fields','Calls','module_fields','includes','values','value','statusCode','getFields,\x20%s,\x20%s,\x20%s','test','Wrong\x20credentials','zip-dir','fast-json-patch','request-promise','moment','mustache','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/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','status','end','json','offset','undefined','count','limit','set','save','update','then','sendStatus','error','stack','name','send','map','SugarcrmAccount','rawAttributes','fieldName','type','key','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','VIRTUAL','merge','options','findAll','rows','catch','includeAll','include','body','find','params','destroy','getConfigurations','findOne','SugarcrmConfiguration','pick','AccountId','Subjects','getSubjects','channel','getDescriptions','create','SugarcrmField','Descriptions','getFields','assigned_user_id','created_by','date_start','duration_minutes'];(function(_0x260771,_0x5148f){var _0x145d4d=function(_0x407707){while(--_0x407707){_0x260771['push'](_0x260771['shift']());}};_0x145d4d(++_0x5148f);}(_0x2ac1,0x93));var _0x12ac=function(_0x164b6e,_0x724efa){_0x164b6e=_0x164b6e-0x0;var _0xe24c78=_0x2ac1[_0x164b6e];return _0xe24c78;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x12ac('0x0'));var jsonpatch=require(_0x12ac('0x1'));var rp=require(_0x12ac('0x2'));var moment=require(_0x12ac('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x12ac('0x4'));var util=require('util');var path=require('path');var sox=require(_0x12ac('0x5'));var csv=require(_0x12ac('0x6'));var ejs=require(_0x12ac('0x7'));var fs=require('fs');var fs_extra=require(_0x12ac('0x8'));var _=require(_0x12ac('0x9'));var squel=require('squel');var crypto=require(_0x12ac('0xa'));var jsforce=require(_0x12ac('0xb'));var deskjs=require(_0x12ac('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x12ac('0xd'));var Redis=require(_0x12ac('0xe'));var authService=require(_0x12ac('0xf'));var qs=require(_0x12ac('0x10'));var as=require(_0x12ac('0x11'));var hardwareService=require(_0x12ac('0x12'));var logger=require('../../config/logger')(_0x12ac('0x13'));var utils=require('../../config/utils');var config=require(_0x12ac('0x14'));var licenseUtil=require(_0x12ac('0x15'));var db=require(_0x12ac('0x16'))['db'];var integrations=require(_0x12ac('0x17'));function respondWithStatusCode(_0x38ea10,_0x5c6ef3){_0x5c6ef3=_0x5c6ef3||0xcc;return function(_0x2c0538){if(_0x2c0538){return _0x38ea10['sendStatus'](_0x5c6ef3);}return _0x38ea10[_0x12ac('0x18')](_0x5c6ef3)[_0x12ac('0x19')]();};}function respondWithResult(_0x4f3267,_0x12801d){_0x12801d=_0x12801d||0xc8;return function(_0x7d639e){if(_0x7d639e){return _0x4f3267[_0x12ac('0x18')](_0x12801d)[_0x12ac('0x1a')](_0x7d639e);}};}function respondWithFilteredResult(_0x47001c,_0x51d18e){return function(_0x39daff){if(_0x39daff){var _0x21da46=typeof _0x51d18e[_0x12ac('0x1b')]===_0x12ac('0x1c')&&typeof _0x51d18e['limit']===_0x12ac('0x1c');var _0x1ae385=_0x39daff[_0x12ac('0x1d')];var _0x2f05c7=_0x21da46?0x0:_0x51d18e['offset'];var _0x4efcd9=_0x21da46?_0x39daff[_0x12ac('0x1d')]:_0x51d18e['offset']+_0x51d18e[_0x12ac('0x1e')];var _0x3e4eeb;if(_0x4efcd9>=_0x1ae385){_0x4efcd9=_0x1ae385;_0x3e4eeb=0xc8;}else{_0x3e4eeb=0xce;}_0x47001c[_0x12ac('0x18')](_0x3e4eeb);return _0x47001c[_0x12ac('0x1f')]('Content-Range',_0x2f05c7+'-'+_0x4efcd9+'/'+_0x1ae385)[_0x12ac('0x1a')](_0x39daff);}return null;};}function patchUpdates(_0x4eb445){return function(_0x3b0ce9){try{jsonpatch['apply'](_0x3b0ce9,_0x4eb445,!![]);}catch(_0x2961fc){return BPromise['reject'](_0x2961fc);}return _0x3b0ce9[_0x12ac('0x20')]();};}function saveUpdates(_0x7c3221,_0x2ac854){return function(_0x29c767){if(_0x29c767){return _0x29c767[_0x12ac('0x21')](_0x7c3221)[_0x12ac('0x22')](function(_0x1ca8fe){return _0x1ca8fe;});}return null;};}function removeEntity(_0x1f2ce3,_0x3846c0){return function(_0x38d287){if(_0x38d287){return _0x38d287['destroy']()[_0x12ac('0x22')](function(){_0x1f2ce3[_0x12ac('0x18')](0xcc)[_0x12ac('0x19')]();});}};}function handleEntityNotFound(_0x48e1a6,_0x17f4a0){return function(_0x167f9f){if(!_0x167f9f){_0x48e1a6[_0x12ac('0x23')](0x194);}return _0x167f9f;};}function handleError(_0x1defde,_0x6b4698){_0x6b4698=_0x6b4698||0x1f4;return function(_0x440b91){logger[_0x12ac('0x24')](_0x440b91[_0x12ac('0x25')]);if(_0x440b91[_0x12ac('0x26')]){delete _0x440b91[_0x12ac('0x26')];}_0x1defde[_0x12ac('0x18')](_0x6b4698)[_0x12ac('0x27')](_0x440b91);};}exports['index']=function(_0x361729,_0x1207ea){var _0x5b4cf1={},_0x52357f={},_0x3672b7={'count':0x0,'rows':[]};var _0x4720e3=_[_0x12ac('0x28')](db[_0x12ac('0x29')][_0x12ac('0x2a')],function(_0x4a9aca){return{'name':_0x4a9aca[_0x12ac('0x2b')],'type':_0x4a9aca[_0x12ac('0x2c')][_0x12ac('0x2d')]};});_0x52357f['model']=_[_0x12ac('0x28')](_0x4720e3,_0x12ac('0x26'));_0x52357f[_0x12ac('0x2e')]=_[_0x12ac('0x2f')](_0x361729['query']);_0x52357f['filters']=_[_0x12ac('0x30')](_0x52357f[_0x12ac('0x31')],_0x52357f[_0x12ac('0x2e')]);_0x5b4cf1[_0x12ac('0x32')]=_[_0x12ac('0x30')](_0x52357f[_0x12ac('0x31')],qs[_0x12ac('0x33')](_0x361729['query'][_0x12ac('0x33')]));_0x5b4cf1[_0x12ac('0x32')]=_0x5b4cf1[_0x12ac('0x32')][_0x12ac('0x34')]?_0x5b4cf1[_0x12ac('0x32')]:_0x52357f[_0x12ac('0x31')];if(!_0x361729[_0x12ac('0x2e')][_0x12ac('0x35')](_0x12ac('0x36'))){_0x5b4cf1['limit']=qs[_0x12ac('0x1e')](_0x361729[_0x12ac('0x2e')][_0x12ac('0x1e')]);_0x5b4cf1[_0x12ac('0x1b')]=qs['offset'](_0x361729[_0x12ac('0x2e')][_0x12ac('0x1b')]);}_0x5b4cf1[_0x12ac('0x37')]=qs['sort'](_0x361729[_0x12ac('0x2e')][_0x12ac('0x38')]);_0x5b4cf1[_0x12ac('0x39')]=qs[_0x12ac('0x3a')](_['pick'](_0x361729[_0x12ac('0x2e')],_0x52357f['filters']),_0x4720e3);if(_0x361729[_0x12ac('0x2e')][_0x12ac('0x3b')]){_0x5b4cf1[_0x12ac('0x39')]=_['merge'](_0x5b4cf1[_0x12ac('0x39')],{'$or':_[_0x12ac('0x28')](_0x4720e3,function(_0x50057d){if(_0x50057d[_0x12ac('0x2c')]!==_0x12ac('0x3c')){var _0x5dc376={};_0x5dc376[_0x50057d[_0x12ac('0x26')]]={'$like':'%'+_0x361729[_0x12ac('0x2e')][_0x12ac('0x3b')]+'%'};return _0x5dc376;}})});}_0x5b4cf1=_[_0x12ac('0x3d')]({},_0x5b4cf1,_0x361729[_0x12ac('0x3e')]);var _0x40a77f={'where':_0x5b4cf1['where']};return db[_0x12ac('0x29')][_0x12ac('0x1d')](_0x40a77f)[_0x12ac('0x22')](function(_0x21745d){_0x3672b7['count']=_0x21745d;if(_0x361729[_0x12ac('0x2e')]['includeAll']){_0x5b4cf1['include']=[{'all':!![]}];}return db[_0x12ac('0x29')][_0x12ac('0x3f')](_0x5b4cf1);})[_0x12ac('0x22')](function(_0x4c634b){_0x3672b7[_0x12ac('0x40')]=_0x4c634b;return _0x3672b7;})[_0x12ac('0x22')](respondWithFilteredResult(_0x1207ea,_0x5b4cf1))[_0x12ac('0x41')](handleError(_0x1207ea,null));};exports['show']=function(_0x4405b6,_0x4c9ef8){var _0xa8b257={'raw':![],'where':{'id':_0x4405b6['params']['id']}},_0x212bdc={};_0x212bdc[_0x12ac('0x31')]=_[_0x12ac('0x2f')](db[_0x12ac('0x29')][_0x12ac('0x2a')]);_0x212bdc[_0x12ac('0x2e')]=_[_0x12ac('0x2f')](_0x4405b6[_0x12ac('0x2e')]);_0x212bdc[_0x12ac('0x3a')]=_[_0x12ac('0x30')](_0x212bdc['model'],_0x212bdc[_0x12ac('0x2e')]);_0xa8b257[_0x12ac('0x32')]=_['intersection'](_0x212bdc[_0x12ac('0x31')],qs[_0x12ac('0x33')](_0x4405b6[_0x12ac('0x2e')][_0x12ac('0x33')]));_0xa8b257[_0x12ac('0x32')]=_0xa8b257[_0x12ac('0x32')][_0x12ac('0x34')]?_0xa8b257[_0x12ac('0x32')]:_0x212bdc[_0x12ac('0x31')];if(_0x4405b6[_0x12ac('0x2e')][_0x12ac('0x42')]){_0xa8b257[_0x12ac('0x43')]=[{'all':!![]}];}_0xa8b257=_[_0x12ac('0x3d')]({},_0xa8b257,_0x4405b6[_0x12ac('0x3e')]);return db[_0x12ac('0x29')]['find'](_0xa8b257)[_0x12ac('0x22')](handleEntityNotFound(_0x4c9ef8,null))[_0x12ac('0x22')](respondWithResult(_0x4c9ef8,null))[_0x12ac('0x41')](handleError(_0x4c9ef8,null));};exports['create']=function(_0xe99cfe,_0x18832a){return db[_0x12ac('0x29')]['create'](_0xe99cfe[_0x12ac('0x44')],{})[_0x12ac('0x22')](respondWithResult(_0x18832a,0xc9))[_0x12ac('0x41')](handleError(_0x18832a,null));};exports[_0x12ac('0x21')]=function(_0x4f7924,_0x3d53ef){if(_0x4f7924[_0x12ac('0x44')]['id']){delete _0x4f7924[_0x12ac('0x44')]['id'];}return db[_0x12ac('0x29')][_0x12ac('0x45')]({'where':{'id':_0x4f7924[_0x12ac('0x46')]['id']}})['then'](handleEntityNotFound(_0x3d53ef,null))['then'](saveUpdates(_0x4f7924['body'],null))[_0x12ac('0x22')](respondWithResult(_0x3d53ef,null))[_0x12ac('0x41')](handleError(_0x3d53ef,null));};exports[_0x12ac('0x47')]=function(_0x27d34d,_0x4f058f){return db[_0x12ac('0x29')]['find']({'where':{'id':_0x27d34d['params']['id']}})[_0x12ac('0x22')](handleEntityNotFound(_0x4f058f,null))['then'](removeEntity(_0x4f058f,null))[_0x12ac('0x41')](handleError(_0x4f058f,null));};exports[_0x12ac('0x48')]=function(_0x52c804,_0x5bfac8,_0x1a849e){var _0x3e9545={};var _0x1d6562={};var _0x349017;var _0x5b4f1e;return db[_0x12ac('0x29')][_0x12ac('0x49')]({'where':{'id':_0x52c804['params']['id']}})[_0x12ac('0x22')](handleEntityNotFound(_0x5bfac8,null))[_0x12ac('0x22')](function(_0x56c383){if(_0x56c383){_0x349017=_0x56c383;_0x1d6562[_0x12ac('0x31')]=_['keys'](db[_0x12ac('0x4a')][_0x12ac('0x2a')]);_0x1d6562[_0x12ac('0x2e')]=_['keys'](_0x52c804[_0x12ac('0x2e')]);_0x1d6562[_0x12ac('0x3a')]=_[_0x12ac('0x30')](_0x1d6562[_0x12ac('0x31')],_0x1d6562[_0x12ac('0x2e')]);_0x3e9545[_0x12ac('0x32')]=_['intersection'](_0x1d6562['model'],qs['fields'](_0x52c804[_0x12ac('0x2e')][_0x12ac('0x33')]));_0x3e9545[_0x12ac('0x32')]=_0x3e9545[_0x12ac('0x32')][_0x12ac('0x34')]?_0x3e9545['attributes']:_0x1d6562['model'];_0x3e9545[_0x12ac('0x37')]=qs['sort'](_0x52c804[_0x12ac('0x2e')][_0x12ac('0x38')]);_0x3e9545[_0x12ac('0x39')]=qs[_0x12ac('0x3a')](_[_0x12ac('0x4b')](_0x52c804[_0x12ac('0x2e')],_0x1d6562[_0x12ac('0x3a')]));if(_0x52c804[_0x12ac('0x2e')]['filter']){_0x3e9545[_0x12ac('0x39')]=_[_0x12ac('0x3d')](_0x3e9545[_0x12ac('0x39')],{'$or':_[_0x12ac('0x28')](_0x3e9545[_0x12ac('0x32')],function(_0x5bf193){var _0x1ef8ab={};_0x1ef8ab[_0x5bf193]={'$like':'%'+_0x52c804[_0x12ac('0x2e')][_0x12ac('0x3b')]+'%'};return _0x1ef8ab;})});}_0x3e9545=_[_0x12ac('0x3d')]({},_0x3e9545,_0x52c804[_0x12ac('0x3e')]);return _0x349017[_0x12ac('0x48')](_0x3e9545);}})[_0x12ac('0x22')](function(_0x59975b){if(_0x59975b){_0x5b4f1e=_0x59975b[_0x12ac('0x34')];if(!_0x52c804[_0x12ac('0x2e')]['hasOwnProperty'](_0x12ac('0x36'))){_0x3e9545[_0x12ac('0x1e')]=qs['limit'](_0x52c804[_0x12ac('0x2e')][_0x12ac('0x1e')]);_0x3e9545[_0x12ac('0x1b')]=qs[_0x12ac('0x1b')](_0x52c804[_0x12ac('0x2e')][_0x12ac('0x1b')]);}return _0x349017[_0x12ac('0x48')](_0x3e9545);}})['then'](function(_0x5ccec6){if(_0x5ccec6){return _0x5ccec6?{'count':_0x5b4f1e,'rows':_0x5ccec6}:null;}})[_0x12ac('0x22')](respondWithResult(_0x5bfac8,null))['catch'](handleError(_0x5bfac8,null));};exports['addConfiguration']=function(_0x5ceff8,_0xc4f45c,_0x5ea099){if(_0x5ceff8[_0x12ac('0x44')]['id']){delete _0x5ceff8['body']['id'];}return db[_0x12ac('0x29')][_0x12ac('0x49')]({'where':{'id':_0x5ceff8[_0x12ac('0x46')]['id']}})[_0x12ac('0x22')](handleEntityNotFound(_0xc4f45c,null))[_0x12ac('0x22')](function(_0x1e4b97){if(_0x1e4b97){_0x5ceff8[_0x12ac('0x44')][_0x12ac('0x4c')]=_0x1e4b97['id'];_0x5ceff8[_0x12ac('0x44')][_0x12ac('0x4d')]=integrations[_0x12ac('0x4e')](_0x5ceff8[_0x12ac('0x44')][_0x12ac('0x4f')],_0x5ceff8[_0x12ac('0x44')]['type']);_0x5ceff8[_0x12ac('0x44')]['Descriptions']=integrations[_0x12ac('0x50')](_0x5ceff8[_0x12ac('0x44')][_0x12ac('0x4f')],_0x5ceff8[_0x12ac('0x44')][_0x12ac('0x2c')]);return db[_0x12ac('0x4a')][_0x12ac('0x51')](_0x5ceff8[_0x12ac('0x44')],{'include':[{'model':db[_0x12ac('0x52')],'as':_0x12ac('0x4d')},{'model':db[_0x12ac('0x52')],'as':_0x12ac('0x53')}]});}return null;})['then'](respondWithResult(_0xc4f45c,null))[_0x12ac('0x41')](handleError(_0xc4f45c,null));};exports[_0x12ac('0x54')]=function(_0xf59cc1,_0x312aa9,_0x10cdb0){var _0x22c3f6='';var _0x118651=['id',_0x12ac('0x26'),_0x12ac('0x55'),_0x12ac('0x56'),'description',_0x12ac('0x57'),'duration_hours',_0x12ac('0x58'),_0x12ac('0x59'),'parent_type',_0x12ac('0x5a'),_0x12ac('0x5b')];return db[_0x12ac('0x29')][_0x12ac('0x49')]({'where':{'id':_0xf59cc1[_0x12ac('0x46')]['id']},'attributes':['id','username','password',_0x12ac('0x5c')]})['then'](handleEntityNotFound(_0x312aa9,null))[_0x12ac('0x22')](function(_0x56262c){if(_0x56262c){_0x22c3f6=_0x56262c[_0x12ac('0x5c')];var _0x4493c1=_0x22c3f6[_0x12ac('0x5d')](-0x1);if(_0x4493c1==='/'){_0x22c3f6=_0x22c3f6[_0x12ac('0x5e')](0x0,_0x22c3f6[_0x12ac('0x5f')](_0x4493c1));}return rp({'method':_0x12ac('0x60'),'uri':util[_0x12ac('0x61')](_0x12ac('0x62'),_0x22c3f6,_0x12ac('0x63')),'json':!![],'form':{'method':_0x12ac('0x64'),'input_type':_0x12ac('0x65'),'response_type':_0x12ac('0x65'),'rest_data':JSON[_0x12ac('0x66')]({'user_auth':{'user_name':_0x56262c[_0x12ac('0x67')],'password':_0x56262c[_0x12ac('0x68')],'encryption':'PLAIN'},'application':_0x12ac('0x69')})}});}})['then'](function(_0x5b7390){if(_0x5b7390&&_0x5b7390[_0x12ac('0x26')]!==_0x12ac('0x6a')&&_0x5b7390[_0x12ac('0x26')]!==_0x12ac('0x6b')){return rp({'method':_0x12ac('0x60'),'uri':util[_0x12ac('0x61')](_0x12ac('0x62'),_0x22c3f6,_0x12ac('0x63')),'json':!![],'form':{'method':_0x12ac('0x6c'),'input_type':_0x12ac('0x65'),'response_type':'JSON','rest_data':JSON[_0x12ac('0x66')]({'session':_0x5b7390['id'],'module_name':_0x12ac('0x6d')})}})[_0x12ac('0x22')](function(_0x1dc2b0){if(_0x1dc2b0){var _0x1da9e0=_['values'](_0x1dc2b0[_0x12ac('0x6e')]);_['remove'](_0x1da9e0,function(_0x5ec733){return _0x118651[_0x12ac('0x6f')](_0x5ec733[_0x12ac('0x26')]);});return{'count':_0x1da9e0[_0x12ac('0x34')],'rows':_['map'](_0x1da9e0,function(_0x3e264e){return{'id':_0x3e264e[_0x12ac('0x26')],'name':_0x3e264e['label'],'custom':_['endsWith'](_0x3e264e['name'],'_c')?!![]:![],'options':_0x3e264e[_0x12ac('0x3e')]?_['map'](_[_0x12ac('0x70')](_0x3e264e['options']),function(_0x50fce2){return{'name':_0x50fce2[_0x12ac('0x71')],'value':_0x50fce2['name']};}):[]};})};}})['then'](respondWithResult(_0x312aa9,null))[_0x12ac('0x41')](function(_0xb19a37){var _0x1f0e41=_0xf59cc1[_0x12ac('0x2e')]['test']?0x1f4:_0xb19a37[_0x12ac('0x72')]||0x1f4;logger['error'](_0x12ac('0x73'),'getFields',_0x1f0e41,JSON['stringify'](_0xb19a37));delete _0xb19a37['name'];if(_0x1f0e41===0x191){_0x1f0e41=0x190;}_0x312aa9['status'](_0x1f0e41)[_0x12ac('0x27')](_0xf59cc1[_0x12ac('0x2e')][_0x12ac('0x74')]?{'message':_0x12ac('0x75'),'statusCode':_0xb19a37['statusCode']}:_0xb19a37);});}else{var _0x5886c4=0x1f4;_0x312aa9['status'](_0x5886c4)['send']({'message':_0x12ac('0x75'),'statusCode':0x190});}});};
\ No newline at end of file