2019-07-29 22:17:38 +08:00
|
|
|
import _ from 'lodash';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import LocalSettings from '/imports/api/local-settings';
|
|
|
|
import setChangedLocalSettings from '../modifiers/setChangedLocalSettings';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2019-07-29 22:17:38 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
export default function userChangedLocalSettings(settings) {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-07-29 22:17:38 +08:00
|
|
|
|
|
|
|
if (!meetingId || !requesterUserId) return;
|
|
|
|
|
|
|
|
check(settings, Object);
|
2021-03-17 00:15:41 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
2019-07-29 22:17:38 +08:00
|
|
|
|
|
|
|
const userLocalSettings = LocalSettings
|
|
|
|
.findOne({ meetingId, userId: requesterUserId },
|
|
|
|
{
|
|
|
|
fields: { settings: 1 },
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!userLocalSettings || !_.isEqual(userLocalSettings.settings, settings)) {
|
|
|
|
setChangedLocalSettings(meetingId, requesterUserId, settings);
|
|
|
|
}
|
|
|
|
}
|