Built motion from commit 48095ee.|0.0.102
[motion.git] / server / api / chat_room / chat_room.controller.js
1 var _0x938f=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x64\x35","\x6D\x6F\x6D\x65\x6E\x74","\x74\x6F\x2D\x63\x73\x76","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x69\x6E\x64\x65\x78","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x69\x64","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x72\x6F\x6C\x65","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x6D\x65\x72\x67\x65","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x74\x61\x67\x73","\x24\x61\x6E\x64","\x69\x73\x41\x72\x72\x61\x79","\x6C\x65\x6E\x67\x74\x68","\x25","\x3B\x25","\x70\x75\x73\x68","\x67\x65\x74\x41\x67\x65\x6E\x74\x73","\x75\x73\x65\x72","\x67\x65\x74\x41\x67\x65\x6E\x74\x73\x49\x64\x42\x79\x55\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x61\x6C\x6C","\x73\x63\x6F\x70\x65","\x67\x65\x74\x47\x72\x6F\x75\x70\x73","\x67\x72\x6F\x75\x70","\x61\x67\x65\x6E\x74","\x6D\x61\x70","\x75\x73\x65\x72\x70\x69\x63","\x66\x69\x6E\x64\x41\x6C\x6C","\x67\x65\x74\x45\x78\x74\x65\x72\x6E\x61\x6C\x73","\x65\x78\x74\x65\x72\x6E\x61\x6C","\x69\x6E\x63\x6C\x75\x64\x65","\x67\x65\x74\x41\x67\x65\x6E\x74","\x70\x61\x72\x61\x6D\x73","\x67\x65\x74\x4F\x6E\x6C\x69\x6E\x65\x52\x6F\x6F\x6D","\x6F\x6E\x6C\x69\x6E\x65","\x6D\x65","\x65\x72\x72\x6F\x72","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x67\x65\x74\x43\x68\x61\x74\x52\x6F\x6F\x6D\x73","\x73\x68\x6F\x77","\x61\x64\x64\x72\x65\x73\x73","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x55\x73\x65\x72\x73","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x67\x65\x74\x55\x73\x65\x72\x73","\x75\x73\x65\x72\x73","\x73\x65\x74\x55\x73\x65\x72\x73","\x73\x70\x72\x65\x61\x64","\x62\x61\x73\x65\x36\x34","\x73\x6F\x72\x74","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x4F\x50\x45\x4E","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x63\x72\x65\x61\x74\x65\x4D\x65\x73\x73\x61\x67\x65","\x62\x6F\x64\x79","\x74\x79\x70\x65","\x63\x72\x65\x61\x74\x65","\x65\x78\x70\x6F\x72\x74","\x20","\x72\x65\x70\x6C\x61\x63\x65","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x66\x6F\x72\x45\x61\x63\x68","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x74\x65\x78\x74\x2F\x63\x73\x76","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x54\x79\x70\x65","\x67\x65\x74\x52\x6F\x6F\x6D\x47\x72\x6F\x75\x70\x73","\x75\x70\x64\x61\x74\x65","\x75\x70\x64\x61\x74\x65\x55\x73\x65\x72\x73","\x64\x65\x73\x74\x72\x6F\x79"];_0x938f[0];var _=require(_0x938f[1]);var md5=require(_0x938f[2]);var moment=require(_0x938f[3]);var csv=require(_0x938f[4]);var Util=require(_0x938f[5]);var User=require(_0x938f[7])[_0x938f[6]];var Agent=require(_0x938f[7])[_0x938f[6]];var ChatRoom=require(_0x938f[7])[_0x938f[8]];var ChatMessage=require(_0x938f[7])[_0x938f[9]];var ChatWebsite=require(_0x938f[7])[_0x938f[10]];var ChatVisitor=require(_0x938f[7])[_0x938f[11]];var UserHasChatRoom=require(_0x938f[7])[_0x938f[12]];exports[_0x938f[13]]=function(_0x8782xd,_0x8782xe,_0x8782xf){return ChatRoom[_0x938f[28]](_[_0x938f[27]](Util[_0x938f[20]](_0x8782xd[_0x938f[19]]),{include:[{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[24],_0x938f[25],_0x938f[26]]},{model:ChatMessage},{model:ChatVisitor}]}))[_0x938f[18]](function(_0x8782x11){_0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x11)})[_0x938f[15]](function(_0x8782x10){console[_0x938f[14]](_0x8782x10);return handleError(_0x8782xe,_0x8782x10)})};function checkTags(_0x8782x13){if(_0x8782x13){if(_0x8782x13[_0x938f[29]]){_0x8782x13[_0x938f[30]]=[];if(_[_0x938f[31]](_0x8782x13[_0x938f[29]])){for(var _0x8782x14=0;_0x8782x14<_0x8782x13[_0x938f[29]][_0x938f[32]];_0x8782x14++){_0x8782x13[_0x938f[30]][_0x938f[35]]({tags:{$like:_0x938f[33]+_0x8782x13[_0x938f[29]][_0x8782x14]+_0x938f[34]}})}}else {_0x8782x13[_0x938f[30]][_0x938f[35]]({tags:{$like:_0x938f[33]+_0x8782x13[_0x938f[29]]+_0x938f[34]}})};delete _0x8782x13[_0x938f[29]]}}}exports[_0x938f[36]]=function(_0x8782xd,_0x8782xe,_0x8782xf){switch(_0x8782xd[_0x938f[37]][_0x938f[25]]){case _0x938f[37]:return User[_0x938f[39]](_0x8782xd[_0x938f[37]][_0x938f[21]],{attributes:[_0x938f[21]],where:{id:{$ne:_0x8782xd[_0x938f[37]][_0x938f[21]]},online:true}})[_0x938f[18]](Util[_0x938f[38]](_[_0x938f[27]](_0x8782xd[_0x938f[19]],{id:{$ne:_0x8782xd[_0x938f[37]][_0x938f[21]]}})))[_0x938f[18]](function(_0x8782x11){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x11)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)});default:return User[_0x938f[41]](_0x938f[40])[_0x938f[28]](_[_0x938f[27]](Util[_0x938f[20]](_0x8782xd[_0x938f[19]]),{where:{id:{$ne:_0x8782xd[_0x938f[37]][_0x938f[21]]},online:true}}))[_0x938f[18]](function(_0x8782x11){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x11)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})}};exports[_0x938f[42]]=function(_0x8782xd,_0x8782xe,_0x8782xf){checkTags(_0x8782xd[_0x938f[19]]);var _0x8782x15={where:_[_0x938f[27]]({type:_0x938f[43]},_0x8782xd[_0x938f[19]])};switch(_0x8782xd[_0x938f[37]][_0x938f[25]]){case _0x938f[44]:_[_0x938f[27]](_0x8782x15,{include:[{model:User,attributes:[_0x938f[21]],where:{id:_0x8782xd[_0x938f[37]][_0x938f[21]]}}]});break;default:};return ChatRoom[_0x938f[47]](_0x8782x15)[_0x938f[18]](function(_0x8782x16){return ChatRoom[_0x938f[47]]({where:{id:{$in:_[_0x938f[45]](_0x8782x16,_0x938f[21])}},include:[{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[25],_0x938f[46]]},{model:ChatVisitor}]})})[_0x938f[18]](function(_0x8782x16){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]]({rows:_0x8782x16,count:_0x8782x16[_0x938f[32]]})})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[48]]=function(_0x8782xd,_0x8782xe,_0x8782xf){checkTags(_0x8782xd[_0x938f[19]]);var _0x8782x15={where:_[_0x938f[27]]({type:_0x938f[49]},_0x8782xd[_0x938f[19]]),include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[23]]}]};switch(_0x8782xd[_0x938f[37]][_0x938f[25]]){case _0x938f[44]:_0x8782x15[_0x938f[50]][_0x938f[35]]({model:User,attributes:[_0x938f[21]],where:{id:_0x8782xd[_0x938f[37]][_0x938f[21]]}});break;default:};return ChatRoom[_0x938f[47]](_0x8782x15)[_0x938f[18]](function(_0x8782x16){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]]({rows:_0x8782x16,count:_0x8782x16[_0x938f[32]]})})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[51]]=function(_0x8782xd,_0x8782xe,_0x8782xf){return User[_0x938f[41]](_0x938f[40])[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]])[_0x938f[18]](function(_0x8782x11){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x11)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[53]]=function(_0x8782xd,_0x8782xe,_0x8782xf){return ChatRoom[_0x938f[41]](_0x938f[54])[_0x938f[28]](_[_0x938f[27]](Util[_0x938f[20]](_0x8782xd[_0x938f[19]]),{include:[{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[24],_0x938f[25],_0x938f[26]]},{model:ChatMessage},{model:ChatVisitor}]}))[_0x938f[18]](function(_0x8782x11){_0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x11)})[_0x938f[15]](function(_0x8782x10){console[_0x938f[14]](_0x8782x10);return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[55]]=function(_0x8782xd,_0x8782xe){return User[_0x938f[39]](_0x8782xd[_0x938f[37]][_0x938f[21]])[_0x938f[18]](function(_0x8782x17){return _0x8782x17[_0x938f[58]]({include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[23],_0x938f[24]]},{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[24],_0x938f[25],_0x938f[26]]}]})})[_0x938f[18]](function(_0x8782x16){if(!_0x8782x16){return _0x8782xe[_0x938f[57]](404)};return _0x8782xe[_0x938f[16]](_0x8782x16)})[_0x938f[15]](function(_0x8782x10){console[_0x938f[56]](_0x8782x10);return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[59]]=function(_0x8782xd,_0x8782xe){return ChatRoom[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]],{include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[24],_0x938f[23]]},{model:User,attributes:[_0x938f[21],_0x938f[24],_0x938f[22],_0x938f[23],_0x938f[46],_0x938f[25],_0x938f[26]]}]},{model:User,attributes:[_0x938f[21],_0x938f[24],_0x938f[22],_0x938f[23],_0x938f[46],_0x938f[25],_0x938f[26]]},{model:ChatVisitor},{model:ChatWebsite,attributes:[_0x938f[21],_0x938f[22],_0x938f[60]]}]})[_0x938f[18]](function(_0x8782x18){if(!_0x8782x18){return _0x8782xe[_0x938f[57]](404)};return _0x8782xe[_0x938f[16]](_0x8782x18)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[61]]=function(_0x8782xd,_0x8782xe,_0x8782xf){var _0x8782x19;return ChatRoom[_0x938f[71]]({where:{token:md5(JSON[_0x938f[69]](_0x8782xd[_0x938f[19]][_0x938f[64]][_0x938f[68]]())).toString(_0x938f[67])},defaults:{type:_0x938f[26],token:md5(JSON[_0x938f[69]](_0x8782xd[_0x938f[19]][_0x938f[64]][_0x938f[68]]())).toString(_0x938f[67]),status:_0x938f[70]},include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[24],_0x938f[23]]},{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[24],_0x938f[25],_0x938f[26]]}]},{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[24],_0x938f[25],_0x938f[26]]}]})[_0x938f[66]](function(_0x8782x18,_0x8782x1b){_0x8782x19=_0x8782x18;if(_0x8782x1b){return _0x8782x19[_0x938f[65]](_0x8782xd[_0x938f[19]][_0x938f[64]])}})[_0x938f[18]](function(){return _0x8782x19[_0x938f[63]]()})[_0x938f[18]](function(_0x8782x1a){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_[_0x938f[27]](_0x8782x19[_0x938f[62]],{Users:_0x8782x1a}))})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[72]]=function(_0x8782xd,_0x8782xe,_0x8782xf){var _0x8782x19;return ChatRoom[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]])[_0x938f[18]](function(_0x8782x18){_0x8782x19=_0x8782x18;if(!_0x8782x19){return _0x8782xe[_0x938f[57]](404)}})[_0x938f[18]](function(){return ChatMessage[_0x938f[75]](_[_0x938f[27]](_0x8782xd[_0x938f[73]],{type:_0x8782x19[_0x938f[74]],ChatRoomId:_0x8782xd[_0x938f[52]][_0x938f[21]],UserId:_0x8782xd[_0x938f[37]][_0x938f[21]]}))})[_0x938f[18]](function(_0x8782x1c){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x1c)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[76]]=function(_0x8782xd,_0x8782xe,_0x8782xf){return ChatRoom[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]],{include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[23]]},{model:User,attributes:[_0x938f[21],_0x938f[23]]}]}]})[_0x938f[18]](function(_0x8782x18){var _0x8782x1d=[];_0x8782x18[_0x938f[81]][_0x938f[80]](function(_0x8782x1c){_0x8782x1d[_0x938f[35]]({name:_0x8782x1c[_0x938f[6]]?_0x8782x1c[_0x938f[6]][_0x938f[23]]:_0x8782x1c[_0x938f[11]][_0x938f[23]],text:_0x8782x1c[_0x938f[73]][_0x938f[78]](/(\r\n|\n|\r)/gm,_0x938f[77]),date:_0x8782x1c[_0x938f[79]]})});return _0x8782xe[_0x938f[74]](_0x938f[82])[_0x938f[17]](200)[_0x938f[16]](csv(_0x8782x1d))})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[83]]=function(_0x8782xd,_0x8782xe){return User[_0x938f[39]](_0x8782xd[_0x938f[37]][_0x938f[21]])[_0x938f[18]](function(_0x8782x17){return _0x8782x17[_0x938f[58]]({where:{type:_0x8782xd[_0x938f[52]][_0x938f[74]]},include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[23],_0x938f[24]]}]})})[_0x938f[18]](function(_0x8782x16){if(!_0x8782x16){return _0x8782xe[_0x938f[57]](404)};return _0x8782xe[_0x938f[16]](_0x8782x16)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[84]]=function(_0x8782xd,_0x8782xe){return User[_0x938f[39]](_0x8782xd[_0x938f[37]][_0x938f[21]])[_0x938f[18]](function(_0x8782x17){return _0x8782x17[_0x938f[58]]({include:[{model:ChatVisitor,attributes:[_0x938f[21],_0x938f[23],_0x938f[24]]},{model:User,attributes:[_0x938f[21],_0x938f[22],_0x938f[23],_0x938f[24],_0x938f[25],_0x938f[26]]}]})})[_0x938f[18]](function(_0x8782x16){if(!_0x8782x16){return _0x8782xe[_0x938f[57]](404)};return _0x8782xe[_0x938f[16]](_0x8782x16)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[75]]=function(_0x8782xd,_0x8782xe){};exports[_0x938f[85]]=function(_0x8782xd,_0x8782xe){if(_0x8782xd[_0x938f[73]][_0x938f[21]]){delete _0x8782xd[_0x938f[73]][_0x938f[21]]};return ChatRoom[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]])[_0x938f[18]](function(_0x8782x18){if(!_0x8782x18){return _0x8782xe[_0x938f[57]](404)};return _0x8782x18[_0x938f[85]](_0x8782xd[_0x938f[73]])})[_0x938f[18]](function(_0x8782x18){return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x18)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[86]]=function(_0x8782xd,_0x8782xe){var _0x8782x19;if(_0x8782xd[_0x938f[73]][_0x938f[21]]){delete _0x8782xd[_0x938f[73]][_0x938f[21]]};return ChatRoom[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]])[_0x938f[18]](function(_0x8782x18){if(!_0x8782x18||!_0x8782xd[_0x938f[73]][_0x938f[64]]){return _0x8782xe[_0x938f[57]](404)};return _0x8782x18})[_0x938f[18]](function(_0x8782x18){return _0x8782x18[_0x938f[85]]({type:_0x938f[43],token:md5(JSON[_0x938f[69]](_0x8782xd[_0x938f[73]][_0x938f[64]][_0x938f[68]]())).toString(_0x938f[67])})})[_0x938f[18]](function(_0x8782x18){_0x8782x19=_0x8782x18;return _0x8782x18[_0x938f[65]](_0x8782xd[_0x938f[73]][_0x938f[64]][_0x938f[68]](),{individualHooks:true})})[_0x938f[18]](function(){return _0x8782x19[_0x938f[63]]()})[_0x938f[18]](function(_0x8782x1a){_[_0x938f[27]](_0x8782x19[_0x938f[62]],{Users:_0x8782x1a});return _0x8782xe[_0x938f[17]](200)[_0x938f[16]](_0x8782x19)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};exports[_0x938f[87]]=function(_0x8782xd,_0x8782xe){return ChatRoom[_0x938f[39]](_0x8782xd[_0x938f[52]][_0x938f[21]])[_0x938f[18]](function(_0x8782x18){if(!_0x8782x18){return _0x8782xe[_0x938f[57]](404)};return _0x8782x18[_0x938f[87]]()})[_0x938f[18]](function(){return _0x8782xe[_0x938f[57]](204)})[_0x938f[15]](function(_0x8782x10){return handleError(_0x8782xe,_0x8782x10)})};function handleError(_0x8782xe,_0x8782x10){return _0x8782xe[_0x938f[17]](500)[_0x938f[16]](_0x8782x10)}