remove bonfire/comments models
remove comments from user router
This commit is contained in:
@ -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": []
|
||||
}
|
@ -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": []
|
||||
}
|
@ -44,10 +44,6 @@
|
||||
"author": {
|
||||
"type": {}
|
||||
},
|
||||
"comments": {
|
||||
"type": "array",
|
||||
"default": []
|
||||
},
|
||||
"image": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user