2019-07-29 22:17:38 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import LocalSettings from '/imports/api/local-settings';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
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
|
|
|
function localSettings() {
|
|
|
|
if (!this.userId) {
|
|
|
|
return LocalSettings.find({ meetingId: '' });
|
|
|
|
}
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-07-29 22:17:38 +08:00
|
|
|
|
|
|
|
Logger.debug(`Publishing local settings for user=${requesterUserId}`);
|
|
|
|
|
|
|
|
return LocalSettings.find({ meetingId, userId: requesterUserId });
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundLocalSettings = localSettings.bind(this);
|
|
|
|
return boundLocalSettings(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('local-settings', publish);
|