bcf859a81df7aa10547ced78daf9cbe28d61255a
[motion.git] / server / config / integrations / index.js
1 var _0xe740=["\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"];_0xe740[0];var _=require(_0xe740[1]);var IntegrationModel=require(_0xe740[3])[_0xe740[2]];var Variable=require(_0xe740[3])[_0xe740[4]];var Zendesk=require(_0xe740[5]);var Salesforce=require(_0xe740[6]);var Motionbar=require(_0xe740[7]);var MAX_CALLS=200;function Integration(_0x8c92x9){console[_0xe740[9]](_0xe740[8]);var _0x8c92xa= new Zendesk();var _0x8c92xb= new Salesforce();var _0x8c92xc= new Motionbar();var _0x8c92xd=[];var _0x8c92xe=[];var _0x8c92xf=[];_0x8c92x9[_0xe740[24]](_0xe740[10],function(_0x8c92x10){if(_0x8c92x10[_0xe740[12]](_0xe740[11])&&_0x8c92x10[_0xe740[12]](_0xe740[13])){var _0x8c92x11=_[_0xe740[18]](_0x8c92xe,function(_0x8c92x12){return (_0x8c92x12[_0xe740[14]]===_[_0xe740[16]](_[_0xe740[15]](_0x8c92x10[_0xe740[11]])))||(_[_0xe740[17]](_0x8c92x12[_0xe740[14]])===_[_0xe740[16]](_[_0xe740[15]](_0x8c92x10[_0xe740[11]])))});if(_0x8c92x11){var _0x8c92x13=_[_0xe740[18]](_0x8c92xf,function(_0x8c92x12){return _0x8c92x12[_0xe740[19]]===_0x8c92x10[_0xe740[19]]});if(_0x8c92x13){_0x8c92x13[_0xe740[21]][_0xe740[20]]({name:_0x8c92x11[_0xe740[14]],value:_0x8c92x10[_0xe740[13]]})}else {if(_0x8c92xf[_0xe740[22]]>=MAX_CALLS){_0x8c92xf[_0xe740[23]]()};var _0x8c92x14={uniqueid:_0x8c92x10[_0xe740[19]],variables:[{name:_0x8c92x11[_0xe740[14]],value:_0x8c92x10[_0xe740[13]]}]};_0x8c92xf[_0xe740[20]](_0x8c92x14)}}}});Variable[_0xe740[26]]()[_0xe740[25]](function(_0x8c92x15){_0x8c92xe=_0x8c92x15;synchVariables(_0x8c92xe)});IntegrationModel[_0xe740[26]]({where:{active:1}})[_0xe740[25]](function(_0x8c92x16){_0x8c92xd=_0x8c92x16;synchIntegrations(_0x8c92xd)});this[_0xe740[27]]=function(_0x8c92x17,_0x8c92x18,_0x8c92x19){var _0x8c92x13=_[_0xe740[18]](_0x8c92xf,function(_0x8c92x12){return _0x8c92x12[_0xe740[19]]===_0x8c92x18[_0xe740[19]]});var _0x8c92x15=_0x8c92x13?_0x8c92x13[_0xe740[21]]:[];if(integrationIsActive(_0x8c92x17[_0xe740[28]],_0x8c92xd)){switch(_0x8c92x17[_0xe740[28]]){case _0xe740[32]:_0x8c92xa[_0xe740[31]](_0x8c92x17[_0xe740[29]],_0x8c92x17[_0xe740[30]],_0x8c92x19,_0x8c92x18,_0x8c92x15,_0x8c92x18[_0xe740[19]]);break;case _0xe740[33]:_0x8c92xb[_0xe740[31]](_0x8c92x17[_0xe740[29]],_0x8c92x17[_0xe740[30]],_0x8c92x19,_0x8c92x18,_0x8c92x15,_0x8c92x18[_0xe740[19]]);break;default:console[_0xe740[9]](_0xe740[34],_0x8c92x17[_0xe740[28]])}};if(_0x8c92x17[_0xe740[35]]===_0xe740[36]){_0x8c92xc[_0xe740[31]](_0x8c92x17,_0x8c92x19,_0x8c92x18,_0x8c92x15,_0x8c92x18[_0xe740[19]])}}}function integrationIsActive(_0x8c92x1b,_0x8c92x1c){var _0x8c92x1d=_[_0xe740[38]](_0x8c92x1c,_0xe740[37]);if(_[_0xe740[39]](_0x8c92x1d,_0x8c92x1b)>=0){return true};return false}function synchIntegrations(_0x8c92x1c){IntegrationModel[_0xe740[44]](function(_0x8c92x18){if(_0x8c92x18[_0xe740[40]]){updateCollection(_0x8c92x1c,_0x8c92x18)}else {_[_0xe740[42]](_0x8c92x1c,{id:_0x8c92x18[_0xe740[41]]})};console[_0xe740[9]](_0xe740[43],_0x8c92x1c[_0xe740[22]])})}function synchVariables(_0x8c92x1c){Variable[_0xe740[46]](function(_0x8c92x18){updateCollection(_0x8c92x1c,_0x8c92x18);console[_0xe740[9]](_0xe740[45],_0x8c92x1c[_0xe740[22]])});Variable[_0xe740[44]](function(_0x8c92x18){updateCollection(_0x8c92x1c,_0x8c92x18);console[_0xe740[9]](_0xe740[47],_0x8c92x1c[_0xe740[22]])});Variable[_0xe740[49]](function(_0x8c92x18){_[_0xe740[42]](_0x8c92x1c,{id:_0x8c92x18[_0xe740[41]]});console[_0xe740[9]](_0xe740[48],_0x8c92x1c[_0xe740[22]])})}function updateCollection(_0x8c92x21,_0x8c92x18){var _0x8c92x22=_[_0xe740[18]](_0x8c92x21,{id:_0x8c92x18[_0xe740[41]]});var _0x8c92x23=_0x8c92x21[_0xe740[39]](_0x8c92x22);if(_0x8c92x22){_[_0xe740[50]](_0x8c92x21[_0x8c92x23],_0x8c92x18)}else {_0x8c92x21[_0xe740[51]](_0x8c92x18)}}module[_0xe740[52]]=Integration