Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intSugarcrmAccount / intSugarcrmAccount.controller.js
index 1d3fb41..ddf930a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9f5e=['findOne','Subjects','getSubjects','channel','SugarcrmField','Descriptions','created_by','description','duration_minutes','parent_id','parent_type','parent_name','direction','password','remoteUri','lastIndexOf','POST','%s%s','/service/v4_1/rest.php','login','JSON','username','PLAIN','Password\x20Expired','format','get_module_fields','Calls','values','module_fields','remove','includes','label','endsWith','value','test','statusCode','getFields,\x20%s,\x20%s,\x20%s','Wrong\x20credentials','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/integrations/configuration','client','http','then','request\x20sent','debug','SugarcrmAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','SugarcrmAccount,\x20%s,\x20%s','message','info','result','catch','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','destroy','stack','name','send','index','map','SugarcrmAccount','rawAttributes','fieldName','type','key','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','VIRTUAL','merge','options','includeAll','include','findAll','rows','show','create','body','params','SugarcrmConfiguration','getConfigurations','addConfiguration'];(function(_0x20714a,_0x7de591){var _0x15e877=function(_0x3f9f8d){while(--_0x3f9f8d){_0x20714a['push'](_0x20714a['shift']());}};_0x15e877(++_0x7de591);}(_0x9f5e,0x1b2));var _0xe9f5=function(_0x4c0422,_0x402161){_0x4c0422=_0x4c0422-0x0;var _0x4d7fb9=_0x9f5e[_0x4c0422];return _0x4d7fb9;};'use strict';var pdf=require(_0xe9f5('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xe9f5('0x1'));var zipdir=require(_0xe9f5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe9f5('0x3'));var moment=require(_0xe9f5('0x4'));var BPromise=require(_0xe9f5('0x5'));var Mustache=require(_0xe9f5('0x6'));var util=require(_0xe9f5('0x7'));var path=require('path');var sox=require(_0xe9f5('0x8'));var csv=require(_0xe9f5('0x9'));var ejs=require(_0xe9f5('0xa'));var fs=require('fs');var _=require(_0xe9f5('0xb'));var squel=require(_0xe9f5('0xc'));var crypto=require('crypto');var jsforce=require(_0xe9f5('0xd'));var deskjs=require(_0xe9f5('0xe'));var toCsv=require(_0xe9f5('0x9'));var querystring=require(_0xe9f5('0xf'));var Papa=require(_0xe9f5('0x10'));var Redis=require(_0xe9f5('0x11'));var authService=require(_0xe9f5('0x12'));var qs=require(_0xe9f5('0x13'));var as=require(_0xe9f5('0x14'));var hardwareService=require(_0xe9f5('0x15'));var logger=require(_0xe9f5('0x16'))(_0xe9f5('0x17'));var utils=require(_0xe9f5('0x18'));var config=require(_0xe9f5('0x19'));var licenseUtil=require(_0xe9f5('0x1a'));var db=require(_0xe9f5('0x1b'))['db'];var integrations=require(_0xe9f5('0x1c'));var jayson=require('jayson/promise');var client=jayson[_0xe9f5('0x1d')][_0xe9f5('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x3e741f,_0x630fee,_0x50c454,_0x5870c8){return new BPromise(function(_0x140f66,_0x4788ce){var _0x584556=_0x5870c8||client;return _0x584556['request'](_0x3e741f,_0x50c454)[_0xe9f5('0x1f')](function(_0x46ea22){logger['info']('SugarcrmAccount,\x20%s,\x20%s',_0x630fee,_0xe9f5('0x20'));logger[_0xe9f5('0x21')](_0xe9f5('0x22'),_0x630fee,'request\x20sent',JSON[_0xe9f5('0x23')](_0x46ea22));if(_0x46ea22[_0xe9f5('0x24')]){if(_0x46ea22[_0xe9f5('0x24')][_0xe9f5('0x25')]===0x1f4){logger[_0xe9f5('0x24')](_0xe9f5('0x26'),_0x630fee,_0x46ea22[_0xe9f5('0x24')][_0xe9f5('0x27')]);return _0x4788ce(_0x46ea22['error'][_0xe9f5('0x27')]);}logger[_0xe9f5('0x24')](_0xe9f5('0x26'),_0x630fee,_0x46ea22[_0xe9f5('0x24')]['message']);return _0x140f66(_0x46ea22[_0xe9f5('0x24')][_0xe9f5('0x27')]);}else{logger[_0xe9f5('0x28')](_0xe9f5('0x26'),_0x630fee,'request\x20sent');_0x140f66(_0x46ea22[_0xe9f5('0x29')][_0xe9f5('0x27')]);}})[_0xe9f5('0x2a')](function(_0xa800d3){logger[_0xe9f5('0x24')]('SugarcrmAccount,\x20%s,\x20%s',_0x630fee,_0xa800d3);_0x4788ce(_0xa800d3);});});}function respondWithStatusCode(_0xefd5e7,_0x593741){_0x593741=_0x593741||0xcc;return function(_0x476a15){if(_0x476a15){return _0xefd5e7['sendStatus'](_0x593741);}return _0xefd5e7[_0xe9f5('0x2b')](_0x593741)[_0xe9f5('0x2c')]();};}function respondWithResult(_0x2a489d,_0x260513){_0x260513=_0x260513||0xc8;return function(_0x506642){if(_0x506642){return _0x2a489d['status'](_0x260513)[_0xe9f5('0x2d')](_0x506642);}};}function respondWithFilteredResult(_0x39e5ef,_0x246acd){return function(_0x1294d3){if(_0x1294d3){var _0x1b9bea=_0x1294d3[_0xe9f5('0x2e')],_0x1a219e=_0x246acd[_0xe9f5('0x2f')],_0x45df45=_0x246acd['offset']+_0x246acd[_0xe9f5('0x30')],_0x1d036c;if(_0x45df45>=_0x1b9bea){_0x45df45=_0x1b9bea;_0x1d036c=0xc8;}else{_0x1d036c=0xce;}_0x39e5ef[_0xe9f5('0x2b')](_0x1d036c);return _0x39e5ef[_0xe9f5('0x31')](_0xe9f5('0x32'),_0x1a219e+'-'+_0x45df45+'/'+_0x1b9bea)[_0xe9f5('0x2d')](_0x1294d3);}return null;};}function patchUpdates(_0x137d2a){return function(_0x34509e){try{jsonpatch[_0xe9f5('0x33')](_0x34509e,_0x137d2a,!![]);}catch(_0x5c85e0){return BPromise[_0xe9f5('0x34')](_0x5c85e0);}return _0x34509e[_0xe9f5('0x35')]();};}function saveUpdates(_0x3f918a,_0x76da58){return function(_0x480606){if(_0x480606){return _0x480606['update'](_0x3f918a)['then'](function(_0x527212){return _0x527212;});}return null;};}function removeEntity(_0x5f59c4,_0x53b8eb){return function(_0x4e4b8f){if(_0x4e4b8f){return _0x4e4b8f[_0xe9f5('0x36')]()['then'](function(){_0x5f59c4[_0xe9f5('0x2b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3b22f5,_0xe2ad86){return function(_0x113932){if(!_0x113932){_0x3b22f5['sendStatus'](0x194);}return _0x113932;};}function handleError(_0x37c02c,_0x1231ac){_0x1231ac=_0x1231ac||0x1f4;return function(_0x55a6d5){logger[_0xe9f5('0x24')](_0x55a6d5[_0xe9f5('0x37')]);if(_0x55a6d5[_0xe9f5('0x38')]){delete _0x55a6d5[_0xe9f5('0x38')];}_0x37c02c[_0xe9f5('0x2b')](_0x1231ac)[_0xe9f5('0x39')](_0x55a6d5);};}exports[_0xe9f5('0x3a')]=function(_0x3a4486,_0x296422){var _0x35a8d8={},_0x170d79={},_0x33cfc0={'count':0x0,'rows':[]};var _0x21caeb=_[_0xe9f5('0x3b')](db[_0xe9f5('0x3c')][_0xe9f5('0x3d')],function(_0x6b864e){return{'name':_0x6b864e[_0xe9f5('0x3e')],'type':_0x6b864e[_0xe9f5('0x3f')][_0xe9f5('0x40')]};});_0x170d79['model']=_[_0xe9f5('0x3b')](_0x21caeb,_0xe9f5('0x38'));_0x170d79[_0xe9f5('0x41')]=_[_0xe9f5('0x42')](_0x3a4486[_0xe9f5('0x41')]);_0x170d79[_0xe9f5('0x43')]=_['intersection'](_0x170d79[_0xe9f5('0x44')],_0x170d79[_0xe9f5('0x41')]);_0x35a8d8[_0xe9f5('0x45')]=_[_0xe9f5('0x46')](_0x170d79[_0xe9f5('0x44')],qs[_0xe9f5('0x47')](_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x47')]));_0x35a8d8[_0xe9f5('0x45')]=_0x35a8d8[_0xe9f5('0x45')][_0xe9f5('0x48')]?_0x35a8d8['attributes']:_0x170d79[_0xe9f5('0x44')];if(!_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x49')](_0xe9f5('0x4a'))){_0x35a8d8[_0xe9f5('0x30')]=qs[_0xe9f5('0x30')](_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x30')]);_0x35a8d8[_0xe9f5('0x2f')]=qs['offset'](_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x2f')]);}_0x35a8d8[_0xe9f5('0x4b')]=qs[_0xe9f5('0x4c')](_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x4c')]);_0x35a8d8['where']=qs['filters'](_[_0xe9f5('0x4d')](_0x3a4486[_0xe9f5('0x41')],_0x170d79['filters']),_0x21caeb);if(_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x4e')]){_0x35a8d8['where']=_['merge'](_0x35a8d8[_0xe9f5('0x4f')],{'$or':_['map'](_0x21caeb,function(_0x35a8b4){if(_0x35a8b4['type']!==_0xe9f5('0x50')){var _0x180278={};_0x180278[_0x35a8b4[_0xe9f5('0x38')]]={'$like':'%'+_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x4e')]+'%'};return _0x180278;}})});}_0x35a8d8=_[_0xe9f5('0x51')]({},_0x35a8d8,_0x3a4486[_0xe9f5('0x52')]);var _0x532751={'where':_0x35a8d8['where']};return db[_0xe9f5('0x3c')]['count'](_0x532751)[_0xe9f5('0x1f')](function(_0xac5847){_0x33cfc0[_0xe9f5('0x2e')]=_0xac5847;if(_0x3a4486[_0xe9f5('0x41')][_0xe9f5('0x53')]){_0x35a8d8[_0xe9f5('0x54')]=[{'all':!![]}];}return db[_0xe9f5('0x3c')][_0xe9f5('0x55')](_0x35a8d8);})[_0xe9f5('0x1f')](function(_0x1342a2){_0x33cfc0[_0xe9f5('0x56')]=_0x1342a2;return _0x33cfc0;})['then'](respondWithFilteredResult(_0x296422,_0x35a8d8))['catch'](handleError(_0x296422,null));};exports[_0xe9f5('0x57')]=function(_0x1fd18f,_0x102101){var _0x139513={'raw':![],'where':{'id':_0x1fd18f['params']['id']}},_0x180346={};_0x180346['model']=_[_0xe9f5('0x42')](db[_0xe9f5('0x3c')][_0xe9f5('0x3d')]);_0x180346['query']=_[_0xe9f5('0x42')](_0x1fd18f[_0xe9f5('0x41')]);_0x180346[_0xe9f5('0x43')]=_[_0xe9f5('0x46')](_0x180346[_0xe9f5('0x44')],_0x180346[_0xe9f5('0x41')]);_0x139513[_0xe9f5('0x45')]=_[_0xe9f5('0x46')](_0x180346[_0xe9f5('0x44')],qs['fields'](_0x1fd18f[_0xe9f5('0x41')][_0xe9f5('0x47')]));_0x139513[_0xe9f5('0x45')]=_0x139513[_0xe9f5('0x45')][_0xe9f5('0x48')]?_0x139513[_0xe9f5('0x45')]:_0x180346[_0xe9f5('0x44')];if(_0x1fd18f[_0xe9f5('0x41')]['includeAll']){_0x139513[_0xe9f5('0x54')]=[{'all':!![]}];}_0x139513=_[_0xe9f5('0x51')]({},_0x139513,_0x1fd18f[_0xe9f5('0x52')]);return db['SugarcrmAccount']['find'](_0x139513)[_0xe9f5('0x1f')](handleEntityNotFound(_0x102101,null))[_0xe9f5('0x1f')](respondWithResult(_0x102101,null))['catch'](handleError(_0x102101,null));};exports[_0xe9f5('0x58')]=function(_0x1c9ccf,_0x135a7e){return db[_0xe9f5('0x3c')][_0xe9f5('0x58')](_0x1c9ccf[_0xe9f5('0x59')],{})[_0xe9f5('0x1f')](respondWithResult(_0x135a7e,0xc9))['catch'](handleError(_0x135a7e,null));};exports['update']=function(_0x3d81d7,_0x4d6368){if(_0x3d81d7['body']['id']){delete _0x3d81d7[_0xe9f5('0x59')]['id'];}return db[_0xe9f5('0x3c')]['find']({'where':{'id':_0x3d81d7[_0xe9f5('0x5a')]['id']}})['then'](handleEntityNotFound(_0x4d6368,null))[_0xe9f5('0x1f')](saveUpdates(_0x3d81d7['body'],null))[_0xe9f5('0x1f')](respondWithResult(_0x4d6368,null))[_0xe9f5('0x2a')](handleError(_0x4d6368,null));};exports[_0xe9f5('0x36')]=function(_0x262cb6,_0x2b52b4){return db['SugarcrmAccount']['find']({'where':{'id':_0x262cb6[_0xe9f5('0x5a')]['id']}})[_0xe9f5('0x1f')](handleEntityNotFound(_0x2b52b4,null))[_0xe9f5('0x1f')](removeEntity(_0x2b52b4,null))[_0xe9f5('0x2a')](handleError(_0x2b52b4,null));};exports['getConfigurations']=function(_0x1026da,_0x17b459,_0x1503a5){var _0x1d5f00={};var _0x4eca5d={};var _0x285d3e;var _0x2766a0;return db[_0xe9f5('0x3c')]['findOne']({'where':{'id':_0x1026da[_0xe9f5('0x5a')]['id']}})['then'](handleEntityNotFound(_0x17b459,null))[_0xe9f5('0x1f')](function(_0x1ccc51){if(_0x1ccc51){_0x285d3e=_0x1ccc51;_0x4eca5d[_0xe9f5('0x44')]=_[_0xe9f5('0x42')](db[_0xe9f5('0x5b')][_0xe9f5('0x3d')]);_0x4eca5d[_0xe9f5('0x41')]=_[_0xe9f5('0x42')](_0x1026da['query']);_0x4eca5d[_0xe9f5('0x43')]=_[_0xe9f5('0x46')](_0x4eca5d[_0xe9f5('0x44')],_0x4eca5d[_0xe9f5('0x41')]);_0x1d5f00[_0xe9f5('0x45')]=_['intersection'](_0x4eca5d[_0xe9f5('0x44')],qs[_0xe9f5('0x47')](_0x1026da[_0xe9f5('0x41')]['fields']));_0x1d5f00[_0xe9f5('0x45')]=_0x1d5f00['attributes'][_0xe9f5('0x48')]?_0x1d5f00[_0xe9f5('0x45')]:_0x4eca5d[_0xe9f5('0x44')];_0x1d5f00[_0xe9f5('0x4b')]=qs[_0xe9f5('0x4c')](_0x1026da['query'][_0xe9f5('0x4c')]);_0x1d5f00[_0xe9f5('0x4f')]=qs['filters'](_[_0xe9f5('0x4d')](_0x1026da[_0xe9f5('0x41')],_0x4eca5d[_0xe9f5('0x43')]));if(_0x1026da[_0xe9f5('0x41')][_0xe9f5('0x4e')]){_0x1d5f00['where']=_[_0xe9f5('0x51')](_0x1d5f00[_0xe9f5('0x4f')],{'$or':_[_0xe9f5('0x3b')](_0x1d5f00[_0xe9f5('0x45')],function(_0x3d30f4){var _0x7e3558={};_0x7e3558[_0x3d30f4]={'$like':'%'+_0x1026da[_0xe9f5('0x41')]['filter']+'%'};return _0x7e3558;})});}_0x1d5f00=_['merge']({},_0x1d5f00,_0x1026da['options']);return _0x285d3e[_0xe9f5('0x5c')](_0x1d5f00);}})[_0xe9f5('0x1f')](function(_0xb3f69e){if(_0xb3f69e){_0x2766a0=_0xb3f69e[_0xe9f5('0x48')];if(!_0x1026da[_0xe9f5('0x41')][_0xe9f5('0x49')](_0xe9f5('0x4a'))){_0x1d5f00[_0xe9f5('0x30')]=qs['limit'](_0x1026da[_0xe9f5('0x41')][_0xe9f5('0x30')]);_0x1d5f00[_0xe9f5('0x2f')]=qs[_0xe9f5('0x2f')](_0x1026da[_0xe9f5('0x41')][_0xe9f5('0x2f')]);}return _0x285d3e[_0xe9f5('0x5c')](_0x1d5f00);}})['then'](function(_0x1f96ca){if(_0x1f96ca){return _0x1f96ca?{'count':_0x2766a0,'rows':_0x1f96ca}:null;}})[_0xe9f5('0x1f')](respondWithResult(_0x17b459,null))[_0xe9f5('0x2a')](handleError(_0x17b459,null));};exports[_0xe9f5('0x5d')]=function(_0x1b8b19,_0x24b80f,_0x5e2cad){if(_0x1b8b19[_0xe9f5('0x59')]['id']){delete _0x1b8b19[_0xe9f5('0x59')]['id'];}return db[_0xe9f5('0x3c')][_0xe9f5('0x5e')]({'where':{'id':_0x1b8b19[_0xe9f5('0x5a')]['id']}})[_0xe9f5('0x1f')](handleEntityNotFound(_0x24b80f,null))[_0xe9f5('0x1f')](function(_0x3d0082){if(_0x3d0082){_0x1b8b19[_0xe9f5('0x59')]['AccountId']=_0x3d0082['id'];_0x1b8b19[_0xe9f5('0x59')][_0xe9f5('0x5f')]=integrations[_0xe9f5('0x60')](_0x1b8b19[_0xe9f5('0x59')][_0xe9f5('0x61')],_0x1b8b19[_0xe9f5('0x59')][_0xe9f5('0x3f')]);_0x1b8b19[_0xe9f5('0x59')]['Descriptions']=integrations['getDescriptions'](_0x1b8b19[_0xe9f5('0x59')][_0xe9f5('0x61')],_0x1b8b19[_0xe9f5('0x59')][_0xe9f5('0x3f')]);return db[_0xe9f5('0x5b')][_0xe9f5('0x58')](_0x1b8b19[_0xe9f5('0x59')],{'include':[{'model':db['SugarcrmField'],'as':_0xe9f5('0x5f')},{'model':db[_0xe9f5('0x62')],'as':_0xe9f5('0x63')}]});}return null;})[_0xe9f5('0x1f')](respondWithResult(_0x24b80f,null))[_0xe9f5('0x2a')](handleError(_0x24b80f,null));};exports['getFields']=function(_0x3426b8,_0x1e0196,_0x5a45fd){var _0x3e9b33='';var _0x122ba1=['id',_0xe9f5('0x38'),'assigned_user_id',_0xe9f5('0x64'),_0xe9f5('0x65'),'date_start','duration_hours',_0xe9f5('0x66'),_0xe9f5('0x67'),_0xe9f5('0x68'),_0xe9f5('0x69'),_0xe9f5('0x6a')];return db['SugarcrmAccount'][_0xe9f5('0x5e')]({'where':{'id':_0x3426b8[_0xe9f5('0x5a')]['id']},'attributes':['id','username',_0xe9f5('0x6b'),_0xe9f5('0x6c')]})['then'](handleEntityNotFound(_0x1e0196,null))[_0xe9f5('0x1f')](function(_0x19b228){if(_0x19b228){_0x3e9b33=_0x19b228[_0xe9f5('0x6c')];var _0x8da823=_0x3e9b33['slice'](-0x1);if(_0x8da823==='/'){_0x3e9b33=_0x3e9b33['substring'](0x0,_0x3e9b33[_0xe9f5('0x6d')](_0x8da823));}return rp({'method':_0xe9f5('0x6e'),'uri':util['format'](_0xe9f5('0x6f'),_0x3e9b33,_0xe9f5('0x70')),'json':!![],'form':{'method':_0xe9f5('0x71'),'input_type':_0xe9f5('0x72'),'response_type':_0xe9f5('0x72'),'rest_data':JSON['stringify']({'user_auth':{'user_name':_0x19b228[_0xe9f5('0x73')],'password':_0x19b228[_0xe9f5('0x6b')],'encryption':_0xe9f5('0x74')},'application':'xCALLY\x20Motion\x20Integration'})}});}})[_0xe9f5('0x1f')](function(_0x96de49){if(_0x96de49&&_0x96de49[_0xe9f5('0x38')]!=='Invalid\x20Login'&&_0x96de49[_0xe9f5('0x38')]!==_0xe9f5('0x75')){return rp({'method':_0xe9f5('0x6e'),'uri':util[_0xe9f5('0x76')](_0xe9f5('0x6f'),_0x3e9b33,_0xe9f5('0x70')),'json':!![],'form':{'method':_0xe9f5('0x77'),'input_type':_0xe9f5('0x72'),'response_type':_0xe9f5('0x72'),'rest_data':JSON[_0xe9f5('0x23')]({'session':_0x96de49['id'],'module_name':_0xe9f5('0x78')})}})[_0xe9f5('0x1f')](function(_0x337ec7){if(_0x337ec7){var _0x2ac538=_[_0xe9f5('0x79')](_0x337ec7[_0xe9f5('0x7a')]);_[_0xe9f5('0x7b')](_0x2ac538,function(_0x2d84be){return _0x122ba1[_0xe9f5('0x7c')](_0x2d84be[_0xe9f5('0x38')]);});return{'count':_0x2ac538['length'],'rows':_[_0xe9f5('0x3b')](_0x2ac538,function(_0x484e8c){return{'id':_0x484e8c[_0xe9f5('0x38')],'name':_0x484e8c[_0xe9f5('0x7d')],'custom':_[_0xe9f5('0x7e')](_0x484e8c['name'],'_c')?!![]:![],'options':_0x484e8c[_0xe9f5('0x52')]?_['map'](_[_0xe9f5('0x79')](_0x484e8c[_0xe9f5('0x52')]),function(_0x6bba53){return{'name':_0x6bba53[_0xe9f5('0x7f')],'value':_0x6bba53['name']};}):[]};})};}})[_0xe9f5('0x1f')](respondWithResult(_0x1e0196,null))[_0xe9f5('0x2a')](function(_0x5a986f){var _0x620955=_0x3426b8[_0xe9f5('0x41')][_0xe9f5('0x80')]?0x1f4:_0x5a986f[_0xe9f5('0x81')]||0x1f4;logger['error'](_0xe9f5('0x82'),'getFields',_0x620955,JSON['stringify'](_0x5a986f));delete _0x5a986f[_0xe9f5('0x38')];if(_0x620955===0x191){_0x620955=0x190;}_0x1e0196[_0xe9f5('0x2b')](_0x620955)['send'](_0x3426b8[_0xe9f5('0x41')][_0xe9f5('0x80')]?{'message':'Wrong\x20credentials','statusCode':_0x5a986f['statusCode']}:_0x5a986f);});}else{var _0x12f39f=0x1f4;_0x1e0196['status'](_0x12f39f)[_0xe9f5('0x39')]({'message':_0xe9f5('0x83'),'statusCode':0x190});}});};
\ No newline at end of file
+var _0x5ad0=['get_module_fields','stringify','Calls','values','module_fields','remove','includes','label','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','../../components/integrations/configuration','sendStatus','status','end','json','undefined','count','offset','limit','set','apply','save','then','destroy','error','stack','name','index','map','fieldName','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','where','pick','filters','filter','merge','type','VIRTUAL','SugarcrmAccount','includeAll','include','findAll','rows','catch','show','params','rawAttributes','options','find','create','body','update','getConfigurations','findOne','order','sort','addConfiguration','AccountId','Subjects','getSubjects','getDescriptions','Descriptions','getFields','assigned_user_id','created_by','description','date_start','duration_hours','duration_minutes','parent_id','parent_name','direction','username','remoteUri','slice','substring','lastIndexOf','POST','format','%s%s','/service/v4_1/rest.php','login','JSON','password','PLAIN','xCALLY\x20Motion\x20Integration','Invalid\x20Login'];(function(_0x6925fa,_0x4e6100){var _0x56d211=function(_0x59fe6d){while(--_0x59fe6d){_0x6925fa['push'](_0x6925fa['shift']());}};_0x56d211(++_0x4e6100);}(_0x5ad0,0x180));var _0x05ad=function(_0x73cc50,_0xad8fea){_0x73cc50=_0x73cc50-0x0;var _0x56859f=_0x5ad0[_0x73cc50];return _0x56859f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x05ad('0x0'));var zipdir=require(_0x05ad('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x05ad('0x2'));var moment=require(_0x05ad('0x3'));var BPromise=require(_0x05ad('0x4'));var Mustache=require(_0x05ad('0x5'));var util=require(_0x05ad('0x6'));var path=require(_0x05ad('0x7'));var sox=require('sox');var csv=require(_0x05ad('0x8'));var ejs=require(_0x05ad('0x9'));var fs=require('fs');var fs_extra=require(_0x05ad('0xa'));var _=require(_0x05ad('0xb'));var squel=require(_0x05ad('0xc'));var crypto=require(_0x05ad('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x05ad('0xe'));var toCsv=require(_0x05ad('0x8'));var querystring=require(_0x05ad('0xf'));var Papa=require(_0x05ad('0x10'));var Redis=require(_0x05ad('0x11'));var authService=require(_0x05ad('0x12'));var qs=require(_0x05ad('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x05ad('0x14'));var logger=require(_0x05ad('0x15'))(_0x05ad('0x16'));var utils=require(_0x05ad('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x05ad('0x18'));var db=require(_0x05ad('0x19'))['db'];var integrations=require(_0x05ad('0x1a'));function respondWithStatusCode(_0xf53f0d,_0x1d176c){_0x1d176c=_0x1d176c||0xcc;return function(_0x43981b){if(_0x43981b){return _0xf53f0d[_0x05ad('0x1b')](_0x1d176c);}return _0xf53f0d[_0x05ad('0x1c')](_0x1d176c)[_0x05ad('0x1d')]();};}function respondWithResult(_0x1dc69e,_0x1b233f){_0x1b233f=_0x1b233f||0xc8;return function(_0x1b0335){if(_0x1b0335){return _0x1dc69e[_0x05ad('0x1c')](_0x1b233f)[_0x05ad('0x1e')](_0x1b0335);}};}function respondWithFilteredResult(_0x217fb6,_0x4c0fd8){return function(_0x20adfa){if(_0x20adfa){var _0x312493=typeof _0x4c0fd8['offset']===_0x05ad('0x1f')&&typeof _0x4c0fd8['limit']===_0x05ad('0x1f');var _0x46f97c=_0x20adfa[_0x05ad('0x20')];var _0x539203=_0x312493?0x0:_0x4c0fd8[_0x05ad('0x21')];var _0x2d820f=_0x312493?_0x20adfa[_0x05ad('0x20')]:_0x4c0fd8[_0x05ad('0x21')]+_0x4c0fd8[_0x05ad('0x22')];var _0x20d204;if(_0x2d820f>=_0x46f97c){_0x2d820f=_0x46f97c;_0x20d204=0xc8;}else{_0x20d204=0xce;}_0x217fb6[_0x05ad('0x1c')](_0x20d204);return _0x217fb6[_0x05ad('0x23')]('Content-Range',_0x539203+'-'+_0x2d820f+'/'+_0x46f97c)[_0x05ad('0x1e')](_0x20adfa);}return null;};}function patchUpdates(_0x236ab8){return function(_0x550534){try{jsonpatch[_0x05ad('0x24')](_0x550534,_0x236ab8,!![]);}catch(_0x231a2f){return BPromise['reject'](_0x231a2f);}return _0x550534[_0x05ad('0x25')]();};}function saveUpdates(_0x67b7c4,_0xfc86d4){return function(_0x3baf30){if(_0x3baf30){return _0x3baf30['update'](_0x67b7c4)[_0x05ad('0x26')](function(_0x56be3d){return _0x56be3d;});}return null;};}function removeEntity(_0x449b0f,_0x5a4806){return function(_0x4fdbc1){if(_0x4fdbc1){return _0x4fdbc1[_0x05ad('0x27')]()[_0x05ad('0x26')](function(){_0x449b0f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5c5fd1,_0x5ebfd9){return function(_0x97ea61){if(!_0x97ea61){_0x5c5fd1[_0x05ad('0x1b')](0x194);}return _0x97ea61;};}function handleError(_0x52a10a,_0xa76b7){_0xa76b7=_0xa76b7||0x1f4;return function(_0x52fa0a){logger[_0x05ad('0x28')](_0x52fa0a[_0x05ad('0x29')]);if(_0x52fa0a[_0x05ad('0x2a')]){delete _0x52fa0a['name'];}_0x52a10a['status'](_0xa76b7)['send'](_0x52fa0a);};}exports[_0x05ad('0x2b')]=function(_0x22b071,_0x5b653c){var _0x1d769c={},_0x11ee81={},_0x577d01={'count':0x0,'rows':[]};var _0x5b5ff7=_[_0x05ad('0x2c')](db['SugarcrmAccount']['rawAttributes'],function(_0x29b021){return{'name':_0x29b021[_0x05ad('0x2d')],'type':_0x29b021['type'][_0x05ad('0x2e')]};});_0x11ee81[_0x05ad('0x2f')]=_[_0x05ad('0x2c')](_0x5b5ff7,_0x05ad('0x2a'));_0x11ee81[_0x05ad('0x30')]=_[_0x05ad('0x31')](_0x22b071[_0x05ad('0x30')]);_0x11ee81['filters']=_[_0x05ad('0x32')](_0x11ee81['model'],_0x11ee81['query']);_0x1d769c[_0x05ad('0x33')]=_[_0x05ad('0x32')](_0x11ee81['model'],qs['fields'](_0x22b071[_0x05ad('0x30')][_0x05ad('0x34')]));_0x1d769c['attributes']=_0x1d769c[_0x05ad('0x33')][_0x05ad('0x35')]?_0x1d769c[_0x05ad('0x33')]:_0x11ee81['model'];if(!_0x22b071[_0x05ad('0x30')][_0x05ad('0x36')](_0x05ad('0x37'))){_0x1d769c[_0x05ad('0x22')]=qs[_0x05ad('0x22')](_0x22b071[_0x05ad('0x30')][_0x05ad('0x22')]);_0x1d769c[_0x05ad('0x21')]=qs['offset'](_0x22b071[_0x05ad('0x30')][_0x05ad('0x21')]);}_0x1d769c['order']=qs['sort'](_0x22b071[_0x05ad('0x30')]['sort']);_0x1d769c[_0x05ad('0x38')]=qs['filters'](_[_0x05ad('0x39')](_0x22b071['query'],_0x11ee81[_0x05ad('0x3a')]),_0x5b5ff7);if(_0x22b071[_0x05ad('0x30')][_0x05ad('0x3b')]){_0x1d769c['where']=_[_0x05ad('0x3c')](_0x1d769c[_0x05ad('0x38')],{'$or':_['map'](_0x5b5ff7,function(_0x19f8c3){if(_0x19f8c3[_0x05ad('0x3d')]!==_0x05ad('0x3e')){var _0x1f1f51={};_0x1f1f51[_0x19f8c3['name']]={'$like':'%'+_0x22b071[_0x05ad('0x30')][_0x05ad('0x3b')]+'%'};return _0x1f1f51;}})});}_0x1d769c=_[_0x05ad('0x3c')]({},_0x1d769c,_0x22b071['options']);var _0x17655f={'where':_0x1d769c[_0x05ad('0x38')]};return db[_0x05ad('0x3f')][_0x05ad('0x20')](_0x17655f)['then'](function(_0x59b5b2){_0x577d01[_0x05ad('0x20')]=_0x59b5b2;if(_0x22b071[_0x05ad('0x30')][_0x05ad('0x40')]){_0x1d769c[_0x05ad('0x41')]=[{'all':!![]}];}return db[_0x05ad('0x3f')][_0x05ad('0x42')](_0x1d769c);})[_0x05ad('0x26')](function(_0x4a41a8){_0x577d01[_0x05ad('0x43')]=_0x4a41a8;return _0x577d01;})[_0x05ad('0x26')](respondWithFilteredResult(_0x5b653c,_0x1d769c))[_0x05ad('0x44')](handleError(_0x5b653c,null));};exports[_0x05ad('0x45')]=function(_0x4d196d,_0x36c199){var _0x4c05d8={'raw':![],'where':{'id':_0x4d196d[_0x05ad('0x46')]['id']}},_0x2f6f2a={};_0x2f6f2a[_0x05ad('0x2f')]=_['keys'](db[_0x05ad('0x3f')][_0x05ad('0x47')]);_0x2f6f2a[_0x05ad('0x30')]=_['keys'](_0x4d196d[_0x05ad('0x30')]);_0x2f6f2a[_0x05ad('0x3a')]=_[_0x05ad('0x32')](_0x2f6f2a[_0x05ad('0x2f')],_0x2f6f2a[_0x05ad('0x30')]);_0x4c05d8[_0x05ad('0x33')]=_[_0x05ad('0x32')](_0x2f6f2a[_0x05ad('0x2f')],qs['fields'](_0x4d196d[_0x05ad('0x30')]['fields']));_0x4c05d8['attributes']=_0x4c05d8[_0x05ad('0x33')][_0x05ad('0x35')]?_0x4c05d8['attributes']:_0x2f6f2a['model'];if(_0x4d196d['query']['includeAll']){_0x4c05d8[_0x05ad('0x41')]=[{'all':!![]}];}_0x4c05d8=_[_0x05ad('0x3c')]({},_0x4c05d8,_0x4d196d[_0x05ad('0x48')]);return db[_0x05ad('0x3f')][_0x05ad('0x49')](_0x4c05d8)['then'](handleEntityNotFound(_0x36c199,null))[_0x05ad('0x26')](respondWithResult(_0x36c199,null))[_0x05ad('0x44')](handleError(_0x36c199,null));};exports[_0x05ad('0x4a')]=function(_0x4cdac0,_0x204b27){return db[_0x05ad('0x3f')][_0x05ad('0x4a')](_0x4cdac0[_0x05ad('0x4b')],{})['then'](respondWithResult(_0x204b27,0xc9))[_0x05ad('0x44')](handleError(_0x204b27,null));};exports[_0x05ad('0x4c')]=function(_0x3c6bb6,_0xdd10c2){if(_0x3c6bb6[_0x05ad('0x4b')]['id']){delete _0x3c6bb6[_0x05ad('0x4b')]['id'];}return db['SugarcrmAccount']['find']({'where':{'id':_0x3c6bb6[_0x05ad('0x46')]['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0xdd10c2,null))[_0x05ad('0x26')](saveUpdates(_0x3c6bb6[_0x05ad('0x4b')],null))[_0x05ad('0x26')](respondWithResult(_0xdd10c2,null))[_0x05ad('0x44')](handleError(_0xdd10c2,null));};exports[_0x05ad('0x27')]=function(_0x342482,_0x14cb81){return db[_0x05ad('0x3f')][_0x05ad('0x49')]({'where':{'id':_0x342482[_0x05ad('0x46')]['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0x14cb81,null))['then'](removeEntity(_0x14cb81,null))[_0x05ad('0x44')](handleError(_0x14cb81,null));};exports[_0x05ad('0x4d')]=function(_0x4f924d,_0x35b4de,_0x4b1416){var _0x32044c={};var _0x266768={};var _0x1f7a30;var _0x42d153;return db[_0x05ad('0x3f')][_0x05ad('0x4e')]({'where':{'id':_0x4f924d[_0x05ad('0x46')]['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0x35b4de,null))[_0x05ad('0x26')](function(_0x5a756d){if(_0x5a756d){_0x1f7a30=_0x5a756d;_0x266768['model']=_[_0x05ad('0x31')](db['SugarcrmConfiguration'][_0x05ad('0x47')]);_0x266768[_0x05ad('0x30')]=_[_0x05ad('0x31')](_0x4f924d[_0x05ad('0x30')]);_0x266768['filters']=_[_0x05ad('0x32')](_0x266768['model'],_0x266768['query']);_0x32044c[_0x05ad('0x33')]=_[_0x05ad('0x32')](_0x266768[_0x05ad('0x2f')],qs[_0x05ad('0x34')](_0x4f924d[_0x05ad('0x30')][_0x05ad('0x34')]));_0x32044c['attributes']=_0x32044c[_0x05ad('0x33')]['length']?_0x32044c[_0x05ad('0x33')]:_0x266768[_0x05ad('0x2f')];_0x32044c[_0x05ad('0x4f')]=qs[_0x05ad('0x50')](_0x4f924d[_0x05ad('0x30')][_0x05ad('0x50')]);_0x32044c[_0x05ad('0x38')]=qs[_0x05ad('0x3a')](_[_0x05ad('0x39')](_0x4f924d['query'],_0x266768[_0x05ad('0x3a')]));if(_0x4f924d[_0x05ad('0x30')][_0x05ad('0x3b')]){_0x32044c[_0x05ad('0x38')]=_[_0x05ad('0x3c')](_0x32044c[_0x05ad('0x38')],{'$or':_[_0x05ad('0x2c')](_0x32044c[_0x05ad('0x33')],function(_0x5dc4f1){var _0x581688={};_0x581688[_0x5dc4f1]={'$like':'%'+_0x4f924d[_0x05ad('0x30')]['filter']+'%'};return _0x581688;})});}_0x32044c=_[_0x05ad('0x3c')]({},_0x32044c,_0x4f924d[_0x05ad('0x48')]);return _0x1f7a30[_0x05ad('0x4d')](_0x32044c);}})[_0x05ad('0x26')](function(_0x80b2bd){if(_0x80b2bd){_0x42d153=_0x80b2bd[_0x05ad('0x35')];if(!_0x4f924d[_0x05ad('0x30')][_0x05ad('0x36')]('nolimit')){_0x32044c[_0x05ad('0x22')]=qs[_0x05ad('0x22')](_0x4f924d['query'][_0x05ad('0x22')]);_0x32044c['offset']=qs[_0x05ad('0x21')](_0x4f924d['query']['offset']);}return _0x1f7a30[_0x05ad('0x4d')](_0x32044c);}})[_0x05ad('0x26')](function(_0x5838df){if(_0x5838df){return _0x5838df?{'count':_0x42d153,'rows':_0x5838df}:null;}})['then'](respondWithResult(_0x35b4de,null))[_0x05ad('0x44')](handleError(_0x35b4de,null));};exports[_0x05ad('0x51')]=function(_0x5d4928,_0x27da03,_0x4b63e7){if(_0x5d4928['body']['id']){delete _0x5d4928[_0x05ad('0x4b')]['id'];}return db[_0x05ad('0x3f')][_0x05ad('0x4e')]({'where':{'id':_0x5d4928['params']['id']}})[_0x05ad('0x26')](handleEntityNotFound(_0x27da03,null))[_0x05ad('0x26')](function(_0x33601a){if(_0x33601a){_0x5d4928['body'][_0x05ad('0x52')]=_0x33601a['id'];_0x5d4928[_0x05ad('0x4b')][_0x05ad('0x53')]=integrations[_0x05ad('0x54')](_0x5d4928[_0x05ad('0x4b')]['channel'],_0x5d4928[_0x05ad('0x4b')][_0x05ad('0x3d')]);_0x5d4928[_0x05ad('0x4b')]['Descriptions']=integrations[_0x05ad('0x55')](_0x5d4928[_0x05ad('0x4b')]['channel'],_0x5d4928[_0x05ad('0x4b')][_0x05ad('0x3d')]);return db['SugarcrmConfiguration']['create'](_0x5d4928['body'],{'include':[{'model':db['SugarcrmField'],'as':_0x05ad('0x53')},{'model':db['SugarcrmField'],'as':_0x05ad('0x56')}]});}return null;})[_0x05ad('0x26')](respondWithResult(_0x27da03,null))[_0x05ad('0x44')](handleError(_0x27da03,null));};exports[_0x05ad('0x57')]=function(_0x2a5d42,_0x3ad660,_0x2a1e77){var _0x24d4b5='';var _0xeeedc0=['id',_0x05ad('0x2a'),_0x05ad('0x58'),_0x05ad('0x59'),_0x05ad('0x5a'),_0x05ad('0x5b'),_0x05ad('0x5c'),_0x05ad('0x5d'),_0x05ad('0x5e'),'parent_type',_0x05ad('0x5f'),_0x05ad('0x60')];return db[_0x05ad('0x3f')][_0x05ad('0x4e')]({'where':{'id':_0x2a5d42['params']['id']},'attributes':['id',_0x05ad('0x61'),'password','remoteUri']})[_0x05ad('0x26')](handleEntityNotFound(_0x3ad660,null))[_0x05ad('0x26')](function(_0x5a0cb5){if(_0x5a0cb5){_0x24d4b5=_0x5a0cb5[_0x05ad('0x62')];var _0xfa71c9=_0x24d4b5[_0x05ad('0x63')](-0x1);if(_0xfa71c9==='/'){_0x24d4b5=_0x24d4b5[_0x05ad('0x64')](0x0,_0x24d4b5[_0x05ad('0x65')](_0xfa71c9));}return rp({'method':_0x05ad('0x66'),'uri':util[_0x05ad('0x67')](_0x05ad('0x68'),_0x24d4b5,_0x05ad('0x69')),'json':!![],'form':{'method':_0x05ad('0x6a'),'input_type':'JSON','response_type':_0x05ad('0x6b'),'rest_data':JSON['stringify']({'user_auth':{'user_name':_0x5a0cb5['username'],'password':_0x5a0cb5[_0x05ad('0x6c')],'encryption':_0x05ad('0x6d')},'application':_0x05ad('0x6e')})}});}})[_0x05ad('0x26')](function(_0x536895){if(_0x536895&&_0x536895[_0x05ad('0x2a')]!==_0x05ad('0x6f')&&_0x536895['name']!=='Password\x20Expired'){return rp({'method':'POST','uri':util[_0x05ad('0x67')](_0x05ad('0x68'),_0x24d4b5,_0x05ad('0x69')),'json':!![],'form':{'method':_0x05ad('0x70'),'input_type':_0x05ad('0x6b'),'response_type':_0x05ad('0x6b'),'rest_data':JSON[_0x05ad('0x71')]({'session':_0x536895['id'],'module_name':_0x05ad('0x72')})}})[_0x05ad('0x26')](function(_0x2039ba){if(_0x2039ba){var _0x49b089=_[_0x05ad('0x73')](_0x2039ba[_0x05ad('0x74')]);_[_0x05ad('0x75')](_0x49b089,function(_0x471a6f){return _0xeeedc0[_0x05ad('0x76')](_0x471a6f[_0x05ad('0x2a')]);});return{'count':_0x49b089[_0x05ad('0x35')],'rows':_[_0x05ad('0x2c')](_0x49b089,function(_0x174f68){return{'id':_0x174f68['name'],'name':_0x174f68[_0x05ad('0x77')],'custom':_['endsWith'](_0x174f68[_0x05ad('0x2a')],'_c')?!![]:![],'options':_0x174f68[_0x05ad('0x48')]?_[_0x05ad('0x2c')](_[_0x05ad('0x73')](_0x174f68[_0x05ad('0x48')]),function(_0x4e2994){return{'name':_0x4e2994['value'],'value':_0x4e2994[_0x05ad('0x2a')]};}):[]};})};}})[_0x05ad('0x26')](respondWithResult(_0x3ad660,null))[_0x05ad('0x44')](function(_0x2d32aa){var _0xa45d80=_0x2a5d42[_0x05ad('0x30')]['test']?0x1f4:_0x2d32aa[_0x05ad('0x78')]||0x1f4;logger['error'](_0x05ad('0x79'),_0x05ad('0x57'),_0xa45d80,JSON[_0x05ad('0x71')](_0x2d32aa));delete _0x2d32aa[_0x05ad('0x2a')];if(_0xa45d80===0x191){_0xa45d80=0x190;}_0x3ad660[_0x05ad('0x1c')](_0xa45d80)[_0x05ad('0x7a')](_0x2a5d42['query']['test']?{'message':'Wrong\x20credentials','statusCode':_0x2d32aa[_0x05ad('0x78')]}:_0x2d32aa);});}else{var _0xb1f42d=0x1f4;_0x3ad660[_0x05ad('0x1c')](_0xb1f42d)[_0x05ad('0x7a')]({'message':_0x05ad('0x7b'),'statusCode':0x190});}});};
\ No newline at end of file