generate blur thumbnail for all items!
This commit is contained in:
@@ -1082,12 +1082,10 @@ export default router => {
|
||||
VALUES (${itemid}, ${newRatingId}, ${req.session.id})
|
||||
`;
|
||||
|
||||
// If switching to NSFW/NSFL, ensure blurred thumbnail exists
|
||||
if (newRatingId === 2 || newRatingId === nsfl_id) {
|
||||
await queue.genBlurredThumbnail(itemid).catch(err => {
|
||||
console.error(`[RATING_TOGGLE] Blurred thumbnail generation failed for ${itemid}:`, err);
|
||||
});
|
||||
}
|
||||
// Ensure blurred thumbnail exists
|
||||
await queue.genBlurredThumbnail(itemid).catch(err => {
|
||||
console.error(`[RATING_TOGGLE] Blurred thumbnail generation failed for ${itemid}:`, err);
|
||||
});
|
||||
});
|
||||
|
||||
const newRating = newRatingId === 1 ? 'sfw' : (newRatingId === 2 ? 'nsfw' : 'nsfl');
|
||||
|
||||
@@ -115,14 +115,12 @@ export default router => {
|
||||
await db`INSERT INTO tags_assign ${db({ tag_id: nextTagId, item_id: postid, user_id: +req.session.id })}`;
|
||||
}
|
||||
|
||||
// Automatically generate blurred thumbnail if cycling TO NSFW or NSFL
|
||||
if (nextTagId === 2 || nextTagId === nsflId) {
|
||||
const blurPath = path.join(cfg.paths.t, `${postid}_blur.webp`);
|
||||
try {
|
||||
await fs.promises.access(blurPath);
|
||||
} catch {
|
||||
await queue.genBlurredThumbnail(postid, false);
|
||||
}
|
||||
// Automatically generate/verify blurred thumbnail on cycle
|
||||
const blurPath = path.join(cfg.paths.t, `${postid}_blur.webp`);
|
||||
try {
|
||||
await fs.promises.access(blurPath);
|
||||
} catch {
|
||||
await queue.genBlurredThumbnail(postid, false);
|
||||
}
|
||||
|
||||
const labels = { 1: { label: 'SFW', cls: 'sfw' }, 2: { label: 'NSFW', cls: 'nsfw' }, [nsflId]: { label: 'NSFL', cls: 'nsfl' } };
|
||||
@@ -180,16 +178,13 @@ export default router => {
|
||||
|
||||
await audit.log(req.session.id, 'toggle_tag', 'item', postid, auditDetails);
|
||||
|
||||
// Generate blurred thumbnail if toggling TO NSFW
|
||||
if (hasSFW && !hasNSFW) {
|
||||
// Was SFW, now NSFW - check if blur exists and generate if not
|
||||
const blurPath = path.join(cfg.paths.t, `${postid}_blur.webp`);
|
||||
try {
|
||||
await fs.promises.access(blurPath);
|
||||
} catch {
|
||||
// Doesn't exist - generate it
|
||||
await queue.genBlurredThumbnail(postid, false);
|
||||
}
|
||||
// Ensure blurred thumbnail exists on toggle
|
||||
const blurPath = path.join(cfg.paths.t, `${postid}_blur.webp`);
|
||||
try {
|
||||
await fs.promises.access(blurPath);
|
||||
} catch {
|
||||
// Doesn't exist - generate it
|
||||
await queue.genBlurredThumbnail(postid, false);
|
||||
}
|
||||
|
||||
const freshTags = await lib.getTags(postid);
|
||||
|
||||
@@ -301,9 +301,7 @@ export default router => {
|
||||
if (effectiveRating) {
|
||||
const ratingTagId = effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3));
|
||||
await db`insert into tags_assign ${db({ item_id: itemid, tag_id: ratingTagId, user_id: req.session.id })} on conflict do nothing`;
|
||||
if (effectiveRating === 'nsfw' || effectiveRating === 'nsfl') {
|
||||
await queue.genBlurredThumbnail(itemid, isApprovalRequired).catch(() => {});
|
||||
}
|
||||
await queue.genBlurredThumbnail(itemid, isApprovalRequired).catch(() => {});
|
||||
}
|
||||
|
||||
// Assign user tags + auto-tags
|
||||
@@ -575,7 +573,7 @@ export default router => {
|
||||
|
||||
try {
|
||||
await queue.genThumbnail(filename, mime, itemid, url, isApprovalRequired);
|
||||
if (effectiveRating === 'nsfw' || effectiveRating === 'nsfl') await queue.genBlurredThumbnail(itemid, isApprovalRequired);
|
||||
await queue.genBlurredThumbnail(itemid, isApprovalRequired);
|
||||
} catch (err) {
|
||||
const tDir = isApprovalRequired ? path.join(cfg.paths.pending, 't') : cfg.paths.t;
|
||||
await queue.spawn('magick', ['-size', '128x128', 'xc:#1a1a1a', path.join(tDir, `${itemid}.webp`)]).catch(() => {});
|
||||
|
||||
@@ -449,7 +449,7 @@ export default (router) => {
|
||||
// Process thumbnail
|
||||
try {
|
||||
await queue.genThumbnail(filename, mime, itemid, url, isApprovalRequired);
|
||||
if (rating === 'nsfw' || rating === 'nsfl') await queue.genBlurredThumbnail(itemid, isApprovalRequired);
|
||||
await queue.genBlurredThumbnail(itemid, isApprovalRequired);
|
||||
} catch (err) {
|
||||
console.error('[REHOST] Thumbnail error:', err);
|
||||
}
|
||||
|
||||
@@ -705,7 +705,7 @@ export default async bot => {
|
||||
// Generate Thumbnail
|
||||
try {
|
||||
await queue.genThumbnail(filename, mime, itemid, link, manualApproval);
|
||||
if (isNSFW) await queue.genBlurredThumbnail(itemid, manualApproval);
|
||||
await queue.genBlurredThumbnail(itemid, manualApproval);
|
||||
} catch (err) {
|
||||
const tDir = manualApproval ? path.join(cfg.paths.pending, 't') : cfg.paths.t;
|
||||
await queue.spawn('magick', ['./mugge.png', path.join(tDir, `${itemid}.webp`)]);
|
||||
@@ -815,7 +815,7 @@ export default async bot => {
|
||||
// Generate Thumbnail
|
||||
try {
|
||||
await queue.genThumbnail(filename, mime, itemid, link, manualApproval);
|
||||
if (isNSFW) await queue.genBlurredThumbnail(itemid, manualApproval);
|
||||
await queue.genBlurredThumbnail(itemid, manualApproval);
|
||||
} catch (err) {
|
||||
const tDir = manualApproval ? path.join(cfg.paths.pending, 't') : cfg.paths.t;
|
||||
await queue.spawn('magick', ['./mugge.png', path.join(tDir, `${itemid}.webp`)]);
|
||||
|
||||
Reference in New Issue
Block a user