2017-06-27 20:40:28 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-06-27 20:40:28 +08:00
|
|
|
|
2017-06-29 21:09:11 +08:00
|
|
|
export default function handleEmojiStatus({ body }, meetingId) {
|
2017-07-13 21:15:42 +08:00
|
|
|
const { userId, emoji } = body;
|
2017-06-27 20:40:28 +08:00
|
|
|
|
|
|
|
check(userId, String);
|
2017-07-13 21:15:42 +08:00
|
|
|
check(emoji, String);
|
2017-06-27 20:40:28 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
2017-07-26 22:09:07 +08:00
|
|
|
emojiTime: (new Date()).getTime(),
|
|
|
|
emoji,
|
2017-06-27 20:40:28 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
2017-10-06 20:50:01 +08:00
|
|
|
Logger.error(`Assigning user emoji status: ${err}`);
|
|
|
|
return;
|
2017-06-27 20:40:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
2017-10-06 20:50:01 +08:00
|
|
|
Logger.info(`Assigned user emoji status${
|
|
|
|
emoji} id=${userId} meeting=${meetingId}`,
|
2017-06-27 20:40:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return Users.update(selector, modifier, cb);
|
|
|
|
}
|