Built motion from commit 3594e56.|0.0.120
[motion.git] / server / api / user_has_chat_room / user_has_chat_room.socket.js
index c58a829..ac8afc0 100644 (file)
@@ -1,58 +1 @@
-/**
- * Broadcast updates to client when the model changes
- */
-
-'use strict';
-var _ = require('lodash');
-var User = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatVisitor = require('../../models').ChatVisitor;
-var UserHasChatRoom = require('../../models').UserHasChatRoom;
-
-exports.register = function (socket) {
-  UserHasChatRoom.afterCreate(function (doc) {
-    onSave(socket, doc);
-  });
-  UserHasChatRoom.afterDestroy(function (doc) {
-    onRemove(socket, doc);
-  });
-}
-
-function onSave(socket, doc) {
-
-  var _chatRoom;
-
-  return ChatRoom
-    .findById(doc.ChatRoomId, {
-      include: [{
-        model: ChatVisitor,
-        attributes: ['id', 'email', 'fullname']
-      }, {
-        model: User,
-        attributes: ['id', 'email', 'name', 'fullname']
-      }]
-    })
-    .then(function (chatRoom) {
-      _chatRoom = chatRoom;
-      _chatRoom.dataValues.ChatMessages = [];
-
-      console.log('_chatRoom', _chatRoom);
-
-      var ids = _.pluck(_chatRoom.Users, 'id');
-
-      ids.forEach(function (id) {
-        if (socket.userId == id) {
-          socket.emit('user_has_chat_room:save', _chatRoom.dataValues)
-        }
-      });
-
-      return;
-    })
-    .catch(function (err) {
-      console.error(err);
-    });
-}
-
-function onRemove(socket, doc) {
-  socket.emit('user_has_chat_room:remove', doc);
-}
+var _0x9ad0=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x2E\x2F\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x2E\x65\x76\x65\x6E\x74\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x73\x61\x76\x65","\x72\x65\x6D\x6F\x76\x65","\x72\x65\x67\x69\x73\x74\x65\x72","\x6C\x65\x6E\x67\x74\x68","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A","\x6F\x6E","\x64\x69\x73\x63\x6F\x6E\x6E\x65\x63\x74","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x75\x73\x65\x72\x49\x64","\x69\x64","\x65\x6D\x69\x74","\x66\x6F\x72\x45\x61\x63\x68","\x55\x73\x65\x72\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A\x73\x61\x76\x65","\x75\x73\x65\x72\x5F\x68\x61\x73\x5F\x63\x68\x61\x74\x5F\x72\x6F\x6F\x6D\x3A\x72\x65\x6D\x6F\x76\x65","\x72\x65\x6D\x6F\x76\x65\x4C\x69\x73\x74\x65\x6E\x65\x72"];_0x9ad0[0];const UserHasChatRoomEvents=require(_0x9ad0[1]);const ChatRoom=require(_0x9ad0[3])[_0x9ad0[2]];const User=require(_0x9ad0[3])[_0x9ad0[4]];var events=[_0x9ad0[5],_0x9ad0[6]];exports[_0x9ad0[7]]= function(_0x9c95x5){for(var _0x9c95x6=0,_0x9c95x7=events[_0x9ad0[8]];_0x9c95x6< _0x9c95x7;_0x9c95x6++){var _0x9c95x8=events[_0x9c95x6];var _0x9c95x9=createListener(_0x9ad0[9]+ _0x9c95x8,_0x9c95x5);UserHasChatRoomEvents[_0x9ad0[10]](_0x9c95x8,_0x9c95x9);_0x9c95x5[_0x9ad0[10]](_0x9ad0[11],removeListener(_0x9c95x8,_0x9c95x9))}};function createListener(_0x9c95x8,_0x9c95x5){return function(_0x9c95xb){switch(_0x9c95x8){case _0x9ad0[21]:return ChatRoom[_0x9ad0[20]](_0x9c95xb.ChatRoomId,{include:[{model:User,attributes:[_0x9ad0[15]]}]})[_0x9ad0[19]](function(_0x9c95xd){_0x9c95xd[_0x9ad0[18]][_0x9ad0[17]](function(_0x9c95xe){if(_0x9c95x5[_0x9ad0[14]]== _0x9c95xe[_0x9ad0[15]]){_0x9c95x5[_0x9ad0[16]](_0x9c95x8,_0x9c95xb)}})})[_0x9ad0[13]](function(_0x9c95xc){console[_0x9ad0[12]](_0x9c95xc)});case _0x9ad0[22]:_0x9c95x5[_0x9ad0[16]](_0x9c95x8,_0x9c95xb);break;default:}}}function removeListener(_0x9c95x8,_0x9c95x9){return function(){UserHasChatRoomEvents[_0x9ad0[23]](_0x9c95x8,_0x9c95x9)}}
\ No newline at end of file