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