Node.js based forum software built for the modern web
fix: explicitly set `updated` property when federating notes out
Julian Lam6fe4d44675f1
diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.jsindex 07f433b8f1..0cf0ff87de 100644--- a/src/activitypub/helpers.js+++ b/src/activitypub/helpers.js@@ -256,7 +256,10 @@ Helpers.resolveObjects = async (ids) => {const post = (await posts.getPostSummaryByPids([resolvedId],activitypub._constants.uid,- { stripTags: false }+ {+ stripTags: false,+ extraFields: ['edited'],+ })).pop();if (!post) {throw new Error('[[error:activitypub.invalid-id]]');diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.jsindex 6304c26daa..cb02ae12be 100644--- a/src/activitypub/mocks.js+++ b/src/activitypub/mocks.js@@ -277,7 +277,8 @@ Mocks.note = async (post) => {});}- const published = new Date(parseInt(post.timestamp, 10)).toISOString();+ const published = post.timestampISO;+ const updated = post.edited ? post.editedISO : null;// todo: post visibilityconst to = new Set([activitypub._constants.publicAddress]);@@ -420,6 +421,7 @@ Mocks.note = async (post) => {cc: Array.from(cc),inReplyTo,published,+ updated,url: id,attributedTo: `${nconf.get('url')}/uid/${post.user.uid}`,context: `${nconf.get('url')}/topic/${post.topic.tid}`,diff --git a/src/api/posts.js b/src/api/posts.jsindex e56a4a125b..3c90ee4f92 100644--- a/src/api/posts.js+++ b/src/api/posts.js@@ -207,7 +207,7 @@ async function deleteOrRestore(caller, data, params) {});// Explicitly non-awaited- posts.getPostSummaryByPids([data.pid], caller.uid, {}).then(([post]) => {+ posts.getPostSummaryByPids([data.pid], caller.uid, { extraFields: ['edited'] }).then(([post]) => {require('.').activitypub.update.note(caller, { post });});}diff --git a/src/controllers/activitypub/actors.js b/src/controllers/activitypub/actors.jsindex 49e906bb0a..d82e38bd2c 100644--- a/src/controllers/activitypub/actors.js+++ b/src/controllers/activitypub/actors.js@@ -58,7 +58,10 @@ Actors.note = async function (req, res) {// technically a note isn't an actor, but it is here purely for organizational purposes.// but also, wouldn't it be wild if you could follow a note? lol.const allowed = utils.isNumber(req.params.pid) && await privileges.posts.can('topics:read', req.params.pid, activitypub._constants.uid);- const post = (await posts.getPostSummaryByPids([req.params.pid], req.uid, { stripTags: false })).pop();+ const post = (await posts.getPostSummaryByPids([req.params.pid], req.uid, {+ stripTags: false,+ extraFields: ['edited'],+ })).pop();if (!allowed || !post) {return res.sendStatus(404);}