close #265 global and board setting to disable .onion file posting

merge-requests/208/head
Thomas Lynch 4 years ago
parent b5f04b428e
commit a2d34ac4af
  1. 4
      configs/main.js.example
  2. 7
      controllers/forms/makepost.js
  3. 3
      migrations/index.js
  4. 12
      migrations/migration-0.0.14.js
  5. 1
      models/forms/changeboardsettings.js
  6. 2
      package.json
  7. 4
      views/pages/managesettings.pug

@ -66,6 +66,9 @@ module.exports = {
cacheTime: 3600 //in seconds, idk whats a good value
},
//disable file posting over .onion globally, overrides any board setting.
disableOnionFilePosting: false,
floodTimers: { //basic delays to stop flooding, in ms. 0 to disable
sameContentSameIp: 120000, //same message or any file from same ip
sameContentAnyIp: 30000, //same message or file from any ip
@ -332,6 +335,7 @@ module.exports = {
defaultName: 'Anon',
customCSS: null,
blockedCountries: [], //2 char ISO country codes to block
disableOnionFilePosting: false,
filters: [], //words/phrases to block
filterMode: 0, //0=nothing, 1=prevent post, 2=auto ban
filterBanDuration: 0, //duration (in ms) to ban if filter mode=2

@ -3,7 +3,7 @@
const makePost = require(__dirname+'/../../models/forms/makepost.js')
, deleteTempFiles = require(__dirname+'/../../helpers/files/deletetempfiles.js')
, dynamicResponse = require(__dirname+'/../../helpers/dynamic.js')
, { globalLimits } = require(__dirname+'/../../configs/main.js')
, { globalLimits, disableOnionFilePosting } = require(__dirname+'/../../configs/main.js')
, { Files } = require(__dirname+'/../../db/');
module.exports = async (req, res, next) => {
@ -14,6 +14,11 @@ module.exports = async (req, res, next) => {
if ((!req.body.message || req.body.message.length === 0) && res.locals.numFiles === 0) {
errors.push('Posts must include a message or file');
}
if (res.locals.tor
&& (disableOnionFilePosting || res.locals.board.settings.disableOnionFilePosting)
&& res.locals.numFiles > 0) {
errors.push(`Posting files through the .onion address has been disabled ${disableOnionFilePosting ? 'globally' : 'on this board'}`);
}
if (res.locals.numFiles > res.locals.board.settings.maxFiles) {
errors.push(`Too many files. Max files per post ${res.locals.board.settings.maxFiles < globalLimits.postFiles.max ? 'on this board ' : ''}is ${res.locals.board.settings.maxFiles}`);
}

@ -13,5 +13,6 @@ module.exports = {
'0.0.10': require(__dirname+'/migration-0.0.10.js'), //add links to modlog for new logs
'0.0.11': require(__dirname+'/migration-0.0.11.js'), //rename captcha "text" field to "answer" since we support multiple captcha types now
'0.0.12': require(__dirname+'/migration-0.0.12.js'), //yotsuba b -> yotsuba-b
'0.0.13': require(__dirname+'/migration-0.0.13.js'), //add r9k mode
'0.0.13': require(__dirname+'/migration-0.0.13.js'), //add r9k mode (files)
'0.0.14': require(__dirname+'/migration-0.0.14.js'), //add option for disable .onion file posts to board settings
}

@ -0,0 +1,12 @@
'use strict';
module.exports = async(db, redis) => {
console.log('Adding disableOnionFilePosting setting');
await db.collection('boards').updateMany({}, {
'$set': {
'settings.disableOnionFilePosting': false,
}
});
console.log('Cleared boards cache');
await redis.deletePattern('board:*');
};

@ -113,6 +113,7 @@ module.exports = async (req, res, next) => {
'tags': arraySetting(req.body.tags, oldSettings.tags, 10),
'filters': arraySetting(req.body.filters, oldSettings.filters, 50),
'blockedCountries': req.body.countries || [],
'disableOnionFilePosting': booleanSetting(req.body.disable_onion_file_posting),
'strictFiltering': booleanSetting(req.body.strict_filtering),
'customCss': globalLimits.customCss.enabled ? (req.body.custom_css !== null ? req.body.custom_css : oldSettings.customCss) : null,
'announcement': {

@ -1,7 +1,7 @@
{
"name": "jschan",
"version": "0.0.1",
"migrateVersion": "0.0.13",
"migrateVersion": "0.0.14",
"description": "",
"main": "server.js",
"dependencies": {

@ -225,6 +225,10 @@ block content
.row
.label Blocked Countries
include ../includes/2charisocountries.pug
.row
.label Disable .onion file posting
label.postform-style.ph-5
input(type='checkbox', name='disable_onion_file_posting', value='true' checked=board.settings.disableOnionFilePosting)
.row
.label Filters
textarea(name='filters' placeholder='Newline separated, max 50') #{board.settings.filters.join('\n')}

Loading…
Cancel
Save