feat: redirect cold requests to remote resources to their canonical source, #14043

This commit is contained in:
Julian Lam
2026-03-03 12:25:47 -05:00
parent 7429b5d4ed
commit 2b12f8b578
2 changed files with 14 additions and 6 deletions

View File

@@ -24,6 +24,10 @@ profileController.get = async function (req, res, next) {
return next();
}
if (meta.config.activitypubEnabled && !res.locals.isAPI && !utils.isNumber(userData.uid)) {
return helpers.redirect(res, `/outgoing?url=${encodeURIComponent(userData.uid)}`);
}
await incrementProfileViews(req, userData);
const [latestPosts, bestPosts, customUserFields] = await Promise.all([

View File

@@ -19,12 +19,16 @@ postsController.redirectToPost = async function (req, res, next) {
return next();
}
// Kickstart note assertion if applicable
if (!utils.isNumber(pid) && req.uid && meta.config.activitypubEnabled) {
const exists = await posts.exists(pid);
if (!exists) {
await activitypub.notes.assert(req.uid, pid);
}
// Kickstart note assertion if applicable -- might not be needed, if no ill effects, remove 1 Apr 2026
// if (!utils.isNumber(pid) && req.uid && meta.config.activitypubEnabled) {
// const exists = await posts.exists(pid);
// if (!exists) {
// await activitypub.notes.assert(req.uid, pid);
// }
// }
if (meta.config.activitypubEnabled && !res.locals.isAPI && !utils.isNumber(pid)) {
return helpers.redirect(res, `/outgoing?url=${encodeURIComponent(pid)}`);
}
const [canRead, path] = await Promise.all([