2019-03-29 02:47:11 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Note from '/imports/api/note';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
function note() {
|
|
|
|
if (!this.userId) {
|
|
|
|
return Note.find({ meetingId: '' });
|
|
|
|
}
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
Logger.info(`Publishing note for ${meetingId} ${requesterUserId}`);
|
2019-03-29 02:47:11 +08:00
|
|
|
|
|
|
|
return Note.find({ meetingId });
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundNote = note.bind(this);
|
|
|
|
return boundNote(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('note', publish);
|