From 363f4bd1b18956290fc2d1561c8efb52913f435f Mon Sep 17 00:00:00 2001 From: fatchan Date: Tue, 30 Apr 2019 06:53:28 +0000 Subject: [PATCH] add IP delete by board or global (no by-thread) --- controllers/forms.js | 34 +++++++++++++++++--- gulp/res/css/style.css | 5 ++- helpers/actionchecker.js | 3 +- views/includes/actionfooter.pug | 7 ++-- views/includes/actionfooter_globalmanage.pug | 8 +---- views/includes/actionfooter_manage.pug | 2 +- views/mixins/post.pug | 2 +- 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/controllers/forms.js b/controllers/forms.js index dacac6e5..5c9f3bb4 100644 --- a/controllers/forms.js +++ b/controllers/forms.js @@ -382,8 +382,23 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve messages.push(message); } } - //TODO: IP-based deletes here. will need to gather all thread/board/global posts by IP, then run them through deletePosts - if (req.body.delete) { + if (hasPerms && (req.body.delete_ip_board || req.body.delete_ip_global)) { + const deletePostIps = posts.map(x => x.ip); + let query = { + 'ip': { + '$in': deletePostIps + } + }; + if (req.body.delete_ip_board) { + query['board'] = req.params.board; + } + const deleteIpPosts = await Posts.db.find(query).toArray(); + if (deleteIpPosts && deleteIpPosts.length > 0) { + const { message } = await deletePosts(req, res, next, deleteIpPosts, req.params.board); + messages.push(message); + aggregateNeeded = true; + } + } else if (req.body.delete) { const { message } = await deletePosts(req, res, next, passwordPosts, req.params.board); messages.push(message); aggregateNeeded = true; @@ -597,8 +612,19 @@ router.post('/global/actions', checkPermsMiddleware, paramConverter, async(req, } messages.push(message); } - //TODO: IP-based deletes here. will need to gather all thread/board/global posts by IP, then run them through deletePosts - if (req.body.delete) { + if (hasPerms && req.body.delete_ip_global) { + const deletePostIps = posts.map(x => x.ip); + const deleteIpPosts = await Posts.db.find({ + 'ip': { + '$in': deletePostIps + } + }).toArray(); + if (deleteIpPosts && deleteIpPosts.length > 0) { + const { message } = await deletePosts(req, res, next, deleteIpPosts, null); + messages.push(message); + aggregateNeeded = true; + } + } else if (req.body.delete) { const { message } = await deletePosts(req, res, next, posts); messages.push(message); aggregateNeeded = true; diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index 6fe8418f..1d86ae05 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -45,10 +45,13 @@ body { margin: 10px 0; padding: 10px; } +a, a:visited { + text-decoration: underline; + color: #34345C; +} .pages a { text-decoration: none; - color: black; } object { diff --git a/helpers/actionchecker.js b/helpers/actionchecker.js index 784c2e13..10ab2486 100644 --- a/helpers/actionchecker.js +++ b/helpers/actionchecker.js @@ -8,8 +8,7 @@ const actions = [ {name:'global_report', global:false, auth:false, passwords:false}, {name:'spoiler', global:true, auth:false, passwords:true}, {name:'delete', global:true, auth:false, passwords:true}, - {name:'delete_ip_thread', global:true, auth:true, passwords:false}, - {name:'delete_ip_board', global:true, auth:true, passwords:false}, + {name:'delete_ip_board', global:false, auth:true, passwords:false}, {name:'delete_ip_global', global:true, auth:true, passwords:false}, {name:'delete_file', global:true, auth:false, passwords:true}, {name:'dismiss', global:false, auth:true, passwords:false}, diff --git a/views/includes/actionfooter.pug b/views/includes/actionfooter.pug index 3ea0aa20..1a1bf0ea 100644 --- a/views/includes/actionfooter.pug +++ b/views/includes/actionfooter.pug @@ -24,15 +24,12 @@ label.toggle-label Toggle Post Actions input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off') .actions h4.no-m-p Mod Actions: - label - input.post-check(type='checkbox', name='delete_ip_thread' value=1) - | Delete IP+ thread label input.post-check(type='checkbox', name='delete_ip_board' value=1) - | Delete IP+ board + | Delete from IP on board label input.post-check(type='checkbox', name='delete_ip_global' value=1) - | Delete IP+ global + | Delete from IP globally label input.post-check(type='checkbox', name='sticky' value=1) | Sticky diff --git a/views/includes/actionfooter_globalmanage.pug b/views/includes/actionfooter_globalmanage.pug index 6adec277..ef99d875 100644 --- a/views/includes/actionfooter_globalmanage.pug +++ b/views/includes/actionfooter_globalmanage.pug @@ -16,15 +16,9 @@ label.toggle-label Toggle Post Actions input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off') .actions h4.no-m-p Mod Actions: - label - input.post-check(type='checkbox', name='delete_ip_thread' value=1) - | Delete IP+ thread - label - input.post-check(type='checkbox', name='delete_ip_board' value=1) - | Delete IP+ board label input.post-check(type='checkbox', name='delete_ip_global' value=1) - | Delete IP+ global + | Delete from IP globally label input.post-check(type='checkbox', name='global_dismiss' value=1) | Dismiss Global Reports diff --git a/views/includes/actionfooter_manage.pug b/views/includes/actionfooter_manage.pug index d51d2c60..478d605a 100644 --- a/views/includes/actionfooter_manage.pug +++ b/views/includes/actionfooter_manage.pug @@ -23,7 +23,7 @@ label.toggle-label Toggle Post Actions h4.no-m-p Mod Actions: label input.post-check(type='checkbox', name='delete_ip_board' value=1) - | Delete IP+ board + | Delete from IP on board label input.post-check(type='checkbox', name='dismiss' value=1) | Dismiss Reports diff --git a/views/mixins/post.pug b/views/mixins/post.pug index 9ef4b3c2..555dcfdb 100644 --- a/views/mixins/post.pug +++ b/views/mixins/post.pug @@ -34,7 +34,7 @@ mixin post(post, truncate, manage=false, globalmanage=false) | span.user-id(style=`background: #${post.userId}`) #{post.userId} | - span: a(href=postURL) #{post.postId} + span: a(href=postURL) No.#{post.postId} .post-data if post.files.length > 0 .post-files