openvibers/openvibe.media Commits

/p/:slug/screenshot: a slug Media doesn't hold (pastes made in Community since the move) goes to Community like /p/:slug and /raw; a private one answers the same way. Hero-moment thumbnails linked here and showed broken images

OP OpenVibers committed 23 Sept 2026 · 9de4b2528d · 2 files, +13 −0


Changes

ddiff --git a/server/public/routes.js b/server/public/routes.js
iindex 5ed6e96..7454f69 100644
---- a/server/public/routes.js
++++ b/server/public/routes.js
@@@ -526,6 +526,13 @@ router.get('/p/:slug/raw', (req, res) => {
router.get('/p/:slug/screenshot', (req, res) => {
try {
const paste = db.getPasteBySlug(String(req.params.slug));
++ // Pastes made since the move live in Community only: send an unknown slug there, like
++ // /p/:slug and /p/:slug/raw (Community answers with the image, or its own 404). Stored
++ // hero-moment thumbnails pointed here and showed broken images.
++ if ((!paste || paste.visibility === 'private') && movedTo()) { // private answers like missing
++ res.set('Cache-Control', 'public, max-age=3600');
++ return res.redirect(301, `${movedTo()}/p/${encodeURIComponent(String(req.params.slug))}/screenshot`);
++ }
if (!paste || !paste.screenshot_path) return res.status(404).send('Not found');
if (paste.visibility === 'private') return res.status(404).send('Not found');
if (!fs.existsSync(paste.screenshot_path)) return res.status(404).send('Not found');
ddiff --git a/test/private-not-found.test.js b/test/private-not-found.test.js
iindex bcfe62e..79a52b9 100644
---- a/test/private-not-found.test.js
++++ b/test/private-not-found.test.js
@@@ -143,6 +143,12 @@ const server = http.createServer(app);
assert.deepStrictEqual([r.status, r.location], [301, 'https://community.test/p/no-such/raw'], 'moved: every slug goes to Community');
r = await get('/p/priv-shot/raw');
assert.deepStrictEqual([r.status, r.location], [301, 'https://community.test/p/priv-shot/raw'], 'moved: a private screenshot is not bounced to /screenshot');
++ // /p/:slug/screenshot: a slug Media doesn't hold (pastes made in Community since the move, whose
++ // screenshots hero moments linked here) goes to Community; a private one answers the same way.
++ r = await get('/p/no-such/screenshot');
++ assert.deepStrictEqual([r.status, r.location], [301, 'https://community.test/p/no-such/screenshot'], 'moved: an unknown screenshot slug goes to Community');
++ r = await get('/p/priv-shot/screenshot');
++ assert.deepStrictEqual([r.status, r.location], [301, 'https://community.test/p/priv-shot/screenshot'], 'moved: a private screenshot looks like an unknown one');
delete process.env.PASTES_MOVED_TO;
console.log('✅ /p/:slug/raw: private looks missing');