cyclical threads, fix trying empty bulkwrite in deleteposts, fix missing thumbs in catalog tiles

merge-requests/208/head
fatchan 5 years ago
parent dc3005a3db
commit 4bf56fdc3b
  1. 4
      db/posts.js
  2. 4
      gulp/res/img/cyclic.svg
  3. 1
      helpers/checks/actionchecker.js
  4. 1
      helpers/posting/quotes.js
  5. 4
      models/forms/deletepost.js
  6. 18
      models/forms/makepost.js
  7. 3
      views/includes/actionfooter.pug
  8. 17
      views/mixins/catalogtile.pug
  9. 7
      views/mixins/post.pug

@ -274,7 +274,7 @@ module.exports = {
if (data.thread !== null) { if (data.thread !== null) {
const filter = { const filter = {
'postId': data.thread, 'postId': data.thread,
'board': board 'board': board._id
} }
//update thread reply and reply file count //update thread reply and reply file count
const query = { const query = {
@ -297,7 +297,7 @@ module.exports = {
} }
//get the postId and add it to the post //get the postId and add it to the post
const postId = await Boards.getNextId(board); const postId = await Boards.getNextId(board._id);
data.postId = postId; data.postId = postId;
//insert the post itself //insert the post itself

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="24" height="24"
viewBox="0 0 24 24"
style="enable-background:new 0 0 24 24;; fill:#f00;"><polygon points="11,6 11,0 14,3 "></polygon><polygon points="13,18 13,24 10,21 "></polygon><polygon points="18,11 24,11 21,14 "></polygon><g> <path d="M5.079,8C6.463,5.611,9.041,4,12,4c0.339,0,0.672,0.028,1,0.069V2.05C12.671,2.018,12.338,2,12,2C7.9,2,4.381,4.47,2.838,8 H5.079z"></path> <path d="M16,5.079c2.389,1.384,4,3.962,4,6.921c0,0.339-0.028,0.672-0.069,1h2.019c0.033-0.329,0.05-0.662,0.05-1 c0-4.1-2.47-7.619-6-9.162V5.079z"></path> <path d="M8,18.921C5.611,17.537,4,14.959,4,12c0-0.339,0.028-0.672,0.069-1H2.05C2.018,11.329,2,11.662,2,12 c0,4.1,2.47,7.619,6,9.162V18.921z"></path> <path d="M18.921,16c-1.384,2.389-3.962,4-6.921,4c-0.339,0-0.672-0.028-1-0.069v2.019c0.329,0.033,0.662,0.05,1,0.05 c4.1,0,7.619-2.47,9.162-6H18.921z"></path></g><polygon points="6,13 0,13 3,10 "></polygon></svg>

After

Width:  |  Height:  |  Size: 956 B

@ -7,6 +7,7 @@ const actions = [
{name:'delete', global:true, auth:false, passwords:true, build:true}, {name:'delete', global:true, auth:false, passwords:true, build:true},
{name:'lock', global:false, auth:true, passwords:false, build:true}, {name:'lock', global:false, auth:true, passwords:false, build:true},
{name:'sticky', global:false, auth:true, passwords:false, build:true}, {name:'sticky', global:false, auth:true, passwords:false, build:true},
{name:'cyclic', global:false, auth:true, passwords:false, build:true},
{name:'sage', global:false, auth:true, passwords:false, build:true}, {name:'sage', global:false, auth:true, passwords:false, build:true},
{name:'report', global:false, auth:false, passwords:false, build:false}, {name:'report', global:false, auth:false, passwords:false, build:false},
{name:'global_report', global:false, auth:false, passwords:false, build:false}, {name:'global_report', global:false, auth:false, passwords:false, build:false},

@ -26,6 +26,7 @@ module.exports = async (board, text, thread) => {
} }
}); });
} }
if (crossQuotes) { if (crossQuotes) {
for (let i = 0; i < crossQuotes.length; i++) { for (let i = 0; i < crossQuotes.length; i++) {
const crossQuote = crossQuotes[i].split('/'); const crossQuote = crossQuotes[i].split('/');

@ -73,7 +73,9 @@ module.exports = async (posts, board) => {
}); });
} }
} }
await Posts.db.bulkWrite(bulkWrites); if (bulkWrites.length > 0) {
await Posts.db.bulkWrite(bulkWrites);
}
//TODO: remarkup to unlink quotes in posts that quote deleted posts //TODO: remarkup to unlink quotes in posts that quote deleted posts
//TODO: file ref counting decrement, oncei implement counting in make post //TODO: file ref counting decrement, oncei implement counting in make post

@ -58,7 +58,7 @@ module.exports = async (req, res, next) => {
'redirect': redirect 'redirect': redirect
}); });
} }
if (thread.replyposts >= res.locals.board.settings.replyLimit) { //reply limit if (thread.replyposts >= res.locals.board.settings.replyLimit && !thread.cyclic) { //reply limit
await deleteTempFiles(req).catch(e => console.error); await deleteTempFiles(req).catch(e => console.error);
return res.status(400).render('message', { return res.status(400).render('message', {
'title': 'Bad request', 'title': 'Bad request',
@ -263,11 +263,25 @@ module.exports = async (req, res, next) => {
'sticky': false, 'sticky': false,
'locked': false, 'locked': false,
'saged': false, 'saged': false,
'cyclic': false,
'salt': salt 'salt': salt
}); });
} }
const postId = await Posts.insertOne(req.params.board, data, thread); const postId = await Posts.insertOne(res.locals.board, data, thread);
//for cyclic threads, delete posts beyond bump limit
if (thread && thread.cyclic && thread.replyposts > res.locals.board.settings.replyLimit) {
//is there a way to NOT have to fetch before deleting for this?
const cyclicOverflowPosts = await Posts.db.find({
'thread': data.thread,
'board': req.params.board
}).sort({
'postId': -1,
}).skip(res.locals.board.settings.replyLimit).toArray();
await deletePosts(cyclicOverflowPosts, req.params.board);
}
const successRedirect = `/${req.params.board}/thread/${req.body.thread || postId}.html#${postId}`; const successRedirect = `/${req.params.board}/thread/${req.body.thread || postId}.html#${postId}`;
console.log('--------------------------------'); console.log('--------------------------------');
console.log(`NEW POST -> ${successRedirect}`); console.log(`NEW POST -> ${successRedirect}`);

@ -41,6 +41,9 @@ details.toggle-label
label label
input.post-check(type='checkbox', name='sage' value=1) input.post-check(type='checkbox', name='sage' value=1)
| Sage | Sage
label
input.post-check(type='checkbox', name='cyclic' value=1)
| Cycle
label label
input.post-check(type='checkbox', name='ban' value=1) input.post-check(type='checkbox', name='ban' value=1)
| Ban Poster | Ban Poster

@ -3,13 +3,16 @@ mixin catalogtile(board, post, index)
- const postURL = `/${board._id}/thread/${post.postId}.html#${post.postId}` - const postURL = `/${board._id}/thread/${post.postId}.html#${post.postId}`
header.post-info header.post-info
if post.sticky if post.sticky
img(src='/img/sticky.svg' height='12') img(src='/img/sticky.svg' height='12' title='Sticky')
| |
if post.saged if post.saged
img(src='/img/saged.svg' height='12') img(src='/img/saged.svg' height='12' title='Bumplocked')
| |
if post.locked if post.locked
img(src='/img/locked.svg' height='12') img(src='/img/locked.svg' height='12' title='Locked')
|
if post.cyclic
img(src='/img/cyclic.svg' height='13' title='Cyclic')
| |
a.no-decoration.post-subject(href=postURL) #{post.subject || '#'+post.postId} a.no-decoration.post-subject(href=postURL) #{post.subject || '#'+post.postId}
| - | -
@ -24,7 +27,11 @@ mixin catalogtile(board, post, index)
if post.spoiler if post.spoiler
img.catalog-thumb(src='/img/spoiler.png' width='64' height='64') img.catalog-thumb(src='/img/spoiler.png' width='64' height='64')
else else
object.catalog-thumb(data=`/img/thumb-${post.files[0].filename.split('.')[0]}.jpg` width='64' height='64') if post.files[0].hasThumb
img(src='/img/deleted.png' width='64' height='64') object.catalog-thumb(data=`/img/thumb-${post.files[0].filename.split('.')[0]}.jpg` width='64' height='64')
img(src='/img/deleted.png' width='64' height='64')
else
object.catalog-thumb(data=`/img/${post.files[0].filename}` width='64' height='64')
img(src='/img/deleted.png' width='64' height='64')
if post.message if post.message
pre.no-m-p.post-message !{post.message} pre.no-m-p.post-message !{post.message}

@ -10,14 +10,17 @@ mixin post(post, truncate, manage=false, globalmanage=false)
| |
if !post.thread if !post.thread
if post.sticky if post.sticky
img(src='/img/sticky.svg' height='12' title='Stickied') img(src='/img/sticky.svg' height='12' title='Sticky')
| |
if post.saged if post.saged
img(src='/img/saged.svg' height='12' title='Permasaged') img(src='/img/saged.svg' height='12' title='Bumplocked')
| |
if post.locked if post.locked
img(src='/img/locked.svg' height='12' title='Locked') img(src='/img/locked.svg' height='12' title='Locked')
| |
if post.cyclic
img(src='/img/cyclic.svg' height='13' title='Cyclic')
|
if post.subject if post.subject
span.post-subject #{post.subject} span.post-subject #{post.subject}
| |

Loading…
Cancel
Save