Built motion from commit 0c27b27.|1.0.11
[motion.git] / server / api / sound / sound.controller.js
1 var _0xbbf2=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x6F\x75\x6E\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x70\x6C\x6F\x61\x64\x2D\x66\x69\x6C\x65","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x73\x6F\x78","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x66\x73","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x66\x69\x6C\x65\x2D\x62\x61\x73\x65\x36\x34","\x62\x6C\x75\x65\x62\x69\x72\x64","\x53\x65\x74\x74\x69\x6E\x67","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x53\x6F\x75\x6E\x64\x73","\x6A\x6F\x69\x6E","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x65\x78\x74\x6E\x61\x6D\x65","\x4D\x61\x78\x20\x6E\x75\x6D\x62\x65\x72\x20\x6F\x66\x20\x66\x69\x6C\x65\x73\x20\x75\x70\x6C\x6F\x61\x64\x20\x65\x78\x63\x65\x65\x64\x65\x64","\x4F\x6E\x6C\x79\x20\x77\x61\x76\x2C\x6D\x70\x33\x2C\x67\x73\x6D\x2C\x20\x61\x6E\x64\x20\x6F\x67\x67\x20\x66\x6F\x72\x6D\x61\x74\x20\x61\x63\x63\x65\x70\x74\x65\x64","\x54\x68\x65\x20\x6D\x61\x78\x69\x6D\x75\x6D\x20\x66\x69\x6C\x65\x20\x73\x69\x7A\x65\x20\x69\x73\x20\x31\x35\x20\x4D\x62","\x49\x6E\x76\x61\x6C\x69\x64\x20\x72\x65\x71\x75\x65\x73\x74","\x65\x6E\x64","\x66\x69\x6C\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x66\x6F\x72\x6D\x61\x74","\x73\x75\x62\x73\x74\x72\x69\x6E\x67","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x66\x6F\x72\x6D\x61\x74","\x77\x61\x76","\x6E\x61\x6D\x65","\x64\x69\x73\x70\x6C\x61\x79\x5F\x6E\x61\x6D\x65","\x62\x61\x73\x65\x6E\x61\x6D\x65","\x73\x61\x76\x65\x5F\x6E\x61\x6D\x65","\x73\x6F\x75\x6E\x64\x50\x61\x74\x68","\x2F\x76\x61\x72\x2F\x6F\x70\x74\x2F\x6D\x6F\x74\x69\x6F\x6E\x2F\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x73\x6F\x75\x6E\x64\x73\x2F\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x2E","\x30\x37\x37\x37","\x63\x68\x6D\x6F\x64\x53\x79\x6E\x63","\x69\x64\x65\x6E\x74\x69\x66\x79","\x74\x72\x61\x6E\x73\x63\x6F\x64\x65","\x65\x72\x72\x6F\x72","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x45\x72\x72\x6F\x72\x3A\x20","\x75\x6E\x6C\x69\x6E\x6B","\x6F\x6E","\x70\x72\x6F\x67\x72\x65\x73\x73","\x73\x72\x63","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x64\x75\x72\x61\x74\x69\x6F\x6E","\x64\x75\x72\x61\x74\x69\x6F\x6E","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x62\x69\x74\x52\x61\x74\x65","\x62\x69\x74\x52\x61\x74\x65","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x64\x65\x73\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x64\x75\x72\x61\x74\x69\x6F\x6E","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x62\x69\x74\x52\x61\x74\x65","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x63\x6F\x6D\x70\x6C\x65\x74\x65\x64","\x6C\x6F\x67","\x73\x74\x61\x72\x74","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x55\x70\x6C\x6F\x61\x64\x20\x65\x72\x72\x6F\x72\x20\x3A","\x70\x61\x72\x73\x65","\x75\x70\x64\x61\x74\x65","\x62\x6F\x64\x79","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x6F\x72\x69\x67\x69\x6E\x61\x6C","\x73\x74\x72\x65\x61\x6D","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x62\x61\x73\x65\x36\x34","\x62\x69\x6E\x61\x72\x79","\x72\x65\x61\x64\x46\x69\x6C\x65","\x70\x72\x6F\x6D\x69\x73\x69\x66\x79","\x53\x6F\x75\x6E\x64\x73","\x5F\x66\x6F\x72\x6D\x61\x74"];_0xbbf2[0];var _=require(_0xbbf2[1]);var Sound=require(_0xbbf2[3])[_0xbbf2[2]];var uploadFile=require(_0xbbf2[4]);var sr=require(_0xbbf2[5]);var sox=require(_0xbbf2[6]);var path=require(_0xbbf2[7]);var config=require(_0xbbf2[8]);var fs=require(_0xbbf2[9]);var sequelize=require(_0xbbf2[3])[_0xbbf2[10]];var base64=require(_0xbbf2[11]);var Promise=require(_0xbbf2[12]);var Setting=require(_0xbbf2[3])[_0xbbf2[13]];exports[_0xbbf2[14]]= function(_0xc092xd,_0xc092xe){return Sound[_0xbbf2[19]]()[_0xbbf2[18]](function(_0xc092x10){return _0xc092xe[_0xbbf2[17]](200)[_0xbbf2[16]](_0xc092x10)})[_0xbbf2[15]](function(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)})};exports[_0xbbf2[20]]= function(_0xc092xd,_0xc092xe){return Sound[_0xbbf2[24]](_0xc092xd[_0xbbf2[23]][_0xbbf2[22]])[_0xbbf2[18]](function(Sound){if(!Sound){return _0xc092xe[_0xbbf2[21]](404)};return _0xc092xe[_0xbbf2[16]](Sound)})[_0xbbf2[15]](function(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)})};exports[_0xbbf2[25]]= function(_0xc092xd,_0xc092xe){var _0xc092x11= new uploadFile({dest:path[_0xbbf2[27]](config[_0xbbf2[26]]),maxFileSize:15* 1000000,maxNumberOfFiles:10,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(wav|mp3|gsm|ogg)$/i,rename:function(_0xc092x12,_0xc092x13){return sr()+ path[_0xbbf2[29]](_0xc092x13[_0xbbf2[28]])},messages:{maxNumberOfFiles:_0xbbf2[30],acceptFileTypes:_0xbbf2[31],maxFileSize:_0xbbf2[32],invalidRequest:_0xbbf2[33]}});_0xc092x11[_0xbbf2[56]](_0xbbf2[34],function(_0xc092x14,_0xc092x15){if(!_0xc092x15[_0xbbf2[35]][_0xbbf2[28]]){return _0xc092xe[_0xbbf2[17]](500)[_0xbbf2[16]](_0xc092x11)};return Setting[_0xbbf2[24]](1)[_0xbbf2[18]](function(_0xc092x16){var _0xc092x17={};var _0xc092x18=path[_0xbbf2[29]](_0xc092x15[_0xbbf2[35]][_0xbbf2[28]]);_0xc092x17[_0xbbf2[36]]= _0xbbf2[37];_0xc092x17[_0xbbf2[38]]= path[_0xbbf2[29]](_0xc092x15[_0xbbf2[35]][_0xbbf2[28]])[_0xbbf2[39]](1);_0xc092x17[_0xbbf2[40]]= _0xbbf2[41];_0xc092x17[_0xbbf2[42]]= _0xc092x17[_0xbbf2[43]]= path[_0xbbf2[44]](_0xc092x15[_0xbbf2[35]][_0xbbf2[7]],_0xc092x18);_0xc092x17[_0xbbf2[45]]= path[_0xbbf2[44]](_0xc092x15[_0xbbf2[35]][_0xbbf2[28]],_0xc092x18);var _0xc092x19=path[_0xbbf2[27]](config[_0xbbf2[26]],_0xc092x17[_0xbbf2[45]]+ _0xc092x18);var _0xc092x1a=path[_0xbbf2[27]](_0xc092x16[_0xbbf2[46]]|| _0xbbf2[47],_0xc092x17[_0xbbf2[45]]+ _0xbbf2[48]+ _0xc092x17[_0xbbf2[40]]);fs[_0xbbf2[50]](_0xc092x19,parseInt(_0xbbf2[49],8));sox[_0xbbf2[51]](_0xc092x19,function(_0xc092xf,_0xc092x1b){});var _0xc092x1c=sox[_0xbbf2[52]](_0xc092x19,_0xc092x1a,{sampleRate:8000,format:_0xbbf2[41],channelCount:1,bitRate:192* 1024,compressionQuality:5});_0xc092x1c[_0xbbf2[56]](_0xbbf2[53],function(_0xc092xf){console[_0xbbf2[53]](_0xbbf2[54],_0xc092xf);fs[_0xbbf2[55]](_0xc092x19,function(_0xc092xf){if(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)}});return handleError(_0xc092xe,_0xc092xf)});_0xc092x1c[_0xbbf2[56]](_0xbbf2[57],function(_0xc092x1d,_0xc092x1e){});_0xc092x1c[_0xbbf2[56]](_0xbbf2[58],function(_0xc092x1f){_0xc092x17[_0xbbf2[59]]= isNaN(_0xc092x1f[_0xbbf2[60]])?null:_0xc092x1f[_0xbbf2[60]]* 1000;_0xc092x17[_0xbbf2[61]]= isNaN(_0xc092x1f[_0xbbf2[62]])?null:_0xc092x1f[_0xbbf2[62]];_0xc092x17[_0xbbf2[63]]= isNaN(_0xc092x1f[_0xbbf2[64]])?null:_0xc092x1f[_0xbbf2[64]];_0xc092x17[_0xbbf2[65]]= isNaN(_0xc092x1f[_0xbbf2[66]])?null:_0xc092x1f[_0xbbf2[66]];_0xc092x17[_0xbbf2[67]]= isNaN(_0xc092x1f[_0xbbf2[68]])?null:_0xc092x1f[_0xbbf2[68]]});_0xc092x1c[_0xbbf2[56]](_0xbbf2[69],function(_0xc092x1f){_0xc092x17[_0xbbf2[70]]= isNaN(_0xc092x1f[_0xbbf2[60]])?null:_0xc092x1f[_0xbbf2[60]]* 1000;_0xc092x17[_0xbbf2[71]]= isNaN(_0xc092x1f[_0xbbf2[62]])?null:_0xc092x1f[_0xbbf2[62]];_0xc092x17[_0xbbf2[72]]= isNaN(_0xc092x1f[_0xbbf2[64]])?null:_0xc092x1f[_0xbbf2[64]];_0xc092x17[_0xbbf2[73]]= isNaN(_0xc092x1f[_0xbbf2[66]])?null:_0xc092x1f[_0xbbf2[66]];_0xc092x17[_0xbbf2[74]]= isNaN(_0xc092x1f[_0xbbf2[68]])?null:_0xc092x1f[_0xbbf2[68]]});_0xc092x1c[_0xbbf2[56]](_0xbbf2[34],function(){console[_0xbbf2[76]](_0xbbf2[75]);fs[_0xbbf2[50]](_0xc092x1a,parseInt(_0xbbf2[49],8));return Sound[_0xbbf2[25]](_0xc092x17)[_0xbbf2[18]](function(_0xc092x20){return _0xc092xe[_0xbbf2[17]](201)[_0xbbf2[16]](_0xc092x20)})[_0xbbf2[15]](function(_0xc092xf){console[_0xbbf2[76]](_0xc092xf);return handleError(_0xc092xe,_0xc092xf)})});_0xc092x1c[_0xbbf2[77]]()})[_0xbbf2[15]](function(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)})});_0xc092x11[_0xbbf2[56]](_0xbbf2[53],function(_0xc092xf){console[_0xbbf2[76]](_0xbbf2[78],_0xc092xf);return handleError(_0xc092xe,_0xc092xf)});_0xc092x11[_0xbbf2[79]](_0xc092xd)};exports[_0xbbf2[80]]= function(_0xc092xd,_0xc092xe){if(_0xc092xd[_0xbbf2[81]][_0xbbf2[22]]){delete _0xc092xd[_0xbbf2[81]][_0xbbf2[22]]};return Sound[_0xbbf2[24]](_0xc092xd[_0xbbf2[23]][_0xbbf2[22]])[_0xbbf2[18]](function(_0xc092x20){if(!_0xc092x20){return _0xc092xe[_0xbbf2[21]](404)};var _0xc092x21=_[_0xbbf2[82]](_0xc092x20,_0xc092xd[_0xbbf2[81]]);return _0xc092x21[_0xbbf2[83]]()})[_0xbbf2[18]](function(_0xc092x20){return _0xc092xe[_0xbbf2[17]](200)[_0xbbf2[16]](_0xc092x20)})[_0xbbf2[15]](function(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)})};exports[_0xbbf2[84]]= function(_0xc092xd,_0xc092xe){var _0xc092x22;return Setting[_0xbbf2[24]](1)[_0xbbf2[18]](function(_0xc092x16){_0xc092x22= _0xc092x16;return Sound[_0xbbf2[24]](_0xc092xd[_0xbbf2[23]][_0xbbf2[22]])})[_0xbbf2[18]](function(_0xc092x20){if(!_0xc092x20){return _0xc092xe[_0xbbf2[21]](404)};var _0xc092x23=path[_0xbbf2[27]](config[_0xbbf2[26]],_0xc092x20[_0xbbf2[45]]+ _0xbbf2[48]+ _0xc092x20[_0xbbf2[38]]);var _0xc092x24=path[_0xbbf2[27]](_0xc092x22[_0xbbf2[46]]|| _0xbbf2[47],_0xc092x20[_0xbbf2[45]]+ _0xbbf2[48]+ _0xc092x20[_0xbbf2[40]]);return sequelize[_0xbbf2[85]](function(_0xc092x25){return _0xc092x20[_0xbbf2[84]]({transaction:_0xc092x25})[_0xbbf2[18]](function(){fs[_0xbbf2[55]](_0xc092x23,function(_0xc092xf){if(_0xc092xf){console[_0xbbf2[76]](_0xc092xf)}});fs[_0xbbf2[55]](_0xc092x24,function(_0xc092xf){if(_0xc092xf){console[_0xbbf2[76]](_0xc092xf)}});return _0xc092xe[_0xbbf2[17]](200)[_0xbbf2[16]](_0xc092x20)})})[_0xbbf2[15]](function(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)})})[_0xbbf2[15]](function(_0xc092xf){return handleError(_0xc092xe,_0xc092xf)})};exports[_0xbbf2[86]]= function(_0xc092xd,_0xc092xe){getStream(_0xc092xd,_0xc092xe,_0xbbf2[87])};exports[_0xbbf2[88]]= function(_0xc092xd,_0xc092xe){getStream(_0xc092xd,_0xc092xe,_0xbbf2[89])};function getStream(_0xc092xd,_0xc092xe,_0xc092x27){return Sound[_0xbbf2[24]](_0xc092xd[_0xbbf2[23]][_0xbbf2[22]])[_0xbbf2[18]](function(_0xc092x20){var _0xc092x29=Promise[_0xbbf2[93]](fs[_0xbbf2[92]]);return _0xc092x29(path[_0xbbf2[27]](config[_0xc092x27+ _0xbbf2[94]],_0xc092x20[_0xbbf2[45]]+ _0xbbf2[48]+ _0xc092x20[_0xc092x27+ _0xbbf2[95]]))})[_0xbbf2[18]](function(_0xc092x1b){var _0xc092x28= new Buffer(_0xc092x1b,_0xbbf2[91]).toString(_0xbbf2[90]);return _0xc092x28})[_0xbbf2[18]](function(_0xc092x28){return _0xc092xe[_0xbbf2[17]](200)[_0xbbf2[16]]({downloadString:_0xc092x28})})[_0xbbf2[15]](function(_0xc092xf){console[_0xbbf2[76]](_0xc092xf);return handleError(_0xc092xe,_0xc092xf)})}function handleError(_0xc092xe,_0xc092xf){return _0xc092xe[_0xbbf2[17]](500)[_0xbbf2[16]](_0xc092xf)}