fix: explicitly set updated property when federating notes out

This commit is contained in:
Julian Lam
2024-09-24 12:15:10 -04:00
parent e0c410cd7c
commit 6fe4d44675
4 changed files with 12 additions and 4 deletions

View File

@@ -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]]');

View File

@@ -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 visibility
const 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}`,

View File

@@ -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 });
});
}

View File

@@ -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);
}