This commit is contained in:
2026-08-22 02:14:22 +02:00
parent 162a6bc0fc
commit 9377f05454
2 changed files with 40 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import { getEnableItemSlugs } from '../../settings.mjs';
import { applyWordFilter } from '../../wordfilter.mjs';
import queue from '../../queue.mjs';
import path from "path";
import f0cklib from "../../routeinc/f0cklib.mjs";
// ──────────────────────────────────────────────────────────────────────
// In-memory job progress map (keyed by jobId string)
@@ -503,6 +504,26 @@ export default router => {
}
}
// Broadcast new_item event for live grid updates (only if auto-approved)
if (!isApprovalRequired) {
f0cklib.clearCountCache();
try {
await db`SELECT pg_notify('new_item', ${JSON.stringify({
id: itemid,
dest: filename,
mime: 'video/youtube',
username: req.session.user,
display_name: req.session.display_name || null,
tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0,
is_oc: !!is_oc,
slug: itemSlug,
visibility: targetVisibility
})})`;
} catch (err) {
console.error('[UPLOAD-URL] YouTube new_item notify failed:', err);
}
}
return res.json({
success: true,
msg: isApprovalRequired ? 'YouTube video embedded! Pending admin approval.' : 'YouTube video embedded!',

View File

@@ -406,6 +406,25 @@ export const handleUpload = async (req, res, self) => {
}
}
if (!manualApproval) {
f0cklib.clearCountCache();
try {
await db`SELECT pg_notify('new_item', ${JSON.stringify({
id: itemid,
dest: filename,
mime: 'video/youtube',
username: req.session.user,
display_name: req.session.display_name || null,
tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0,
is_oc: !!is_oc,
slug: itemSlug,
visibility: targetVisibility
})})`;
} catch (err) {
console.error('[UPLOAD] YouTube new_item notify failed:', err);
}
}
const itemRoute = itemSlug ? `/${itemSlug}` : `/${itemid}`;
const successMsg = manualApproval ? 'Upload successful! Your upload is pending admin approval.' : 'Upload successful! Your upload is now live.';
return sendJson(res, {