changed subscribers to list and fixed #13

This commit is contained in:
yamanq 2016-08-15 13:48:00 -04:00
parent 4326346af5
commit 0200c0dc78
2 changed files with 12 additions and 2 deletions

View File

@ -22,7 +22,7 @@ classes.schema = new SimpleSchema({
moderators: {type: [String], optional: true},
banned: {type: [String], optional: true},
blockEdit: {type: [String], optional: true},
subscribers: {type: Number, optional: true}
subscribers: {type: [String], optional: true}
});
work.schema = new SimpleSchema({

View File

@ -127,7 +127,7 @@ Meteor.methods({
} else {
input.status = false;
}
input.subscribers = 0;
input.subscribers = [Meteor.userId()];
input.admin = Meteor.userId();
if (input.privacy) {
Meteor.call('genCode', function(error, result) {
@ -154,6 +154,16 @@ Meteor.methods({
_id: classid
});
if (Meteor.user() !== null && found !== null && (found.admin === Meteor.user()._id || Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']))) {
for (var i = 0; i < found.subscribers.length; i++) {
profile.classes.splice(index, 1);
Meteor.users.update({
_id: found.subscribers[i]
}, {
$set: {
profile: current
}
});
};
classes.remove({
_id: classid
});