|
@@ -9,11 +9,13 @@ const getInKey = (realKey) => {
|
|
|
const createMessage = (roomId, user, msg) => {
|
|
|
const msgConfigKey = `msg:${roomId}`;
|
|
|
const msgObj = {
|
|
|
- ...user,
|
|
|
+ userId: user.userId,
|
|
|
+ nickname: user.nickname,
|
|
|
+ roomId: roomId,
|
|
|
msg: msg,
|
|
|
createTime: Math.floor(Date.now() / 1000),
|
|
|
};
|
|
|
- return pubClient.hSet(getInKey(msgConfigKey), msgObj);
|
|
|
+ return pubClient.hSet(getInKey(msgConfigKey), user.userId, JSON.stringify(msgObj));
|
|
|
};
|
|
|
|
|
|
export { createMessage };
|