Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index f32d572..6dc175d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfe15=['filter','merge','options','includeAll','include','findAll','rows','show','params','find','create','body','getConfigurations','findOne','sort','hasOwnProperty','addConfiguration','AccountId','getSubjects','channel','Descriptions','DeskConfiguration','DeskField','Subjects','getFields','priority','authType','username','consumerKey','token','tokenSecret','remoteUri','slice','substring','GET','format','%s/custom_fields','application/json','basic','headers','Authorization','%s:%s','toString','concat','_embedded','entries','active','label','test','getFields,\x20%s,\x20%s,\x20%s','statusCode','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','ejs','lodash','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/environment','../../components/integrations/configuration','jayson/promise','client','request','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','json','offset','limit','set','Content-Range','apply','save','update','destroy','end','stack','name','send','index','map','DeskAccount','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','order','where','filters','pick'];(function(_0x474c00,_0x2f143a){var _0x40538c=function(_0x1edfef){while(--_0x1edfef){_0x474c00['push'](_0x474c00['shift']());}};_0x40538c(++_0x2f143a);}(_0xfe15,0x19b));var _0x5fe1=function(_0x17e5bf,_0x513beb){_0x17e5bf=_0x17e5bf-0x0;var _0x2b7ae6=_0xfe15[_0x17e5bf];return _0x2b7ae6;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x5fe1('0x0'));var rimraf=require(_0x5fe1('0x1'));var zipdir=require(_0x5fe1('0x2'));var jsonpatch=require(_0x5fe1('0x3'));var rp=require('request-promise');var moment=require(_0x5fe1('0x4'));var BPromise=require(_0x5fe1('0x5'));var Mustache=require('mustache');var util=require(_0x5fe1('0x6'));var path=require(_0x5fe1('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x5fe1('0x8'));var fs=require('fs');var _=require(_0x5fe1('0x9'));var squel=require('squel');var crypto=require(_0x5fe1('0xa'));var jsforce=require('jsforce');var deskjs=require(_0x5fe1('0xb'));var toCsv=require(_0x5fe1('0xc'));var querystring=require(_0x5fe1('0xd'));var Papa=require(_0x5fe1('0xe'));var Redis=require(_0x5fe1('0xf'));var authService=require(_0x5fe1('0x10'));var qs=require(_0x5fe1('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require(_0x5fe1('0x12'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0x5fe1('0x13'));var jayson=require(_0x5fe1('0x14'));var client=jayson[_0x5fe1('0x15')]['http']({'port':0x232a});function respondWithRpcPromise(_0x14deb3,_0x456927,_0xb02cbc,_0x5eb46b){return new BPromise(function(_0x441033,_0x1b782f){var _0x2d2f2c=_0x5eb46b||client;return _0x2d2f2c[_0x5fe1('0x16')](_0x14deb3,_0xb02cbc)[_0x5fe1('0x17')](function(_0x2dc831){logger[_0x5fe1('0x18')](_0x5fe1('0x19'),_0x456927,_0x5fe1('0x1a'));logger[_0x5fe1('0x1b')](_0x5fe1('0x1c'),_0x456927,_0x5fe1('0x1a'),JSON[_0x5fe1('0x1d')](_0x2dc831));if(_0x2dc831[_0x5fe1('0x1e')]){if(_0x2dc831['error'][_0x5fe1('0x1f')]===0x1f4){logger[_0x5fe1('0x1e')](_0x5fe1('0x19'),_0x456927,_0x2dc831[_0x5fe1('0x1e')][_0x5fe1('0x20')]);return _0x1b782f(_0x2dc831[_0x5fe1('0x1e')][_0x5fe1('0x20')]);}logger[_0x5fe1('0x1e')](_0x5fe1('0x19'),_0x456927,_0x2dc831[_0x5fe1('0x1e')][_0x5fe1('0x20')]);return _0x441033(_0x2dc831['error'][_0x5fe1('0x20')]);}else{logger['info'](_0x5fe1('0x19'),_0x456927,_0x5fe1('0x1a'));_0x441033(_0x2dc831[_0x5fe1('0x21')][_0x5fe1('0x20')]);}})[_0x5fe1('0x22')](function(_0x309c0e){logger[_0x5fe1('0x1e')](_0x5fe1('0x19'),_0x456927,_0x309c0e);_0x1b782f(_0x309c0e);});});}function respondWithStatusCode(_0xe6907d,_0x35d37c){_0x35d37c=_0x35d37c||0xcc;return function(_0x235ba6){if(_0x235ba6){return _0xe6907d[_0x5fe1('0x23')](_0x35d37c);}return _0xe6907d[_0x5fe1('0x24')](_0x35d37c)['end']();};}function respondWithResult(_0x48b83,_0x4685a4){_0x4685a4=_0x4685a4||0xc8;return function(_0x2b6ae1){if(_0x2b6ae1){return _0x48b83[_0x5fe1('0x24')](_0x4685a4)[_0x5fe1('0x25')](_0x2b6ae1);}};}function respondWithFilteredResult(_0x53a62e,_0x202280){return function(_0x1decc7){if(_0x1decc7){var _0x35e6f0=_0x1decc7['count'],_0x51ed6e=_0x202280[_0x5fe1('0x26')],_0x3b7ec0=_0x202280[_0x5fe1('0x26')]+_0x202280[_0x5fe1('0x27')],_0x5562eb;if(_0x3b7ec0>=_0x35e6f0){_0x3b7ec0=_0x35e6f0;_0x5562eb=0xc8;}else{_0x5562eb=0xce;}_0x53a62e[_0x5fe1('0x24')](_0x5562eb);return _0x53a62e[_0x5fe1('0x28')](_0x5fe1('0x29'),_0x51ed6e+'-'+_0x3b7ec0+'/'+_0x35e6f0)['json'](_0x1decc7);}return null;};}function patchUpdates(_0x26834e){return function(_0x14cc1f){try{jsonpatch[_0x5fe1('0x2a')](_0x14cc1f,_0x26834e,!![]);}catch(_0x543c90){return BPromise['reject'](_0x543c90);}return _0x14cc1f[_0x5fe1('0x2b')]();};}function saveUpdates(_0x3946c6,_0x745d04){return function(_0x438c73){if(_0x438c73){return _0x438c73[_0x5fe1('0x2c')](_0x3946c6)['then'](function(_0x404441){return _0x404441;});}return null;};}function removeEntity(_0xc67a7e,_0x325f04){return function(_0x1f2bd5){if(_0x1f2bd5){return _0x1f2bd5[_0x5fe1('0x2d')]()[_0x5fe1('0x17')](function(){_0xc67a7e[_0x5fe1('0x24')](0xcc)[_0x5fe1('0x2e')]();});}};}function handleEntityNotFound(_0x546ece,_0x57b345){return function(_0x4bb4b8){if(!_0x4bb4b8){_0x546ece[_0x5fe1('0x23')](0x194);}return _0x4bb4b8;};}function handleError(_0x112639,_0x4e66dd){_0x4e66dd=_0x4e66dd||0x1f4;return function(_0x5d0ce5){logger[_0x5fe1('0x1e')](_0x5d0ce5[_0x5fe1('0x2f')]);if(_0x5d0ce5[_0x5fe1('0x30')]){delete _0x5d0ce5['name'];}_0x112639[_0x5fe1('0x24')](_0x4e66dd)[_0x5fe1('0x31')](_0x5d0ce5);};}exports[_0x5fe1('0x32')]=function(_0x3540f5,_0x4d3abf){var _0x50d983={},_0x271369={},_0x36592f={'count':0x0,'rows':[]};var _0x309176=_[_0x5fe1('0x33')](db[_0x5fe1('0x34')][_0x5fe1('0x35')],function(_0x5ccff0){return{'name':_0x5ccff0[_0x5fe1('0x36')],'type':_0x5ccff0[_0x5fe1('0x37')][_0x5fe1('0x38')]};});_0x271369[_0x5fe1('0x39')]=_[_0x5fe1('0x33')](_0x309176,'name');_0x271369[_0x5fe1('0x3a')]=_[_0x5fe1('0x3b')](_0x3540f5['query']);_0x271369['filters']=_[_0x5fe1('0x3c')](_0x271369[_0x5fe1('0x39')],_0x271369[_0x5fe1('0x3a')]);_0x50d983[_0x5fe1('0x3d')]=_[_0x5fe1('0x3c')](_0x271369[_0x5fe1('0x39')],qs[_0x5fe1('0x3e')](_0x3540f5[_0x5fe1('0x3a')][_0x5fe1('0x3e')]));_0x50d983[_0x5fe1('0x3d')]=_0x50d983['attributes'][_0x5fe1('0x3f')]?_0x50d983[_0x5fe1('0x3d')]:_0x271369['model'];if(!_0x3540f5[_0x5fe1('0x3a')]['hasOwnProperty'](_0x5fe1('0x40'))){_0x50d983[_0x5fe1('0x27')]=qs['limit'](_0x3540f5[_0x5fe1('0x3a')][_0x5fe1('0x27')]);_0x50d983[_0x5fe1('0x26')]=qs[_0x5fe1('0x26')](_0x3540f5[_0x5fe1('0x3a')][_0x5fe1('0x26')]);}_0x50d983[_0x5fe1('0x41')]=qs['sort'](_0x3540f5['query']['sort']);_0x50d983[_0x5fe1('0x42')]=qs[_0x5fe1('0x43')](_[_0x5fe1('0x44')](_0x3540f5['query'],_0x271369['filters']),_0x309176);if(_0x3540f5[_0x5fe1('0x3a')][_0x5fe1('0x45')]){_0x50d983['where']=_['merge'](_0x50d983[_0x5fe1('0x42')],{'$or':_[_0x5fe1('0x33')](_0x309176,function(_0x19534d){if(_0x19534d[_0x5fe1('0x37')]!=='VIRTUAL'){var _0x34387b={};_0x34387b[_0x19534d[_0x5fe1('0x30')]]={'$like':'%'+_0x3540f5[_0x5fe1('0x3a')][_0x5fe1('0x45')]+'%'};return _0x34387b;}})});}_0x50d983=_[_0x5fe1('0x46')]({},_0x50d983,_0x3540f5[_0x5fe1('0x47')]);var _0x2d96b3={'where':_0x50d983[_0x5fe1('0x42')]};return db[_0x5fe1('0x34')]['count'](_0x2d96b3)['then'](function(_0xc65d8f){_0x36592f['count']=_0xc65d8f;if(_0x3540f5[_0x5fe1('0x3a')][_0x5fe1('0x48')]){_0x50d983[_0x5fe1('0x49')]=[{'all':!![]}];}return db[_0x5fe1('0x34')][_0x5fe1('0x4a')](_0x50d983);})['then'](function(_0x254aa3){_0x36592f[_0x5fe1('0x4b')]=_0x254aa3;return _0x36592f;})[_0x5fe1('0x17')](respondWithFilteredResult(_0x4d3abf,_0x50d983))[_0x5fe1('0x22')](handleError(_0x4d3abf,null));};exports[_0x5fe1('0x4c')]=function(_0x236b81,_0x2f9f86){var _0x5e8670={'raw':![],'where':{'id':_0x236b81[_0x5fe1('0x4d')]['id']}},_0x445935={};_0x445935[_0x5fe1('0x39')]=_[_0x5fe1('0x3b')](db[_0x5fe1('0x34')][_0x5fe1('0x35')]);_0x445935[_0x5fe1('0x3a')]=_[_0x5fe1('0x3b')](_0x236b81['query']);_0x445935[_0x5fe1('0x43')]=_['intersection'](_0x445935['model'],_0x445935[_0x5fe1('0x3a')]);_0x5e8670[_0x5fe1('0x3d')]=_[_0x5fe1('0x3c')](_0x445935[_0x5fe1('0x39')],qs['fields'](_0x236b81[_0x5fe1('0x3a')][_0x5fe1('0x3e')]));_0x5e8670['attributes']=_0x5e8670[_0x5fe1('0x3d')][_0x5fe1('0x3f')]?_0x5e8670[_0x5fe1('0x3d')]:_0x445935[_0x5fe1('0x39')];if(_0x236b81['query'][_0x5fe1('0x48')]){_0x5e8670['include']=[{'all':!![]}];}_0x5e8670=_['merge']({},_0x5e8670,_0x236b81['options']);return db[_0x5fe1('0x34')][_0x5fe1('0x4e')](_0x5e8670)[_0x5fe1('0x17')](handleEntityNotFound(_0x2f9f86,null))[_0x5fe1('0x17')](respondWithResult(_0x2f9f86,null))['catch'](handleError(_0x2f9f86,null));};exports[_0x5fe1('0x4f')]=function(_0xd16148,_0x312c4b){return db['DeskAccount'][_0x5fe1('0x4f')](_0xd16148[_0x5fe1('0x50')],{})['then'](respondWithResult(_0x312c4b,0xc9))[_0x5fe1('0x22')](handleError(_0x312c4b,null));};exports[_0x5fe1('0x2c')]=function(_0x25d801,_0xd0362b){if(_0x25d801['body']['id']){delete _0x25d801[_0x5fe1('0x50')]['id'];}return db['DeskAccount'][_0x5fe1('0x4e')]({'where':{'id':_0x25d801[_0x5fe1('0x4d')]['id']}})['then'](handleEntityNotFound(_0xd0362b,null))[_0x5fe1('0x17')](saveUpdates(_0x25d801['body'],null))[_0x5fe1('0x17')](respondWithResult(_0xd0362b,null))[_0x5fe1('0x22')](handleError(_0xd0362b,null));};exports[_0x5fe1('0x2d')]=function(_0x16622b,_0x20676b){return db[_0x5fe1('0x34')]['find']({'where':{'id':_0x16622b[_0x5fe1('0x4d')]['id']}})['then'](handleEntityNotFound(_0x20676b,null))[_0x5fe1('0x17')](removeEntity(_0x20676b,null))['catch'](handleError(_0x20676b,null));};exports[_0x5fe1('0x51')]=function(_0x83a4d,_0x105c94,_0x5c758f){var _0x260970={};var _0x5ed596={};var _0x8131a8;var _0x4e407a;return db[_0x5fe1('0x34')][_0x5fe1('0x52')]({'where':{'id':_0x83a4d['params']['id']}})[_0x5fe1('0x17')](handleEntityNotFound(_0x105c94,null))[_0x5fe1('0x17')](function(_0x2037c5){if(_0x2037c5){_0x8131a8=_0x2037c5;_0x5ed596[_0x5fe1('0x39')]=_['keys'](db['DeskConfiguration'][_0x5fe1('0x35')]);_0x5ed596['query']=_[_0x5fe1('0x3b')](_0x83a4d[_0x5fe1('0x3a')]);_0x5ed596[_0x5fe1('0x43')]=_['intersection'](_0x5ed596[_0x5fe1('0x39')],_0x5ed596[_0x5fe1('0x3a')]);_0x260970['attributes']=_[_0x5fe1('0x3c')](_0x5ed596['model'],qs[_0x5fe1('0x3e')](_0x83a4d[_0x5fe1('0x3a')]['fields']));_0x260970[_0x5fe1('0x3d')]=_0x260970[_0x5fe1('0x3d')][_0x5fe1('0x3f')]?_0x260970['attributes']:_0x5ed596[_0x5fe1('0x39')];_0x260970[_0x5fe1('0x41')]=qs[_0x5fe1('0x53')](_0x83a4d[_0x5fe1('0x3a')]['sort']);_0x260970[_0x5fe1('0x42')]=qs[_0x5fe1('0x43')](_[_0x5fe1('0x44')](_0x83a4d['query'],_0x5ed596['filters']));if(_0x83a4d[_0x5fe1('0x3a')][_0x5fe1('0x45')]){_0x260970[_0x5fe1('0x42')]=_['merge'](_0x260970[_0x5fe1('0x42')],{'$or':_[_0x5fe1('0x33')](_0x260970[_0x5fe1('0x3d')],function(_0xff9fae){var _0x382865={};_0x382865[_0xff9fae]={'$like':'%'+_0x83a4d[_0x5fe1('0x3a')][_0x5fe1('0x45')]+'%'};return _0x382865;})});}_0x260970=_[_0x5fe1('0x46')]({},_0x260970,_0x83a4d[_0x5fe1('0x47')]);return _0x8131a8['getConfigurations'](_0x260970);}})[_0x5fe1('0x17')](function(_0x5e1074){if(_0x5e1074){_0x4e407a=_0x5e1074[_0x5fe1('0x3f')];if(!_0x83a4d['query'][_0x5fe1('0x54')](_0x5fe1('0x40'))){_0x260970[_0x5fe1('0x27')]=qs[_0x5fe1('0x27')](_0x83a4d[_0x5fe1('0x3a')]['limit']);_0x260970[_0x5fe1('0x26')]=qs[_0x5fe1('0x26')](_0x83a4d[_0x5fe1('0x3a')][_0x5fe1('0x26')]);}return _0x8131a8[_0x5fe1('0x51')](_0x260970);}})[_0x5fe1('0x17')](function(_0x417a8c){if(_0x417a8c){return _0x417a8c?{'count':_0x4e407a,'rows':_0x417a8c}:null;}})[_0x5fe1('0x17')](respondWithResult(_0x105c94,null))[_0x5fe1('0x22')](handleError(_0x105c94,null));};exports[_0x5fe1('0x55')]=function(_0x4f0e32,_0x2b1ed8,_0x30fbbd){if(_0x4f0e32['body']['id']){delete _0x4f0e32[_0x5fe1('0x50')]['id'];}return db[_0x5fe1('0x34')][_0x5fe1('0x52')]({'where':{'id':_0x4f0e32[_0x5fe1('0x4d')]['id']}})[_0x5fe1('0x17')](handleEntityNotFound(_0x2b1ed8,null))[_0x5fe1('0x17')](function(_0x135161){if(_0x135161){_0x4f0e32[_0x5fe1('0x50')][_0x5fe1('0x56')]=_0x135161['id'];_0x4f0e32[_0x5fe1('0x50')]['Subjects']=integrations[_0x5fe1('0x57')](_0x4f0e32['body'][_0x5fe1('0x58')],_0x4f0e32['body'][_0x5fe1('0x37')]);_0x4f0e32[_0x5fe1('0x50')][_0x5fe1('0x59')]=integrations['getDescriptions'](_0x4f0e32['body'][_0x5fe1('0x58')],_0x4f0e32[_0x5fe1('0x50')][_0x5fe1('0x37')]);return db[_0x5fe1('0x5a')][_0x5fe1('0x4f')](_0x4f0e32[_0x5fe1('0x50')],{'include':[{'model':db[_0x5fe1('0x5b')],'as':_0x5fe1('0x5c')},{'model':db[_0x5fe1('0x5b')],'as':_0x5fe1('0x59')}]});}return null;})[_0x5fe1('0x17')](respondWithResult(_0x2b1ed8,null))['catch'](handleError(_0x2b1ed8,null));};exports[_0x5fe1('0x5d')]=function(_0x4ea78e,_0x5a764b,_0x4970a9){var _0xc7e4f5=[{'name':_0x5fe1('0x5e'),'label':'priority','custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x5af57e='';return db[_0x5fe1('0x34')][_0x5fe1('0x52')]({'where':{'id':_0x4ea78e['params']['id']},'attributes':['id','remoteUri',_0x5fe1('0x5f'),_0x5fe1('0x60'),'password',_0x5fe1('0x61'),'consumerSecret',_0x5fe1('0x62'),_0x5fe1('0x63')]})['then'](handleEntityNotFound(_0x5a764b,null))[_0x5fe1('0x17')](function(_0x20ce6c){if(_0x20ce6c){_0x5af57e=_0x20ce6c[_0x5fe1('0x64')];var _0x7277d6=_0x5af57e[_0x5fe1('0x65')](-0x1);if(_0x7277d6==='/'){_0x5af57e=_0x5af57e[_0x5fe1('0x66')](0x0,_0x5af57e['lastIndexOf'](_0x7277d6));}var _0x158656={'method':_0x5fe1('0x67'),'uri':util[_0x5fe1('0x68')](_0x5fe1('0x69'),_0x5af57e),'headers':{'Content-Type':_0x5fe1('0x6a'),'Accept':_0x5fe1('0x6a')},'json':!![]};if(_0x20ce6c[_0x5fe1('0x5f')]===_0x5fe1('0x6b')){_0x158656[_0x5fe1('0x6c')][_0x5fe1('0x6d')]=util[_0x5fe1('0x68')]('Basic\x20%s',new Buffer(util[_0x5fe1('0x68')](_0x5fe1('0x6e'),_0x20ce6c[_0x5fe1('0x60')],_0x20ce6c['password']))[_0x5fe1('0x6f')]('base64'));}return rp(_0x158656)[_0x5fe1('0x17')](function(_0x38c191){return _0xc7e4f5[_0x5fe1('0x70')](_['map'](_0x38c191[_0x5fe1('0x71')][_0x5fe1('0x72')],function(_0x402c03){return{'id':_0x402c03[_0x5fe1('0x30')],'name':_0x402c03[_0x5fe1('0x30')],'type':_0x402c03[_0x5fe1('0x37')],'active':_0x402c03[_0x5fe1('0x73')],'label':_0x402c03[_0x5fe1('0x74')],'custom':!![]};}));});}})[_0x5fe1('0x17')](function(_0x31cfdb){return{'count':_0x31cfdb[_0x5fe1('0x3f')],'rows':_0x31cfdb};})[_0x5fe1('0x17')](respondWithResult(_0x5a764b,null))[_0x5fe1('0x22')](function(_0x89e8ae){var _0x45aeb9=_0x4ea78e[_0x5fe1('0x3a')][_0x5fe1('0x75')]?0x1f4:_0x89e8ae['statusCode']||0x1f4;logger['error'](_0x5fe1('0x76'),'getFields',_0x45aeb9,JSON['stringify'](_0x89e8ae));delete _0x89e8ae[_0x5fe1('0x30')];if(_0x45aeb9===0x191){_0x45aeb9=0x190;}_0x5a764b['status'](_0x45aeb9)[_0x5fe1('0x31')](_0x4ea78e[_0x5fe1('0x3a')][_0x5fe1('0x75')]?{'message':'Wrong\x20credentials','statusCode':_0x89e8ae[_0x5fe1('0x77')]}:_0x89e8ae);});};
\ No newline at end of file
+var _0xacf3=['../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','http','request','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','end','status','json','count','offset','limit','set','Content-Range','apply','save','destroy','sendStatus','name','index','map','DeskAccount','fieldName','type','key','keys','filters','model','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','options','includeAll','rows','show','rawAttributes','create','update','body','find','params','getConfigurations','findOne','DeskConfiguration','AccountId','Subjects','getSubjects','channel','getDescriptions','DeskField','getFields','priority','remoteUri','username','consumerKey','token','tokenSecret','slice','substring','lastIndexOf','GET','%s/custom_fields','application/json','authType','basic','headers','format','Basic\x20%s','password','base64','concat','_embedded','entries','label','test','getFields,\x20%s,\x20%s,\x20%s','send','statusCode','html-pdf','eml-format','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment'];(function(_0x21a9d9,_0x4d5ac8){var _0x46adce=function(_0xfdd336){while(--_0xfdd336){_0x21a9d9['push'](_0x21a9d9['shift']());}};_0x46adce(++_0x4d5ac8);}(_0xacf3,0x152));var _0x3acf=function(_0x46e363,_0x45d7e2){_0x46e363=_0x46e363-0x0;var _0x3fb059=_0xacf3[_0x46e363];return _0x3fb059;};'use strict';var pdf=require(_0x3acf('0x0'));var emlformat=require(_0x3acf('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x3acf('0x2'));var rp=require(_0x3acf('0x3'));var moment=require(_0x3acf('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x3acf('0x5'));var util=require(_0x3acf('0x6'));var path=require(_0x3acf('0x7'));var sox=require(_0x3acf('0x8'));var csv=require(_0x3acf('0x9'));var ejs=require(_0x3acf('0xa'));var fs=require('fs');var _=require(_0x3acf('0xb'));var squel=require(_0x3acf('0xc'));var crypto=require(_0x3acf('0xd'));var jsforce=require(_0x3acf('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x3acf('0x9'));var querystring=require('querystring');var Papa=require(_0x3acf('0xf'));var Redis=require(_0x3acf('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x3acf('0x11'));var as=require(_0x3acf('0x12'));var hardwareService=require(_0x3acf('0x13'));var logger=require('../../config/logger')(_0x3acf('0x14'));var utils=require('../../config/utils');var config=require(_0x3acf('0x15'));var licenseUtil=require(_0x3acf('0x16'));var db=require(_0x3acf('0x17'))['db'];var integrations=require(_0x3acf('0x18'));var jayson=require(_0x3acf('0x19'));var client=jayson['client'][_0x3acf('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x3164fb,_0x58205b,_0x4fb41f,_0x154170){return new BPromise(function(_0xef65b9,_0x52f371){var _0x172814=_0x154170||client;return _0x172814[_0x3acf('0x1b')](_0x3164fb,_0x4fb41f)[_0x3acf('0x1c')](function(_0x2de7c6){logger[_0x3acf('0x1d')](_0x3acf('0x1e'),_0x58205b,_0x3acf('0x1f'));logger['debug'](_0x3acf('0x20'),_0x58205b,_0x3acf('0x1f'),JSON[_0x3acf('0x21')](_0x2de7c6));if(_0x2de7c6['error']){if(_0x2de7c6[_0x3acf('0x22')][_0x3acf('0x23')]===0x1f4){logger[_0x3acf('0x22')](_0x3acf('0x1e'),_0x58205b,_0x2de7c6[_0x3acf('0x22')][_0x3acf('0x24')]);return _0x52f371(_0x2de7c6['error']['message']);}logger[_0x3acf('0x22')](_0x3acf('0x1e'),_0x58205b,_0x2de7c6[_0x3acf('0x22')][_0x3acf('0x24')]);return _0xef65b9(_0x2de7c6[_0x3acf('0x22')][_0x3acf('0x24')]);}else{logger['info'](_0x3acf('0x1e'),_0x58205b,_0x3acf('0x1f'));_0xef65b9(_0x2de7c6[_0x3acf('0x25')][_0x3acf('0x24')]);}})[_0x3acf('0x26')](function(_0x182030){logger[_0x3acf('0x22')]('DeskAccount,\x20%s,\x20%s',_0x58205b,_0x182030);_0x52f371(_0x182030);});});}function respondWithStatusCode(_0x55076b,_0x1c8da3){_0x1c8da3=_0x1c8da3||0xcc;return function(_0x18a0b9){if(_0x18a0b9){return _0x55076b['sendStatus'](_0x1c8da3);}return _0x55076b['status'](_0x1c8da3)[_0x3acf('0x27')]();};}function respondWithResult(_0xeae2f8,_0x27ddd4){_0x27ddd4=_0x27ddd4||0xc8;return function(_0x4f8c01){if(_0x4f8c01){return _0xeae2f8[_0x3acf('0x28')](_0x27ddd4)[_0x3acf('0x29')](_0x4f8c01);}};}function respondWithFilteredResult(_0x1a7eb9,_0x33a645){return function(_0x22e921){if(_0x22e921){var _0x41050e=_0x22e921[_0x3acf('0x2a')],_0x1e2ad0=_0x33a645[_0x3acf('0x2b')],_0x5f3cc1=_0x33a645[_0x3acf('0x2b')]+_0x33a645[_0x3acf('0x2c')],_0x5118e9;if(_0x5f3cc1>=_0x41050e){_0x5f3cc1=_0x41050e;_0x5118e9=0xc8;}else{_0x5118e9=0xce;}_0x1a7eb9['status'](_0x5118e9);return _0x1a7eb9[_0x3acf('0x2d')](_0x3acf('0x2e'),_0x1e2ad0+'-'+_0x5f3cc1+'/'+_0x41050e)[_0x3acf('0x29')](_0x22e921);}return null;};}function patchUpdates(_0x378a75){return function(_0x3f2651){try{jsonpatch[_0x3acf('0x2f')](_0x3f2651,_0x378a75,!![]);}catch(_0x1fa344){return BPromise['reject'](_0x1fa344);}return _0x3f2651[_0x3acf('0x30')]();};}function saveUpdates(_0x555f6c,_0x170d0f){return function(_0xcb4a97){if(_0xcb4a97){return _0xcb4a97['update'](_0x555f6c)[_0x3acf('0x1c')](function(_0xb3e7c9){return _0xb3e7c9;});}return null;};}function removeEntity(_0x3e18d0,_0x504eb5){return function(_0x4d6781){if(_0x4d6781){return _0x4d6781[_0x3acf('0x31')]()[_0x3acf('0x1c')](function(){_0x3e18d0[_0x3acf('0x28')](0xcc)[_0x3acf('0x27')]();});}};}function handleEntityNotFound(_0xb906e7,_0x1f17a1){return function(_0x2502f8){if(!_0x2502f8){_0xb906e7[_0x3acf('0x32')](0x194);}return _0x2502f8;};}function handleError(_0x398d3f,_0x494732){_0x494732=_0x494732||0x1f4;return function(_0x43a015){logger[_0x3acf('0x22')](_0x43a015['stack']);if(_0x43a015[_0x3acf('0x33')]){delete _0x43a015[_0x3acf('0x33')];}_0x398d3f['status'](_0x494732)['send'](_0x43a015);};}exports[_0x3acf('0x34')]=function(_0x3cbc98,_0x5f2f26){var _0x4357f7={},_0x56e30e={},_0x564ff1={'count':0x0,'rows':[]};var _0x286af8=_[_0x3acf('0x35')](db[_0x3acf('0x36')]['rawAttributes'],function(_0x333acb){return{'name':_0x333acb[_0x3acf('0x37')],'type':_0x333acb[_0x3acf('0x38')][_0x3acf('0x39')]};});_0x56e30e['model']=_['map'](_0x286af8,_0x3acf('0x33'));_0x56e30e['query']=_[_0x3acf('0x3a')](_0x3cbc98['query']);_0x56e30e[_0x3acf('0x3b')]=_['intersection'](_0x56e30e[_0x3acf('0x3c')],_0x56e30e[_0x3acf('0x3d')]);_0x4357f7[_0x3acf('0x3e')]=_[_0x3acf('0x3f')](_0x56e30e[_0x3acf('0x3c')],qs[_0x3acf('0x40')](_0x3cbc98['query']['fields']));_0x4357f7[_0x3acf('0x3e')]=_0x4357f7[_0x3acf('0x3e')][_0x3acf('0x41')]?_0x4357f7[_0x3acf('0x3e')]:_0x56e30e[_0x3acf('0x3c')];if(!_0x3cbc98['query'][_0x3acf('0x42')](_0x3acf('0x43'))){_0x4357f7[_0x3acf('0x2c')]=qs[_0x3acf('0x2c')](_0x3cbc98[_0x3acf('0x3d')][_0x3acf('0x2c')]);_0x4357f7[_0x3acf('0x2b')]=qs[_0x3acf('0x2b')](_0x3cbc98['query'][_0x3acf('0x2b')]);}_0x4357f7[_0x3acf('0x44')]=qs[_0x3acf('0x45')](_0x3cbc98['query'][_0x3acf('0x45')]);_0x4357f7[_0x3acf('0x46')]=qs[_0x3acf('0x3b')](_['pick'](_0x3cbc98[_0x3acf('0x3d')],_0x56e30e[_0x3acf('0x3b')]),_0x286af8);if(_0x3cbc98['query'][_0x3acf('0x47')]){_0x4357f7[_0x3acf('0x46')]=_[_0x3acf('0x48')](_0x4357f7['where'],{'$or':_[_0x3acf('0x35')](_0x286af8,function(_0x63fb6d){if(_0x63fb6d['type']!=='VIRTUAL'){var _0x45c86b={};_0x45c86b[_0x63fb6d[_0x3acf('0x33')]]={'$like':'%'+_0x3cbc98[_0x3acf('0x3d')][_0x3acf('0x47')]+'%'};return _0x45c86b;}})});}_0x4357f7=_[_0x3acf('0x48')]({},_0x4357f7,_0x3cbc98[_0x3acf('0x49')]);var _0x117627={'where':_0x4357f7[_0x3acf('0x46')]};return db[_0x3acf('0x36')][_0x3acf('0x2a')](_0x117627)[_0x3acf('0x1c')](function(_0x3b5660){_0x564ff1['count']=_0x3b5660;if(_0x3cbc98[_0x3acf('0x3d')][_0x3acf('0x4a')]){_0x4357f7['include']=[{'all':!![]}];}return db[_0x3acf('0x36')]['findAll'](_0x4357f7);})[_0x3acf('0x1c')](function(_0x41d8b4){_0x564ff1[_0x3acf('0x4b')]=_0x41d8b4;return _0x564ff1;})[_0x3acf('0x1c')](respondWithFilteredResult(_0x5f2f26,_0x4357f7))[_0x3acf('0x26')](handleError(_0x5f2f26,null));};exports[_0x3acf('0x4c')]=function(_0x138801,_0x34f9ae){var _0x1d00ba={'raw':![],'where':{'id':_0x138801['params']['id']}},_0x321639={};_0x321639[_0x3acf('0x3c')]=_[_0x3acf('0x3a')](db[_0x3acf('0x36')][_0x3acf('0x4d')]);_0x321639[_0x3acf('0x3d')]=_[_0x3acf('0x3a')](_0x138801[_0x3acf('0x3d')]);_0x321639[_0x3acf('0x3b')]=_[_0x3acf('0x3f')](_0x321639[_0x3acf('0x3c')],_0x321639['query']);_0x1d00ba[_0x3acf('0x3e')]=_['intersection'](_0x321639[_0x3acf('0x3c')],qs[_0x3acf('0x40')](_0x138801['query'][_0x3acf('0x40')]));_0x1d00ba['attributes']=_0x1d00ba['attributes'][_0x3acf('0x41')]?_0x1d00ba['attributes']:_0x321639['model'];if(_0x138801['query'][_0x3acf('0x4a')]){_0x1d00ba['include']=[{'all':!![]}];}_0x1d00ba=_['merge']({},_0x1d00ba,_0x138801[_0x3acf('0x49')]);return db['DeskAccount']['find'](_0x1d00ba)[_0x3acf('0x1c')](handleEntityNotFound(_0x34f9ae,null))[_0x3acf('0x1c')](respondWithResult(_0x34f9ae,null))[_0x3acf('0x26')](handleError(_0x34f9ae,null));};exports[_0x3acf('0x4e')]=function(_0xcfe728,_0x41a3d9){return db[_0x3acf('0x36')]['create'](_0xcfe728['body'],{})[_0x3acf('0x1c')](respondWithResult(_0x41a3d9,0xc9))[_0x3acf('0x26')](handleError(_0x41a3d9,null));};exports[_0x3acf('0x4f')]=function(_0x53bd71,_0x2cb6b9){if(_0x53bd71[_0x3acf('0x50')]['id']){delete _0x53bd71[_0x3acf('0x50')]['id'];}return db['DeskAccount'][_0x3acf('0x51')]({'where':{'id':_0x53bd71[_0x3acf('0x52')]['id']}})[_0x3acf('0x1c')](handleEntityNotFound(_0x2cb6b9,null))['then'](saveUpdates(_0x53bd71[_0x3acf('0x50')],null))['then'](respondWithResult(_0x2cb6b9,null))[_0x3acf('0x26')](handleError(_0x2cb6b9,null));};exports[_0x3acf('0x31')]=function(_0x296386,_0x505b18){return db[_0x3acf('0x36')][_0x3acf('0x51')]({'where':{'id':_0x296386[_0x3acf('0x52')]['id']}})['then'](handleEntityNotFound(_0x505b18,null))[_0x3acf('0x1c')](removeEntity(_0x505b18,null))[_0x3acf('0x26')](handleError(_0x505b18,null));};exports[_0x3acf('0x53')]=function(_0x4d3a86,_0x46859c,_0x5f4a62){var _0x4fa401={};var _0x5cc1e7={};var _0x395944;var _0x4020fa;return db['DeskAccount'][_0x3acf('0x54')]({'where':{'id':_0x4d3a86[_0x3acf('0x52')]['id']}})['then'](handleEntityNotFound(_0x46859c,null))['then'](function(_0x37d2d3){if(_0x37d2d3){_0x395944=_0x37d2d3;_0x5cc1e7['model']=_[_0x3acf('0x3a')](db[_0x3acf('0x55')][_0x3acf('0x4d')]);_0x5cc1e7[_0x3acf('0x3d')]=_[_0x3acf('0x3a')](_0x4d3a86[_0x3acf('0x3d')]);_0x5cc1e7[_0x3acf('0x3b')]=_[_0x3acf('0x3f')](_0x5cc1e7[_0x3acf('0x3c')],_0x5cc1e7[_0x3acf('0x3d')]);_0x4fa401[_0x3acf('0x3e')]=_[_0x3acf('0x3f')](_0x5cc1e7[_0x3acf('0x3c')],qs[_0x3acf('0x40')](_0x4d3a86[_0x3acf('0x3d')][_0x3acf('0x40')]));_0x4fa401[_0x3acf('0x3e')]=_0x4fa401[_0x3acf('0x3e')]['length']?_0x4fa401[_0x3acf('0x3e')]:_0x5cc1e7[_0x3acf('0x3c')];_0x4fa401[_0x3acf('0x44')]=qs['sort'](_0x4d3a86[_0x3acf('0x3d')][_0x3acf('0x45')]);_0x4fa401['where']=qs[_0x3acf('0x3b')](_['pick'](_0x4d3a86['query'],_0x5cc1e7[_0x3acf('0x3b')]));if(_0x4d3a86[_0x3acf('0x3d')][_0x3acf('0x47')]){_0x4fa401[_0x3acf('0x46')]=_[_0x3acf('0x48')](_0x4fa401[_0x3acf('0x46')],{'$or':_[_0x3acf('0x35')](_0x4fa401[_0x3acf('0x3e')],function(_0x4e1ac8){var _0x494ee9={};_0x494ee9[_0x4e1ac8]={'$like':'%'+_0x4d3a86[_0x3acf('0x3d')][_0x3acf('0x47')]+'%'};return _0x494ee9;})});}_0x4fa401=_[_0x3acf('0x48')]({},_0x4fa401,_0x4d3a86[_0x3acf('0x49')]);return _0x395944['getConfigurations'](_0x4fa401);}})['then'](function(_0x1897c3){if(_0x1897c3){_0x4020fa=_0x1897c3[_0x3acf('0x41')];if(!_0x4d3a86[_0x3acf('0x3d')][_0x3acf('0x42')](_0x3acf('0x43'))){_0x4fa401['limit']=qs[_0x3acf('0x2c')](_0x4d3a86['query'][_0x3acf('0x2c')]);_0x4fa401['offset']=qs[_0x3acf('0x2b')](_0x4d3a86[_0x3acf('0x3d')][_0x3acf('0x2b')]);}return _0x395944[_0x3acf('0x53')](_0x4fa401);}})[_0x3acf('0x1c')](function(_0x55e82e){if(_0x55e82e){return _0x55e82e?{'count':_0x4020fa,'rows':_0x55e82e}:null;}})[_0x3acf('0x1c')](respondWithResult(_0x46859c,null))[_0x3acf('0x26')](handleError(_0x46859c,null));};exports['addConfiguration']=function(_0x208571,_0x1b8210,_0x505b6b){if(_0x208571['body']['id']){delete _0x208571[_0x3acf('0x50')]['id'];}return db[_0x3acf('0x36')][_0x3acf('0x54')]({'where':{'id':_0x208571[_0x3acf('0x52')]['id']}})['then'](handleEntityNotFound(_0x1b8210,null))['then'](function(_0x341911){if(_0x341911){_0x208571[_0x3acf('0x50')][_0x3acf('0x56')]=_0x341911['id'];_0x208571['body'][_0x3acf('0x57')]=integrations[_0x3acf('0x58')](_0x208571['body'][_0x3acf('0x59')],_0x208571['body'][_0x3acf('0x38')]);_0x208571[_0x3acf('0x50')]['Descriptions']=integrations[_0x3acf('0x5a')](_0x208571[_0x3acf('0x50')][_0x3acf('0x59')],_0x208571['body'][_0x3acf('0x38')]);return db[_0x3acf('0x55')]['create'](_0x208571[_0x3acf('0x50')],{'include':[{'model':db[_0x3acf('0x5b')],'as':_0x3acf('0x57')},{'model':db[_0x3acf('0x5b')],'as':'Descriptions'}]});}return null;})['then'](respondWithResult(_0x1b8210,null))['catch'](handleError(_0x1b8210,null));};exports[_0x3acf('0x5c')]=function(_0x3b3de7,_0x2a2d14,_0x118533){var _0x546719=[{'name':_0x3acf('0x5d'),'label':_0x3acf('0x5d'),'custom':![],'options':[{'name':0x1,'value':0x1},{'name':0x2,'value':0x2},{'name':0x3,'value':0x3},{'name':0x4,'value':0x4},{'name':0x5,'value':0x5},{'name':0x6,'value':0x6},{'name':0x7,'value':0x7},{'name':0x8,'value':0x8},{'name':0x9,'value':0x9},{'name':0xa,'value':0xa}]}];var _0x5051b4='';return db[_0x3acf('0x36')]['findOne']({'where':{'id':_0x3b3de7[_0x3acf('0x52')]['id']},'attributes':['id',_0x3acf('0x5e'),'authType',_0x3acf('0x5f'),'password',_0x3acf('0x60'),'consumerSecret',_0x3acf('0x61'),_0x3acf('0x62')]})[_0x3acf('0x1c')](handleEntityNotFound(_0x2a2d14,null))[_0x3acf('0x1c')](function(_0x4b7dbf){if(_0x4b7dbf){_0x5051b4=_0x4b7dbf['remoteUri'];var _0x109d3f=_0x5051b4[_0x3acf('0x63')](-0x1);if(_0x109d3f==='/'){_0x5051b4=_0x5051b4[_0x3acf('0x64')](0x0,_0x5051b4[_0x3acf('0x65')](_0x109d3f));}var _0x348260={'method':_0x3acf('0x66'),'uri':util['format'](_0x3acf('0x67'),_0x5051b4),'headers':{'Content-Type':_0x3acf('0x68'),'Accept':_0x3acf('0x68')},'json':!![]};if(_0x4b7dbf[_0x3acf('0x69')]===_0x3acf('0x6a')){_0x348260[_0x3acf('0x6b')]['Authorization']=util[_0x3acf('0x6c')](_0x3acf('0x6d'),new Buffer(util[_0x3acf('0x6c')]('%s:%s',_0x4b7dbf[_0x3acf('0x5f')],_0x4b7dbf[_0x3acf('0x6e')]))['toString'](_0x3acf('0x6f')));}return rp(_0x348260)[_0x3acf('0x1c')](function(_0x144563){return _0x546719[_0x3acf('0x70')](_[_0x3acf('0x35')](_0x144563[_0x3acf('0x71')][_0x3acf('0x72')],function(_0x1dcb40){return{'id':_0x1dcb40['name'],'name':_0x1dcb40['name'],'type':_0x1dcb40['type'],'active':_0x1dcb40['active'],'label':_0x1dcb40[_0x3acf('0x73')],'custom':!![]};}));});}})[_0x3acf('0x1c')](function(_0x592dfe){return{'count':_0x592dfe[_0x3acf('0x41')],'rows':_0x592dfe};})[_0x3acf('0x1c')](respondWithResult(_0x2a2d14,null))[_0x3acf('0x26')](function(_0x331c2d){var _0xc23050=_0x3b3de7[_0x3acf('0x3d')][_0x3acf('0x74')]?0x1f4:_0x331c2d['statusCode']||0x1f4;logger['error'](_0x3acf('0x75'),_0x3acf('0x5c'),_0xc23050,JSON[_0x3acf('0x21')](_0x331c2d));delete _0x331c2d[_0x3acf('0x33')];if(_0xc23050===0x191){_0xc23050=0x190;}_0x2a2d14[_0x3acf('0x28')](_0xc23050)[_0x3acf('0x76')](_0x3b3de7['query'][_0x3acf('0x74')]?{'message':'Wrong\x20credentials','statusCode':_0x331c2d[_0x3acf('0x77')]}:_0x331c2d);});};
\ No newline at end of file