HTML5-clent messages on chat

This commit is contained in:
JaeeunCho 2016-10-25 10:22:55 -07:00
parent 6d1823f2c7
commit 8bb915e8cd

View File

@ -39,6 +39,24 @@ const mapUser = (user) => ({
isLocked: user.locked,
});
// ====>>> implemented part
const nullUser = (userID, userName) => ({
id: userID,
name: userName,
emoji: {
status: '',
changedAt: 0,
},
isPresenter: false,
isModerator: false,
isCurrent: false,
isVoiceUser: false,
isMuted: false,
isListenOnly: false,
isSharingWebcam: false,
isLocked: false,
});
const mapMessage = (messagePayload) => {
const { message } = messagePayload;
@ -48,9 +66,10 @@ const mapMessage = (messagePayload) => {
time: message.from_time, //+ message.from_tz_offset,
sender: null,
};
//console.log(SYSTEM_CHAT_TYPE);
if (message.chat_type !== SYSTEM_CHAT_TYPE) {
mappedMessage.sender = getUser(message.from_userid);
// ====>>> implemented part
mappedMessage.sender = getUser(message.from_userid, message.from_username);
}
return mappedMessage;
@ -86,12 +105,13 @@ const reduceMessages = (previous, current, index, array) => {
}
};
const getUser = (userID) => {
// ====>>> implemented part
const getUser = (userID, userName) => {
const user = Users.findOne({ userId: userID });
if (user) {
return mapUser(user.user);
} else {
return null;
return nullUser(userID, userName);
}
};