e7c5538aa3ad130c7e41c2dc15528c3b0cb0721f
[motion.git] / server / config / integrations / index.js
1 var _0x91cb=["\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"];_0x91cb[0];var _=require(_0x91cb[1]);var IntegrationModel=require(_0x91cb[3])[_0x91cb[2]];var Variable=require(_0x91cb[3])[_0x91cb[4]];var Zendesk=require(_0x91cb[5]);var Salesforce=require(_0x91cb[6]);var Motionbar=require(_0x91cb[7]);var MAX_CALLS=200;function Integration(_0xc0fcx9){console[_0x91cb[9]](_0x91cb[8]);var _0xc0fcxa= new Zendesk();var _0xc0fcxb= new Salesforce();var _0xc0fcxc= new Motionbar();var _0xc0fcxd=[];var _0xc0fcxe=[];var _0xc0fcxf=[];_0xc0fcx9[_0x91cb[24]](_0x91cb[10],function(_0xc0fcx10){if(_0xc0fcx10[_0x91cb[12]](_0x91cb[11])&& _0xc0fcx10[_0x91cb[12]](_0x91cb[13])){var _0xc0fcx11=_[_0x91cb[18]](_0xc0fcxe,function(_0xc0fcx12){return (_0xc0fcx12[_0x91cb[14]]=== _[_0x91cb[16]](_[_0x91cb[15]](_0xc0fcx10[_0x91cb[11]])))|| (_[_0x91cb[17]](_0xc0fcx12[_0x91cb[14]])=== _[_0x91cb[16]](_[_0x91cb[15]](_0xc0fcx10[_0x91cb[11]])))});if(_0xc0fcx11){var _0xc0fcx13=_[_0x91cb[18]](_0xc0fcxf,function(_0xc0fcx12){return _0xc0fcx12[_0x91cb[19]]=== _0xc0fcx10[_0x91cb[19]]});if(_0xc0fcx13){_0xc0fcx13[_0x91cb[21]][_0x91cb[20]]({name:_0xc0fcx11[_0x91cb[14]],value:_0xc0fcx10[_0x91cb[13]]})}else {if(_0xc0fcxf[_0x91cb[22]]>= MAX_CALLS){_0xc0fcxf[_0x91cb[23]]()};var _0xc0fcx14={uniqueid:_0xc0fcx10[_0x91cb[19]],variables:[{name:_0xc0fcx11[_0x91cb[14]],value:_0xc0fcx10[_0x91cb[13]]}]};_0xc0fcxf[_0x91cb[20]](_0xc0fcx14)}}}});Variable[_0x91cb[26]]()[_0x91cb[25]](function(_0xc0fcx15){_0xc0fcxe= _0xc0fcx15;synchVariables(_0xc0fcxe)});IntegrationModel[_0x91cb[26]]({where:{active:1}})[_0x91cb[25]](function(_0xc0fcx16){_0xc0fcxd= _0xc0fcx16;synchIntegrations(_0xc0fcxd)});this[_0x91cb[27]]= function(_0xc0fcx17,_0xc0fcx18,_0xc0fcx19,_0xc0fcx1a){var _0xc0fcx13=_[_0x91cb[18]](_0xc0fcxf,function(_0xc0fcx12){return _0xc0fcx12[_0x91cb[19]]=== _0xc0fcx18[_0x91cb[19]]});var _0xc0fcx15=_0xc0fcx13?_0xc0fcx13[_0x91cb[21]]:[];if(integrationIsActive(_0xc0fcx17[_0x91cb[28]],_0xc0fcxd)){switch(_0xc0fcx17[_0x91cb[28]]){case _0x91cb[32]:_0xc0fcxa[_0x91cb[31]](_0xc0fcx17[_0x91cb[29]],_0xc0fcx17[_0x91cb[30]],_0xc0fcx19,_0xc0fcx1a,_0xc0fcx18,_0xc0fcx15);break;case _0x91cb[33]:_0xc0fcxb[_0x91cb[31]](_0xc0fcx17[_0x91cb[29]],_0xc0fcx17[_0x91cb[30]],_0xc0fcx19,_0xc0fcx1a,_0xc0fcx18,_0xc0fcx15);break;default:console[_0x91cb[9]](_0x91cb[34],_0xc0fcx17[_0x91cb[28]])}};if(_0xc0fcx17[_0x91cb[35]]=== _0x91cb[36]){_0xc0fcxc[_0x91cb[31]](_0xc0fcx17,_0xc0fcx19,_0xc0fcx18,_0xc0fcx15)}}}function integrationIsActive(_0xc0fcx1c,_0xc0fcx1d){var _0xc0fcx1e=_[_0x91cb[38]](_0xc0fcx1d,_0x91cb[37]);if(_[_0x91cb[39]](_0xc0fcx1e,_0xc0fcx1c)>= 0){return true};return false}function synchIntegrations(_0xc0fcx1d){IntegrationModel[_0x91cb[44]](function(_0xc0fcx18){if(_0xc0fcx18[_0x91cb[40]]){updateCollection(_0xc0fcx1d,_0xc0fcx18)}else {_[_0x91cb[42]](_0xc0fcx1d,{id:_0xc0fcx18[_0x91cb[41]]})};console[_0x91cb[9]](_0x91cb[43],_0xc0fcx1d[_0x91cb[22]])})}function synchVariables(_0xc0fcx1d){Variable[_0x91cb[46]](function(_0xc0fcx18){updateCollection(_0xc0fcx1d,_0xc0fcx18);console[_0x91cb[9]](_0x91cb[45],_0xc0fcx1d[_0x91cb[22]])});Variable[_0x91cb[44]](function(_0xc0fcx18){updateCollection(_0xc0fcx1d,_0xc0fcx18);console[_0x91cb[9]](_0x91cb[47],_0xc0fcx1d[_0x91cb[22]])});Variable[_0x91cb[49]](function(_0xc0fcx18){_[_0x91cb[42]](_0xc0fcx1d,{id:_0xc0fcx18[_0x91cb[41]]});console[_0x91cb[9]](_0x91cb[48],_0xc0fcx1d[_0x91cb[22]])})}function updateCollection(_0xc0fcx22,_0xc0fcx18){var _0xc0fcx23=_[_0x91cb[18]](_0xc0fcx22,{id:_0xc0fcx18[_0x91cb[41]]});var _0xc0fcx24=_0xc0fcx22[_0x91cb[39]](_0xc0fcx23);if(_0xc0fcx23){_[_0x91cb[50]](_0xc0fcx22[_0xc0fcx24],_0xc0fcx18)}else {_0xc0fcx22[_0x91cb[51]](_0xc0fcx18)}}module[_0x91cb[52]]= Integration