Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / api / intDeskAccount / intDeskAccount.controller.js
index 12e9c1d..9be4704 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0d2f=['destroy','getConfigurations','findOne','DeskConfiguration','order','hasOwnProperty','Subjects','getSubjects','channel','Descriptions','getDescriptions','DeskField','getFields','priority','remoteUri','username','consumerKey','consumerSecret','tokenSecret','slice','substring','lastIndexOf','GET','format','application/json','authType','Authorization','password','toString','base64','concat','_embedded','entries','active','label','statusCode','test','Wrong\x20credentials','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','request','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','status','json','count','offset','limit','Content-Range','apply','reject','update','stack','name','send','index','map','DeskAccount','fieldName','type','model','keys','query','filters','intersection','attributes','fields','nolimit','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','rawAttributes','length','find','create','body','params'];(function(_0x33fb84,_0x1ce421){var _0x43781f=function(_0x23e38c){while(--_0x23e38c){_0x33fb84['push'](_0x33fb84['shift']());}};_0x43781f(++_0x1ce421);}(_0x0d2f,0x9e));var _0xf0d2=function(_0x36550b,_0x4b697c){_0x36550b=_0x36550b-0x0;var _0x4989af=_0x0d2f[_0x36550b];return _0x4989af;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf0d2('0x0'));var rimraf=require(_0xf0d2('0x1'));var zipdir=require(_0xf0d2('0x2'));var jsonpatch=require(_0xf0d2('0x3'));var rp=require('request-promise');var moment=require(_0xf0d2('0x4'));var BPromise=require(_0xf0d2('0x5'));var Mustache=require(_0xf0d2('0x6'));var util=require('util');var path=require('path');var sox=require(_0xf0d2('0x7'));var csv=require(_0xf0d2('0x8'));var ejs=require(_0xf0d2('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0xf0d2('0xa'));var crypto=require(_0xf0d2('0xb'));var jsforce=require(_0xf0d2('0xc'));var deskjs=require(_0xf0d2('0xd'));var toCsv=require('to-csv');var querystring=require(_0xf0d2('0xe'));var Papa=require(_0xf0d2('0xf'));var Redis=require(_0xf0d2('0x10'));var authService=require(_0xf0d2('0x11'));var qs=require(_0xf0d2('0x12'));var as=require(_0xf0d2('0x13'));var hardwareService=require(_0xf0d2('0x14'));var logger=require('../../config/logger')(_0xf0d2('0x15'));var utils=require(_0xf0d2('0x16'));var config=require(_0xf0d2('0x17'));var licenseUtil=require(_0xf0d2('0x18'));var db=require(_0xf0d2('0x19'))['db'];var integrations=require('../../components/integrations/configuration');var jayson=require(_0xf0d2('0x1a'));var client=jayson[_0xf0d2('0x1b')]['http']({'port':0x232a});function respondWithRpcPromise(_0x3b64fa,_0x25c747,_0x4beef8,_0x3c0e23){return new BPromise(function(_0x2132de,_0x5f0d5e){var _0x4576c9=_0x3c0e23||client;return _0x4576c9[_0xf0d2('0x1c')](_0x3b64fa,_0x4beef8)[_0xf0d2('0x1d')](function(_0x49de3f){logger[_0xf0d2('0x1e')](_0xf0d2('0x1f'),_0x25c747,_0xf0d2('0x20'));logger[_0xf0d2('0x21')](_0xf0d2('0x22'),_0x25c747,'request\x20sent',JSON[_0xf0d2('0x23')](_0x49de3f));if(_0x49de3f[_0xf0d2('0x24')]){if(_0x49de3f['error']['code']===0x1f4){logger['error'](_0xf0d2('0x1f'),_0x25c747,_0x49de3f[_0xf0d2('0x24')][_0xf0d2('0x25')]);return _0x5f0d5e(_0x49de3f[_0xf0d2('0x24')][_0xf0d2('0x25')]);}logger[_0xf0d2('0x24')](_0xf0d2('0x1f'),_0x25c747,_0x49de3f[_0xf0d2('0x24')]['message']);return _0x2132de(_0x49de3f[_0xf0d2('0x24')][_0xf0d2('0x25')]);}else{logger[_0xf0d2('0x1e')]('DeskAccount,\x20%s,\x20%s',_0x25c747,'request\x20sent');_0x2132de(_0x49de3f['result'][_0xf0d2('0x25')]);}})[_0xf0d2('0x26')](function(_0x4cca33){logger[_0xf0d2('0x24')](_0xf0d2('0x1f'),_0x25c747,_0x4cca33);_0x5f0d5e(_0x4cca33);});});}function respondWithStatusCode(_0x4f3270,_0x39326a){_0x39326a=_0x39326a||0xcc;return function(_0x25dea4){if(_0x25dea4){return _0x4f3270['sendStatus'](_0x39326a);}return _0x4f3270['status'](_0x39326a)['end']();};}function respondWithResult(_0x40603e,_0x41a400){_0x41a400=_0x41a400||0xc8;return function(_0x2a5523){if(_0x2a5523){return _0x40603e[_0xf0d2('0x27')](_0x41a400)[_0xf0d2('0x28')](_0x2a5523);}};}function respondWithFilteredResult(_0x22ca2a,_0x442b4f){return function(_0xbe21fc){if(_0xbe21fc){var _0x15b6f1=_0xbe21fc[_0xf0d2('0x29')],_0x4dd9a2=_0x442b4f[_0xf0d2('0x2a')],_0xcd531a=_0x442b4f[_0xf0d2('0x2a')]+_0x442b4f[_0xf0d2('0x2b')],_0x112be9;if(_0xcd531a>=_0x15b6f1){_0xcd531a=_0x15b6f1;_0x112be9=0xc8;}else{_0x112be9=0xce;}_0x22ca2a[_0xf0d2('0x27')](_0x112be9);return _0x22ca2a['set'](_0xf0d2('0x2c'),_0x4dd9a2+'-'+_0xcd531a+'/'+_0x15b6f1)[_0xf0d2('0x28')](_0xbe21fc);}return null;};}function patchUpdates(_0x1be9cf){return function(_0x2be876){try{jsonpatch[_0xf0d2('0x2d')](_0x2be876,_0x1be9cf,!![]);}catch(_0x3d6973){return BPromise[_0xf0d2('0x2e')](_0x3d6973);}return _0x2be876['save']();};}function saveUpdates(_0x17637b,_0x28b229){return function(_0x280f8f){if(_0x280f8f){return _0x280f8f[_0xf0d2('0x2f')](_0x17637b)[_0xf0d2('0x1d')](function(_0x5d7613){return _0x5d7613;});}return null;};}function removeEntity(_0x3cf903,_0x3c9a15){return function(_0x153da6){if(_0x153da6){return _0x153da6['destroy']()[_0xf0d2('0x1d')](function(){_0x3cf903[_0xf0d2('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5e1938,_0x33852a){return function(_0x98c78c){if(!_0x98c78c){_0x5e1938['sendStatus'](0x194);}return _0x98c78c;};}function handleError(_0x376dc8,_0xabc580){_0xabc580=_0xabc580||0x1f4;return function(_0x2ae9a9){logger[_0xf0d2('0x24')](_0x2ae9a9[_0xf0d2('0x30')]);if(_0x2ae9a9[_0xf0d2('0x31')]){delete _0x2ae9a9['name'];}_0x376dc8[_0xf0d2('0x27')](_0xabc580)[_0xf0d2('0x32')](_0x2ae9a9);};}exports[_0xf0d2('0x33')]=function(_0x5d950b,_0x5ede25){var _0x331133={},_0x144e3a={},_0x42479c={'count':0x0,'rows':[]};var _0x24f1ea=_[_0xf0d2('0x34')](db[_0xf0d2('0x35')]['rawAttributes'],function(_0x1e03fa){return{'name':_0x1e03fa[_0xf0d2('0x36')],'type':_0x1e03fa[_0xf0d2('0x37')]['key']};});_0x144e3a[_0xf0d2('0x38')]=_['map'](_0x24f1ea,_0xf0d2('0x31'));_0x144e3a['query']=_[_0xf0d2('0x39')](_0x5d950b[_0xf0d2('0x3a')]);_0x144e3a[_0xf0d2('0x3b')]=_[_0xf0d2('0x3c')](_0x144e3a['model'],_0x144e3a['query']);_0x331133[_0xf0d2('0x3d')]=_['intersection'](_0x144e3a[_0xf0d2('0x38')],qs[_0xf0d2('0x3e')](_0x5d950b[_0xf0d2('0x3a')]['fields']));_0x331133[_0xf0d2('0x3d')]=_0x331133[_0xf0d2('0x3d')]['length']?_0x331133[_0xf0d2('0x3d')]:_0x144e3a[_0xf0d2('0x38')];if(!_0x5d950b[_0xf0d2('0x3a')]['hasOwnProperty'](_0xf0d2('0x3f'))){_0x331133[_0xf0d2('0x2b')]=qs[_0xf0d2('0x2b')](_0x5d950b[_0xf0d2('0x3a')][_0xf0d2('0x2b')]);_0x331133[_0xf0d2('0x2a')]=qs[_0xf0d2('0x2a')](_0x5d950b[_0xf0d2('0x3a')][_0xf0d2('0x2a')]);}_0x331133['order']=qs[_0xf0d2('0x40')](_0x5d950b[_0xf0d2('0x3a')][_0xf0d2('0x40')]);_0x331133['where']=qs[_0xf0d2('0x3b')](_[_0xf0d2('0x41')](_0x5d950b[_0xf0d2('0x3a')],_0x144e3a[_0xf0d2('0x3b')]),_0x24f1ea);if(_0x5d950b[_0xf0d2('0x3a')][_0xf0d2('0x42')]){_0x331133[_0xf0d2('0x43')]=_[_0xf0d2('0x44')](_0x331133['where'],{'$or':_[_0xf0d2('0x34')](_0x24f1ea,function(_0x45e66a){if(_0x45e66a['type']!==_0xf0d2('0x45')){var _0x3e5ae3={};_0x3e5ae3[_0x45e66a['name']]={'$like':'%'+_0x5d950b[_0xf0d2('0x3a')][_0xf0d2('0x42')]+'%'};return _0x3e5ae3;}})});}_0x331133=_[_0xf0d2('0x44')]({},_0x331133,_0x5d950b[_0xf0d2('0x46')]);var _0x350ba4={'where':_0x331133[_0xf0d2('0x43')]};return db[_0xf0d2('0x35')]['count'](_0x350ba4)['then'](function(_0x3982a4){_0x42479c[_0xf0d2('0x29')]=_0x3982a4;if(_0x5d950b[_0xf0d2('0x3a')][_0xf0d2('0x47')]){_0x331133[_0xf0d2('0x48')]=[{'all':!![]}];}return db[_0xf0d2('0x35')][_0xf0d2('0x49')](_0x331133);})[_0xf0d2('0x1d')](function(_0x2dd888){_0x42479c[_0xf0d2('0x4a')]=_0x2dd888;return _0x42479c;})[_0xf0d2('0x1d')](respondWithFilteredResult(_0x5ede25,_0x331133))[_0xf0d2('0x26')](handleError(_0x5ede25,null));};exports[_0xf0d2('0x4b')]=function(_0x8c28c0,_0x557856){var _0x4d4027={'raw':![],'where':{'id':_0x8c28c0['params']['id']}},_0x442c66={};_0x442c66['model']=_[_0xf0d2('0x39')](db['DeskAccount'][_0xf0d2('0x4c')]);_0x442c66[_0xf0d2('0x3a')]=_[_0xf0d2('0x39')](_0x8c28c0['query']);_0x442c66[_0xf0d2('0x3b')]=_['intersection'](_0x442c66['model'],_0x442c66[_0xf0d2('0x3a')]);_0x4d4027['attributes']=_[_0xf0d2('0x3c')](_0x442c66[_0xf0d2('0x38')],qs['fields'](_0x8c28c0[_0xf0d2('0x3a')][_0xf0d2('0x3e')]));_0x4d4027[_0xf0d2('0x3d')]=_0x4d4027[_0xf0d2('0x3d')][_0xf0d2('0x4d')]?_0x4d4027[_0xf0d2('0x3d')]:_0x442c66[_0xf0d2('0x38')];if(_0x8c28c0['query'][_0xf0d2('0x47')]){_0x4d4027['include']=[{'all':!![]}];}_0x4d4027=_['merge']({},_0x4d4027,_0x8c28c0[_0xf0d2('0x46')]);return db['DeskAccount'][_0xf0d2('0x4e')](_0x4d4027)[_0xf0d2('0x1d')](handleEntityNotFound(_0x557856,null))[_0xf0d2('0x1d')](respondWithResult(_0x557856,null))[_0xf0d2('0x26')](handleError(_0x557856,null));};exports[_0xf0d2('0x4f')]=function(_0x2cf985,_0x1943cc){return db['DeskAccount'][_0xf0d2('0x4f')](_0x2cf985['body'],{})[_0xf0d2('0x1d')](respondWithResult(_0x1943cc,0xc9))[_0xf0d2('0x26')](handleError(_0x1943cc,null));};exports[_0xf0d2('0x2f')]=function(_0x22a360,_0x2927fd){if(_0x22a360[_0xf0d2('0x50')]['id']){delete _0x22a360['body']['id'];}return db[_0xf0d2('0x35')][_0xf0d2('0x4e')]({'where':{'id':_0x22a360[_0xf0d2('0x51')]['id']}})[_0xf0d2('0x1d')](handleEntityNotFound(_0x2927fd,null))[_0xf0d2('0x1d')](saveUpdates(_0x22a360[_0xf0d2('0x50')],null))['then'](respondWithResult(_0x2927fd,null))[_0xf0d2('0x26')](handleError(_0x2927fd,null));};exports[_0xf0d2('0x52')]=function(_0x2f2ed3,_0x45f65d){return db[_0xf0d2('0x35')][_0xf0d2('0x4e')]({'where':{'id':_0x2f2ed3[_0xf0d2('0x51')]['id']}})[_0xf0d2('0x1d')](handleEntityNotFound(_0x45f65d,null))[_0xf0d2('0x1d')](removeEntity(_0x45f65d,null))[_0xf0d2('0x26')](handleError(_0x45f65d,null));};exports[_0xf0d2('0x53')]=function(_0x5e28ed,_0x4c4d6a,_0x477d13){var _0x4b7402={};var _0x1b4823={};var _0x26a779;var _0x55f4df;return db[_0xf0d2('0x35')][_0xf0d2('0x54')]({'where':{'id':_0x5e28ed[_0xf0d2('0x51')]['id']}})[_0xf0d2('0x1d')](handleEntityNotFound(_0x4c4d6a,null))[_0xf0d2('0x1d')](function(_0x347c70){if(_0x347c70){_0x26a779=_0x347c70;_0x1b4823[_0xf0d2('0x38')]=_['keys'](db[_0xf0d2('0x55')]['rawAttributes']);_0x1b4823[_0xf0d2('0x3a')]=_[_0xf0d2('0x39')](_0x5e28ed[_0xf0d2('0x3a')]);_0x1b4823[_0xf0d2('0x3b')]=_['intersection'](_0x1b4823['model'],_0x1b4823[_0xf0d2('0x3a')]);_0x4b7402[_0xf0d2('0x3d')]=_[_0xf0d2('0x3c')](_0x1b4823[_0xf0d2('0x38')],qs['fields'](_0x5e28ed['query'][_0xf0d2('0x3e')]));_0x4b7402[_0xf0d2('0x3d')]=_0x4b7402[_0xf0d2('0x3d')][_0xf0d2('0x4d')]?_0x4b7402[_0xf0d2('0x3d')]:_0x1b4823[_0xf0d2('0x38')];_0x4b7402[_0xf0d2('0x56')]=qs['sort'](_0x5e28ed[_0xf0d2('0x3a')][_0xf0d2('0x40')]);_0x4b7402[_0xf0d2('0x43')]=qs[_0xf0d2('0x3b')](_[_0xf0d2('0x41')](_0x5e28ed[_0xf0d2('0x3a')],_0x1b4823[_0xf0d2('0x3b')]));if(_0x5e28ed[_0xf0d2('0x3a')]['filter']){_0x4b7402[_0xf0d2('0x43')]=_[_0xf0d2('0x44')](_0x4b7402['where'],{'$or':_[_0xf0d2('0x34')](_0x4b7402['attributes'],function(_0x523f81){var _0x758df7={};_0x758df7[_0x523f81]={'$like':'%'+_0x5e28ed[_0xf0d2('0x3a')][_0xf0d2('0x42')]+'%'};return _0x758df7;})});}_0x4b7402=_[_0xf0d2('0x44')]({},_0x4b7402,_0x5e28ed[_0xf0d2('0x46')]);return _0x26a779[_0xf0d2('0x53')](_0x4b7402);}})[_0xf0d2('0x1d')](function(_0x17d7f0){if(_0x17d7f0){_0x55f4df=_0x17d7f0['length'];if(!_0x5e28ed[_0xf0d2('0x3a')][_0xf0d2('0x57')](_0xf0d2('0x3f'))){_0x4b7402[_0xf0d2('0x2b')]=qs[_0xf0d2('0x2b')](_0x5e28ed['query'][_0xf0d2('0x2b')]);_0x4b7402[_0xf0d2('0x2a')]=qs[_0xf0d2('0x2a')](_0x5e28ed[_0xf0d2('0x3a')][_0xf0d2('0x2a')]);}return _0x26a779[_0xf0d2('0x53')](_0x4b7402);}})['then'](function(_0x25a17b){if(_0x25a17b){return _0x25a17b?{'count':_0x55f4df,'rows':_0x25a17b}:null;}})[_0xf0d2('0x1d')](respondWithResult(_0x4c4d6a,null))[_0xf0d2('0x26')](handleError(_0x4c4d6a,null));};exports['addConfiguration']=function(_0x2f6bde,_0x3a44b3,_0x40d105){if(_0x2f6bde[_0xf0d2('0x50')]['id']){delete _0x2f6bde[_0xf0d2('0x50')]['id'];}return db['DeskAccount'][_0xf0d2('0x54')]({'where':{'id':_0x2f6bde['params']['id']}})['then'](handleEntityNotFound(_0x3a44b3,null))[_0xf0d2('0x1d')](function(_0x21197f){if(_0x21197f){_0x2f6bde[_0xf0d2('0x50')]['AccountId']=_0x21197f['id'];_0x2f6bde[_0xf0d2('0x50')][_0xf0d2('0x58')]=integrations[_0xf0d2('0x59')](_0x2f6bde[_0xf0d2('0x50')][_0xf0d2('0x5a')],_0x2f6bde['body'][_0xf0d2('0x37')]);_0x2f6bde[_0xf0d2('0x50')][_0xf0d2('0x5b')]=integrations[_0xf0d2('0x5c')](_0x2f6bde[_0xf0d2('0x50')][_0xf0d2('0x5a')],_0x2f6bde[_0xf0d2('0x50')][_0xf0d2('0x37')]);return db[_0xf0d2('0x55')]['create'](_0x2f6bde[_0xf0d2('0x50')],{'include':[{'model':db['DeskField'],'as':_0xf0d2('0x58')},{'model':db[_0xf0d2('0x5d')],'as':_0xf0d2('0x5b')}]});}return null;})['then'](respondWithResult(_0x3a44b3,null))[_0xf0d2('0x26')](handleError(_0x3a44b3,null));};exports[_0xf0d2('0x5e')]=function(_0x35cbc7,_0x34c6e5,_0x25375c){var _0xadeeaa=[{'name':_0xf0d2('0x5f'),'label':_0xf0d2('0x5f'),'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 _0x10a23a='';return db[_0xf0d2('0x35')][_0xf0d2('0x54')]({'where':{'id':_0x35cbc7[_0xf0d2('0x51')]['id']},'attributes':['id',_0xf0d2('0x60'),'authType',_0xf0d2('0x61'),'password',_0xf0d2('0x62'),_0xf0d2('0x63'),'token',_0xf0d2('0x64')]})[_0xf0d2('0x1d')](handleEntityNotFound(_0x34c6e5,null))['then'](function(_0x5a7e97){if(_0x5a7e97){_0x10a23a=_0x5a7e97['remoteUri'];var _0x158a48=_0x10a23a[_0xf0d2('0x65')](-0x1);if(_0x158a48==='/'){_0x10a23a=_0x10a23a[_0xf0d2('0x66')](0x0,_0x10a23a[_0xf0d2('0x67')](_0x158a48));}var _0x5637cb={'method':_0xf0d2('0x68'),'uri':util[_0xf0d2('0x69')]('%s/custom_fields',_0x10a23a),'headers':{'Content-Type':_0xf0d2('0x6a'),'Accept':_0xf0d2('0x6a')},'json':!![]};if(_0x5a7e97[_0xf0d2('0x6b')]==='basic'){_0x5637cb['headers'][_0xf0d2('0x6c')]=util[_0xf0d2('0x69')]('Basic\x20%s',new Buffer(util[_0xf0d2('0x69')]('%s:%s',_0x5a7e97['username'],_0x5a7e97[_0xf0d2('0x6d')]))[_0xf0d2('0x6e')](_0xf0d2('0x6f')));}return rp(_0x5637cb)[_0xf0d2('0x1d')](function(_0x957ca5){return _0xadeeaa[_0xf0d2('0x70')](_['map'](_0x957ca5[_0xf0d2('0x71')][_0xf0d2('0x72')],function(_0x32cc7c){return{'id':_0x32cc7c[_0xf0d2('0x31')],'name':_0x32cc7c[_0xf0d2('0x31')],'type':_0x32cc7c[_0xf0d2('0x37')],'active':_0x32cc7c[_0xf0d2('0x73')],'label':_0x32cc7c[_0xf0d2('0x74')],'custom':!![]};}));});}})['then'](function(_0x3cf517){return{'count':_0x3cf517['length'],'rows':_0x3cf517};})[_0xf0d2('0x1d')](respondWithResult(_0x34c6e5,null))['catch'](function(_0x56f583){var _0x5d0e08=_0x35cbc7['query']['test']?0x1f4:_0x56f583[_0xf0d2('0x75')]||0x1f4;logger['error']('getFields,\x20%s,\x20%s,\x20%s',_0xf0d2('0x5e'),_0x5d0e08,JSON[_0xf0d2('0x23')](_0x56f583));delete _0x56f583[_0xf0d2('0x31')];if(_0x5d0e08===0x191){_0x5d0e08=0x190;}_0x34c6e5[_0xf0d2('0x27')](_0x5d0e08)['send'](_0x35cbc7[_0xf0d2('0x3a')][_0xf0d2('0x76')]?{'message':_0xf0d2('0x77'),'statusCode':_0x56f583[_0xf0d2('0x75')]}:_0x56f583);});};
\ No newline at end of file
+var _0xb091=['params','includeAll','include','body','find','getConfigurations','DeskConfiguration','filter','hasOwnProperty','addConfiguration','AccountId','Subjects','getSubjects','channel','Descriptions','DeskField','getFields','priority','remoteUri','authType','password','consumerSecret','token','slice','substring','lastIndexOf','GET','format','%s/custom_fields','application/json','basic','headers','Authorization','%s:%s','username','toString','base64','entries','active','label','test','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','statusCode','eml-format','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../config/logger','api','../../config/license/util','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','http','request','then','DeskAccount,\x20%s,\x20%s','request\x20sent','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','status','offset','limit','undefined','count','set','json','apply','destroy','end','name','index','map','DeskAccount','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort','where','filters','pick','merge','VIRTUAL','options','show'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xb091,0xa4));var _0x1b09=function(_0x17f6db,_0x1869bd){_0x17f6db=_0x17f6db-0x0;var _0x5a5399=_0xb091[_0x17f6db];return _0x5a5399;};'use strict';var emlformat=require(_0x1b09('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x1b09('0x1'));var rp=require(_0x1b09('0x2'));var moment=require('moment');var BPromise=require(_0x1b09('0x3'));var Mustache=require(_0x1b09('0x4'));var util=require('util');var path=require(_0x1b09('0x5'));var sox=require(_0x1b09('0x6'));var csv=require(_0x1b09('0x7'));var ejs=require(_0x1b09('0x8'));var fs=require('fs');var fs_extra=require(_0x1b09('0x9'));var _=require(_0x1b09('0xa'));var squel=require(_0x1b09('0xb'));var crypto=require(_0x1b09('0xc'));var jsforce=require(_0x1b09('0xd'));var deskjs=require(_0x1b09('0xe'));var toCsv=require('to-csv');var querystring=require(_0x1b09('0xf'));var Papa=require(_0x1b09('0x10'));var Redis=require(_0x1b09('0x11'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x1b09('0x12'))(_0x1b09('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x1b09('0x14'));var db=require(_0x1b09('0x15'))['db'];var integrations=require(_0x1b09('0x16'));var jayson=require(_0x1b09('0x17'));var client=jayson[_0x1b09('0x18')][_0x1b09('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x5411cb,_0x442236,_0x1718b6,_0x486a15){return new BPromise(function(_0x738ede,_0xbc83cd){var _0x8ca361=_0x486a15||client;return _0x8ca361[_0x1b09('0x1a')](_0x5411cb,_0x1718b6)[_0x1b09('0x1b')](function(_0x2c13b8){logger['info'](_0x1b09('0x1c'),_0x442236,_0x1b09('0x1d'));logger['debug'](_0x1b09('0x1e'),_0x442236,'request\x20sent',JSON[_0x1b09('0x1f')](_0x2c13b8));if(_0x2c13b8[_0x1b09('0x20')]){if(_0x2c13b8[_0x1b09('0x20')][_0x1b09('0x21')]===0x1f4){logger[_0x1b09('0x20')](_0x1b09('0x1c'),_0x442236,_0x2c13b8[_0x1b09('0x20')][_0x1b09('0x22')]);return _0xbc83cd(_0x2c13b8[_0x1b09('0x20')][_0x1b09('0x22')]);}logger['error']('DeskAccount,\x20%s,\x20%s',_0x442236,_0x2c13b8['error'][_0x1b09('0x22')]);return _0x738ede(_0x2c13b8['error'][_0x1b09('0x22')]);}else{logger[_0x1b09('0x23')](_0x1b09('0x1c'),_0x442236,_0x1b09('0x1d'));_0x738ede(_0x2c13b8[_0x1b09('0x24')][_0x1b09('0x22')]);}})[_0x1b09('0x25')](function(_0x10b06a){logger['error'](_0x1b09('0x1c'),_0x442236,_0x10b06a);_0xbc83cd(_0x10b06a);});});}function respondWithStatusCode(_0x4da7a8,_0x5f42cb){_0x5f42cb=_0x5f42cb||0xcc;return function(_0x390e77){if(_0x390e77){return _0x4da7a8[_0x1b09('0x26')](_0x5f42cb);}return _0x4da7a8[_0x1b09('0x27')](_0x5f42cb)['end']();};}function respondWithResult(_0x113946,_0x53ce23){_0x53ce23=_0x53ce23||0xc8;return function(_0x49dad6){if(_0x49dad6){return _0x113946['status'](_0x53ce23)['json'](_0x49dad6);}};}function respondWithFilteredResult(_0x2f31e3,_0x24e422){return function(_0x282b50){if(_0x282b50){var _0x2337b9=typeof _0x24e422[_0x1b09('0x28')]==='undefined'&&typeof _0x24e422[_0x1b09('0x29')]===_0x1b09('0x2a');var _0x32c8f8=_0x282b50['count'];var _0x2bf3a6=_0x2337b9?0x0:_0x24e422['offset'];var _0x20a1f3=_0x2337b9?_0x282b50[_0x1b09('0x2b')]:_0x24e422[_0x1b09('0x28')]+_0x24e422[_0x1b09('0x29')];var _0x3a89cb;if(_0x20a1f3>=_0x32c8f8){_0x20a1f3=_0x32c8f8;_0x3a89cb=0xc8;}else{_0x3a89cb=0xce;}_0x2f31e3['status'](_0x3a89cb);return _0x2f31e3[_0x1b09('0x2c')]('Content-Range',_0x2bf3a6+'-'+_0x20a1f3+'/'+_0x32c8f8)[_0x1b09('0x2d')](_0x282b50);}return null;};}function patchUpdates(_0x4cb045){return function(_0x1aefaa){try{jsonpatch[_0x1b09('0x2e')](_0x1aefaa,_0x4cb045,!![]);}catch(_0x49b06e){return BPromise['reject'](_0x49b06e);}return _0x1aefaa['save']();};}function saveUpdates(_0x2ec6ed,_0x208205){return function(_0x474cdc){if(_0x474cdc){return _0x474cdc['update'](_0x2ec6ed)[_0x1b09('0x1b')](function(_0x47b352){return _0x47b352;});}return null;};}function removeEntity(_0x24d795,_0x142921){return function(_0x5a8960){if(_0x5a8960){return _0x5a8960[_0x1b09('0x2f')]()[_0x1b09('0x1b')](function(){_0x24d795[_0x1b09('0x27')](0xcc)[_0x1b09('0x30')]();});}};}function handleEntityNotFound(_0x1f787c,_0x2b436b){return function(_0x1b6f9c){if(!_0x1b6f9c){_0x1f787c[_0x1b09('0x26')](0x194);}return _0x1b6f9c;};}function handleError(_0xa4cc28,_0x1dba63){_0x1dba63=_0x1dba63||0x1f4;return function(_0x53b764){logger[_0x1b09('0x20')](_0x53b764['stack']);if(_0x53b764[_0x1b09('0x31')]){delete _0x53b764['name'];}_0xa4cc28[_0x1b09('0x27')](_0x1dba63)['send'](_0x53b764);};}exports[_0x1b09('0x32')]=function(_0x5411cc,_0x4e7c45){var _0x191af4={},_0x15f5e8={},_0x11ced3={'count':0x0,'rows':[]};var _0x35e465=_[_0x1b09('0x33')](db[_0x1b09('0x34')][_0x1b09('0x35')],function(_0x522c24){return{'name':_0x522c24[_0x1b09('0x36')],'type':_0x522c24[_0x1b09('0x37')][_0x1b09('0x38')]};});_0x15f5e8[_0x1b09('0x39')]=_['map'](_0x35e465,_0x1b09('0x31'));_0x15f5e8[_0x1b09('0x3a')]=_[_0x1b09('0x3b')](_0x5411cc['query']);_0x15f5e8['filters']=_[_0x1b09('0x3c')](_0x15f5e8[_0x1b09('0x39')],_0x15f5e8['query']);_0x191af4[_0x1b09('0x3d')]=_['intersection'](_0x15f5e8['model'],qs['fields'](_0x5411cc[_0x1b09('0x3a')][_0x1b09('0x3e')]));_0x191af4[_0x1b09('0x3d')]=_0x191af4[_0x1b09('0x3d')][_0x1b09('0x3f')]?_0x191af4['attributes']:_0x15f5e8['model'];if(!_0x5411cc[_0x1b09('0x3a')]['hasOwnProperty'](_0x1b09('0x40'))){_0x191af4['limit']=qs[_0x1b09('0x29')](_0x5411cc[_0x1b09('0x3a')][_0x1b09('0x29')]);_0x191af4[_0x1b09('0x28')]=qs[_0x1b09('0x28')](_0x5411cc[_0x1b09('0x3a')][_0x1b09('0x28')]);}_0x191af4[_0x1b09('0x41')]=qs[_0x1b09('0x42')](_0x5411cc[_0x1b09('0x3a')]['sort']);_0x191af4[_0x1b09('0x43')]=qs[_0x1b09('0x44')](_[_0x1b09('0x45')](_0x5411cc[_0x1b09('0x3a')],_0x15f5e8[_0x1b09('0x44')]),_0x35e465);if(_0x5411cc[_0x1b09('0x3a')]['filter']){_0x191af4[_0x1b09('0x43')]=_[_0x1b09('0x46')](_0x191af4[_0x1b09('0x43')],{'$or':_[_0x1b09('0x33')](_0x35e465,function(_0x3ad37b){if(_0x3ad37b[_0x1b09('0x37')]!==_0x1b09('0x47')){var _0x3d9dee={};_0x3d9dee[_0x3ad37b[_0x1b09('0x31')]]={'$like':'%'+_0x5411cc[_0x1b09('0x3a')]['filter']+'%'};return _0x3d9dee;}})});}_0x191af4=_[_0x1b09('0x46')]({},_0x191af4,_0x5411cc[_0x1b09('0x48')]);var _0x11fff0={'where':_0x191af4[_0x1b09('0x43')]};return db[_0x1b09('0x34')][_0x1b09('0x2b')](_0x11fff0)[_0x1b09('0x1b')](function(_0x53351c){_0x11ced3[_0x1b09('0x2b')]=_0x53351c;if(_0x5411cc[_0x1b09('0x3a')]['includeAll']){_0x191af4['include']=[{'all':!![]}];}return db[_0x1b09('0x34')]['findAll'](_0x191af4);})[_0x1b09('0x1b')](function(_0x597ed4){_0x11ced3['rows']=_0x597ed4;return _0x11ced3;})[_0x1b09('0x1b')](respondWithFilteredResult(_0x4e7c45,_0x191af4))[_0x1b09('0x25')](handleError(_0x4e7c45,null));};exports[_0x1b09('0x49')]=function(_0x2c9638,_0x432cf1){var _0x4b7de8={'raw':![],'where':{'id':_0x2c9638[_0x1b09('0x4a')]['id']}},_0x5ac147={};_0x5ac147[_0x1b09('0x39')]=_[_0x1b09('0x3b')](db[_0x1b09('0x34')][_0x1b09('0x35')]);_0x5ac147[_0x1b09('0x3a')]=_[_0x1b09('0x3b')](_0x2c9638['query']);_0x5ac147['filters']=_[_0x1b09('0x3c')](_0x5ac147[_0x1b09('0x39')],_0x5ac147['query']);_0x4b7de8[_0x1b09('0x3d')]=_[_0x1b09('0x3c')](_0x5ac147[_0x1b09('0x39')],qs[_0x1b09('0x3e')](_0x2c9638[_0x1b09('0x3a')][_0x1b09('0x3e')]));_0x4b7de8[_0x1b09('0x3d')]=_0x4b7de8['attributes'][_0x1b09('0x3f')]?_0x4b7de8[_0x1b09('0x3d')]:_0x5ac147[_0x1b09('0x39')];if(_0x2c9638[_0x1b09('0x3a')][_0x1b09('0x4b')]){_0x4b7de8[_0x1b09('0x4c')]=[{'all':!![]}];}_0x4b7de8=_[_0x1b09('0x46')]({},_0x4b7de8,_0x2c9638[_0x1b09('0x48')]);return db[_0x1b09('0x34')]['find'](_0x4b7de8)[_0x1b09('0x1b')](handleEntityNotFound(_0x432cf1,null))['then'](respondWithResult(_0x432cf1,null))[_0x1b09('0x25')](handleError(_0x432cf1,null));};exports['create']=function(_0x467cbc,_0x18039c){return db['DeskAccount']['create'](_0x467cbc[_0x1b09('0x4d')],{})['then'](respondWithResult(_0x18039c,0xc9))[_0x1b09('0x25')](handleError(_0x18039c,null));};exports['update']=function(_0x4c57ef,_0x8936e6){if(_0x4c57ef[_0x1b09('0x4d')]['id']){delete _0x4c57ef['body']['id'];}return db[_0x1b09('0x34')]['find']({'where':{'id':_0x4c57ef[_0x1b09('0x4a')]['id']}})['then'](handleEntityNotFound(_0x8936e6,null))[_0x1b09('0x1b')](saveUpdates(_0x4c57ef[_0x1b09('0x4d')],null))[_0x1b09('0x1b')](respondWithResult(_0x8936e6,null))[_0x1b09('0x25')](handleError(_0x8936e6,null));};exports[_0x1b09('0x2f')]=function(_0x46ac14,_0x5bdd74){return db[_0x1b09('0x34')][_0x1b09('0x4e')]({'where':{'id':_0x46ac14[_0x1b09('0x4a')]['id']}})[_0x1b09('0x1b')](handleEntityNotFound(_0x5bdd74,null))[_0x1b09('0x1b')](removeEntity(_0x5bdd74,null))['catch'](handleError(_0x5bdd74,null));};exports[_0x1b09('0x4f')]=function(_0x393364,_0x184f61,_0x350f60){var _0x891c37={};var _0x3f71fc={};var _0x4fb060;var _0x2ce726;return db[_0x1b09('0x34')]['findOne']({'where':{'id':_0x393364[_0x1b09('0x4a')]['id']}})['then'](handleEntityNotFound(_0x184f61,null))['then'](function(_0x5fbd09){if(_0x5fbd09){_0x4fb060=_0x5fbd09;_0x3f71fc[_0x1b09('0x39')]=_[_0x1b09('0x3b')](db[_0x1b09('0x50')]['rawAttributes']);_0x3f71fc['query']=_[_0x1b09('0x3b')](_0x393364[_0x1b09('0x3a')]);_0x3f71fc[_0x1b09('0x44')]=_[_0x1b09('0x3c')](_0x3f71fc[_0x1b09('0x39')],_0x3f71fc[_0x1b09('0x3a')]);_0x891c37[_0x1b09('0x3d')]=_[_0x1b09('0x3c')](_0x3f71fc[_0x1b09('0x39')],qs['fields'](_0x393364['query'][_0x1b09('0x3e')]));_0x891c37[_0x1b09('0x3d')]=_0x891c37[_0x1b09('0x3d')][_0x1b09('0x3f')]?_0x891c37[_0x1b09('0x3d')]:_0x3f71fc[_0x1b09('0x39')];_0x891c37['order']=qs[_0x1b09('0x42')](_0x393364[_0x1b09('0x3a')]['sort']);_0x891c37[_0x1b09('0x43')]=qs[_0x1b09('0x44')](_[_0x1b09('0x45')](_0x393364[_0x1b09('0x3a')],_0x3f71fc[_0x1b09('0x44')]));if(_0x393364[_0x1b09('0x3a')][_0x1b09('0x51')]){_0x891c37[_0x1b09('0x43')]=_[_0x1b09('0x46')](_0x891c37[_0x1b09('0x43')],{'$or':_[_0x1b09('0x33')](_0x891c37[_0x1b09('0x3d')],function(_0x3cd938){var _0x5c433d={};_0x5c433d[_0x3cd938]={'$like':'%'+_0x393364[_0x1b09('0x3a')]['filter']+'%'};return _0x5c433d;})});}_0x891c37=_[_0x1b09('0x46')]({},_0x891c37,_0x393364['options']);return _0x4fb060[_0x1b09('0x4f')](_0x891c37);}})[_0x1b09('0x1b')](function(_0x44f51f){if(_0x44f51f){_0x2ce726=_0x44f51f[_0x1b09('0x3f')];if(!_0x393364[_0x1b09('0x3a')][_0x1b09('0x52')](_0x1b09('0x40'))){_0x891c37[_0x1b09('0x29')]=qs[_0x1b09('0x29')](_0x393364[_0x1b09('0x3a')][_0x1b09('0x29')]);_0x891c37[_0x1b09('0x28')]=qs[_0x1b09('0x28')](_0x393364[_0x1b09('0x3a')][_0x1b09('0x28')]);}return _0x4fb060['getConfigurations'](_0x891c37);}})[_0x1b09('0x1b')](function(_0x36d65e){if(_0x36d65e){return _0x36d65e?{'count':_0x2ce726,'rows':_0x36d65e}:null;}})[_0x1b09('0x1b')](respondWithResult(_0x184f61,null))[_0x1b09('0x25')](handleError(_0x184f61,null));};exports[_0x1b09('0x53')]=function(_0xad5557,_0x2be61c,_0xc8cf5b){if(_0xad5557[_0x1b09('0x4d')]['id']){delete _0xad5557['body']['id'];}return db[_0x1b09('0x34')]['findOne']({'where':{'id':_0xad5557[_0x1b09('0x4a')]['id']}})[_0x1b09('0x1b')](handleEntityNotFound(_0x2be61c,null))[_0x1b09('0x1b')](function(_0x20fdde){if(_0x20fdde){_0xad5557['body'][_0x1b09('0x54')]=_0x20fdde['id'];_0xad5557[_0x1b09('0x4d')][_0x1b09('0x55')]=integrations[_0x1b09('0x56')](_0xad5557[_0x1b09('0x4d')][_0x1b09('0x57')],_0xad5557[_0x1b09('0x4d')]['type']);_0xad5557[_0x1b09('0x4d')][_0x1b09('0x58')]=integrations['getDescriptions'](_0xad5557[_0x1b09('0x4d')][_0x1b09('0x57')],_0xad5557['body'][_0x1b09('0x37')]);return db[_0x1b09('0x50')]['create'](_0xad5557['body'],{'include':[{'model':db[_0x1b09('0x59')],'as':_0x1b09('0x55')},{'model':db[_0x1b09('0x59')],'as':'Descriptions'}]});}return null;})[_0x1b09('0x1b')](respondWithResult(_0x2be61c,null))[_0x1b09('0x25')](handleError(_0x2be61c,null));};exports[_0x1b09('0x5a')]=function(_0x5c1b08,_0x1839d2,_0x410c43){var _0x460123=[{'name':_0x1b09('0x5b'),'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 _0x163965='';return db[_0x1b09('0x34')]['findOne']({'where':{'id':_0x5c1b08[_0x1b09('0x4a')]['id']},'attributes':['id',_0x1b09('0x5c'),_0x1b09('0x5d'),'username',_0x1b09('0x5e'),'consumerKey',_0x1b09('0x5f'),_0x1b09('0x60'),'tokenSecret']})['then'](handleEntityNotFound(_0x1839d2,null))[_0x1b09('0x1b')](function(_0x10d926){if(_0x10d926){_0x163965=_0x10d926[_0x1b09('0x5c')];var _0x363805=_0x163965[_0x1b09('0x61')](-0x1);if(_0x363805==='/'){_0x163965=_0x163965[_0x1b09('0x62')](0x0,_0x163965[_0x1b09('0x63')](_0x363805));}var _0x655463={'method':_0x1b09('0x64'),'uri':util[_0x1b09('0x65')](_0x1b09('0x66'),_0x163965),'headers':{'Content-Type':_0x1b09('0x67'),'Accept':'application/json'},'json':!![]};if(_0x10d926[_0x1b09('0x5d')]===_0x1b09('0x68')){_0x655463[_0x1b09('0x69')][_0x1b09('0x6a')]=util[_0x1b09('0x65')]('Basic\x20%s',new Buffer(util[_0x1b09('0x65')](_0x1b09('0x6b'),_0x10d926[_0x1b09('0x6c')],_0x10d926[_0x1b09('0x5e')]))[_0x1b09('0x6d')](_0x1b09('0x6e')));}return rp(_0x655463)[_0x1b09('0x1b')](function(_0x19471e){return _0x460123['concat'](_[_0x1b09('0x33')](_0x19471e['_embedded'][_0x1b09('0x6f')],function(_0x2620dc){return{'id':_0x2620dc[_0x1b09('0x31')],'name':_0x2620dc['name'],'type':_0x2620dc[_0x1b09('0x37')],'active':_0x2620dc[_0x1b09('0x70')],'label':_0x2620dc[_0x1b09('0x71')],'custom':!![]};}));});}})[_0x1b09('0x1b')](function(_0x315584){return{'count':_0x315584['length'],'rows':_0x315584};})[_0x1b09('0x1b')](respondWithResult(_0x1839d2,null))['catch'](function(_0x3332cf){var _0x1941f9=_0x5c1b08['query'][_0x1b09('0x72')]?0x1f4:_0x3332cf['statusCode']||0x1f4;logger[_0x1b09('0x20')](_0x1b09('0x73'),_0x1b09('0x5a'),_0x1941f9,JSON[_0x1b09('0x1f')](_0x3332cf));delete _0x3332cf[_0x1b09('0x31')];if(_0x1941f9===0x191){_0x1941f9=0x190;}_0x1839d2[_0x1b09('0x27')](_0x1941f9)[_0x1b09('0x74')](_0x5c1b08['query']['test']?{'message':_0x1b09('0x75'),'statusCode':_0x3332cf[_0x1b09('0x76')]}:_0x3332cf);});};
\ No newline at end of file