Merge branch 'new-dev' into 'master'

v0.3.0

Closes #420

See merge request fatchan/jschan!237
indiachan-spamvector v0.3.0
Thomas Lynch 2 years ago
commit 9690cc5537
  1. 148
      CHANGELOG.md
  2. 2
      CONTRIBUTING.md
  3. 2
      README.md
  4. 26
      controllers/forms/editbans.js
  5. 13
      db/bans.js
  6. 11
      models/forms/editbans.js
  7. 55
      package-lock.json
  8. 2
      package.json
  9. 5
      views/includes/managebanform.pug
  10. 5
      views/pages/thread.pug

@ -1,44 +1,49 @@
##### 0.1.1
- Added changelog
- Version now changes with some kind of meaning
- Animated gif thumbnails no longer generate static image for images < thumbnail dimensions
- Boards management "Banners" page is now "Assets"
- Boards can have custom flags
### 0.3.0
- Ban durations are now editable. Staff can set a new ban duration (starting from the current date, not the original ban issue date).
- Minor bugfixes.
##### 0.1.2
- Merge webring and local board list and improve webring search and filter functionality
- New stat section of homepage
- Replaced and removed some fatchan-specific media
- Fixed undefined hcaptcha site key bug
- Updated README with info about nginx CSP for 3rd party captcha providers
- Update socket-io 2.x to 4.x
### 0.2.0
- From now on, versioning = major.minor.patch. significant changes = major, feature updates = minor, bugfixes/small stuff = patch.
- Update instructions about nginx changes when upgrading.
- Add an endpoint for getting the csrf token separately from html pages. See API docs for more details.
- Add post "marking" so moved/deleted posts info is sent over websocket. Frontend will handle them. Deleted threads and moved OPs will now also disconnect the socket and remove the post form.
- Block bypasses are now locked to where they were created (anonymizer or clearnet) to prevent some forms of 'smuggling'. This will be improved further in upcoming releases.
- Code highlighting now supports all highlight.js languages when explicitly specified. The whitelist now only applies to auto-detection, as originally intended.
- Quotes for post references in modlog now have the proper quote class, and will show when hovered like any other quote.
- Bugfixes
- [jschan-docs](http://fatchan.gitgud.site/jschan-docs/):
- API docs improvements, now includes csrf token, posting, post actions (and mod variants), and more. It should be enough documentation for somebody to write a mobile app integration.
- [globalafk](https://gitgud.io/fatchan/globalafk/) (my fork):
- On android with termux, tapping the notification will open the post (in mod view) and the notification has new shortcut buttons to quickly delete, delete+ban or delete+global ban.
##### 0.1.3
- Script optimizations, improves page load speed especially on longer threads
- Extra (u) download link for no reason
- favicon, webmanifest, browserconfig, etc for browsers made into gulp task
- Webring now sends and checks for ppd stat
- Board search improved (prefix matches)
- Update code for form submission and data validation, faster and easier to maintain
- Make it more obvious to users with a blacklisted IP if block bypass dnsbl is enabled
- Add new themes
- Improved README
- Many bugfixes
### 0.1.10
- Add thread watcher/watchlist, so users can save list of threads to a little window and see unread count
- There are now API docs available at http://fatchan.gitgud.site/jschan-docs/
- Improved installation nginx script. Confirms overwriting and doesnt break when run more than once
- Some visual tweaks (file "(u)" being on newline, "x" -> "×")
- Bugfixes
##### 0.1.4
- Banner uploading bugfix
### 0.1.9
- Fix "improved" global settings changes not regenerating custom pages properly
- Postmenu dropdown for filters/moderate added to catalog tiles
- Notifications are no longer sent for posts when clicking "view full text"
- Make handling files with no/incorrect extension better
- Image count from OP is included in catalog tiles file count
##### 0.1.5
- Try to fallback thumbnail generation for video with horribly broken encoding
- Country blocklist now can actually fit all countries
- Make "auth level" text box into "account type" dropdown in accounts page, easier to understand
- Board owners can now edit custom pages
- Board owners can now manage custom assets
- Show a little message and disable reply form on full threads (hit reply limit)
- Allow longer language names for code blocks
- User settings import and export option
### 0.1.8
- Much improved nginx configuration for installation, script does most of the work
- Fixed settings form asking to save password -.-
- Multiple files & post flags now shown in catalog view
- Faster, more efficient global settings changes
- Add option for board owner to prevent OP deleting threads that are too old or have too many replies
### 0.1.7
- Update inconsistent wording of custom overboard subtitle from 0.1.6
- Dont show "local first" checkbox in boardlist when webring isn't even enabled
- Bugfix to code markup, remove only leading blank lines, keeping leading whitespace on first non-empty line
- Make overboard settings save somewhat in localstorage to help stupid zoomers who dont know what a BOOKMARK is
##### 0.1.6
#### 0.1.6
- Mongodb v5 and node driver v4 update
- IP rangebans use more reasonable range for ipv6
- Fix ip randomising schedule
@ -56,43 +61,42 @@
- Strict filtering improvements
- Many bugfixes
### 0.1.7
- Update inconsistent wording of custom overboard subtitle from 0.1.6
- Dont show "local first" checkbox in boardlist when webring isn't even enabled
- Bugfix to code markup, remove only leading blank lines, keeping leading whitespace on first non-empty line
- Make overboard settings save somewhat in localstorage to help stupid zoomers who dont know what a BOOKMARK is
#### 0.1.5
- Try to fallback thumbnail generation for video with horribly broken encoding
- Country blocklist now can actually fit all countries
- Make "auth level" text box into "account type" dropdown in accounts page, easier to understand
- Board owners can now edit custom pages
- Board owners can now manage custom assets
- Show a little message and disable reply form on full threads (hit reply limit)
- Allow longer language names for code blocks
- User settings import and export option
### 0.1.8
- Much improved nginx configuration for installation, script does most of the work
- Fixed settings form asking to save password -.-
- Multiple files & post flags now shown in catalog view
- Faster, more efficient global settings changes
- Add option for board owner to prevent OP deleting threads that are too old or have too many replies
#### 0.1.4
- Banner uploading bugfix
### 0.1.9
- Fix "improved" global settings changes not regenerating custom pages properly
- Postmenu dropdown for filters/moderate added to catalog tiles
- Notifications are no longer sent for posts when clicking "view full text"
- Make handling files with no/incorrect extension better
- Image count from OP is included in catalog tiles file count
#### 0.1.3
- Script optimizations, improves page load speed especially on longer threads
- Extra (u) download link for no reason
- favicon, webmanifest, browserconfig, etc for browsers made into gulp task
- Webring now sends and checks for ppd stat
- Board search improved (prefix matches)
- Update code for form submission and data validation, faster and easier to maintain
- Make it more obvious to users with a blacklisted IP if block bypass dnsbl is enabled
- Add new themes
- Improved README
- Many bugfixes
### 0.1.10
- Add thread watcher/watchlist, so users can save list of threads to a little window and see unread count
- There are now API docs available at http://fatchan.gitgud.site/jschan-docs/
- Improved installation nginx script. Confirms overwriting and doesnt break when run more than once
- Some visual tweaks (file "(u)" being on newline, "x" -> "×")
- Bugfixes
#### 0.1.2
- Merge webring and local board list and improve webring search and filter functionality
- New stat section of homepage
- Replaced and removed some fatchan-specific media
- Fixed undefined hcaptcha site key bug
- Updated README with info about nginx CSP for 3rd party captcha providers
- Update socket-io 2.x to 4.x
### 0.2.0
- From now on, versioning = major.minor.patch. significant changes = major, feature updates = minor, bugfixes/small stuff = patch.
- Update instructions about nginx changes when upgrading.
- Add an endpoint for getting the csrf token separately from html pages. See API docs for more details.
- Add post "marking" so moved/deleted posts info is sent over websocket. Frontend will handle them. Deleted threads and moved OPs will now also disconnect the socket and remove the post form.
- Block bypasses are now locked to where they were created (anonymizer or clearnet) to prevent some forms of 'smuggling'. This will be improved further in upcoming releases.
- Code highlighting now supports all highlight.js languages when explicitly specified. The whitelist now only applies to auto-detection, as originally intended.
- Quotes for post references in modlog now have the proper quote class, and will show when hovered like any other quote.
- Bugfixes
- [jschan-docs](http://fatchan.gitgud.site/jschan-docs/):
- API docs improvements, now includes csrf token, posting, post actions (and mod variants), and more. It should be enough documentation for somebody to write a mobile app integration.
- [globalafk](https://gitgud.io/fatchan/globalafk/) (my fork):
- On android with termux, tapping the notification will open the post (in mod view) and the notification has new shortcut buttons to quickly delete, delete+ban or delete+global ban.
#### 0.1.1
- Added changelog
- Version now changes with some kind of meaning
- Animated gif thumbnails no longer generate static image for images < thumbnail dimensions
- Boards management "Banners" page is now "Assets"
- Boards can have custom flags

@ -4,7 +4,7 @@ Thanks for considering contributing.
Some links:
* [Kanban board](https://gitgud.io/fatchan/jschan/-/boards/4780) already has issues in swim lanes.
* IRC: [irc.fatpeople.lol #fatchan](ircs://irc.fatpeople.lol:6697/fatchan)
* IRC: [irc.fatpeople.lol #general](ircs://irc.fatpeople.lol:6697/general)
## LICENSE?

@ -5,7 +5,7 @@ Demo/test instance: [Clearnet](https://fatchan.org), [Tor hidden service](http:/
API documentation: [fatchan/jschan-docs](https://gitgud.io/fatchan/jschan-docs/) - Gitgud pages link: http://fatchan.gitgud.site/jschan-docs/#introduction
Join the IRC: [irc.fatpeople.lol](ircs://irc.fatpeople.lol:6697/fatchan)
Join the IRC: [irc.fatpeople.lol](ircs://irc.fatpeople.lol:6697/general)
## Goals
- Oldschool look, newschool features

@ -3,6 +3,7 @@
const removeBans = require(__dirname+'/../../models/forms/removebans.js')
, dynamicResponse = require(__dirname+'/../../helpers/dynamic.js')
, denyAppeals = require(__dirname+'/../../models/forms/denybanappeals.js')
, editBans = require(__dirname+'/../../models/forms/editbans.js')
, paramConverter = require(__dirname+'/../../helpers/paramconverter.js')
, { checkSchema, lengthBody, numberBody, minmaxBody, numberBodyVariable,
inArrayBody, arrayInBody, existsBody } = require(__dirname+'/../../helpers/schema.js');
@ -10,6 +11,7 @@ const removeBans = require(__dirname+'/../../models/forms/removebans.js')
module.exports = {
paramConverter: paramConverter({
timeFields: ['ban_duration'],
trimFields: ['option'],
allowedArrays: ['checkedbans'],
objectIdArrays: ['checkedbans']
@ -19,7 +21,8 @@ module.exports = {
const errors = await checkSchema([
{ result: lengthBody(req.body.checkedbans, 1), expected: false, error: 'Must select at least one ban' },
{ result: inArrayBody(req.body.option, ['unban', 'deny_appeal']), expected: true, error: 'Invalid ban action' },
{ result: inArrayBody(req.body.option, ['unban', 'edit', 'deny_appeal']), expected: true, error: 'Invalid ban action' },
{ result: req.body.option !== 'edit' || numberBody(req.body.ban_duration, 1), expected: true, error: 'Invalid ban duration' },
]);
const redirect = req.params.board ? `/${req.params.board}/manage/bans.html` : '/globalmanage/bans.html';
@ -35,12 +38,21 @@ module.exports = {
let amount = 0;
let message;
try {
if (req.body.option === 'unban') {
amount = await removeBans(req, res, next);
message = `Removed ${amount} bans`;
} else {
amount = await denyAppeals(req, res, next);
message = `Denied ${amount} appeals`;
switch(req.body.option) {
case 'unban':
amount = await removeBans(req, res, next);
message = `Removed ${amount} bans`;
break;
case 'deny_appeal':
amount = await denyAppeals(req, res, next);
message = `Denied ${amount} appeals`;
break;
case 'edit': //could do other properties in future
amount = await editBans(req, res, next);
message = `Edited ${amount} bans`;
break;
default:
throw 'Invalid ban action'; //should never happen anyway
}
} catch (err) {
return next(err);

@ -92,6 +92,19 @@ module.exports = {
});
},
editDuration: (board, ids, newExpireAt) => {
return db.updateMany({
'board': board,
'_id': {
'$in': ids
},
}, {
'$set': {
'expireAt': newExpireAt,
}
});
},
removeMany: (board, ids) => {
return db.deleteMany({
'board': board,

@ -0,0 +1,11 @@
'use strict';
const { Bans } = require(__dirname+'/../../db/');
module.exports = async (req, res, next) => {
//New ban expiry date is current date + ban_duration. Not based on the original ban issue date.
const newExpireAt = new Date(Date.now() + req.body.ban_duration);
return Bans.editDuration(req.params.board, req.body.checkedbans, newExpireAt).then(result => result.modifiedCount);
}

55
package-lock.json generated

@ -1,12 +1,12 @@
{
"name": "jschan",
"version": "0.2.0",
"version": "0.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "jschan",
"version": "0.2.0",
"version": "0.3.0",
"license": "AGPL-3.0-only",
"dependencies": {
"@fatchan/express-fileupload": "^1.3.1",
@ -492,8 +492,6 @@
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"optional": true,
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@ -501,6 +499,14 @@
"node": ">=0.4.0"
}
},
"node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/agent-base": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
@ -3352,9 +3358,9 @@
}
},
"node_modules/follow-redirects": {
"version": "1.14.7",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==",
"funding": [
{
"type": "individual",
@ -9721,9 +9727,13 @@
}
},
"node_modules/vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng==",
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"dependencies": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
},
"bin": {
"vm2": "bin/vm2"
},
@ -10390,9 +10400,12 @@
"acorn": {
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz",
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==",
"optional": true,
"peer": true
"integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ=="
},
"acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA=="
},
"agent-base": {
"version": "6.0.2",
@ -12629,9 +12642,9 @@
}
},
"follow-redirects": {
"version": "1.14.7",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ=="
"version": "1.14.8",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz",
"integrity": "sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA=="
},
"for-each": {
"version": "0.3.3",
@ -17577,9 +17590,13 @@
}
},
"vm2": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.5.tgz",
"integrity": "sha512-LuCAHZN75H9tdrAiLFf030oW7nJV5xwNMuk1ymOZwopmuK3d2H4L1Kv4+GFHgarKiLfXXLFU+7LDABHnwOkWng=="
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.7.tgz",
"integrity": "sha512-g/GZ7V0Mlmch3eDVOATvAXr1GsJNg6kQ5PjvYy3HbJMCRn5slNbo/u73Uy7r5yUej1cRa3ZjtoVwcWSQuQ/fow==",
"requires": {
"acorn": "^8.7.0",
"acorn-walk": "^8.2.0"
}
},
"void-elements": {
"version": "3.1.0",

@ -1,6 +1,6 @@
{
"name": "jschan",
"version": "0.2.0",
"version": "0.3.0",
"migrateVersion": "0.2.0",
"description": "",
"main": "server.js",

@ -14,5 +14,10 @@ else
.label Deny Appeal
label.postform-style.ph-5
input(type='radio' name='option' value='deny_appeal')
.row
.label Edit Duration
label.postform-style.ph-5.mr-1
input(type='radio' name='option' value='edit')
input(type='text' name='ban_duration' placeholder='Ban duration e.g. 7d' autocomplete='off')
input(type='submit' value='submit')

@ -53,7 +53,10 @@ block content
for post in thread.replies
- uids && post.userId && uids.add(post.userId)
+post(post)
a.bottom-reply.no-decoration.post-button(href='#postform') [New Reply]
if thread.replyposts >= board.settings.replyLimit && !thread.cyclic && !modview
p.title.text-center ⊖ Thread has reached reply limit.
else
a.bottom-reply.no-decoration.post-button(href='#postform') [New Reply]
hr(size=1)
.wrapbar
if modview

Loading…
Cancel
Save