Thomas Lynch 3 years ago
parent 8aecabc905
commit 888d134b5f
No known key found for this signature in database
GPG Key ID: 36A72F7C62CF8480
  1. 6
      gulp/res/css/style.css
  2. 2
      gulp/res/js/filters.js
  3. 13
      gulp/res/js/live.js
  4. 26
      models/forms/deletepost.js
  5. 10
      models/forms/makepost.js

@ -1026,6 +1026,12 @@ input:invalid, textarea:invalid {
background: none; background: none;
} }
.deleted .post-info::before {
content: "Deleted ";
font-weight: bold;
color: var(--title-color);
}
.anchor:target + .post-container, .anchor:target + .post-container,
.anchor:target + .catalog-tile, .anchor:target + .catalog-tile,
.post-container.highlighted, .post-container.highlighted,

@ -77,7 +77,7 @@ const togglePostsHidden = (posts, state, single) => {
} else { } else {
elem.classList['add']('hidden'); elem.classList['add']('hidden');
} }
elem.querySelector('.postmenu').children[0].textContent = (showing ? 'Hide' : 'Show'); elem.querySelector('.postmenu').children[0].textContent = (showing ? 'Hide' : 'Show');
} }
}; };

@ -26,6 +26,18 @@ window.addEventListener('settingsReady', function(event) { //after domcontentloa
lastPostIds[board] = Math.max((lastPostIds[board] || 0), postId); lastPostIds[board] = Math.max((lastPostIds[board] || 0), postId);
} }
//add "deleted" title text to posts to show it was deleted
const deletePost = (data) {
console.log('got delete post message', data);
const anchor = document.getElementById(data.postId);
const postContainer = anchor.nextSibling;
postContainer.classList.add('deleted');
if (postContainer.classList.contains('op')) {
//OP was deleted, os every post in the thread is "deleted". hide new reply buttons (and disconnect socket)
//todo...
}
};
const newPost = (data) => { const newPost = (data) => {
//insert at end of thread, but insert at top for globalmanage //insert at end of thread, but insert at top for globalmanage
console.log('got new post', data); console.log('got new post', data);
@ -236,6 +248,7 @@ window.addEventListener('settingsReady', function(event) { //after domcontentloa
enableLive(); enableLive();
}); });
socket.on('newPost', newPost); socket.on('newPost', newPost);
socket.on('deletePost', deletePost);
} else { } else {
//websocket not supported, update with polling to api //websocket not supported, update with polling to api
updateButton.removeAttribute('style'); updateButton.removeAttribute('style');

@ -35,7 +35,7 @@ module.exports = async (posts, board, all=false) => {
threadPosts = await Posts.getMultipleThreadPosts(board, threadPostIds); threadPosts = await Posts.getMultipleThreadPosts(board, threadPostIds);
} else { } else {
//otherwise we fetch posts from threads on different boards separarely //otherwise we fetch posts from threads on different boards separarely
//TODO: use big board:$or/postid:$in query so this can be tackled in a single db query //TODO: use big board:$or/postid:$in query so this can be tackled in a single db query
await Promise.all(threads.map(async thread => { await Promise.all(threads.map(async thread => {
//for each thread, fetch all posts from the matching board and thread matching the threads postId //for each thread, fetch all posts from the matching board and thread matching the threads postId
const currentThreadPosts = await Posts.getThreadPosts(thread.board, thread.postId); const currentThreadPosts = await Posts.getThreadPosts(thread.board, thread.postId);
@ -61,7 +61,7 @@ module.exports = async (posts, board, all=false) => {
if (postFiles.length > 0) { if (postFiles.length > 0) {
const fileNames = postFiles.map(x => x.filename)//[...new Set(postFiles.map(x => x.filename))]; const fileNames = postFiles.map(x => x.filename)//[...new Set(postFiles.map(x => x.filename))];
await Files.decrement(fileNames); await Files.decrement(fileNames);
if (pruneImmediately) { if (pruneImmediately) {
await pruneFiles(fileNames); await pruneFiles(fileNames);
} }
@ -112,6 +112,8 @@ module.exports = async (posts, board, all=false) => {
//deleting before remarkup so quotes are accurate //deleting before remarkup so quotes are accurate
const deletedPosts = await Posts.deleteMany(postMongoIds).then(result => result.deletedCount); const deletedPosts = await Posts.deleteMany(postMongoIds).then(result => result.deletedCount);
//emit the deletes to thread sockets (not recent sockets [yet?])
//Socketio.emitRoom(`board-thread`, 'deletePost', {postId:xxx});
if (all === false) { if (all === false) {
//get posts that quoted deleted posts so we can remarkup them //get posts that quoted deleted posts so we can remarkup them
@ -125,18 +127,18 @@ module.exports = async (posts, board, all=false) => {
message = sanitize(quotedMessage, sanitizeOptions.after); message = sanitize(quotedMessage, sanitizeOptions.after);
bulkWrites.push({ bulkWrites.push({
'updateOne': { 'updateOne': {
'filter': { 'filter': {
'_id': post._id '_id': post._id
}, },
'update': { 'update': {
'$set': { '$set': {
'quotes': threadQuotes, 'quotes': threadQuotes,
'crossquotes': crossQuotes, 'crossquotes': crossQuotes,
'message': message 'message': message
} }
} }
} }
}); });
} }
})); }));
} }

@ -34,7 +34,7 @@ const path = require('path')
module.exports = async (req, res, next) => { module.exports = async (req, res, next) => {
const { checkRealMimeTypes, thumbSize, thumbExtension, videoThumbPercentage, const { checkRealMimeTypes, thumbSize, thumbExtension, videoThumbPercentage,
strictFiltering, animatedGifThumbnails, audioThumbnails } = config.get; strictFiltering, animatedGifThumbnails, audioThumbnails, ipHashPermLevel } = config.get;
//spam/flood check //spam/flood check
const flood = await spamCheck(req, res); const flood = await spamCheck(req, res);
@ -614,9 +614,13 @@ ${res.locals.numFiles > 0 ? req.files.file.map(f => f.name+'|'+(f.phash || '')).
const { raw, single } = data.ip; const { raw, single } = data.ip;
//but emit it to manage pages because they need to get all posts through socket including thread //but emit it to manage pages because they need to get all posts through socket including thread
Socketio.emitRoom('globalmanage-recent-hashed', 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw: null } }); Socketio.emitRoom('globalmanage-recent-hashed', 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw: null } });
Socketio.emitRoom('globalmanage-recent-raw', 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw } });
Socketio.emitRoom(`${res.locals.board._id}-manage-recent-hashed`, 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw: null } }); Socketio.emitRoom(`${res.locals.board._id}-manage-recent-hashed`, 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw: null } });
Socketio.emitRoom(`${res.locals.board._id}-manage-recent-raw`, 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw } }); if (ipHashPermLevel > -1) {
//small optimisation for boards where this is manually set to -1 for privacy, no need to emit to rooms that cant be accessed
//even if they are empty it will create extra communication noise in redis, socket adapter, etc.
Socketio.emitRoom('globalmanage-recent-raw', 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw } });
Socketio.emitRoom(`${res.locals.board._id}-manage-recent-raw`, 'newPost', { ...projectedPost, ip: { single: single.slice(-10), raw } });
}
//now add other pages to be built in background //now add other pages to be built in background
if (enableCaptcha) { if (enableCaptcha) {

Loading…
Cancel
Save