Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index bca6da8..0d96a1c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x537f=['querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','request','then','info','ZohoConfiguration,\x20%s,\x20%s','request\x20sent','debug','ZohoConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','end','status','json','limit','offset','count','set','Content-Range','apply','reject','save','update','stack','name','send','render','body','contact','agent','interaction','account','index','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','merge','VIRTUAL','options','ZohoConfiguration','include','rows','show','params','includeAll','find','destroy','getFields','findOne','ZohoField','pick','filter','nolimit','getSubjects','getDescriptions','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','sox','to-csv','ejs','fs-extra','crypto','desk.js'];(function(_0xef225b,_0x3f5a0d){var _0x251195=function(_0x96456d){while(--_0x96456d){_0xef225b['push'](_0xef225b['shift']());}};_0x251195(++_0x3f5a0d);}(_0x537f,0x1c5));var _0xf537=function(_0x660c48,_0x150b0a){_0x660c48=_0x660c48-0x0;var _0xdc5e90=_0x537f[_0x660c48];return _0xdc5e90;};'use strict';var emlformat=require(_0xf537('0x0'));var rimraf=require(_0xf537('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf537('0x2'));var rp=require(_0xf537('0x3'));var moment=require(_0xf537('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xf537('0x5'));var util=require('util');var path=require('path');var sox=require(_0xf537('0x6'));var csv=require(_0xf537('0x7'));var ejs=require(_0xf537('0x8'));var fs=require('fs');var fs_extra=require(_0xf537('0x9'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xf537('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xf537('0xb'));var toCsv=require('to-csv');var querystring=require(_0xf537('0xc'));var Papa=require('papaparse');var Redis=require(_0xf537('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xf537('0xe'));var as=require(_0xf537('0xf'));var hardwareService=require(_0xf537('0x10'));var logger=require(_0xf537('0x11'))('api');var utils=require(_0xf537('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf537('0x13'))['db'];var jayson=require(_0xf537('0x14'));var client=jayson[_0xf537('0x15')]['http']({'port':0x232a});function respondWithRpcPromise(_0xb8bcc4,_0x466308,_0x21da0e,_0x18c63d){return new BPromise(function(_0x49be48,_0x242f2b){var _0x297811=_0x18c63d||client;return _0x297811[_0xf537('0x16')](_0xb8bcc4,_0x21da0e)[_0xf537('0x17')](function(_0x2db86a){logger[_0xf537('0x18')](_0xf537('0x19'),_0x466308,_0xf537('0x1a'));logger[_0xf537('0x1b')](_0xf537('0x1c'),_0x466308,_0xf537('0x1a'),JSON[_0xf537('0x1d')](_0x2db86a));if(_0x2db86a['error']){if(_0x2db86a[_0xf537('0x1e')][_0xf537('0x1f')]===0x1f4){logger[_0xf537('0x1e')](_0xf537('0x19'),_0x466308,_0x2db86a[_0xf537('0x1e')][_0xf537('0x20')]);return _0x242f2b(_0x2db86a[_0xf537('0x1e')][_0xf537('0x20')]);}logger[_0xf537('0x1e')](_0xf537('0x19'),_0x466308,_0x2db86a[_0xf537('0x1e')][_0xf537('0x20')]);return _0x49be48(_0x2db86a['error'][_0xf537('0x20')]);}else{logger[_0xf537('0x18')](_0xf537('0x19'),_0x466308,_0xf537('0x1a'));_0x49be48(_0x2db86a['result'][_0xf537('0x20')]);}})[_0xf537('0x21')](function(_0x1bd9f6){logger[_0xf537('0x1e')](_0xf537('0x19'),_0x466308,_0x1bd9f6);_0x242f2b(_0x1bd9f6);});});}function respondWithStatusCode(_0x458588,_0x4801cd){_0x4801cd=_0x4801cd||0xcc;return function(_0x453287){if(_0x453287){return _0x458588[_0xf537('0x22')](_0x4801cd);}return _0x458588['status'](_0x4801cd)[_0xf537('0x23')]();};}function respondWithResult(_0x30f7c9,_0x7b7a0){_0x7b7a0=_0x7b7a0||0xc8;return function(_0x557116){if(_0x557116){return _0x30f7c9[_0xf537('0x24')](_0x7b7a0)[_0xf537('0x25')](_0x557116);}};}function respondWithFilteredResult(_0x429b3b,_0x6697e2){return function(_0x5bedde){if(_0x5bedde){var _0x10638d=typeof _0x6697e2['offset']==='undefined'&&typeof _0x6697e2[_0xf537('0x26')]==='undefined';var _0x332d29=_0x5bedde['count'];var _0x24740b=_0x10638d?0x0:_0x6697e2[_0xf537('0x27')];var _0x349a3a=_0x10638d?_0x5bedde[_0xf537('0x28')]:_0x6697e2[_0xf537('0x27')]+_0x6697e2['limit'];var _0x2ce240;if(_0x349a3a>=_0x332d29){_0x349a3a=_0x332d29;_0x2ce240=0xc8;}else{_0x2ce240=0xce;}_0x429b3b[_0xf537('0x24')](_0x2ce240);return _0x429b3b[_0xf537('0x29')](_0xf537('0x2a'),_0x24740b+'-'+_0x349a3a+'/'+_0x332d29)[_0xf537('0x25')](_0x5bedde);}return null;};}function patchUpdates(_0x2d6a57){return function(_0x2ccadd){try{jsonpatch[_0xf537('0x2b')](_0x2ccadd,_0x2d6a57,!![]);}catch(_0x4f8203){return BPromise[_0xf537('0x2c')](_0x4f8203);}return _0x2ccadd[_0xf537('0x2d')]();};}function saveUpdates(_0x3a30fe,_0x1b12db){return function(_0x1555d4){if(_0x1555d4){return _0x1555d4[_0xf537('0x2e')](_0x3a30fe)[_0xf537('0x17')](function(_0x444cbe){return _0x444cbe;});}return null;};}function removeEntity(_0x51981c,_0xeea127){return function(_0xcb28e1){if(_0xcb28e1){return _0xcb28e1['destroy']()[_0xf537('0x17')](function(){_0x51981c[_0xf537('0x24')](0xcc)[_0xf537('0x23')]();});}};}function handleEntityNotFound(_0x5281d8,_0x8595d){return function(_0x93e308){if(!_0x93e308){_0x5281d8[_0xf537('0x22')](0x194);}return _0x93e308;};}function handleError(_0x1d949e,_0x3d025d){_0x3d025d=_0x3d025d||0x1f4;return function(_0x3024c9){logger['error'](_0x3024c9[_0xf537('0x2f')]);if(_0x3024c9[_0xf537('0x30')]){delete _0x3024c9['name'];}_0x1d949e['status'](_0x3d025d)[_0xf537('0x31')](_0x3024c9);};}function getMustacheRender(_0x259dfc,_0x5e8e88){return Mustache[_0xf537('0x32')](_0x259dfc,_['merge'](_0x5e8e88[_0xf537('0x33')],{'contact':_0x5e8e88[_0xf537('0x34')],'message':_0x5e8e88[_0xf537('0x20')],'agent':_0x5e8e88[_0xf537('0x35')],'interaction':_0x5e8e88[_0xf537('0x36')],'account':_0x5e8e88[_0xf537('0x37')]}))||'';}exports[_0xf537('0x38')]=function(_0x40b8fe,_0x3f0193){var _0x5a5fd5={},_0x297250={},_0x433853={'count':0x0,'rows':[]};var _0x5c95e1=_['map'](db['ZohoConfiguration'][_0xf537('0x39')],function(_0x10adb0){return{'name':_0x10adb0[_0xf537('0x3a')],'type':_0x10adb0[_0xf537('0x3b')][_0xf537('0x3c')]};});_0x297250[_0xf537('0x3d')]=_[_0xf537('0x3e')](_0x5c95e1,_0xf537('0x30'));_0x297250[_0xf537('0x3f')]=_[_0xf537('0x40')](_0x40b8fe[_0xf537('0x3f')]);_0x297250[_0xf537('0x41')]=_[_0xf537('0x42')](_0x297250[_0xf537('0x3d')],_0x297250[_0xf537('0x3f')]);_0x5a5fd5['attributes']=_[_0xf537('0x42')](_0x297250[_0xf537('0x3d')],qs[_0xf537('0x43')](_0x40b8fe['query'][_0xf537('0x43')]));_0x5a5fd5['attributes']=_0x5a5fd5[_0xf537('0x44')][_0xf537('0x45')]?_0x5a5fd5[_0xf537('0x44')]:_0x297250[_0xf537('0x3d')];if(!_0x40b8fe[_0xf537('0x3f')][_0xf537('0x46')]('nolimit')){_0x5a5fd5[_0xf537('0x26')]=qs[_0xf537('0x26')](_0x40b8fe[_0xf537('0x3f')][_0xf537('0x26')]);_0x5a5fd5['offset']=qs[_0xf537('0x27')](_0x40b8fe[_0xf537('0x3f')][_0xf537('0x27')]);}_0x5a5fd5[_0xf537('0x47')]=qs[_0xf537('0x48')](_0x40b8fe['query'][_0xf537('0x48')]);_0x5a5fd5[_0xf537('0x49')]=qs[_0xf537('0x41')](_['pick'](_0x40b8fe['query'],_0x297250[_0xf537('0x41')]),_0x5c95e1);if(_0x40b8fe['query']['filter']){_0x5a5fd5[_0xf537('0x49')]=_[_0xf537('0x4a')](_0x5a5fd5[_0xf537('0x49')],{'$or':_[_0xf537('0x3e')](_0x5c95e1,function(_0x541d4b){if(_0x541d4b['type']!==_0xf537('0x4b')){var _0x2847d5={};_0x2847d5[_0x541d4b[_0xf537('0x30')]]={'$like':'%'+_0x40b8fe[_0xf537('0x3f')]['filter']+'%'};return _0x2847d5;}})});}_0x5a5fd5=_[_0xf537('0x4a')]({},_0x5a5fd5,_0x40b8fe[_0xf537('0x4c')]);var _0x71197b={'where':_0x5a5fd5['where']};return db[_0xf537('0x4d')]['count'](_0x71197b)[_0xf537('0x17')](function(_0x546b87){_0x433853[_0xf537('0x28')]=_0x546b87;if(_0x40b8fe[_0xf537('0x3f')]['includeAll']){_0x5a5fd5[_0xf537('0x4e')]=[{'all':!![]}];}return db['ZohoConfiguration']['findAll'](_0x5a5fd5);})[_0xf537('0x17')](function(_0x715852){_0x433853[_0xf537('0x4f')]=_0x715852;return _0x433853;})[_0xf537('0x17')](respondWithFilteredResult(_0x3f0193,_0x5a5fd5))['catch'](handleError(_0x3f0193,null));};exports[_0xf537('0x50')]=function(_0x47d7e0,_0x441f89){var _0x3e959a={'raw':![],'where':{'id':_0x47d7e0[_0xf537('0x51')]['id']}},_0x73372a={};_0x73372a[_0xf537('0x3d')]=_[_0xf537('0x40')](db[_0xf537('0x4d')]['rawAttributes']);_0x73372a[_0xf537('0x3f')]=_[_0xf537('0x40')](_0x47d7e0[_0xf537('0x3f')]);_0x73372a[_0xf537('0x41')]=_['intersection'](_0x73372a[_0xf537('0x3d')],_0x73372a[_0xf537('0x3f')]);_0x3e959a[_0xf537('0x44')]=_['intersection'](_0x73372a[_0xf537('0x3d')],qs[_0xf537('0x43')](_0x47d7e0[_0xf537('0x3f')][_0xf537('0x43')]));_0x3e959a[_0xf537('0x44')]=_0x3e959a[_0xf537('0x44')][_0xf537('0x45')]?_0x3e959a[_0xf537('0x44')]:_0x73372a['model'];if(_0x47d7e0[_0xf537('0x3f')][_0xf537('0x52')]){_0x3e959a[_0xf537('0x4e')]=[{'all':!![]}];}_0x3e959a=_[_0xf537('0x4a')]({},_0x3e959a,_0x47d7e0[_0xf537('0x4c')]);return db[_0xf537('0x4d')]['find'](_0x3e959a)['then'](handleEntityNotFound(_0x441f89,null))[_0xf537('0x17')](respondWithResult(_0x441f89,null))[_0xf537('0x21')](handleError(_0x441f89,null));};exports['create']=function(_0x13cd4a,_0x237a58){return db['ZohoConfiguration']['create'](_0x13cd4a[_0xf537('0x33')],{})[_0xf537('0x17')](respondWithResult(_0x237a58,0xc9))['catch'](handleError(_0x237a58,null));};exports['update']=function(_0x554943,_0x45ff9c){if(_0x554943[_0xf537('0x33')]['id']){delete _0x554943[_0xf537('0x33')]['id'];}return db[_0xf537('0x4d')][_0xf537('0x53')]({'where':{'id':_0x554943[_0xf537('0x51')]['id']}})[_0xf537('0x17')](handleEntityNotFound(_0x45ff9c,null))[_0xf537('0x17')](saveUpdates(_0x554943[_0xf537('0x33')],null))[_0xf537('0x17')](respondWithResult(_0x45ff9c,null))[_0xf537('0x21')](handleError(_0x45ff9c,null));};exports[_0xf537('0x54')]=function(_0x5b4952,_0x309fcb){return db[_0xf537('0x4d')][_0xf537('0x53')]({'where':{'id':_0x5b4952[_0xf537('0x51')]['id']}})[_0xf537('0x17')](handleEntityNotFound(_0x309fcb,null))['then'](removeEntity(_0x309fcb,null))[_0xf537('0x21')](handleError(_0x309fcb,null));};exports[_0xf537('0x55')]=function(_0x2c0f01,_0x6b7cf2,_0x3061bb){var _0xa35dd1={};var _0x5dc6c9={};var _0x268e11;var _0x3f88ce;return db[_0xf537('0x4d')][_0xf537('0x56')]({'where':{'id':_0x2c0f01[_0xf537('0x51')]['id']}})[_0xf537('0x17')](handleEntityNotFound(_0x6b7cf2,null))[_0xf537('0x17')](function(_0x4c34c7){if(_0x4c34c7){_0x268e11=_0x4c34c7;_0x5dc6c9[_0xf537('0x3d')]=_['keys'](db[_0xf537('0x57')][_0xf537('0x39')]);_0x5dc6c9['query']=_[_0xf537('0x40')](_0x2c0f01[_0xf537('0x3f')]);_0x5dc6c9['filters']=_[_0xf537('0x42')](_0x5dc6c9[_0xf537('0x3d')],_0x5dc6c9[_0xf537('0x3f')]);_0xa35dd1[_0xf537('0x44')]=_[_0xf537('0x42')](_0x5dc6c9[_0xf537('0x3d')],qs[_0xf537('0x43')](_0x2c0f01[_0xf537('0x3f')][_0xf537('0x43')]));_0xa35dd1[_0xf537('0x44')]=_0xa35dd1[_0xf537('0x44')][_0xf537('0x45')]?_0xa35dd1[_0xf537('0x44')]:_0x5dc6c9['model'];_0xa35dd1[_0xf537('0x47')]=qs['sort'](_0x2c0f01[_0xf537('0x3f')][_0xf537('0x48')]);_0xa35dd1[_0xf537('0x49')]=qs[_0xf537('0x41')](_[_0xf537('0x58')](_0x2c0f01[_0xf537('0x3f')],_0x5dc6c9[_0xf537('0x41')]));if(_0x2c0f01['query'][_0xf537('0x59')]){_0xa35dd1['where']=_[_0xf537('0x4a')](_0xa35dd1[_0xf537('0x49')],{'$or':_[_0xf537('0x3e')](_0xa35dd1['attributes'],function(_0x427ee6){var _0x2dd8bc={};_0x2dd8bc[_0x427ee6]={'$like':'%'+_0x2c0f01[_0xf537('0x3f')][_0xf537('0x59')]+'%'};return _0x2dd8bc;})});}_0xa35dd1=_[_0xf537('0x4a')]({},_0xa35dd1,_0x2c0f01['options']);return _0x268e11[_0xf537('0x55')](_0xa35dd1);}})[_0xf537('0x17')](function(_0x538715){if(_0x538715){_0x3f88ce=_0x538715[_0xf537('0x45')];if(!_0x2c0f01[_0xf537('0x3f')][_0xf537('0x46')](_0xf537('0x5a'))){_0xa35dd1['limit']=qs['limit'](_0x2c0f01['query'][_0xf537('0x26')]);_0xa35dd1[_0xf537('0x27')]=qs[_0xf537('0x27')](_0x2c0f01['query'][_0xf537('0x27')]);}return _0x268e11[_0xf537('0x55')](_0xa35dd1);}})[_0xf537('0x17')](function(_0x33126e){if(_0x33126e){return _0x33126e?{'count':_0x3f88ce,'rows':_0x33126e}:null;}})[_0xf537('0x17')](respondWithResult(_0x6b7cf2,null))[_0xf537('0x21')](handleError(_0x6b7cf2,null));};exports[_0xf537('0x5b')]=function(_0x1739ea,_0x324106,_0x2d2e24){var _0x28bd30={};var _0x335112={};var _0x2d0b85;var _0x156cb5;return db['ZohoConfiguration'][_0xf537('0x56')]({'where':{'id':_0x1739ea[_0xf537('0x51')]['id']}})[_0xf537('0x17')](handleEntityNotFound(_0x324106,null))[_0xf537('0x17')](function(_0x407657){if(_0x407657){_0x2d0b85=_0x407657;_0x335112[_0xf537('0x3d')]=_[_0xf537('0x40')](db[_0xf537('0x57')]['rawAttributes']);_0x335112[_0xf537('0x3f')]=_['keys'](_0x1739ea[_0xf537('0x3f')]);_0x335112[_0xf537('0x41')]=_['intersection'](_0x335112[_0xf537('0x3d')],_0x335112[_0xf537('0x3f')]);_0x28bd30[_0xf537('0x44')]=_['intersection'](_0x335112[_0xf537('0x3d')],qs[_0xf537('0x43')](_0x1739ea['query'][_0xf537('0x43')]));_0x28bd30['attributes']=_0x28bd30[_0xf537('0x44')]['length']?_0x28bd30[_0xf537('0x44')]:_0x335112[_0xf537('0x3d')];_0x28bd30[_0xf537('0x47')]=qs[_0xf537('0x48')](_0x1739ea['query'][_0xf537('0x48')]);_0x28bd30[_0xf537('0x49')]=qs[_0xf537('0x41')](_['pick'](_0x1739ea['query'],_0x335112['filters']));if(_0x1739ea[_0xf537('0x3f')][_0xf537('0x59')]){_0x28bd30[_0xf537('0x49')]=_['merge'](_0x28bd30[_0xf537('0x49')],{'$or':_[_0xf537('0x3e')](_0x28bd30['attributes'],function(_0x234e6f){var _0x508d0d={};_0x508d0d[_0x234e6f]={'$like':'%'+_0x1739ea[_0xf537('0x3f')][_0xf537('0x59')]+'%'};return _0x508d0d;})});}_0x28bd30=_[_0xf537('0x4a')]({},_0x28bd30,_0x1739ea['options']);return _0x2d0b85[_0xf537('0x5b')](_0x28bd30);}})[_0xf537('0x17')](function(_0x39d208){if(_0x39d208){_0x156cb5=_0x39d208[_0xf537('0x45')];if(!_0x1739ea['query']['hasOwnProperty'](_0xf537('0x5a'))){_0x28bd30[_0xf537('0x26')]=qs[_0xf537('0x26')](_0x1739ea['query']['limit']);_0x28bd30[_0xf537('0x27')]=qs[_0xf537('0x27')](_0x1739ea[_0xf537('0x3f')][_0xf537('0x27')]);}return _0x2d0b85[_0xf537('0x5b')](_0x28bd30);}})['then'](function(_0x14360f){if(_0x14360f){return _0x14360f?{'count':_0x156cb5,'rows':_0x14360f}:null;}})[_0xf537('0x17')](respondWithResult(_0x324106,null))[_0xf537('0x21')](handleError(_0x324106,null));};exports['getDescriptions']=function(_0x3cb048,_0x933d9c,_0x29f54e){var _0x43982b={};var _0x35cc7b={};var _0x6cdbbc;var _0x48045a;return db[_0xf537('0x4d')][_0xf537('0x56')]({'where':{'id':_0x3cb048['params']['id']}})[_0xf537('0x17')](handleEntityNotFound(_0x933d9c,null))['then'](function(_0x3f2a73){if(_0x3f2a73){_0x6cdbbc=_0x3f2a73;_0x35cc7b[_0xf537('0x3d')]=_[_0xf537('0x40')](db['ZohoField'][_0xf537('0x39')]);_0x35cc7b[_0xf537('0x3f')]=_[_0xf537('0x40')](_0x3cb048['query']);_0x35cc7b[_0xf537('0x41')]=_[_0xf537('0x42')](_0x35cc7b[_0xf537('0x3d')],_0x35cc7b[_0xf537('0x3f')]);_0x43982b[_0xf537('0x44')]=_[_0xf537('0x42')](_0x35cc7b[_0xf537('0x3d')],qs[_0xf537('0x43')](_0x3cb048[_0xf537('0x3f')][_0xf537('0x43')]));_0x43982b['attributes']=_0x43982b[_0xf537('0x44')][_0xf537('0x45')]?_0x43982b[_0xf537('0x44')]:_0x35cc7b[_0xf537('0x3d')];_0x43982b[_0xf537('0x47')]=qs[_0xf537('0x48')](_0x3cb048[_0xf537('0x3f')]['sort']);_0x43982b[_0xf537('0x49')]=qs['filters'](_['pick'](_0x3cb048[_0xf537('0x3f')],_0x35cc7b['filters']));if(_0x3cb048['query'][_0xf537('0x59')]){_0x43982b[_0xf537('0x49')]=_[_0xf537('0x4a')](_0x43982b[_0xf537('0x49')],{'$or':_[_0xf537('0x3e')](_0x43982b[_0xf537('0x44')],function(_0xa1fab3){var _0xd764ce={};_0xd764ce[_0xa1fab3]={'$like':'%'+_0x3cb048[_0xf537('0x3f')][_0xf537('0x59')]+'%'};return _0xd764ce;})});}_0x43982b=_['merge']({},_0x43982b,_0x3cb048[_0xf537('0x4c')]);return _0x6cdbbc[_0xf537('0x5c')](_0x43982b);}})[_0xf537('0x17')](function(_0x40ea2f){if(_0x40ea2f){_0x48045a=_0x40ea2f[_0xf537('0x45')];if(!_0x3cb048['query']['hasOwnProperty'](_0xf537('0x5a'))){_0x43982b['limit']=qs[_0xf537('0x26')](_0x3cb048[_0xf537('0x3f')][_0xf537('0x26')]);_0x43982b[_0xf537('0x27')]=qs[_0xf537('0x27')](_0x3cb048[_0xf537('0x3f')]['offset']);}return _0x6cdbbc[_0xf537('0x5c')](_0x43982b);}})[_0xf537('0x17')](function(_0x4fd108){if(_0x4fd108){return _0x4fd108?{'count':_0x48045a,'rows':_0x4fd108}:null;}})[_0xf537('0x17')](respondWithResult(_0x933d9c,null))[_0xf537('0x21')](handleError(_0x933d9c,null));};
\ No newline at end of file
+var _0x8b59=['keys','query','filters','intersection','fields','attributes','length','model','hasOwnProperty','order','sort','where','pick','filter','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','create','body','getFields','findOne','ZohoField','nolimit','getSubjects','getDescriptions','rimraf','zip-dir','request-promise','moment','mustache','util','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','jayson/promise','http','request','ZohoConfiguration,\x20%s,\x20%s','request\x20sent','debug','ZohoConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','stack','name','send','render','merge','agent','account','index','ZohoConfiguration','rawAttributes','type','key','map'];(function(_0x571c22,_0x22ff9b){var _0x59286d=function(_0x543b86){while(--_0x543b86){_0x571c22['push'](_0x571c22['shift']());}};_0x59286d(++_0x22ff9b);}(_0x8b59,0x7f));var _0x98b5=function(_0x74ddc1,_0x500c84){_0x74ddc1=_0x74ddc1-0x0;var _0x51bc45=_0x8b59[_0x74ddc1];return _0x51bc45;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x98b5('0x0'));var zipdir=require(_0x98b5('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x98b5('0x2'));var moment=require(_0x98b5('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x98b5('0x4'));var util=require(_0x98b5('0x5'));var path=require('path');var sox=require(_0x98b5('0x6'));var csv=require(_0x98b5('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x98b5('0x8'));var _=require(_0x98b5('0x9'));var squel=require(_0x98b5('0xa'));var crypto=require(_0x98b5('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x98b5('0xc'));var toCsv=require(_0x98b5('0x7'));var querystring=require(_0x98b5('0xd'));var Papa=require(_0x98b5('0xe'));var Redis=require(_0x98b5('0xf'));var authService=require(_0x98b5('0x10'));var qs=require(_0x98b5('0x11'));var as=require(_0x98b5('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x98b5('0x13'))(_0x98b5('0x14'));var utils=require(_0x98b5('0x15'));var config=require(_0x98b5('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x98b5('0x17'))['db'];var jayson=require(_0x98b5('0x18'));var client=jayson['client'][_0x98b5('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x378b19,_0x492669,_0x3a67c6,_0x14928a){return new BPromise(function(_0x2a55a8,_0x366c23){var _0x2d1abb=_0x14928a||client;return _0x2d1abb[_0x98b5('0x1a')](_0x378b19,_0x3a67c6)['then'](function(_0x419571){logger['info'](_0x98b5('0x1b'),_0x492669,_0x98b5('0x1c'));logger[_0x98b5('0x1d')](_0x98b5('0x1e'),_0x492669,_0x98b5('0x1c'),JSON[_0x98b5('0x1f')](_0x419571));if(_0x419571['error']){if(_0x419571[_0x98b5('0x20')][_0x98b5('0x21')]===0x1f4){logger[_0x98b5('0x20')]('ZohoConfiguration,\x20%s,\x20%s',_0x492669,_0x419571['error'][_0x98b5('0x22')]);return _0x366c23(_0x419571['error']['message']);}logger[_0x98b5('0x20')]('ZohoConfiguration,\x20%s,\x20%s',_0x492669,_0x419571[_0x98b5('0x20')][_0x98b5('0x22')]);return _0x2a55a8(_0x419571['error'][_0x98b5('0x22')]);}else{logger['info'](_0x98b5('0x1b'),_0x492669,_0x98b5('0x1c'));_0x2a55a8(_0x419571[_0x98b5('0x23')][_0x98b5('0x22')]);}})[_0x98b5('0x24')](function(_0x5603ac){logger[_0x98b5('0x20')](_0x98b5('0x1b'),_0x492669,_0x5603ac);_0x366c23(_0x5603ac);});});}function respondWithStatusCode(_0x1fe7e6,_0x5504af){_0x5504af=_0x5504af||0xcc;return function(_0x16c2b8){if(_0x16c2b8){return _0x1fe7e6[_0x98b5('0x25')](_0x5504af);}return _0x1fe7e6[_0x98b5('0x26')](_0x5504af)[_0x98b5('0x27')]();};}function respondWithResult(_0x35d8ce,_0x59df60){_0x59df60=_0x59df60||0xc8;return function(_0x3ebbc1){if(_0x3ebbc1){return _0x35d8ce['status'](_0x59df60)[_0x98b5('0x28')](_0x3ebbc1);}};}function respondWithFilteredResult(_0x2ef4c6,_0x6c005){return function(_0x55c571){if(_0x55c571){var _0x35e631=typeof _0x6c005[_0x98b5('0x29')]===_0x98b5('0x2a')&&typeof _0x6c005[_0x98b5('0x2b')]===_0x98b5('0x2a');var _0x56c649=_0x55c571[_0x98b5('0x2c')];var _0x496dfd=_0x35e631?0x0:_0x6c005[_0x98b5('0x29')];var _0x1f20ce=_0x35e631?_0x55c571[_0x98b5('0x2c')]:_0x6c005[_0x98b5('0x29')]+_0x6c005['limit'];var _0x51ce0b;if(_0x1f20ce>=_0x56c649){_0x1f20ce=_0x56c649;_0x51ce0b=0xc8;}else{_0x51ce0b=0xce;}_0x2ef4c6[_0x98b5('0x26')](_0x51ce0b);return _0x2ef4c6[_0x98b5('0x2d')](_0x98b5('0x2e'),_0x496dfd+'-'+_0x1f20ce+'/'+_0x56c649)['json'](_0x55c571);}return null;};}function patchUpdates(_0x26a1d2){return function(_0x2f9676){try{jsonpatch[_0x98b5('0x2f')](_0x2f9676,_0x26a1d2,!![]);}catch(_0x112b72){return BPromise[_0x98b5('0x30')](_0x112b72);}return _0x2f9676[_0x98b5('0x31')]();};}function saveUpdates(_0x2d3e84,_0x2d85d9){return function(_0xb3968a){if(_0xb3968a){return _0xb3968a['update'](_0x2d3e84)[_0x98b5('0x32')](function(_0x29863b){return _0x29863b;});}return null;};}function removeEntity(_0x17bfaf,_0x3ffa73){return function(_0x32da82){if(_0x32da82){return _0x32da82[_0x98b5('0x33')]()['then'](function(){_0x17bfaf[_0x98b5('0x26')](0xcc)[_0x98b5('0x27')]();});}};}function handleEntityNotFound(_0x11bea6,_0x99adda){return function(_0x4a29b8){if(!_0x4a29b8){_0x11bea6['sendStatus'](0x194);}return _0x4a29b8;};}function handleError(_0x4b4c6b,_0x39a3e8){_0x39a3e8=_0x39a3e8||0x1f4;return function(_0x385fe6){logger[_0x98b5('0x20')](_0x385fe6[_0x98b5('0x34')]);if(_0x385fe6[_0x98b5('0x35')]){delete _0x385fe6['name'];}_0x4b4c6b[_0x98b5('0x26')](_0x39a3e8)[_0x98b5('0x36')](_0x385fe6);};}function getMustacheRender(_0x22a963,_0x41292a){return Mustache[_0x98b5('0x37')](_0x22a963,_[_0x98b5('0x38')](_0x41292a['body'],{'contact':_0x41292a['contact'],'message':_0x41292a[_0x98b5('0x22')],'agent':_0x41292a[_0x98b5('0x39')],'interaction':_0x41292a['interaction'],'account':_0x41292a[_0x98b5('0x3a')]}))||'';}exports[_0x98b5('0x3b')]=function(_0x5165fc,_0x20bed0){var _0x5e699b={},_0x162c75={},_0x42ca09={'count':0x0,'rows':[]};var _0x491eb6=_['map'](db[_0x98b5('0x3c')][_0x98b5('0x3d')],function(_0xa73727){return{'name':_0xa73727['fieldName'],'type':_0xa73727[_0x98b5('0x3e')][_0x98b5('0x3f')]};});_0x162c75['model']=_[_0x98b5('0x40')](_0x491eb6,_0x98b5('0x35'));_0x162c75['query']=_[_0x98b5('0x41')](_0x5165fc[_0x98b5('0x42')]);_0x162c75[_0x98b5('0x43')]=_[_0x98b5('0x44')](_0x162c75['model'],_0x162c75[_0x98b5('0x42')]);_0x5e699b['attributes']=_[_0x98b5('0x44')](_0x162c75['model'],qs['fields'](_0x5165fc['query'][_0x98b5('0x45')]));_0x5e699b[_0x98b5('0x46')]=_0x5e699b[_0x98b5('0x46')][_0x98b5('0x47')]?_0x5e699b['attributes']:_0x162c75[_0x98b5('0x48')];if(!_0x5165fc[_0x98b5('0x42')][_0x98b5('0x49')]('nolimit')){_0x5e699b['limit']=qs[_0x98b5('0x2b')](_0x5165fc['query']['limit']);_0x5e699b[_0x98b5('0x29')]=qs['offset'](_0x5165fc['query'][_0x98b5('0x29')]);}_0x5e699b[_0x98b5('0x4a')]=qs[_0x98b5('0x4b')](_0x5165fc['query'][_0x98b5('0x4b')]);_0x5e699b[_0x98b5('0x4c')]=qs['filters'](_[_0x98b5('0x4d')](_0x5165fc[_0x98b5('0x42')],_0x162c75[_0x98b5('0x43')]),_0x491eb6);if(_0x5165fc[_0x98b5('0x42')][_0x98b5('0x4e')]){_0x5e699b[_0x98b5('0x4c')]=_['merge'](_0x5e699b[_0x98b5('0x4c')],{'$or':_[_0x98b5('0x40')](_0x491eb6,function(_0x289e2d){if(_0x289e2d['type']!==_0x98b5('0x4f')){var _0x4b4730={};_0x4b4730[_0x289e2d['name']]={'$like':'%'+_0x5165fc[_0x98b5('0x42')]['filter']+'%'};return _0x4b4730;}})});}_0x5e699b=_[_0x98b5('0x38')]({},_0x5e699b,_0x5165fc[_0x98b5('0x50')]);var _0x2dba93={'where':_0x5e699b[_0x98b5('0x4c')]};return db[_0x98b5('0x3c')][_0x98b5('0x2c')](_0x2dba93)[_0x98b5('0x32')](function(_0x412aad){_0x42ca09[_0x98b5('0x2c')]=_0x412aad;if(_0x5165fc['query'][_0x98b5('0x51')]){_0x5e699b[_0x98b5('0x52')]=[{'all':!![]}];}return db['ZohoConfiguration'][_0x98b5('0x53')](_0x5e699b);})[_0x98b5('0x32')](function(_0x1e5e87){_0x42ca09[_0x98b5('0x54')]=_0x1e5e87;return _0x42ca09;})[_0x98b5('0x32')](respondWithFilteredResult(_0x20bed0,_0x5e699b))['catch'](handleError(_0x20bed0,null));};exports[_0x98b5('0x55')]=function(_0x22cbec,_0x4757de){var _0x4b88d4={'raw':![],'where':{'id':_0x22cbec[_0x98b5('0x56')]['id']}},_0x4e3127={};_0x4e3127[_0x98b5('0x48')]=_[_0x98b5('0x41')](db['ZohoConfiguration'][_0x98b5('0x3d')]);_0x4e3127[_0x98b5('0x42')]=_['keys'](_0x22cbec[_0x98b5('0x42')]);_0x4e3127[_0x98b5('0x43')]=_[_0x98b5('0x44')](_0x4e3127[_0x98b5('0x48')],_0x4e3127['query']);_0x4b88d4[_0x98b5('0x46')]=_[_0x98b5('0x44')](_0x4e3127['model'],qs['fields'](_0x22cbec['query'][_0x98b5('0x45')]));_0x4b88d4[_0x98b5('0x46')]=_0x4b88d4[_0x98b5('0x46')][_0x98b5('0x47')]?_0x4b88d4[_0x98b5('0x46')]:_0x4e3127[_0x98b5('0x48')];if(_0x22cbec[_0x98b5('0x42')]['includeAll']){_0x4b88d4[_0x98b5('0x52')]=[{'all':!![]}];}_0x4b88d4=_[_0x98b5('0x38')]({},_0x4b88d4,_0x22cbec[_0x98b5('0x50')]);return db[_0x98b5('0x3c')][_0x98b5('0x57')](_0x4b88d4)[_0x98b5('0x32')](handleEntityNotFound(_0x4757de,null))[_0x98b5('0x32')](respondWithResult(_0x4757de,null))['catch'](handleError(_0x4757de,null));};exports[_0x98b5('0x58')]=function(_0xab7394,_0x5e09ba){return db[_0x98b5('0x3c')][_0x98b5('0x58')](_0xab7394['body'],{})[_0x98b5('0x32')](respondWithResult(_0x5e09ba,0xc9))['catch'](handleError(_0x5e09ba,null));};exports['update']=function(_0x49c2ed,_0x4b6094){if(_0x49c2ed[_0x98b5('0x59')]['id']){delete _0x49c2ed[_0x98b5('0x59')]['id'];}return db[_0x98b5('0x3c')][_0x98b5('0x57')]({'where':{'id':_0x49c2ed['params']['id']}})[_0x98b5('0x32')](handleEntityNotFound(_0x4b6094,null))[_0x98b5('0x32')](saveUpdates(_0x49c2ed['body'],null))[_0x98b5('0x32')](respondWithResult(_0x4b6094,null))[_0x98b5('0x24')](handleError(_0x4b6094,null));};exports[_0x98b5('0x33')]=function(_0x2f81f7,_0x4b807f){return db[_0x98b5('0x3c')]['find']({'where':{'id':_0x2f81f7[_0x98b5('0x56')]['id']}})[_0x98b5('0x32')](handleEntityNotFound(_0x4b807f,null))['then'](removeEntity(_0x4b807f,null))[_0x98b5('0x24')](handleError(_0x4b807f,null));};exports[_0x98b5('0x5a')]=function(_0x4d96ca,_0x4a2718,_0x36e7ad){var _0x168ae0={};var _0x56cc25={};var _0x293b66;var _0x228d93;return db[_0x98b5('0x3c')][_0x98b5('0x5b')]({'where':{'id':_0x4d96ca[_0x98b5('0x56')]['id']}})['then'](handleEntityNotFound(_0x4a2718,null))[_0x98b5('0x32')](function(_0x1947b8){if(_0x1947b8){_0x293b66=_0x1947b8;_0x56cc25[_0x98b5('0x48')]=_[_0x98b5('0x41')](db[_0x98b5('0x5c')][_0x98b5('0x3d')]);_0x56cc25['query']=_[_0x98b5('0x41')](_0x4d96ca[_0x98b5('0x42')]);_0x56cc25[_0x98b5('0x43')]=_[_0x98b5('0x44')](_0x56cc25[_0x98b5('0x48')],_0x56cc25[_0x98b5('0x42')]);_0x168ae0[_0x98b5('0x46')]=_[_0x98b5('0x44')](_0x56cc25['model'],qs[_0x98b5('0x45')](_0x4d96ca[_0x98b5('0x42')][_0x98b5('0x45')]));_0x168ae0[_0x98b5('0x46')]=_0x168ae0[_0x98b5('0x46')][_0x98b5('0x47')]?_0x168ae0['attributes']:_0x56cc25['model'];_0x168ae0[_0x98b5('0x4a')]=qs[_0x98b5('0x4b')](_0x4d96ca[_0x98b5('0x42')][_0x98b5('0x4b')]);_0x168ae0[_0x98b5('0x4c')]=qs[_0x98b5('0x43')](_['pick'](_0x4d96ca[_0x98b5('0x42')],_0x56cc25['filters']));if(_0x4d96ca['query'][_0x98b5('0x4e')]){_0x168ae0[_0x98b5('0x4c')]=_[_0x98b5('0x38')](_0x168ae0['where'],{'$or':_[_0x98b5('0x40')](_0x168ae0[_0x98b5('0x46')],function(_0x56bcd4){var _0x44327b={};_0x44327b[_0x56bcd4]={'$like':'%'+_0x4d96ca[_0x98b5('0x42')][_0x98b5('0x4e')]+'%'};return _0x44327b;})});}_0x168ae0=_[_0x98b5('0x38')]({},_0x168ae0,_0x4d96ca[_0x98b5('0x50')]);return _0x293b66[_0x98b5('0x5a')](_0x168ae0);}})[_0x98b5('0x32')](function(_0x282bb7){if(_0x282bb7){_0x228d93=_0x282bb7[_0x98b5('0x47')];if(!_0x4d96ca[_0x98b5('0x42')][_0x98b5('0x49')](_0x98b5('0x5d'))){_0x168ae0[_0x98b5('0x2b')]=qs['limit'](_0x4d96ca['query'][_0x98b5('0x2b')]);_0x168ae0[_0x98b5('0x29')]=qs[_0x98b5('0x29')](_0x4d96ca[_0x98b5('0x42')][_0x98b5('0x29')]);}return _0x293b66[_0x98b5('0x5a')](_0x168ae0);}})['then'](function(_0x43956b){if(_0x43956b){return _0x43956b?{'count':_0x228d93,'rows':_0x43956b}:null;}})[_0x98b5('0x32')](respondWithResult(_0x4a2718,null))[_0x98b5('0x24')](handleError(_0x4a2718,null));};exports['getSubjects']=function(_0x4a79d4,_0xf8fad3,_0x2846f5){var _0x546d9e={};var _0x3d488d={};var _0x33682e;var _0x3733f3;return db[_0x98b5('0x3c')][_0x98b5('0x5b')]({'where':{'id':_0x4a79d4[_0x98b5('0x56')]['id']}})[_0x98b5('0x32')](handleEntityNotFound(_0xf8fad3,null))[_0x98b5('0x32')](function(_0x2041c6){if(_0x2041c6){_0x33682e=_0x2041c6;_0x3d488d[_0x98b5('0x48')]=_['keys'](db['ZohoField'][_0x98b5('0x3d')]);_0x3d488d['query']=_[_0x98b5('0x41')](_0x4a79d4[_0x98b5('0x42')]);_0x3d488d['filters']=_[_0x98b5('0x44')](_0x3d488d[_0x98b5('0x48')],_0x3d488d[_0x98b5('0x42')]);_0x546d9e[_0x98b5('0x46')]=_['intersection'](_0x3d488d['model'],qs[_0x98b5('0x45')](_0x4a79d4[_0x98b5('0x42')][_0x98b5('0x45')]));_0x546d9e[_0x98b5('0x46')]=_0x546d9e[_0x98b5('0x46')][_0x98b5('0x47')]?_0x546d9e[_0x98b5('0x46')]:_0x3d488d[_0x98b5('0x48')];_0x546d9e[_0x98b5('0x4a')]=qs[_0x98b5('0x4b')](_0x4a79d4[_0x98b5('0x42')][_0x98b5('0x4b')]);_0x546d9e[_0x98b5('0x4c')]=qs['filters'](_['pick'](_0x4a79d4['query'],_0x3d488d['filters']));if(_0x4a79d4[_0x98b5('0x42')]['filter']){_0x546d9e['where']=_[_0x98b5('0x38')](_0x546d9e[_0x98b5('0x4c')],{'$or':_['map'](_0x546d9e[_0x98b5('0x46')],function(_0x21d12f){var _0x1a2cf1={};_0x1a2cf1[_0x21d12f]={'$like':'%'+_0x4a79d4[_0x98b5('0x42')][_0x98b5('0x4e')]+'%'};return _0x1a2cf1;})});}_0x546d9e=_[_0x98b5('0x38')]({},_0x546d9e,_0x4a79d4['options']);return _0x33682e[_0x98b5('0x5e')](_0x546d9e);}})[_0x98b5('0x32')](function(_0x3c50a6){if(_0x3c50a6){_0x3733f3=_0x3c50a6[_0x98b5('0x47')];if(!_0x4a79d4[_0x98b5('0x42')][_0x98b5('0x49')](_0x98b5('0x5d'))){_0x546d9e[_0x98b5('0x2b')]=qs[_0x98b5('0x2b')](_0x4a79d4[_0x98b5('0x42')][_0x98b5('0x2b')]);_0x546d9e['offset']=qs['offset'](_0x4a79d4[_0x98b5('0x42')][_0x98b5('0x29')]);}return _0x33682e[_0x98b5('0x5e')](_0x546d9e);}})['then'](function(_0x3aa94b){if(_0x3aa94b){return _0x3aa94b?{'count':_0x3733f3,'rows':_0x3aa94b}:null;}})['then'](respondWithResult(_0xf8fad3,null))[_0x98b5('0x24')](handleError(_0xf8fad3,null));};exports[_0x98b5('0x5f')]=function(_0x30409f,_0x98726d,_0xad94b2){var _0x3db2ca={};var _0x183c8f={};var _0x551ab4;var _0x1f91b8;return db[_0x98b5('0x3c')]['findOne']({'where':{'id':_0x30409f[_0x98b5('0x56')]['id']}})[_0x98b5('0x32')](handleEntityNotFound(_0x98726d,null))['then'](function(_0x5d14c4){if(_0x5d14c4){_0x551ab4=_0x5d14c4;_0x183c8f[_0x98b5('0x48')]=_[_0x98b5('0x41')](db[_0x98b5('0x5c')]['rawAttributes']);_0x183c8f[_0x98b5('0x42')]=_['keys'](_0x30409f[_0x98b5('0x42')]);_0x183c8f[_0x98b5('0x43')]=_[_0x98b5('0x44')](_0x183c8f[_0x98b5('0x48')],_0x183c8f[_0x98b5('0x42')]);_0x3db2ca[_0x98b5('0x46')]=_[_0x98b5('0x44')](_0x183c8f[_0x98b5('0x48')],qs['fields'](_0x30409f[_0x98b5('0x42')][_0x98b5('0x45')]));_0x3db2ca['attributes']=_0x3db2ca[_0x98b5('0x46')][_0x98b5('0x47')]?_0x3db2ca[_0x98b5('0x46')]:_0x183c8f[_0x98b5('0x48')];_0x3db2ca[_0x98b5('0x4a')]=qs[_0x98b5('0x4b')](_0x30409f[_0x98b5('0x42')][_0x98b5('0x4b')]);_0x3db2ca[_0x98b5('0x4c')]=qs[_0x98b5('0x43')](_[_0x98b5('0x4d')](_0x30409f[_0x98b5('0x42')],_0x183c8f['filters']));if(_0x30409f[_0x98b5('0x42')][_0x98b5('0x4e')]){_0x3db2ca[_0x98b5('0x4c')]=_['merge'](_0x3db2ca[_0x98b5('0x4c')],{'$or':_[_0x98b5('0x40')](_0x3db2ca[_0x98b5('0x46')],function(_0x431390){var _0x447463={};_0x447463[_0x431390]={'$like':'%'+_0x30409f[_0x98b5('0x42')][_0x98b5('0x4e')]+'%'};return _0x447463;})});}_0x3db2ca=_[_0x98b5('0x38')]({},_0x3db2ca,_0x30409f[_0x98b5('0x50')]);return _0x551ab4[_0x98b5('0x5f')](_0x3db2ca);}})[_0x98b5('0x32')](function(_0x2dcff2){if(_0x2dcff2){_0x1f91b8=_0x2dcff2[_0x98b5('0x47')];if(!_0x30409f[_0x98b5('0x42')][_0x98b5('0x49')]('nolimit')){_0x3db2ca['limit']=qs[_0x98b5('0x2b')](_0x30409f[_0x98b5('0x42')][_0x98b5('0x2b')]);_0x3db2ca[_0x98b5('0x29')]=qs[_0x98b5('0x29')](_0x30409f[_0x98b5('0x42')][_0x98b5('0x29')]);}return _0x551ab4['getDescriptions'](_0x3db2ca);}})[_0x98b5('0x32')](function(_0x24efe4){if(_0x24efe4){return _0x24efe4?{'count':_0x1f91b8,'rows':_0x24efe4}:null;}})[_0x98b5('0x32')](respondWithResult(_0x98726d,null))[_0x98b5('0x24')](handleError(_0x98726d,null));};
\ No newline at end of file