Handling emoji messages

This commit is contained in:
Klaus 2017-07-13 10:15:42 -03:00
parent 0cdda4f8cb
commit 54234cecac
10 changed files with 52 additions and 27 deletions

View File

@ -8,7 +8,7 @@ import setEmojiStatus from './methods/setEmojiStatus';
import validateAuthToken from './methods/validateAuthToken';
import mapToAcl from '/imports/startup/mapToAcl';
Meteor.methods(mapToAcl(['methods.kickUser', 'methods.listenOnlyToggle', 'methods.userLogout',
Meteor.methods(/*mapToAcl(['methods.kickUser', 'methods.listenOnlyToggle', 'methods.userLogout',
'methods.assignPresenter', 'methods.setEmojiStatus', 'methods.muteUser', 'methods.unmuteUser',
], {
kickUser,
@ -18,6 +18,6 @@ Meteor.methods(mapToAcl(['methods.kickUser', 'methods.listenOnlyToggle', 'method
setEmojiStatus,
muteUser: (...args) => muteToggle(...args, true),
unmuteUser: (...args) => muteToggle(...args, false),
}));
})*/);
Meteor.methods({ validateAuthToken });

View File

@ -3,10 +3,10 @@ import { check } from 'meteor/check';
import Users from '/imports/api/2.0/users';
export default function handleEmojiStatus({ body }, meetingId) {
const { userId, status } = body;
const { userId, emoji } = body;
check(userId, String);
check(status, String);
check(emoji, String);
const selector = {
meetingId,
@ -16,7 +16,7 @@ export default function handleEmojiStatus({ body }, meetingId) {
const modifier = {
$set: {
'user.set_emoji_time': (new Date()).getTime(),
'user.emoji_status': status,
'user.emoji': emoji,
},
};
@ -27,7 +27,7 @@ export default function handleEmojiStatus({ body }, meetingId) {
if (numChanged) {
return Logger.info(`Assigned user emoji status${
status} id=${userId} meeting=${meetingId}`,
emoji} id=${userId} meeting=${meetingId}`,
);
}
};

View File

@ -1,20 +1,13 @@
import { Meteor } from 'meteor/meteor';
// import kickUser from './methods/kickUser';
import listenOnlyToggle from './methods/listenOnlyToggle';
import mapToAcl from '/imports/startup/mapToAcl';
import userLogout from './methods/userLogout';
import validateAuthToken from './methods/validateAuthToken';
import mapToAcl from '/imports/startup/mapToAcl';
import setEmojiStatus from './methods/setEmojiStatus';
Meteor.methods(mapToAcl(['methods.kickUser', 'methods.listenOnlyToggle', 'methods.userLogout',
'methods.assignPresenter', 'methods.setEmojiStatus', 'methods.muteUser', 'methods.unmuteUser',
], {
// kickUser,
// listenOnlyToggle,
// userLogout,
// assignPresenter,
// setEmojiStatus,
// muteUser: (...args) => muteToggle(...args, true),
// unmuteUser: (...args) => muteToggle(...args, false),
}));
Meteor.methods(mapToAcl(['methods.userLogout', 'methods.setEmojiStatus',
], {
userLogout,
setEmojiStatus,
}));
Meteor.methods({ validateAuthToken2x: validateAuthToken });

View File

@ -0,0 +1,32 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis2x';
import Logger from '/imports/startup/server/logger';
export default function setEmojiStatus(credentials, userId, status) {
const REDIS_CONFIG = Meteor.settings.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'ChangeUserEmojiCmdMsg';
const { meetingId, requesterUserId } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(userId, String);
const payload = {
emoji: status,
userId,
};
const header = {
meetingId,
name: EVENT_NAME,
userId: requesterUserId,
};
Logger.verbose(`User '${userId}' emoji status updated to '${status}' by '${
requesterUserId}' from meeting '${meetingId}'`);
return RedisPubSub.publish(CHANNEL, EVENT_NAME, meetingId, payload, header);
}

View File

@ -59,8 +59,8 @@ export default function userLeaving(credentials, userId) {
}
const payload = {
meeting_id: meetingId,
userid: userId,
meetingId,
userId,
};
Logger.verbose(`User '${requesterUserId}' left meeting '${meetingId}'`);

View File

@ -51,7 +51,7 @@ export default function addUser(meetingId, user) {
'user.avatarURL': user.avatar,
'user.set_emoji_time': user.set_emoji_time || (new Date()).getTime(),
'user.joiningTime': (new Date()).getTime(),
'user.emoji_status': user.emoji,
'user.emoji': user.emoji,
'user.presenter': user.presenter,
'user.locked': user.locked,
'user.listenOnly': user.listenOnly,

View File

@ -22,7 +22,7 @@ export default function removeUser(meetingId, userId) {
'user.time_of_joining': 0,
'user.listenOnly': false,
'user.validated': false,
'user.emoji_status': 'none',
'user.emoji': 'none',
'user.presenter': false,
'user.role': 'VIEWER',
},

View File

@ -11,7 +11,7 @@ const getEmojiData = () => {
const userEmojiStatus = Users.findOne({
meetingId: Auth.meetingID,
userId: Auth.userID,
}).user.emoji_status;
}).user.emoji;
return {
userEmojiStatus,

View File

@ -31,7 +31,7 @@ const mapUser = user => ({
id: user.userid,
name: user.name,
emoji: {
status: user.emoji_status,
status: user.emoji,
changedAt: user.set_emoji_time,
},
isPresenter: user.presenter,

View File

@ -20,7 +20,7 @@ const mapUser = user => ({
id: user.userid,
name: user.name,
emoji: {
status: user.emoji_status,
status: user.emoji,
changedAt: user.set_emoji_time,
},
isPresenter: user.presenter,