uga aga
This commit is contained in:
@@ -168,6 +168,32 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
|
|||||||
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
||||||
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); }
|
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); }
|
||||||
setTimeout(() => { _active.delete(jobId); _sync(); }, 350);
|
setTimeout(() => { _active.delete(jobId); _sync(); }, 350);
|
||||||
|
|
||||||
|
const itemId = notif.item_id;
|
||||||
|
if (itemId && window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||||
|
const grid = document.querySelector('.posts');
|
||||||
|
if (grid && !grid.querySelector(`a[href$="/${itemId}"]`)) {
|
||||||
|
fetch(`/api/v2/item/${itemId}`)
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(res => {
|
||||||
|
if (res && res.success && res.rows) {
|
||||||
|
const item = res.rows;
|
||||||
|
window.NotificationSystemInstance.handleNewItem({
|
||||||
|
id: item.id,
|
||||||
|
dest: item.dest,
|
||||||
|
mime: item.mime,
|
||||||
|
username: item.username,
|
||||||
|
display_name: item.display_name || null,
|
||||||
|
tag_id: item.rating_tag_id || item.tag_id || 0,
|
||||||
|
is_oc: !!item.is_oc,
|
||||||
|
slug: item.slug,
|
||||||
|
visibility: item.visibility || 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error('[UrlTracker] Failed to fetch item for live injection:', err));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Failure: update the row to show the error, keep until user closes
|
// Failure: update the row to show the error, keep until user closes
|
||||||
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
||||||
|
|||||||
@@ -807,8 +807,8 @@ export default router => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast new_item event for live grid updates (only if auto-approved and public)
|
// Broadcast new_item event for live grid updates (only if auto-approved)
|
||||||
if (!isApprovalRequired && targetVisibility === 0) {
|
if (!isApprovalRequired) {
|
||||||
try {
|
try {
|
||||||
await db`SELECT pg_notify('new_item', ${JSON.stringify({
|
await db`SELECT pg_notify('new_item', ${JSON.stringify({
|
||||||
id: itemid,
|
id: itemid,
|
||||||
@@ -817,7 +817,9 @@ export default router => {
|
|||||||
username: session.user,
|
username: session.user,
|
||||||
display_name: session.display_name || null,
|
display_name: session.display_name || null,
|
||||||
tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0,
|
tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0,
|
||||||
is_oc: !!is_oc
|
is_oc: !!is_oc,
|
||||||
|
slug: itemSlug,
|
||||||
|
visibility: targetVisibility
|
||||||
})})`;
|
})})`;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[UPLOAD-URL] new_item notify failed:', err);
|
console.error('[UPLOAD-URL] new_item notify failed:', err);
|
||||||
|
|||||||
@@ -213,11 +213,14 @@ db.listen('motd', (payload) => {
|
|||||||
db.listen('new_item', (payload) => {
|
db.listen('new_item', (payload) => {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(payload);
|
const data = JSON.parse(payload);
|
||||||
if (data.visibility && data.visibility !== 0) return;
|
const itemVis = data.visibility || 0;
|
||||||
console.log(`[SSE] Broadcasting new_item (id: ${data.id}) to ${clients.size} clients`);
|
console.log(`[SSE] Broadcasting new_item (id: ${data.id}, visibility: ${itemVis}) to connected clients`);
|
||||||
for (const client of clients) {
|
for (const client of clients) {
|
||||||
|
const isOwner = client.username && data.username && client.username.toLowerCase() === data.username.toLowerCase();
|
||||||
|
if (itemVis === 0 || isOwner) {
|
||||||
client.send({ type: 'new_item', data });
|
client.send({ type: 'new_item', data });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('New item broadcast error:', e);
|
console.error('New item broadcast error:', e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -754,8 +754,8 @@ export const handleUpload = async (req, res, self) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast new_item event for live grid updates (only if auto-approved and public)
|
// Broadcast new_item event for live grid updates (only if auto-approved)
|
||||||
if (!manualApproval && targetVisibility === 0) {
|
if (!manualApproval) {
|
||||||
try {
|
try {
|
||||||
await db`SELECT pg_notify('new_item', ${JSON.stringify({
|
await db`SELECT pg_notify('new_item', ${JSON.stringify({
|
||||||
id: itemid,
|
id: itemid,
|
||||||
@@ -764,7 +764,9 @@ export const handleUpload = async (req, res, self) => {
|
|||||||
username: req.session.user,
|
username: req.session.user,
|
||||||
display_name: req.session.display_name || null,
|
display_name: req.session.display_name || null,
|
||||||
tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0,
|
tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0,
|
||||||
is_oc: !!is_oc
|
is_oc: !!is_oc,
|
||||||
|
slug: itemSlug,
|
||||||
|
visibility: targetVisibility
|
||||||
})})`;
|
})})`;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[UPLOAD] new_item notify failed:', err);
|
console.error('[UPLOAD] new_item notify failed:', err);
|
||||||
|
|||||||
Reference in New Issue
Block a user