bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/whiteboard/cursors/service.js

25 lines
737 B
JavaScript
Raw Normal View History

import Cursor, { publishCursorUpdate } from '/imports/ui/components/cursor/service';
2022-04-05 22:49:13 +08:00
import Users from '/imports/api/users';
2022-05-07 00:37:43 +08:00
const getCurrentCursors = (whiteboardId) => {
const selector = { whiteboardId };
const filter = {};
const cursors = Cursor.find(selector, filter).fetch();
return cursors.map(cursor => {
2022-04-05 22:49:13 +08:00
const { userId } = cursor;
2022-05-07 00:37:43 +08:00
const user = Users.findOne({ userId }, { fields: { name: 1, presenter: 1, userId: 1, role: 1 } });
2022-04-05 22:49:13 +08:00
if (user) {
cursor.userName = user.name;
2022-05-07 00:37:43 +08:00
cursor.userId = user.userId;
cursor.role = user.role;
cursor.presenter = user.presenter;
2022-04-05 22:49:13 +08:00
return cursor;
}
2022-05-07 00:37:43 +08:00
});
2022-04-05 22:49:13 +08:00
};
export default {
2022-05-07 00:37:43 +08:00
getCurrentCursors,
publishCursorUpdate,
};