jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
646 B

'use strict';
const imageHash = require('imghash').hash
, config = require(__dirname+'/../config.js');
module.exports = async (req, res, next) => {
const { hashImages } = config.get;
if (hashImages && res.locals.numFiles > 0 && res.locals.permLevel > 1) {
const hashPromises = [];
for (let i = 0; i < res.locals.numFiles; i++) {
const mainType = req.files.file[i].mimetype.split('/')[0];
if (mainType === 'image' || mainType === 'video') {
hashPromises.push(imageHash(req.files.file[i].tempFilePath, 8, 'hex').then(res => {
req.files.file[i].phash = res;
}));
}
}
await Promise.all(hashPromises);
}
next();
}