bigbluebutton-Github/bigbluebutton-html5/imports/api/user-reaction/server/modifiers/addUserReaction.js
Max Franke d28b93a586 feat(reactions): add user reaction
add user-reaction collection
add emoji picker for user reaction in the user list
add options to enable/disable user-reaction
add a way to pass style to emoji-picker component
2023-04-27 11:54:11 -03:00

35 lines
796 B
JavaScript

import UserReaction from '/imports/api/user-reaction';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
export default function addUserReaction(meetingId, userId, reaction) {
check(meetingId, String);
check(userId, String);
check(reaction, String);
const selector = {
creationDate: new Date(),
meetingId,
userId,
};
const modifier = {
$set: {
meetingId,
userId,
reaction,
},
};
try {
UserReaction.remove({ meetingId, userId });
const { numberAffected } = UserReaction.upsert(selector, modifier);
if (numberAffected) {
Logger.verbose(`Added user reaction meetingId=${meetingId} userId=${userId}`);
}
} catch (err) {
Logger.error(`Adding user reaction: ${err}`);
}
}