-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for bans and partially working num replies
- Loading branch information
1 parent
0e4298c
commit 9db41d4
Showing
15 changed files
with
119 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ node_modules/ | |
.idea/ | ||
*.log.* | ||
uploads/ | ||
package-lock.json | ||
dist/ | ||
package-lock.json | ||
*~ | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const Ban = require(_base + 'models/ban'); | ||
|
||
module.exports = function(req, res, next) { | ||
Ban.findOne({ ip: req.connection.remoteAddress }, function(err, result) { | ||
if (err) { | ||
next(err); | ||
} | ||
|
||
if (result) { | ||
next(new Error('User is banned!')); | ||
} | ||
|
||
next(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const Replies = require(_base + "models/reply"); | ||
|
||
module.exports = { | ||
'/read/numReplies': { | ||
methods: ['get'], | ||
fn: function(req, res, next) { | ||
let _id = req.query._id, //For thread | ||
numReplies = 0; | ||
Replies.find({ threadId: _id }, function(err, threadResults) { | ||
if(err) { | ||
return next(err); | ||
} else { | ||
numReplies = threadResults.length; | ||
console.log(numReplies); | ||
res.json( { result: { numReplies: numReplies } } ); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
const Threads = require(_base + 'models/thread'); | ||
const Threads = require(_base + 'models/thread'), | ||
Replies = require(_base + "models/reply"); | ||
|
||
module.exports = { | ||
'/read/threads': { | ||
methods: ['get'], | ||
fn: function(req, res, next) { | ||
let letter = req.query.letter; | ||
Threads.find({ boardId: letter }, function(err, results) { | ||
if(err) { | ||
return next(err); | ||
} else { | ||
res.json({ result: results }); | ||
} | ||
'/read/threads': { | ||
methods: ['get'], | ||
fn: function(req, res, next) { | ||
let letter = req.query.letter, | ||
numReplies = 0; | ||
Threads.find({ boardId: letter }, function(err, results) { | ||
if(err) { | ||
return next(err); | ||
} else { | ||
for(let i=0; i<results.length; i++) { | ||
numReplies = 0; | ||
Replies.find({ threadId: results[i]._id }, function(err, threadResults) { | ||
if(err) { | ||
return next(err); | ||
} else { | ||
numReplies = threadResults.length; | ||
console.log(numReplies); | ||
} | ||
}); | ||
console.log(numReplies); | ||
results[i].numReplies = numReplies; | ||
} | ||
res.json({ result: results }); | ||
} | ||
}); | ||
} | ||
}; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.