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": {
|
"author": {
|
||||||
"type": {}
|
"type": {}
|
||||||
},
|
},
|
||||||
"comments": {
|
|
||||||
"type": "array",
|
|
||||||
"default": []
|
|
||||||
},
|
|
||||||
"image": {
|
"image": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
|
@ -12,7 +12,6 @@ module.exports = function(app) {
|
|||||||
var router = app.loopback.Router();
|
var router = app.loopback.Router();
|
||||||
var User = app.models.User;
|
var User = app.models.User;
|
||||||
var Story = app.models.Story;
|
var Story = app.models.Story;
|
||||||
var Comment = app.models.Comment;
|
|
||||||
|
|
||||||
router.get('/login', function(req, res) {
|
router.get('/login', function(req, res) {
|
||||||
res.redirect(301, '/signin');
|
res.redirect(301, '/signin');
|
||||||
@ -623,55 +622,23 @@ module.exports = function(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateUserStoryPictures(userId, picture, username, cb) {
|
function updateUserStoryPictures(userId, picture, username, cb) {
|
||||||
|
|
||||||
var counter = 0,
|
|
||||||
foundStories,
|
|
||||||
foundComments;
|
|
||||||
|
|
||||||
Story.find({ 'author.userId': userId }, function(err, stories) {
|
Story.find({ 'author.userId': userId }, function(err, stories) {
|
||||||
if (err) {
|
if (err) { return cb(err); }
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
foundStories = stories;
|
|
||||||
counter++;
|
|
||||||
saveStoriesAndComments();
|
|
||||||
});
|
|
||||||
|
|
||||||
Comment.find({ 'author.userId': userId }, function(err, comments) {
|
const tasks = [];
|
||||||
if (err) {
|
stories.forEach(function(story) {
|
||||||
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) {
|
|
||||||
story.author.picture = picture;
|
story.author.picture = picture;
|
||||||
story.author.username = username;
|
story.author.username = username;
|
||||||
tasks.push(function(cb) {
|
tasks.push(function(cb) {
|
||||||
story.save(cb);
|
story.save(cb);
|
||||||
});
|
});
|
||||||
}, foundStories);
|
});
|
||||||
async.parallel(tasks, function(err) {
|
async.parallel(tasks, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,18 +31,10 @@
|
|||||||
"dataSource": "mail",
|
"dataSource": "mail",
|
||||||
"public": false
|
"public": false
|
||||||
},
|
},
|
||||||
"bonfire": {
|
|
||||||
"dataSource": "db",
|
|
||||||
"public": true
|
|
||||||
},
|
|
||||||
"challenge": {
|
"challenge": {
|
||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
"public": true
|
"public": true
|
||||||
},
|
},
|
||||||
"comment": {
|
|
||||||
"dataSource": "db",
|
|
||||||
"public": true
|
|
||||||
},
|
|
||||||
"fieldGuide": {
|
"fieldGuide": {
|
||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
"public": true
|
"public": true
|
||||||
|
@ -208,7 +208,7 @@ app.use(function(req, res, next) {
|
|||||||
var path = req.path.split('/')[1];
|
var path = req.path.split('/')[1];
|
||||||
if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) {
|
if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) {
|
||||||
return next();
|
return next();
|
||||||
} else if (/\/stories\/comments\/\w+/i.test(req.path)) {
|
} else if (/\/stories\/\w+/i.test(req.path)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
req.session.returnTo = req.path;
|
req.session.returnTo = req.path;
|
||||||
|
Reference in New Issue
Block a user