Files
wekan/server/lib/legacyAvatarRead.js
T
Lauri Ojansivu c2a3909281 Restore authenticated legacy avatars through prefix routes
The early universal file handler returned 404 for CollectionFS avatars before the legacy fallback handler could run, including versioned Meteor-Files URLs. Read legacy avatar metadata and streams only after authenticating the request, retain safe response headers, close conditional-request streams and preserve missing-file responses. Add positive and negative runtime coverage and a browser image regression.

Thanks to xet7 !
2026-09-14 02:48:27 +03:00

13 lines
655 B
JavaScript

import { getUserIdFromRequest } from '/server/lib/requestUser';
import { getOldAttachmentData, getOldAttachmentStream } from '/models/lib/attachmentBackwardCompatibility';
// CollectionFS records cannot reliably establish public-board visibility.
// Require authentication before looking up metadata or opening the old bucket.
export async function readAuthenticatedLegacyAvatar(req, fileId) {
if (!(await getUserIdFromRequest(req))) return null;
const avatar = await getOldAttachmentData(fileId, 'avatars');
if (!avatar) return null;
const stream = await getOldAttachmentStream(fileId, 'avatars');
return stream ? { avatar, stream } : null;
}