46d1bc75d9efdc5ad71b3096be878cb3e79c4393
[motion.git] / server / config / integrations / index.js
1 var _0x6f31=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x61\x72\x69\x61\x62\x6C\x65","\x2E\x2F\x7A\x65\x6E\x64\x65\x73\x6B","\x2E\x2F\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65","\x2E\x2F\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x54\x72\x69\x67\x67\x65\x72\x20\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x20\x49\x6E\x69\x74\x69\x61\x6C\x69\x7A\x61\x74\x69\x6F\x6E\x2E\x2E\x2E","\x6C\x6F\x67","\x76\x61\x72\x73\x65\x74","\x76\x61\x72\x69\x61\x62\x6C\x65","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x76\x61\x6C\x75\x65","\x6E\x61\x6D\x65","\x6B\x65\x79\x73","\x68\x65\x61\x64","\x74\x6F\x4C\x6F\x77\x65\x72","\x66\x69\x6E\x64","\x75\x6E\x69\x71\x75\x65\x69\x64","\x70\x75\x73\x68","\x76\x61\x72\x69\x61\x62\x6C\x65\x73","\x6C\x65\x6E\x67\x74\x68","\x73\x68\x69\x66\x74","\x6F\x6E","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x6D\x61\x6E\x61\x67\x65\x45\x76\x65\x6E\x74","\x64\x61\x74\x61\x31","\x64\x61\x74\x61\x32","\x64\x61\x74\x61\x33","\x68\x61\x6E\x64\x6C\x65\x45\x76\x65\x6E\x74","\x7A\x65\x6E\x64\x65\x73\x6B","\x73\x61\x6C\x65\x73\x66\x6F\x72\x63\x65","\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x20\x6E\x6F\x74\x20\x72\x65\x63\x6F\x67\x6E\x69\x7A\x65\x64\x3A\x20","\x61\x63\x74\x69\x6F\x6E","\x6D\x6F\x74\x69\x6F\x6E\x62\x61\x72","\x73\x74\x61\x74\x65","\x6D\x61\x70","\x69\x6E\x64\x65\x78\x4F\x66","\x61\x63\x74\x69\x76\x65","\x69\x64","\x72\x65\x6D\x6F\x76\x65","\x41\x66\x74\x65\x72\x20\x75\x70\x64\x61\x74\x65\x2C\x20\x69\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E\x73\x20\x61\x72\x65\x20","\x61\x66\x74\x65\x72\x55\x70\x64\x61\x74\x65","\x41\x66\x74\x65\x72\x20\x63\x72\x65\x61\x74\x65\x2C\x20\x56\x61\x72\x69\x61\x62\x6C\x65\x73\x20\x61\x72\x65\x20","\x61\x66\x74\x65\x72\x43\x72\x65\x61\x74\x65","\x41\x66\x74\x65\x72\x20\x75\x70\x64\x61\x74\x65\x2C\x20\x56\x61\x72\x69\x61\x62\x6C\x65\x73\x20\x61\x72\x65\x20","\x41\x66\x74\x65\x72\x20\x64\x65\x73\x74\x72\x6F\x79\x2C\x20\x56\x61\x72\x69\x61\x62\x6C\x65\x73\x20\x61\x72\x65\x20","\x61\x66\x74\x65\x72\x44\x65\x73\x74\x72\x6F\x79","\x6D\x65\x72\x67\x65","\x75\x6E\x73\x68\x69\x66\x74","\x65\x78\x70\x6F\x72\x74\x73"];_0x6f31[0];var _=require(_0x6f31[1]);var IntegrationModel=require(_0x6f31[3])[_0x6f31[2]];var Variable=require(_0x6f31[3])[_0x6f31[4]];var Zendesk=require(_0x6f31[5]);var Salesforce=require(_0x6f31[6]);var Motionbar=require(_0x6f31[7]);var MAX_CALLS=200;function Integration(_0x4cffx9){console[_0x6f31[9]](_0x6f31[8]);var _0x4cffxa= new Zendesk();var _0x4cffxb= new Salesforce();var _0x4cffxc= new Motionbar();var _0x4cffxd=[];var _0x4cffxe=[];var _0x4cffxf=[];_0x4cffx9[_0x6f31[24]](_0x6f31[10],function(_0x4cffx10){if(_0x4cffx10[_0x6f31[12]](_0x6f31[11])&& _0x4cffx10[_0x6f31[12]](_0x6f31[13])){var _0x4cffx11=_[_0x6f31[18]](_0x4cffxe,function(_0x4cffx12){return (_0x4cffx12[_0x6f31[14]]=== _[_0x6f31[16]](_[_0x6f31[15]](_0x4cffx10[_0x6f31[11]])))|| (_[_0x6f31[17]](_0x4cffx12[_0x6f31[14]])=== _[_0x6f31[16]](_[_0x6f31[15]](_0x4cffx10[_0x6f31[11]])))});if(_0x4cffx11){var _0x4cffx13=_[_0x6f31[18]](_0x4cffxf,function(_0x4cffx12){return _0x4cffx12[_0x6f31[19]]=== _0x4cffx10[_0x6f31[19]]});if(_0x4cffx13){_0x4cffx13[_0x6f31[21]][_0x6f31[20]]({name:_0x4cffx11[_0x6f31[14]],value:_0x4cffx10[_0x6f31[13]]})}else {if(_0x4cffxf[_0x6f31[22]]>= MAX_CALLS){_0x4cffxf[_0x6f31[23]]()};var _0x4cffx14={uniqueid:_0x4cffx10[_0x6f31[19]],variables:[{name:_0x4cffx11[_0x6f31[14]],value:_0x4cffx10[_0x6f31[13]]}]};_0x4cffxf[_0x6f31[20]](_0x4cffx14)}}}});Variable[_0x6f31[26]]()[_0x6f31[25]](function(_0x4cffx15){_0x4cffxe= _0x4cffx15;synchVariables(_0x4cffxe)});IntegrationModel[_0x6f31[26]]({where:{active:1}})[_0x6f31[25]](function(_0x4cffx16){_0x4cffxd= _0x4cffx16;synchIntegrations(_0x4cffxd)});this[_0x6f31[27]]= function(_0x4cffx17,_0x4cffx18,_0x4cffx19,_0x4cffx1a){var _0x4cffx13=_[_0x6f31[18]](_0x4cffxf,function(_0x4cffx12){return _0x4cffx12[_0x6f31[19]]=== _0x4cffx18[_0x6f31[19]]});var _0x4cffx15=_0x4cffx13?_0x4cffx13[_0x6f31[21]]:[];if(integrationIsActive(_0x4cffx17[_0x6f31[28]],_0x4cffxd)){switch(_0x4cffx17[_0x6f31[28]]){case _0x6f31[32]:_0x4cffxa[_0x6f31[31]](_0x4cffx17[_0x6f31[29]],_0x4cffx17[_0x6f31[30]],_0x4cffx19,_0x4cffx1a,_0x4cffx18,_0x4cffx15);break;case _0x6f31[33]:_0x4cffxb[_0x6f31[31]](_0x4cffx17[_0x6f31[29]],_0x4cffx17[_0x6f31[30]],_0x4cffx19,_0x4cffx1a,_0x4cffx18,_0x4cffx15);break;default:console[_0x6f31[9]](_0x6f31[34],_0x4cffx17[_0x6f31[28]])}};if(_0x4cffx17[_0x6f31[35]]=== _0x6f31[36]){_0x4cffxc[_0x6f31[31]](_0x4cffx17,_0x4cffx19,_0x4cffx18,_0x4cffx15)}}}function integrationIsActive(_0x4cffx1c,_0x4cffx1d){var _0x4cffx1e=_[_0x6f31[38]](_0x4cffx1d,_0x6f31[37]);if(_[_0x6f31[39]](_0x4cffx1e,_0x4cffx1c)>= 0){return true};return false}function synchIntegrations(_0x4cffx1d){IntegrationModel[_0x6f31[44]](function(_0x4cffx18){if(_0x4cffx18[_0x6f31[40]]){updateCollection(_0x4cffx1d,_0x4cffx18)}else {_[_0x6f31[42]](_0x4cffx1d,{id:_0x4cffx18[_0x6f31[41]]})};console[_0x6f31[9]](_0x6f31[43],_0x4cffx1d[_0x6f31[22]])})}function synchVariables(_0x4cffx1d){Variable[_0x6f31[46]](function(_0x4cffx18){updateCollection(_0x4cffx1d,_0x4cffx18);console[_0x6f31[9]](_0x6f31[45],_0x4cffx1d[_0x6f31[22]])});Variable[_0x6f31[44]](function(_0x4cffx18){updateCollection(_0x4cffx1d,_0x4cffx18);console[_0x6f31[9]](_0x6f31[47],_0x4cffx1d[_0x6f31[22]])});Variable[_0x6f31[49]](function(_0x4cffx18){_[_0x6f31[42]](_0x4cffx1d,{id:_0x4cffx18[_0x6f31[41]]});console[_0x6f31[9]](_0x6f31[48],_0x4cffx1d[_0x6f31[22]])})}function updateCollection(_0x4cffx22,_0x4cffx18){var _0x4cffx23=_[_0x6f31[18]](_0x4cffx22,{id:_0x4cffx18[_0x6f31[41]]});var _0x4cffx24=_0x4cffx22[_0x6f31[39]](_0x4cffx23);if(_0x4cffx23){_[_0x6f31[50]](_0x4cffx22[_0x4cffx24],_0x4cffx18)}else {_0x4cffx22[_0x6f31[51]](_0x4cffx18)}}module[_0x6f31[52]]= Integration