diff --git a/common/models/bonfire.json b/common/models/bonfire.json deleted file mode 100644 index 859f0196ed..0000000000 --- a/common/models/bonfire.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "bonfire", - "base": "PersistedModel", - "idInjection": true, - "trackChanges": false, - "properties": { - "name": { - "type": "string", - "unique": true - }, - "difficulty": { - "type": "string" - }, - "description": { - "type": "array" - }, - "tests": { - "type": "array" - }, - "challengeSeed": { - "type": "array" - }, - "MDNlinks": { - "type": "array" - } - }, - "validations": [], - "relations": {}, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "DENY" - }, - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ], - "methods": [] -} diff --git a/common/models/comment.json b/common/models/comment.json deleted file mode 100644 index ec29a05c98..0000000000 --- a/common/models/comment.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "comment", - "base": "PersistedModel", - "idInjection": true, - "trackChanges": false, - "properties": { - "associatedPost": { - "type": "string", - "required": true - }, - "originalStoryLink": { - "type": "string", - "default": "" - }, - "originalStoryAuthorEmail": { - "type": "string", - "default": "" - }, - "body": { - "type": "string", - "default": "" - }, - "rank": { - "type": "number", - "default": 0 - }, - "upvotes": { - "type": "array", - "default": [] - }, - "author": { - "type": {}, - "default": {} - }, - "comments": { - "type": "array", - "default": [] - }, - "commentOn": { - "type": "number", - "defaultFn": "now" - } - }, - "validations": [], - "relations": {}, - "acls": [ - { - "accessType": "*", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "DENY" - }, - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - }, - { - "accessType": "EXECUTE", - "principalType": "ROLE", - "principalId": "$authenticated", - "permission": "ALLOW", - "property": "create" - } - ], - "methods": [] -} diff --git a/common/models/story.json b/common/models/story.json index 4b50e3eed4..8aab09964b 100644 --- a/common/models/story.json +++ b/common/models/story.json @@ -44,10 +44,6 @@ "author": { "type": {} }, - "comments": { - "type": "array", - "default": [] - }, "image": { "type": "string", "default": "" diff --git a/server/boot/user.js b/server/boot/user.js index 2a6c37d882..1d9327ded2 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -12,7 +12,6 @@ module.exports = function(app) { var router = app.loopback.Router(); var User = app.models.User; var Story = app.models.Story; - var Comment = app.models.Comment; router.get('/login', function(req, res) { res.redirect(301, '/signin'); @@ -623,55 +622,23 @@ module.exports = function(app) { } function updateUserStoryPictures(userId, picture, username, cb) { - - var counter = 0, - foundStories, - foundComments; - Story.find({ 'author.userId': userId }, function(err, stories) { - if (err) { - return cb(err); - } - foundStories = stories; - counter++; - saveStoriesAndComments(); - }); + if (err) { return cb(err); } - Comment.find({ 'author.userId': userId }, function(err, comments) { - if (err) { - return cb(err); - } - foundComments = comments; - counter++; - saveStoriesAndComments(); - }); - - function saveStoriesAndComments() { - if (counter !== 2) { - return; - } - var tasks = []; - R.forEach(function(comment) { - comment.author.picture = picture; - comment.author.username = username; - tasks.push(function(cb) { - comment.save(cb); - }); - }, foundComments); - - R.forEach(function(story) { + const tasks = []; + stories.forEach(function(story) { story.author.picture = picture; story.author.username = username; tasks.push(function(cb) { story.save(cb); }); - }, foundStories); + }); async.parallel(tasks, function(err) { if (err) { return cb(err); } cb(); }); - } + }); } }; diff --git a/server/model-config.json b/server/model-config.json index 56cd5a317d..5ebf445e9a 100644 --- a/server/model-config.json +++ b/server/model-config.json @@ -31,18 +31,10 @@ "dataSource": "mail", "public": false }, - "bonfire": { - "dataSource": "db", - "public": true - }, "challenge": { "dataSource": "db", "public": true }, - "comment": { - "dataSource": "db", - "public": true - }, "fieldGuide": { "dataSource": "db", "public": true diff --git a/server/server.js b/server/server.js index 796c23a1ff..224aade88d 100755 --- a/server/server.js +++ b/server/server.js @@ -208,7 +208,7 @@ app.use(function(req, res, next) { var path = req.path.split('/')[1]; if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) { return next(); - } else if (/\/stories\/comments\/\w+/i.test(req.path)) { + } else if (/\/stories\/\w+/i.test(req.path)) { return next(); } req.session.returnTo = req.path;