From 9377f05454d9da5e97fd659485099b78f5e9e84b Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Sat, 22 Aug 2026 02:14:22 +0200 Subject: [PATCH] hgfd --- src/inc/routes/apiv2/upload.mjs | 21 +++++++++++++++++++++ src/upload_handler.mjs | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/inc/routes/apiv2/upload.mjs b/src/inc/routes/apiv2/upload.mjs index b5c5e8d..5a708c0 100644 --- a/src/inc/routes/apiv2/upload.mjs +++ b/src/inc/routes/apiv2/upload.mjs @@ -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!', diff --git a/src/upload_handler.mjs b/src/upload_handler.mjs index d93ce02..f8b6be8 100644 --- a/src/upload_handler.mjs +++ b/src/upload_handler.mjs @@ -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, {