From 0200c0dc782d7ff7a046a9de1b13706b54f6c8ed Mon Sep 17 00:00:00 2001 From: yamanq Date: Mon, 15 Aug 2016 13:48:00 -0400 Subject: [PATCH] changed subscribers to list and fixed #13 --- hourglass/collections/main.js | 2 +- hourglass/server/main.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hourglass/collections/main.js b/hourglass/collections/main.js index 44b493e..03b1e96 100644 --- a/hourglass/collections/main.js +++ b/hourglass/collections/main.js @@ -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({ diff --git a/hourglass/server/main.js b/hourglass/server/main.js index 346831e..49593c2 100644 --- a/hourglass/server/main.js +++ b/hourglass/server/main.js @@ -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 });