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;
}
.deleted .post-info::before {
content: "Deleted ";
font-weight: bold;
color: var(--title-color);
}
.anchor:target + .post-container,
.anchor:target + .catalog-tile,
.post-container.highlighted,

@ -77,7 +77,7 @@ const togglePostsHidden = (posts, state, single) => {
} else {
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);
}
//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) => {
//insert at end of thread, but insert at top for globalmanage
console.log('got new post', data);
@ -236,6 +248,7 @@ window.addEventListener('settingsReady', function(event) { //after domcontentloa
enableLive();
});
socket.on('newPost', newPost);
socket.on('deletePost', deletePost);
} else {
//websocket not supported, update with polling to api
updateButton.removeAttribute('style');

@ -35,7 +35,7 @@ module.exports = async (posts, board, all=false) => {
threadPosts = await Posts.getMultipleThreadPosts(board, threadPostIds);
} else {
//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 => {
//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);
@ -61,7 +61,7 @@ module.exports = async (posts, board, all=false) => {
if (postFiles.length > 0) {
const fileNames = postFiles.map(x => x.filename)//[...new Set(postFiles.map(x => x.filename))];
await Files.decrement(fileNames);
await Files.decrement(fileNames);
if (pruneImmediately) {
await pruneFiles(fileNames);
}
@ -112,6 +112,8 @@ module.exports = async (posts, board, all=false) => {
//deleting before remarkup so quotes are accurate
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) {
//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);
bulkWrites.push({
'updateOne': {
'filter': {
'_id': post._id
},
'update': {
'$set': {
'quotes': threadQuotes,
'filter': {
'_id': post._id
},
'update': {
'$set': {
'quotes': threadQuotes,
'crossquotes': crossQuotes,
'message': message
}
}
}
});
}
}
}
});
}
}));
}

@ -34,7 +34,7 @@ const path = require('path')
module.exports = async (req, res, next) => {
const { checkRealMimeTypes, thumbSize, thumbExtension, videoThumbPercentage,
strictFiltering, animatedGifThumbnails, audioThumbnails } = config.get;
strictFiltering, animatedGifThumbnails, audioThumbnails, ipHashPermLevel } = config.get;
//spam/flood check
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;
//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-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-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
if (enableCaptcha) {

Loading…
Cancel
Save