fix: #13224, handle note attributedTo when it is of type object

This commit is contained in:
Julian Lam
2025-03-02 21:35:48 -05:00
parent 1d989a0144
commit d948334713

View File

@@ -170,21 +170,28 @@ Mocks.post = async (objects) => {
type, to, cc, audience, attachment, tag, image, type, to, cc, audience, attachment, tag, image,
} = object; } = object;
if (Array.isArray(uid)) { // Handle array attributedTo switch (true) { // non-string attributedTo handling
uid = uid.reduce((valid, cur) => { case Array.isArray(uid): {
if (typeof cur === 'string') { uid = uid.reduce((valid, cur) => {
valid.push(cur); if (typeof cur === 'string') {
} else if (typeof cur === 'object') { valid.push(cur);
if (cur.type === 'Person' && cur.id) { } else if (typeof cur === 'object') {
valid.push(cur.id); if (cur.type === 'Person' && cur.id) {
valid.push(cur.id);
}
} }
}
return valid; return valid;
}, []); }, []);
uid = uid.shift(); // take first valid uid uid = uid.shift(); // take first valid uid
await activitypub.actors.assert(uid); break;
}
case typeof uid === 'object' && uid.hasOwnProperty('id'): {
uid = uid.id;
}
} }
await activitypub.actors.assert(uid);
const resolved = await activitypub.helpers.resolveLocalId(toPid); const resolved = await activitypub.helpers.resolveLocalId(toPid);
if (resolved.type === 'post') { if (resolved.type === 'post') {