bigbluebutton-Github/bigbluebutton-html5/imports/api/local-settings/server/methods/userChangedLocalSettings.js
2021-03-16 13:15:41 -03:00

26 lines
842 B
JavaScript

import _ from 'lodash';
import { check } from 'meteor/check';
import LocalSettings from '/imports/api/local-settings';
import setChangedLocalSettings from '../modifiers/setChangedLocalSettings';
import { extractCredentials } from '/imports/api/common/server/helpers';
export default function userChangedLocalSettings(settings) {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
if (!meetingId || !requesterUserId) return;
check(settings, Object);
check(meetingId, String);
check(requesterUserId, String);
const userLocalSettings = LocalSettings
.findOne({ meetingId, userId: requesterUserId },
{
fields: { settings: 1 },
});
if (!userLocalSettings || !_.isEqual(userLocalSettings.settings, settings)) {
setChangedLocalSettings(meetingId, requesterUserId, settings);
}
}