diff options
author | Rafael Marçalo <63216029+rafa-99@users.noreply.github.com> | 2022-11-05 20:44:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-05 20:44:56 +0000 |
commit | fd5dc21f2da79298f43ce023a9d84f59c20de620 (patch) | |
tree | 63d3572d212b45228577a1e701fccf0eb05eef9a /routes/search.js | |
parent | 2f9c4d5f287c40125703c98e49ab0658a847d99b (diff) | |
parent | cec82f62825a2ac1ce2ede1ed5cecc72a179ae19 (diff) |
Merge pull request #1 from rafa-99/settings
Settings menu
Diffstat (limited to 'routes/search.js')
-rw-r--r-- | routes/search.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/routes/search.js b/routes/search.js index e7a1b41..6732c52 100644 --- a/routes/search.js +++ b/routes/search.js @@ -1,12 +1,29 @@ "use strict"; const apibay = require('../server/js/apibay'); +const config = require('../server/js/config'); const template = require('../server/js/template'); async function search(req, res) { let query = req.body.search; let results = await apibay.hit(query); + + // Filter NSFW Content + if (!config.loadedConfig.settings.nsfw_content) + { + results = Array.prototype.filter.call(results, result => { + + let category = parseInt(result.category); + + if ( !(category > 500 && category < 600) ) + { + return result; + } + + }); + } + res.render('result', {query: query, results: results, functions: template, showSearchBar: true}); }; |