d28b93a586
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
35 lines
796 B
JavaScript
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}`);
|
|
}
|
|
}
|