2019-07-29 22:17:38 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import LocalSettings from '/imports/api/local-settings';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2023-03-16 22:02:33 +08:00
|
|
|
export default async function setChangedLocalSettings(meetingId, userId, settings) {
|
2019-07-29 22:17:38 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(settings, Object);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
settings,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-11-23 21:13:46 +08:00
|
|
|
try {
|
2023-03-16 22:02:33 +08:00
|
|
|
const { numChanged } = await LocalSettings.upsertAsync(selector, modifier);
|
2019-07-29 22:17:38 +08:00
|
|
|
|
|
|
|
if (numChanged) {
|
|
|
|
Logger.info(`Updated settings for user ${userId} on meeting ${meetingId}`);
|
|
|
|
}
|
2020-11-23 21:13:46 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on update settings. ${err}`);
|
|
|
|
}
|
2019-07-29 22:17:38 +08:00
|
|
|
}
|