Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intZendeskAccount / intZendeskAccount.controller.js
index ce54f17..a34e06b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x88c8=['code','message','catch','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','destroy','sendStatus','stack','name','index','map','ZendeskAccount','rawAttributes','key','model','query','keys','intersection','attributes','fields','length','nolimit','where','pick','filters','filter','merge','type','VIRTUAL','count','include','findAll','show','options','find','create','body','params','getConfigurations','ZendeskConfiguration','sort','hasOwnProperty','findOne','Subjects','getDescriptions','channel','ZendeskField','Descriptions','getFields','username','password','token','authType','remoteUri','substring','lastIndexOf','GET','%s/%s','ticket_fields','format','Basic\x20%s','%s:%s','toString','base64','headers','%s/token:%s','Unknown\x20authentication\x20type','subject','group','assignee','includes','position','title','system_field_options','custom_field_options','statusCode','getFields,\x20%s,\x20%s,\x20%s','send','Wrong\x20credentials','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../mysqldb','../../components/integrations/configuration','jayson/promise','client','http','test','Sequelize','ValidationError','request','then','info','ZendeskAccount,\x20%s,\x20%s','request\x20sent','debug','ZendeskAccount,\x20%s,\x20%s,\x20%s','stringify','error'];(function(_0xaf10b7,_0x34c591){var _0xde829=function(_0x5bba24){while(--_0x5bba24){_0xaf10b7['push'](_0xaf10b7['shift']());}};_0xde829(++_0x34c591);}(_0x88c8,0x162));var _0x888c=function(_0x221e40,_0x4678cd){_0x221e40=_0x221e40-0x0;var _0xacfe13=_0x88c8[_0x221e40];return _0xacfe13;};'use strict';var pdf=require(_0x888c('0x0'));var emlformat=require(_0x888c('0x1'));var rimraf=require(_0x888c('0x2'));var zipdir=require(_0x888c('0x3'));var jsonpatch=require(_0x888c('0x4'));var rp=require(_0x888c('0x5'));var moment=require(_0x888c('0x6'));var BPromise=require(_0x888c('0x7'));var Mustache=require(_0x888c('0x8'));var util=require(_0x888c('0x9'));var path=require(_0x888c('0xa'));var sox=require(_0x888c('0xb'));var csv=require('to-csv');var ejs=require(_0x888c('0xc'));var fs=require('fs');var _=require(_0x888c('0xd'));var squel=require(_0x888c('0xe'));var crypto=require(_0x888c('0xf'));var jsforce=require(_0x888c('0x10'));var deskjs=require(_0x888c('0x11'));var toCsv=require(_0x888c('0x12'));var querystring=require(_0x888c('0x13'));var Papa=require(_0x888c('0x14'));var Redis=require(_0x888c('0x15'));var authService=require(_0x888c('0x16'));var qs=require(_0x888c('0x17'));var as=require(_0x888c('0x18'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x888c('0x19'))(_0x888c('0x1a'));var utils=require(_0x888c('0x1b'));var config=require('../../config/environment');var db=require(_0x888c('0x1c'))['db'];var integrations=require(_0x888c('0x1d'));var jayson=require(_0x888c('0x1e'));var client=jayson[_0x888c('0x1f')][_0x888c('0x20')]({'port':0x232a});function checkPasswordPattern(_0x4fd225,_0x54fde6,_0x451825){if(_0x451825){var _0x8d2118=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x8d2118[_0x888c('0x21')](_0x54fde6)){return _0x4fd225;}else{throw new db[(_0x888c('0x22'))][(_0x888c('0x23'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x4fd225;}}function respondWithRpcPromise(_0x44d1b2,_0xaa3b15,_0x9997a2,_0x30ca2a){return new BPromise(function(_0x543d2f,_0x59ca7e){var _0x2c5bf1=_0x30ca2a||client;return _0x2c5bf1[_0x888c('0x24')](_0x44d1b2,_0x9997a2)[_0x888c('0x25')](function(_0x328b75){logger[_0x888c('0x26')](_0x888c('0x27'),_0xaa3b15,_0x888c('0x28'));logger[_0x888c('0x29')](_0x888c('0x2a'),_0xaa3b15,'request\x20sent',JSON[_0x888c('0x2b')](_0x328b75));if(_0x328b75[_0x888c('0x2c')]){if(_0x328b75[_0x888c('0x2c')][_0x888c('0x2d')]===0x1f4){logger[_0x888c('0x2c')](_0x888c('0x27'),_0xaa3b15,_0x328b75[_0x888c('0x2c')][_0x888c('0x2e')]);return _0x59ca7e(_0x328b75['error'][_0x888c('0x2e')]);}logger[_0x888c('0x2c')](_0x888c('0x27'),_0xaa3b15,_0x328b75[_0x888c('0x2c')]['message']);return _0x543d2f(_0x328b75[_0x888c('0x2c')][_0x888c('0x2e')]);}else{logger['info'](_0x888c('0x27'),_0xaa3b15,_0x888c('0x28'));_0x543d2f(_0x328b75['result'][_0x888c('0x2e')]);}})[_0x888c('0x2f')](function(_0x370680){logger[_0x888c('0x2c')](_0x888c('0x27'),_0xaa3b15,_0x370680);_0x59ca7e(_0x370680);});});}function respondWithStatusCode(_0x525fc1,_0x429819){_0x429819=_0x429819||0xcc;return function(_0x5f196c){if(_0x5f196c){return _0x525fc1['sendStatus'](_0x429819);}return _0x525fc1[_0x888c('0x30')](_0x429819)[_0x888c('0x31')]();};}function respondWithResult(_0x80cc0a,_0x3aabcb){_0x3aabcb=_0x3aabcb||0xc8;return function(_0x46d087){if(_0x46d087){return _0x80cc0a[_0x888c('0x30')](_0x3aabcb)[_0x888c('0x32')](_0x46d087);}};}function respondWithFilteredResult(_0x8ea24,_0x1484c0){return function(_0x3ef38e){if(_0x3ef38e){var _0x481c42=_0x3ef38e['count'],_0x39e887=_0x1484c0[_0x888c('0x33')],_0x462c16=_0x1484c0[_0x888c('0x33')]+_0x1484c0[_0x888c('0x34')],_0x5dd346;if(_0x462c16>=_0x481c42){_0x462c16=_0x481c42;_0x5dd346=0xc8;}else{_0x5dd346=0xce;}_0x8ea24[_0x888c('0x30')](_0x5dd346);return _0x8ea24[_0x888c('0x35')](_0x888c('0x36'),_0x39e887+'-'+_0x462c16+'/'+_0x481c42)['json'](_0x3ef38e);}return null;};}function patchUpdates(_0x469fde){return function(_0x412a32){try{jsonpatch[_0x888c('0x37')](_0x412a32,_0x469fde,!![]);}catch(_0x5e9eb4){return BPromise[_0x888c('0x38')](_0x5e9eb4);}return _0x412a32[_0x888c('0x39')]();};}function saveUpdates(_0x5562b1,_0x5560a2){return function(_0x3abeba){if(_0x3abeba){return _0x3abeba[_0x888c('0x3a')](_0x5562b1)[_0x888c('0x25')](function(_0x20348c){return _0x20348c;});}return null;};}function removeEntity(_0x3d1ad9,_0x5611da){return function(_0x19b6fc){if(_0x19b6fc){return _0x19b6fc[_0x888c('0x3b')]()[_0x888c('0x25')](function(){_0x3d1ad9['status'](0xcc)[_0x888c('0x31')]();});}};}function handleEntityNotFound(_0x2b8d67,_0x4586bd){return function(_0x3a3919){if(!_0x3a3919){_0x2b8d67[_0x888c('0x3c')](0x194);}return _0x3a3919;};}function handleError(_0x270026,_0x2897d0){_0x2897d0=_0x2897d0||0x1f4;return function(_0xf107df){logger[_0x888c('0x2c')](_0xf107df[_0x888c('0x3d')]);if(_0xf107df[_0x888c('0x3e')]){delete _0xf107df[_0x888c('0x3e')];}_0x270026['status'](_0x2897d0)['send'](_0xf107df);};}exports[_0x888c('0x3f')]=function(_0x3c4f3b,_0x5e7a5e){var _0x4dd92e={},_0x2e8a3b={},_0x16270f={'count':0x0,'rows':[]};var _0x37c986=_[_0x888c('0x40')](db[_0x888c('0x41')][_0x888c('0x42')],function(_0x3a9dd5){return{'name':_0x3a9dd5['fieldName'],'type':_0x3a9dd5['type'][_0x888c('0x43')]};});_0x2e8a3b[_0x888c('0x44')]=_[_0x888c('0x40')](_0x37c986,'name');_0x2e8a3b[_0x888c('0x45')]=_[_0x888c('0x46')](_0x3c4f3b[_0x888c('0x45')]);_0x2e8a3b['filters']=_[_0x888c('0x47')](_0x2e8a3b[_0x888c('0x44')],_0x2e8a3b[_0x888c('0x45')]);_0x4dd92e[_0x888c('0x48')]=_['intersection'](_0x2e8a3b[_0x888c('0x44')],qs['fields'](_0x3c4f3b[_0x888c('0x45')][_0x888c('0x49')]));_0x4dd92e[_0x888c('0x48')]=_0x4dd92e[_0x888c('0x48')][_0x888c('0x4a')]?_0x4dd92e[_0x888c('0x48')]:_0x2e8a3b[_0x888c('0x44')];if(!_0x3c4f3b[_0x888c('0x45')]['hasOwnProperty'](_0x888c('0x4b'))){_0x4dd92e[_0x888c('0x34')]=qs['limit'](_0x3c4f3b[_0x888c('0x45')][_0x888c('0x34')]);_0x4dd92e[_0x888c('0x33')]=qs[_0x888c('0x33')](_0x3c4f3b[_0x888c('0x45')][_0x888c('0x33')]);}_0x4dd92e['order']=qs['sort'](_0x3c4f3b[_0x888c('0x45')]['sort']);_0x4dd92e[_0x888c('0x4c')]=qs['filters'](_[_0x888c('0x4d')](_0x3c4f3b[_0x888c('0x45')],_0x2e8a3b[_0x888c('0x4e')]),_0x37c986);if(_0x3c4f3b[_0x888c('0x45')][_0x888c('0x4f')]){_0x4dd92e[_0x888c('0x4c')]=_[_0x888c('0x50')](_0x4dd92e[_0x888c('0x4c')],{'$or':_['map'](_0x37c986,function(_0x5214f2){if(_0x5214f2[_0x888c('0x51')]!==_0x888c('0x52')){var _0x29dee2={};_0x29dee2[_0x5214f2[_0x888c('0x3e')]]={'$like':'%'+_0x3c4f3b[_0x888c('0x45')][_0x888c('0x4f')]+'%'};return _0x29dee2;}})});}_0x4dd92e=_['merge']({},_0x4dd92e,_0x3c4f3b['options']);var _0x262626={'where':_0x4dd92e[_0x888c('0x4c')]};return db[_0x888c('0x41')]['count'](_0x262626)['then'](function(_0x253e99){_0x16270f[_0x888c('0x53')]=_0x253e99;if(_0x3c4f3b['query']['includeAll']){_0x4dd92e[_0x888c('0x54')]=[{'all':!![]}];}return db[_0x888c('0x41')][_0x888c('0x55')](_0x4dd92e);})[_0x888c('0x25')](function(_0x1d6722){_0x16270f['rows']=_0x1d6722;return _0x16270f;})[_0x888c('0x25')](respondWithFilteredResult(_0x5e7a5e,_0x4dd92e))[_0x888c('0x2f')](handleError(_0x5e7a5e,null));};exports[_0x888c('0x56')]=function(_0x1d5f14,_0x145a8e){var _0x2f5fb6={'raw':![],'where':{'id':_0x1d5f14['params']['id']}},_0x4c201a={};_0x4c201a[_0x888c('0x44')]=_[_0x888c('0x46')](db[_0x888c('0x41')][_0x888c('0x42')]);_0x4c201a[_0x888c('0x45')]=_[_0x888c('0x46')](_0x1d5f14['query']);_0x4c201a[_0x888c('0x4e')]=_['intersection'](_0x4c201a['model'],_0x4c201a['query']);_0x2f5fb6[_0x888c('0x48')]=_['intersection'](_0x4c201a[_0x888c('0x44')],qs[_0x888c('0x49')](_0x1d5f14[_0x888c('0x45')][_0x888c('0x49')]));_0x2f5fb6['attributes']=_0x2f5fb6[_0x888c('0x48')][_0x888c('0x4a')]?_0x2f5fb6[_0x888c('0x48')]:_0x4c201a[_0x888c('0x44')];if(_0x1d5f14[_0x888c('0x45')]['includeAll']){_0x2f5fb6[_0x888c('0x54')]=[{'all':!![]}];}_0x2f5fb6=_[_0x888c('0x50')]({},_0x2f5fb6,_0x1d5f14[_0x888c('0x57')]);return db['ZendeskAccount'][_0x888c('0x58')](_0x2f5fb6)['then'](handleEntityNotFound(_0x145a8e,null))['then'](respondWithResult(_0x145a8e,null))[_0x888c('0x2f')](handleError(_0x145a8e,null));};exports[_0x888c('0x59')]=function(_0x14f351,_0x2fe3ed){return db[_0x888c('0x41')][_0x888c('0x59')](_0x14f351['body'],{})[_0x888c('0x25')](respondWithResult(_0x2fe3ed,0xc9))[_0x888c('0x2f')](handleError(_0x2fe3ed,null));};exports[_0x888c('0x3a')]=function(_0x3ebf8e,_0x12156e){if(_0x3ebf8e['body']['id']){delete _0x3ebf8e[_0x888c('0x5a')]['id'];}return db[_0x888c('0x41')]['find']({'where':{'id':_0x3ebf8e[_0x888c('0x5b')]['id']}})[_0x888c('0x25')](handleEntityNotFound(_0x12156e,null))[_0x888c('0x25')](saveUpdates(_0x3ebf8e[_0x888c('0x5a')],null))[_0x888c('0x25')](respondWithResult(_0x12156e,null))[_0x888c('0x2f')](handleError(_0x12156e,null));};exports[_0x888c('0x3b')]=function(_0x3f505c,_0x4d0ed6){return db[_0x888c('0x41')][_0x888c('0x58')]({'where':{'id':_0x3f505c[_0x888c('0x5b')]['id']}})[_0x888c('0x25')](handleEntityNotFound(_0x4d0ed6,null))[_0x888c('0x25')](removeEntity(_0x4d0ed6,null))[_0x888c('0x2f')](handleError(_0x4d0ed6,null));};exports[_0x888c('0x5c')]=function(_0x2189e3,_0x27b94b,_0x18d786){var _0x3b6f61={};var _0x4187cf={};var _0x4574fe;var _0x3877e8;return db[_0x888c('0x41')]['findOne']({'where':{'id':_0x2189e3['params']['id']}})[_0x888c('0x25')](handleEntityNotFound(_0x27b94b,null))[_0x888c('0x25')](function(_0x2ce782){if(_0x2ce782){_0x4574fe=_0x2ce782;_0x4187cf['model']=_[_0x888c('0x46')](db[_0x888c('0x5d')][_0x888c('0x42')]);_0x4187cf[_0x888c('0x45')]=_[_0x888c('0x46')](_0x2189e3[_0x888c('0x45')]);_0x4187cf[_0x888c('0x4e')]=_[_0x888c('0x47')](_0x4187cf[_0x888c('0x44')],_0x4187cf[_0x888c('0x45')]);_0x3b6f61[_0x888c('0x48')]=_[_0x888c('0x47')](_0x4187cf[_0x888c('0x44')],qs[_0x888c('0x49')](_0x2189e3['query'][_0x888c('0x49')]));_0x3b6f61['attributes']=_0x3b6f61['attributes']['length']?_0x3b6f61[_0x888c('0x48')]:_0x4187cf[_0x888c('0x44')];_0x3b6f61['order']=qs[_0x888c('0x5e')](_0x2189e3[_0x888c('0x45')][_0x888c('0x5e')]);_0x3b6f61[_0x888c('0x4c')]=qs['filters'](_[_0x888c('0x4d')](_0x2189e3[_0x888c('0x45')],_0x4187cf[_0x888c('0x4e')]));if(_0x2189e3[_0x888c('0x45')][_0x888c('0x4f')]){_0x3b6f61['where']=_[_0x888c('0x50')](_0x3b6f61['where'],{'$or':_[_0x888c('0x40')](_0x3b6f61[_0x888c('0x48')],function(_0x3d4c63){var _0x345d80={};_0x345d80[_0x3d4c63]={'$like':'%'+_0x2189e3[_0x888c('0x45')][_0x888c('0x4f')]+'%'};return _0x345d80;})});}_0x3b6f61=_[_0x888c('0x50')]({},_0x3b6f61,_0x2189e3[_0x888c('0x57')]);return _0x4574fe[_0x888c('0x5c')](_0x3b6f61);}})['then'](function(_0x71a576){if(_0x71a576){_0x3877e8=_0x71a576[_0x888c('0x4a')];if(!_0x2189e3[_0x888c('0x45')][_0x888c('0x5f')](_0x888c('0x4b'))){_0x3b6f61[_0x888c('0x34')]=qs[_0x888c('0x34')](_0x2189e3['query'][_0x888c('0x34')]);_0x3b6f61[_0x888c('0x33')]=qs[_0x888c('0x33')](_0x2189e3[_0x888c('0x45')][_0x888c('0x33')]);}return _0x4574fe[_0x888c('0x5c')](_0x3b6f61);}})['then'](function(_0x3a0f72){if(_0x3a0f72){return _0x3a0f72?{'count':_0x3877e8,'rows':_0x3a0f72}:null;}})[_0x888c('0x25')](respondWithResult(_0x27b94b,null))['catch'](handleError(_0x27b94b,null));};exports['addConfiguration']=function(_0x23c233,_0x364116,_0x19cc2d){if(_0x23c233['body']['id']){delete _0x23c233[_0x888c('0x5a')]['id'];}return db[_0x888c('0x41')][_0x888c('0x60')]({'where':{'id':_0x23c233[_0x888c('0x5b')]['id']}})['then'](handleEntityNotFound(_0x364116,null))[_0x888c('0x25')](function(_0x30eed1){if(_0x30eed1){_0x23c233[_0x888c('0x5a')]['AccountId']=_0x30eed1['id'];_0x23c233['body'][_0x888c('0x61')]=integrations['getSubjects'](_0x23c233[_0x888c('0x5a')]['channel'],_0x23c233[_0x888c('0x5a')][_0x888c('0x51')]);_0x23c233[_0x888c('0x5a')]['Descriptions']=integrations[_0x888c('0x62')](_0x23c233[_0x888c('0x5a')][_0x888c('0x63')],_0x23c233[_0x888c('0x5a')][_0x888c('0x51')]);return db[_0x888c('0x5d')][_0x888c('0x59')](_0x23c233[_0x888c('0x5a')],{'include':[{'model':db[_0x888c('0x64')],'as':_0x888c('0x61')},{'model':db['ZendeskField'],'as':_0x888c('0x65')}]});}return null;})['then'](respondWithResult(_0x364116,null))[_0x888c('0x2f')](handleError(_0x364116,null));};exports[_0x888c('0x66')]=function(_0x2810c9,_0x288c46,_0xa813ff){var _0x3e4c96='';return db[_0x888c('0x41')][_0x888c('0x60')]({'where':{'id':_0x2810c9[_0x888c('0x5b')]['id']},'attributes':['id',_0x888c('0x67'),_0x888c('0x68'),_0x888c('0x69'),_0x888c('0x6a'),'remoteUri']})[_0x888c('0x25')](handleEntityNotFound(_0x288c46,null))[_0x888c('0x25')](function(_0xc60e7d){if(_0xc60e7d){_0x3e4c96=_0xc60e7d[_0x888c('0x6b')];var _0x22d52f=_0x3e4c96['slice'](-0x1);if(_0x22d52f==='/'){_0x3e4c96=_0x3e4c96[_0x888c('0x6c')](0x0,_0x3e4c96[_0x888c('0x6d')](_0x22d52f));}var _0x57ee76={'method':_0x888c('0x6e'),'uri':util['format'](_0x888c('0x6f'),_0x3e4c96,_0x888c('0x70')),'json':!![]};switch(_0xc60e7d[_0x888c('0x6a')]){case _0x888c('0x68'):_0x57ee76['headers']={'Authorization':util[_0x888c('0x71')](_0x888c('0x72'),new Buffer(util['format'](_0x888c('0x73'),_0xc60e7d['username'],_0xc60e7d[_0x888c('0x68')]))[_0x888c('0x74')](_0x888c('0x75')))};break;case _0x888c('0x69'):_0x57ee76[_0x888c('0x76')]={'Authorization':util[_0x888c('0x71')]('Basic\x20%s',new Buffer(util[_0x888c('0x71')](_0x888c('0x77'),_0xc60e7d[_0x888c('0x67')],_0xc60e7d['token']))[_0x888c('0x74')](_0x888c('0x75')))};break;default:throw new db['Sequelize']['ValidationError'](_0x888c('0x78'));}return rp(_0x57ee76);}})[_0x888c('0x25')](function(_0x1be08b){if(_0x1be08b){var _0x20aeb4=[_0x888c('0x79'),'description',_0x888c('0x7a'),_0x888c('0x7b')];_['remove'](_0x1be08b[_0x888c('0x70')],function(_0x323f41){return _0x20aeb4[_0x888c('0x7c')](_0x323f41['type']);});return{'count':_0x1be08b[_0x888c('0x70')]['length'],'rows':_[_0x888c('0x40')](_0x1be08b['ticket_fields'],function(_0x12a2aa){return{'id':_0x12a2aa['id'],'name':_0x12a2aa[_0x888c('0x7d')]>0x7?_0x12a2aa[_0x888c('0x7e')]:_0x12a2aa[_0x888c('0x51')],'custom':_0x12a2aa['position']>0x7?!![]:![],'options':_0x12a2aa[_0x888c('0x7f')]?_0x12a2aa[_0x888c('0x7f')]:_0x12a2aa[_0x888c('0x80')]?_0x12a2aa[_0x888c('0x80')]:[]};})};}})['then'](respondWithResult(_0x288c46,null))[_0x888c('0x2f')](function(_0x5a70fa){var _0x58968f=_0x2810c9[_0x888c('0x45')][_0x888c('0x21')]?0x1f4:_0x5a70fa[_0x888c('0x81')]||0x1f4;logger[_0x888c('0x2c')](_0x888c('0x82'),_0x888c('0x66'),_0x58968f,JSON[_0x888c('0x2b')](_0x5a70fa));delete _0x5a70fa[_0x888c('0x3e')];if(_0x58968f===0x191){_0x58968f=0x190;}_0x288c46[_0x888c('0x30')](_0x58968f)[_0x888c('0x83')](_0x2810c9[_0x888c('0x45')][_0x888c('0x21')]?{'message':_0x888c('0x84'),'statusCode':_0x5a70fa[_0x888c('0x81')]}:_0x5a70fa);});};
\ No newline at end of file
+var _0xbaf0=['findAll','rows','catch','show','params','create','body','find','getConfigurations','findOne','ZendeskConfiguration','pick','Subjects','getSubjects','channel','Descriptions','getDescriptions','ZendeskField','getFields','username','password','token','remoteUri','slice','substring','lastIndexOf','GET','format','%s/%s','ticket_fields','authType','%s:%s','toString','headers','%s/token:%s','base64','Sequelize','ValidationError','subject','description','assignee','remove','includes','position','title','system_field_options','custom_field_options','test','getFields,\x20%s,\x20%s,\x20%s','stringify','Wrong\x20credentials','statusCode','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../components/integrations/configuration','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','end','sendStatus','error','stack','name','send','index','map','ZendeskAccount','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','merge','where','VIRTUAL','filter','options','includeAll','include'];(function(_0x52e817,_0x34ce6d){var _0x2c4811=function(_0x26ff4e){while(--_0x26ff4e){_0x52e817['push'](_0x52e817['shift']());}};_0x2c4811(++_0x34ce6d);}(_0xbaf0,0x12a));var _0x0baf=function(_0x14add3,_0x13ce8d){_0x14add3=_0x14add3-0x0;var _0x4a174f=_0xbaf0[_0x14add3];return _0x4a174f;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0baf('0x0'));var zipdir=require(_0x0baf('0x1'));var jsonpatch=require(_0x0baf('0x2'));var rp=require(_0x0baf('0x3'));var moment=require(_0x0baf('0x4'));var BPromise=require(_0x0baf('0x5'));var Mustache=require('mustache');var util=require(_0x0baf('0x6'));var path=require(_0x0baf('0x7'));var sox=require(_0x0baf('0x8'));var csv=require(_0x0baf('0x9'));var ejs=require(_0x0baf('0xa'));var fs=require('fs');var fs_extra=require(_0x0baf('0xb'));var _=require(_0x0baf('0xc'));var squel=require(_0x0baf('0xd'));var crypto=require(_0x0baf('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x0baf('0xf'));var toCsv=require('to-csv');var querystring=require(_0x0baf('0x10'));var Papa=require(_0x0baf('0x11'));var Redis=require(_0x0baf('0x12'));var authService=require(_0x0baf('0x13'));var qs=require(_0x0baf('0x14'));var as=require(_0x0baf('0x15'));var hardwareService=require(_0x0baf('0x16'));var logger=require(_0x0baf('0x17'))(_0x0baf('0x18'));var utils=require(_0x0baf('0x19'));var config=require(_0x0baf('0x1a'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var integrations=require(_0x0baf('0x1b'));function respondWithStatusCode(_0xe4378c,_0x5db689){_0x5db689=_0x5db689||0xcc;return function(_0x13df17){if(_0x13df17){return _0xe4378c['sendStatus'](_0x5db689);}return _0xe4378c[_0x0baf('0x1c')](_0x5db689)['end']();};}function respondWithResult(_0x1c76a8,_0x1f50c3){_0x1f50c3=_0x1f50c3||0xc8;return function(_0x7fbf67){if(_0x7fbf67){return _0x1c76a8[_0x0baf('0x1c')](_0x1f50c3)[_0x0baf('0x1d')](_0x7fbf67);}};}function respondWithFilteredResult(_0x469599,_0x4f80a8){return function(_0x4cd79d){if(_0x4cd79d){var _0x2312c7=typeof _0x4f80a8[_0x0baf('0x1e')]===_0x0baf('0x1f')&&typeof _0x4f80a8[_0x0baf('0x20')]===_0x0baf('0x1f');var _0x288a98=_0x4cd79d['count'];var _0x63c820=_0x2312c7?0x0:_0x4f80a8[_0x0baf('0x1e')];var _0x1ef0e5=_0x2312c7?_0x4cd79d[_0x0baf('0x21')]:_0x4f80a8[_0x0baf('0x1e')]+_0x4f80a8[_0x0baf('0x20')];var _0x4ff793;if(_0x1ef0e5>=_0x288a98){_0x1ef0e5=_0x288a98;_0x4ff793=0xc8;}else{_0x4ff793=0xce;}_0x469599['status'](_0x4ff793);return _0x469599[_0x0baf('0x22')](_0x0baf('0x23'),_0x63c820+'-'+_0x1ef0e5+'/'+_0x288a98)[_0x0baf('0x1d')](_0x4cd79d);}return null;};}function patchUpdates(_0x1848e8){return function(_0x1fa92b){try{jsonpatch[_0x0baf('0x24')](_0x1fa92b,_0x1848e8,!![]);}catch(_0x210cd8){return BPromise[_0x0baf('0x25')](_0x210cd8);}return _0x1fa92b[_0x0baf('0x26')]();};}function saveUpdates(_0x15a2c3,_0x54f2fa){return function(_0x334bd6){if(_0x334bd6){return _0x334bd6['update'](_0x15a2c3)[_0x0baf('0x27')](function(_0x5dbf00){return _0x5dbf00;});}return null;};}function removeEntity(_0x4de74c,_0x2ef0aa){return function(_0x48a0e9){if(_0x48a0e9){return _0x48a0e9['destroy']()[_0x0baf('0x27')](function(){_0x4de74c[_0x0baf('0x1c')](0xcc)[_0x0baf('0x28')]();});}};}function handleEntityNotFound(_0x19d9fd,_0x3a1ba1){return function(_0x56b299){if(!_0x56b299){_0x19d9fd[_0x0baf('0x29')](0x194);}return _0x56b299;};}function handleError(_0x4681c5,_0x1ca35a){_0x1ca35a=_0x1ca35a||0x1f4;return function(_0x366e71){logger[_0x0baf('0x2a')](_0x366e71[_0x0baf('0x2b')]);if(_0x366e71[_0x0baf('0x2c')]){delete _0x366e71['name'];}_0x4681c5[_0x0baf('0x1c')](_0x1ca35a)[_0x0baf('0x2d')](_0x366e71);};}exports[_0x0baf('0x2e')]=function(_0x265915,_0x55c715){var _0x29dbdf={},_0x34a58a={},_0x5d9d7f={'count':0x0,'rows':[]};var _0x44ec31=_[_0x0baf('0x2f')](db[_0x0baf('0x30')][_0x0baf('0x31')],function(_0xd14f0f){return{'name':_0xd14f0f[_0x0baf('0x32')],'type':_0xd14f0f[_0x0baf('0x33')]['key']};});_0x34a58a[_0x0baf('0x34')]=_[_0x0baf('0x2f')](_0x44ec31,_0x0baf('0x2c'));_0x34a58a[_0x0baf('0x35')]=_[_0x0baf('0x36')](_0x265915[_0x0baf('0x35')]);_0x34a58a[_0x0baf('0x37')]=_[_0x0baf('0x38')](_0x34a58a[_0x0baf('0x34')],_0x34a58a[_0x0baf('0x35')]);_0x29dbdf[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x34a58a[_0x0baf('0x34')],qs[_0x0baf('0x3a')](_0x265915['query'][_0x0baf('0x3a')]));_0x29dbdf['attributes']=_0x29dbdf[_0x0baf('0x39')][_0x0baf('0x3b')]?_0x29dbdf[_0x0baf('0x39')]:_0x34a58a[_0x0baf('0x34')];if(!_0x265915['query'][_0x0baf('0x3c')](_0x0baf('0x3d'))){_0x29dbdf['limit']=qs[_0x0baf('0x20')](_0x265915[_0x0baf('0x35')][_0x0baf('0x20')]);_0x29dbdf[_0x0baf('0x1e')]=qs[_0x0baf('0x1e')](_0x265915[_0x0baf('0x35')][_0x0baf('0x1e')]);}_0x29dbdf[_0x0baf('0x3e')]=qs['sort'](_0x265915[_0x0baf('0x35')][_0x0baf('0x3f')]);_0x29dbdf['where']=qs[_0x0baf('0x37')](_['pick'](_0x265915['query'],_0x34a58a[_0x0baf('0x37')]),_0x44ec31);if(_0x265915[_0x0baf('0x35')]['filter']){_0x29dbdf['where']=_[_0x0baf('0x40')](_0x29dbdf[_0x0baf('0x41')],{'$or':_[_0x0baf('0x2f')](_0x44ec31,function(_0xb2d9ab){if(_0xb2d9ab[_0x0baf('0x33')]!==_0x0baf('0x42')){var _0x290464={};_0x290464[_0xb2d9ab[_0x0baf('0x2c')]]={'$like':'%'+_0x265915[_0x0baf('0x35')][_0x0baf('0x43')]+'%'};return _0x290464;}})});}_0x29dbdf=_[_0x0baf('0x40')]({},_0x29dbdf,_0x265915[_0x0baf('0x44')]);var _0x354cb1={'where':_0x29dbdf[_0x0baf('0x41')]};return db['ZendeskAccount'][_0x0baf('0x21')](_0x354cb1)[_0x0baf('0x27')](function(_0x4f1de9){_0x5d9d7f[_0x0baf('0x21')]=_0x4f1de9;if(_0x265915[_0x0baf('0x35')][_0x0baf('0x45')]){_0x29dbdf[_0x0baf('0x46')]=[{'all':!![]}];}return db[_0x0baf('0x30')][_0x0baf('0x47')](_0x29dbdf);})['then'](function(_0x23ad34){_0x5d9d7f[_0x0baf('0x48')]=_0x23ad34;return _0x5d9d7f;})['then'](respondWithFilteredResult(_0x55c715,_0x29dbdf))[_0x0baf('0x49')](handleError(_0x55c715,null));};exports[_0x0baf('0x4a')]=function(_0x45c6aa,_0x57903e){var _0x504031={'raw':![],'where':{'id':_0x45c6aa[_0x0baf('0x4b')]['id']}},_0x193fd3={};_0x193fd3[_0x0baf('0x34')]=_[_0x0baf('0x36')](db[_0x0baf('0x30')][_0x0baf('0x31')]);_0x193fd3[_0x0baf('0x35')]=_[_0x0baf('0x36')](_0x45c6aa[_0x0baf('0x35')]);_0x193fd3[_0x0baf('0x37')]=_['intersection'](_0x193fd3[_0x0baf('0x34')],_0x193fd3[_0x0baf('0x35')]);_0x504031[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x193fd3[_0x0baf('0x34')],qs['fields'](_0x45c6aa[_0x0baf('0x35')][_0x0baf('0x3a')]));_0x504031[_0x0baf('0x39')]=_0x504031[_0x0baf('0x39')][_0x0baf('0x3b')]?_0x504031['attributes']:_0x193fd3[_0x0baf('0x34')];if(_0x45c6aa[_0x0baf('0x35')][_0x0baf('0x45')]){_0x504031[_0x0baf('0x46')]=[{'all':!![]}];}_0x504031=_[_0x0baf('0x40')]({},_0x504031,_0x45c6aa[_0x0baf('0x44')]);return db[_0x0baf('0x30')]['find'](_0x504031)[_0x0baf('0x27')](handleEntityNotFound(_0x57903e,null))[_0x0baf('0x27')](respondWithResult(_0x57903e,null))[_0x0baf('0x49')](handleError(_0x57903e,null));};exports['create']=function(_0x3c9de3,_0x2222b6){return db[_0x0baf('0x30')][_0x0baf('0x4c')](_0x3c9de3[_0x0baf('0x4d')],{})[_0x0baf('0x27')](respondWithResult(_0x2222b6,0xc9))[_0x0baf('0x49')](handleError(_0x2222b6,null));};exports['update']=function(_0x22c451,_0x428c9b){if(_0x22c451[_0x0baf('0x4d')]['id']){delete _0x22c451[_0x0baf('0x4d')]['id'];}return db[_0x0baf('0x30')][_0x0baf('0x4e')]({'where':{'id':_0x22c451[_0x0baf('0x4b')]['id']}})[_0x0baf('0x27')](handleEntityNotFound(_0x428c9b,null))[_0x0baf('0x27')](saveUpdates(_0x22c451[_0x0baf('0x4d')],null))[_0x0baf('0x27')](respondWithResult(_0x428c9b,null))['catch'](handleError(_0x428c9b,null));};exports['destroy']=function(_0x354329,_0x3d6b19){return db[_0x0baf('0x30')][_0x0baf('0x4e')]({'where':{'id':_0x354329[_0x0baf('0x4b')]['id']}})[_0x0baf('0x27')](handleEntityNotFound(_0x3d6b19,null))[_0x0baf('0x27')](removeEntity(_0x3d6b19,null))['catch'](handleError(_0x3d6b19,null));};exports[_0x0baf('0x4f')]=function(_0x2ef4c1,_0xf2424,_0x16d9fb){var _0x3fdb41={};var _0x1e2671={};var _0x5e1849;var _0x3eebe5;return db['ZendeskAccount'][_0x0baf('0x50')]({'where':{'id':_0x2ef4c1['params']['id']}})[_0x0baf('0x27')](handleEntityNotFound(_0xf2424,null))['then'](function(_0x35b1a5){if(_0x35b1a5){_0x5e1849=_0x35b1a5;_0x1e2671['model']=_[_0x0baf('0x36')](db[_0x0baf('0x51')][_0x0baf('0x31')]);_0x1e2671[_0x0baf('0x35')]=_[_0x0baf('0x36')](_0x2ef4c1['query']);_0x1e2671[_0x0baf('0x37')]=_[_0x0baf('0x38')](_0x1e2671[_0x0baf('0x34')],_0x1e2671[_0x0baf('0x35')]);_0x3fdb41[_0x0baf('0x39')]=_[_0x0baf('0x38')](_0x1e2671['model'],qs[_0x0baf('0x3a')](_0x2ef4c1[_0x0baf('0x35')][_0x0baf('0x3a')]));_0x3fdb41[_0x0baf('0x39')]=_0x3fdb41[_0x0baf('0x39')][_0x0baf('0x3b')]?_0x3fdb41[_0x0baf('0x39')]:_0x1e2671['model'];_0x3fdb41['order']=qs[_0x0baf('0x3f')](_0x2ef4c1[_0x0baf('0x35')][_0x0baf('0x3f')]);_0x3fdb41[_0x0baf('0x41')]=qs[_0x0baf('0x37')](_[_0x0baf('0x52')](_0x2ef4c1[_0x0baf('0x35')],_0x1e2671[_0x0baf('0x37')]));if(_0x2ef4c1[_0x0baf('0x35')]['filter']){_0x3fdb41[_0x0baf('0x41')]=_[_0x0baf('0x40')](_0x3fdb41[_0x0baf('0x41')],{'$or':_[_0x0baf('0x2f')](_0x3fdb41[_0x0baf('0x39')],function(_0xebfc0c){var _0x26f5c9={};_0x26f5c9[_0xebfc0c]={'$like':'%'+_0x2ef4c1['query'][_0x0baf('0x43')]+'%'};return _0x26f5c9;})});}_0x3fdb41=_[_0x0baf('0x40')]({},_0x3fdb41,_0x2ef4c1[_0x0baf('0x44')]);return _0x5e1849[_0x0baf('0x4f')](_0x3fdb41);}})[_0x0baf('0x27')](function(_0x1a6d22){if(_0x1a6d22){_0x3eebe5=_0x1a6d22[_0x0baf('0x3b')];if(!_0x2ef4c1[_0x0baf('0x35')]['hasOwnProperty'](_0x0baf('0x3d'))){_0x3fdb41['limit']=qs[_0x0baf('0x20')](_0x2ef4c1['query']['limit']);_0x3fdb41[_0x0baf('0x1e')]=qs['offset'](_0x2ef4c1[_0x0baf('0x35')][_0x0baf('0x1e')]);}return _0x5e1849['getConfigurations'](_0x3fdb41);}})[_0x0baf('0x27')](function(_0xfb6708){if(_0xfb6708){return _0xfb6708?{'count':_0x3eebe5,'rows':_0xfb6708}:null;}})[_0x0baf('0x27')](respondWithResult(_0xf2424,null))['catch'](handleError(_0xf2424,null));};exports['addConfiguration']=function(_0x2438df,_0x7e8946,_0x6d789f){if(_0x2438df[_0x0baf('0x4d')]['id']){delete _0x2438df[_0x0baf('0x4d')]['id'];}return db['ZendeskAccount'][_0x0baf('0x50')]({'where':{'id':_0x2438df['params']['id']}})['then'](handleEntityNotFound(_0x7e8946,null))['then'](function(_0x427ed1){if(_0x427ed1){_0x2438df['body']['AccountId']=_0x427ed1['id'];_0x2438df[_0x0baf('0x4d')][_0x0baf('0x53')]=integrations[_0x0baf('0x54')](_0x2438df[_0x0baf('0x4d')][_0x0baf('0x55')],_0x2438df[_0x0baf('0x4d')]['type']);_0x2438df[_0x0baf('0x4d')][_0x0baf('0x56')]=integrations[_0x0baf('0x57')](_0x2438df[_0x0baf('0x4d')][_0x0baf('0x55')],_0x2438df[_0x0baf('0x4d')]['type']);return db[_0x0baf('0x51')][_0x0baf('0x4c')](_0x2438df[_0x0baf('0x4d')],{'include':[{'model':db['ZendeskField'],'as':_0x0baf('0x53')},{'model':db[_0x0baf('0x58')],'as':_0x0baf('0x56')}]});}return null;})[_0x0baf('0x27')](respondWithResult(_0x7e8946,null))[_0x0baf('0x49')](handleError(_0x7e8946,null));};exports[_0x0baf('0x59')]=function(_0x4cc046,_0x5874cc,_0x54353a){var _0x4b7caa='';return db[_0x0baf('0x30')][_0x0baf('0x50')]({'where':{'id':_0x4cc046[_0x0baf('0x4b')]['id']},'attributes':['id',_0x0baf('0x5a'),_0x0baf('0x5b'),_0x0baf('0x5c'),'authType','remoteUri']})[_0x0baf('0x27')](handleEntityNotFound(_0x5874cc,null))['then'](function(_0x22cd07){if(_0x22cd07){_0x4b7caa=_0x22cd07[_0x0baf('0x5d')];var _0x4cca39=_0x4b7caa[_0x0baf('0x5e')](-0x1);if(_0x4cca39==='/'){_0x4b7caa=_0x4b7caa[_0x0baf('0x5f')](0x0,_0x4b7caa[_0x0baf('0x60')](_0x4cca39));}var _0xb1d719={'method':_0x0baf('0x61'),'uri':util[_0x0baf('0x62')](_0x0baf('0x63'),_0x4b7caa,_0x0baf('0x64')),'json':!![]};switch(_0x22cd07[_0x0baf('0x65')]){case'password':_0xb1d719['headers']={'Authorization':util['format']('Basic\x20%s',new Buffer(util['format'](_0x0baf('0x66'),_0x22cd07[_0x0baf('0x5a')],_0x22cd07[_0x0baf('0x5b')]))[_0x0baf('0x67')]('base64'))};break;case _0x0baf('0x5c'):_0xb1d719[_0x0baf('0x68')]={'Authorization':util['format']('Basic\x20%s',new Buffer(util[_0x0baf('0x62')](_0x0baf('0x69'),_0x22cd07[_0x0baf('0x5a')],_0x22cd07[_0x0baf('0x5c')]))[_0x0baf('0x67')](_0x0baf('0x6a')))};break;default:throw new db[(_0x0baf('0x6b'))][(_0x0baf('0x6c'))]('Unknown\x20authentication\x20type');}return rp(_0xb1d719);}})[_0x0baf('0x27')](function(_0x1a3b7b){if(_0x1a3b7b){var _0x560c0f=[_0x0baf('0x6d'),_0x0baf('0x6e'),'group',_0x0baf('0x6f')];_[_0x0baf('0x70')](_0x1a3b7b[_0x0baf('0x64')],function(_0x2baede){return _0x560c0f[_0x0baf('0x71')](_0x2baede['type']);});return{'count':_0x1a3b7b['ticket_fields'][_0x0baf('0x3b')],'rows':_[_0x0baf('0x2f')](_0x1a3b7b['ticket_fields'],function(_0x28bc1c){return{'id':_0x28bc1c['id'],'name':_0x28bc1c[_0x0baf('0x72')]>0x7?_0x28bc1c[_0x0baf('0x73')]:_0x28bc1c['type'],'custom':_0x28bc1c[_0x0baf('0x72')]>0x7?!![]:![],'options':_0x28bc1c[_0x0baf('0x74')]?_0x28bc1c[_0x0baf('0x74')]:_0x28bc1c['custom_field_options']?_0x28bc1c[_0x0baf('0x75')]:[]};})};}})['then'](respondWithResult(_0x5874cc,null))[_0x0baf('0x49')](function(_0x3fee46){var _0x3fd039=_0x4cc046[_0x0baf('0x35')][_0x0baf('0x76')]?0x1f4:_0x3fee46['statusCode']||0x1f4;logger[_0x0baf('0x2a')](_0x0baf('0x77'),'getFields',_0x3fd039,JSON[_0x0baf('0x78')](_0x3fee46));delete _0x3fee46[_0x0baf('0x2c')];if(_0x3fd039===0x191){_0x3fd039=0x190;}_0x5874cc[_0x0baf('0x1c')](_0x3fd039)[_0x0baf('0x2d')](_0x4cc046[_0x0baf('0x35')][_0x0baf('0x76')]?{'message':_0x0baf('0x79'),'statusCode':_0x3fee46[_0x0baf('0x7a')]}:_0x3fee46);});};
\ No newline at end of file