Skip to content

Node.js based forum software built for the modern web

feat: restore note assertion on redirectToPost controller, update /ap route to redirect guests to login for 3b86 Object intent support, #14253

Julian Lamb89b5d4ebb33
diff --git a/src/controllers/activitypub/index.js b/src/controllers/activitypub/index.js
index cb9b72bc98..9158dfe102 100644
--- a/src/controllers/activitypub/index.js
+++ b/src/controllers/activitypub/index.js
@@ -51,8 +51,10 @@ Controller.fetch = async (req, res, next) => {
}
}
- // Force outgoing links page on direct access
- if (!res.locals.isAPI) {
+ if (!req.uid) { // Challenge guests with login
+ req.session.returnTo = `/ap?resource=${req.query.resource}`;
+ url = new URL(`login`, nconf.get('url'));
+ } else if (!res.locals.isAPI) { // Force outgoing links page on direct access
url = new URL(`outgoing?url=${encodeURIComponent(url.href)}`, nconf.get('url'));
}
diff --git a/src/controllers/posts.js b/src/controllers/posts.js
index cfda2c90bb..603e060d68 100644
--- a/src/controllers/posts.js
+++ b/src/controllers/posts.js
@@ -6,7 +6,7 @@ const querystring = require('querystring');
const meta = require('../meta');
const posts = require('../posts');
const privileges = require('../privileges');
-// const activitypub = require('../activitypub');
+const activitypub = require('../activitypub');
const utils = require('../utils');
const helpers = require('./helpers');
@@ -19,13 +19,13 @@ postsController.redirectToPost = async function (req, res, next) {
return next();
}
- // 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);
- // }
- // }
+ // 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);
+ }
+ }
if (!req.loggedIn && meta.config.activitypubEnabled && !res.locals.isAPI && !utils.isNumber(pid)) {
return helpers.redirect(res, `/outgoing?url=${encodeURIComponent(pid)}`);