2021-07-16 08:23:16 +08:00
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import Meetings from '../../../api/meetings';
|
|
|
|
|
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
|
|
|
|
|
|
|
const isModerator = () => {
|
|
|
|
const user = Users.findOne(
|
|
|
|
{
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
userId: Auth.userID,
|
|
|
|
},
|
|
|
|
{ fields: { role: 1 } },
|
|
|
|
);
|
|
|
|
|
|
|
|
if (user && user.role === ROLE_MODERATOR) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2021-08-25 22:38:35 +08:00
|
|
|
const getLearningDashboardAccessToken = () => ((
|
2021-07-20 01:02:32 +08:00
|
|
|
Meetings.findOne(
|
|
|
|
{ meetingId: Auth.meetingID },
|
|
|
|
{
|
2021-08-25 22:38:35 +08:00
|
|
|
fields: { 'password.learningDashboardAccessToken': 1 },
|
2021-07-20 01:02:32 +08:00
|
|
|
},
|
2021-08-25 22:38:35 +08:00
|
|
|
) || {}).password || {}).learningDashboardAccessToken || null;
|
2021-07-16 08:23:16 +08:00
|
|
|
|
2021-08-25 22:38:35 +08:00
|
|
|
const openLearningDashboardUrl = () => {
|
|
|
|
window.open(`/learning-dashboard/?meeting=${Auth.meetingID}&report=${getLearningDashboardAccessToken()}`, '_blank');
|
2021-07-16 08:23:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
isModerator,
|
2021-08-25 22:38:35 +08:00
|
|
|
getLearningDashboardAccessToken,
|
|
|
|
openLearningDashboardUrl,
|
2021-07-16 08:23:16 +08:00
|
|
|
};
|