add IP based deleting to forms and form checker

merge-requests/208/head
fatchan 5 years ago
parent d6d9a1af38
commit 022b16cbd7
  1. 10
      controllers/forms.js
  2. 3
      helpers/actionchecker.js
  3. 9
      views/includes/actionfooter.pug
  4. 9
      views/includes/actionfooter_globalmanage.pug
  5. 3
      views/includes/actionfooter_manage.pug

@ -288,7 +288,7 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve
//make sure they checked 1-10 posts //make sure they checked 1-10 posts
if (!req.body.checkedposts || req.body.checkedposts.length === 0 || req.body.checkedposts.length > 10) { if (!req.body.checkedposts || req.body.checkedposts.length === 0 || req.body.checkedposts.length > 10) {
errors.push('Must select 1-10 posts') errors.push('Must select 1-10 posts');
} }
//get what type of actions //get what type of actions
@ -296,12 +296,12 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve
//make sure they selected at least 1 action //make sure they selected at least 1 action
if (!anyValid) { if (!anyValid) {
errors.push('No actions selected') errors.push('No actions selected');
} }
//check if they have permission to perform the actions //check if they have permission to perform the actions
const hasPerms = checkPerms(req, res); const hasPerms = checkPerms(req, res);
if(!hasPerms && anyAuthed) { if(!hasPerms && anyAuthed) {
errors.push('No permission') errors.push('No permission');
} }
//check that actions are valid //check that actions are valid
@ -315,7 +315,7 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve
errors.push('Ban reason must be 50 characters or less'); errors.push('Ban reason must be 50 characters or less');
} }
if ((req.body.report || req.body.global_report) && (!req.body.report_reason || req.body.report_reason.length === 0)) { if ((req.body.report || req.body.global_report) && (!req.body.report_reason || req.body.report_reason.length === 0)) {
errors.push('Reports must have a reason') errors.push('Reports must have a reason');
} }
if (errors.length > 0) { if (errors.length > 0) {
@ -382,6 +382,7 @@ router.post('/board/:board/actions', Boards.exists, banCheck, paramConverter, ve
messages.push(message); 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 (req.body.delete) {
const { message } = await deletePosts(req, res, next, passwordPosts, req.params.board); const { message } = await deletePosts(req, res, next, passwordPosts, req.params.board);
messages.push(message); messages.push(message);
@ -596,6 +597,7 @@ router.post('/global/actions', checkPermsMiddleware, paramConverter, async(req,
} }
messages.push(message); 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 (req.body.delete) {
const { message } = await deletePosts(req, res, next, posts); const { message } = await deletePosts(req, res, next, posts);
messages.push(message); messages.push(message);

@ -8,6 +8,9 @@ const actions = [
{name:'global_report', global:false, auth:false, passwords:false}, {name:'global_report', global:false, auth:false, passwords:false},
{name:'spoiler', global:true, auth:false, passwords:true}, {name:'spoiler', global:true, auth:false, passwords:true},
{name:'delete', 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_global', global:true, auth:true, passwords:false},
{name:'delete_file', global:true, auth:false, passwords:true}, {name:'delete_file', global:true, auth:false, passwords:true},
{name:'dismiss', global:false, auth:true, passwords:false}, {name:'dismiss', global:false, auth:true, passwords:false},
{name:'global_dismiss', global:true, auth:true, passwords:false}, {name:'global_dismiss', global:true, auth:true, passwords:false},

@ -24,6 +24,15 @@ label.toggle-label Toggle Post Actions
input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off') input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off')
.actions .actions
h4.no-m-p Mod 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
label label
input.post-check(type='checkbox', name='sticky' value=1) input.post-check(type='checkbox', name='sticky' value=1)
| Sticky | Sticky

@ -16,6 +16,15 @@ label.toggle-label Toggle Post Actions
input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off') input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off')
.actions .actions
h4.no-m-p Mod 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
label label
input.post-check(type='checkbox', name='global_dismiss' value=1) input.post-check(type='checkbox', name='global_dismiss' value=1)
| Dismiss Global Reports | Dismiss Global Reports

@ -21,6 +21,9 @@ label.toggle-label Toggle Post Actions
input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off') input#report(type='text', name='report_reason', placeholder='report reason' autocomplete='off')
.actions .actions
h4.no-m-p Mod Actions: h4.no-m-p Mod Actions:
label
input.post-check(type='checkbox', name='delete_ip_board' value=1)
| Delete IP+ board
label label
input.post-check(type='checkbox', name='dismiss' value=1) input.post-check(type='checkbox', name='dismiss' value=1)
| Dismiss Reports | Dismiss Reports

Loading…
Cancel
Save