bigbluebutton-Github/bigbluebutton-html5/imports/api/local-settings/server/methods/userChangedLocalSettings.js

31 lines
1.0 KiB
JavaScript
Raw Normal View History

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';
import Logger from '/imports/startup/server/logger';
2023-02-23 21:27:16 +08:00
import { isEqual } from 'radash';
export default async function userChangedLocalSettings(settings) {
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
if (!meetingId || !requesterUserId) return;
check(settings, Object);
check(meetingId, String);
check(requesterUserId, String);
const userLocalSettings = await LocalSettings
.findOneAsync({ meetingId, userId: requesterUserId },
{
fields: { settings: 1 },
});
2023-02-23 21:27:16 +08:00
if (!userLocalSettings || !isEqual(userLocalSettings.settings, settings)) {
await setChangedLocalSettings(meetingId, requesterUserId, settings);
}
} catch (err) {
Logger.error(`Exception while invoking method userChangedLocalSettings ${err.stack}`);
}
}